federation in progress - associate a local slice to a foreign node
[plcapi.git] / PLC / Slices.py
index 02c34c3..81df6c9 100644 (file)
@@ -8,6 +8,7 @@ from PLC.Debug import profile
 from PLC.Table import Row, Table
 from PLC.SliceInstantiations import SliceInstantiations
 from PLC.Nodes import Node, Nodes
+from PLC.ForeignNodes import ForeignNode, ForeignNodes
 import PLC.Persons
 
 class Slice(Row):
@@ -23,10 +24,10 @@ class Slice(Row):
     fields = {
         'slice_id': Parameter(int, "Slice identifier"),
         'site_id': Parameter(int, "Identifier of the site to which this slice belongs"),
-        'name': Parameter(str, "Slice name", max = 32, optional = False),
+        'name': Parameter(str, "Slice name", max = 32),
         'instantiation': Parameter(str, "Slice instantiation state"),
-        'url': Parameter(str, "URL further describing this slice", max = 254),
-        'description': Parameter(str, "Slice description", max = 2048),
+        'url': Parameter(str, "URL further describing this slice", max = 254, nullok = True),
+        'description': Parameter(str, "Slice description", max = 2048, nullok = True),
         'max_nodes': Parameter(int, "Maximum number of nodes that can be assigned to this slice"),
         'creator_person_id': Parameter(int, "Identifier of the account that created this slice"),
         'created': Parameter(int, "Date and time when slice was created, in seconds since UNIX epoch", ro = True),
@@ -130,13 +131,16 @@ class Slice(Row):
             self['person_ids'].remove(person_id)
             person['slice_ids'].remove(slice_id)
 
-    def add_node(self, node, commit = True):
+    def add_node(self, node, is_foreign_node = False, commit = True):
         """
         Add node to existing slice.
         """
 
         assert 'slice_id' in self
-        assert isinstance(node, Node)
+        if not is_foreign_node:
+            assert isinstance(node, Node)
+        else:
+            assert isinstance(node, ForeignNode)
         assert 'node_id' in node
 
         slice_id = self['slice_id']