CORD-2331: Hack to allow creation of node labels from outside core
Change-Id: Ia11072311c8602b23ca12f50370b6b87a079ccaa
(cherry picked from commit a3929c1a01c1615703d1e6a51a611211e2405b5b)
diff --git a/xos/core/models/attic/nodelabel_model.py b/xos/core/models/attic/nodelabel_model.py
new file mode 100644
index 0000000..67df5f9
--- /dev/null
+++ b/xos/core/models/attic/nodelabel_model.py
@@ -0,0 +1,29 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+def __xos_save_base(self, *args, **kwds):
+ """ Hack to allow the creation of NodeLabel objects from outside core
+ until the ORM is extended with support for ManyToMany relations.
+ """
+
+ if self.name and '###' in self.name:
+ from core.models import Node
+
+ self.name, node_id_str = self.name.split('###')
+ node_ids = map(int, node_id_str.split(','))
+
+ for node_id in node_ids:
+ node = Node.get(node_id)
+ self.node.add(node)