- assert 'node_ids' in self
- assert 'slice_id' in self
- assert isinstance(value, list)
-
- (node_ids, hostnames) = self.separate_types(value)[0:2]
-
- # Translate hostnames into node_ids
- if hostnames:
- nodes = Nodes(self.api, hostnames, ['node_id']).dict('node_id')
- node_ids += nodes.keys()
-
- # Add new ids, remove stale ids
- if self['node_ids'] != node_ids:
- from PLC.Methods.AddSliceToNodes import AddSliceToNodes
- from PLC.Methods.DeleteSliceFromNodes import DeleteSliceFromNodes
- new_nodes = set(node_ids).difference(self['node_ids'])
- stale_nodes = set(self['node_ids']).difference(node_ids)
-
- if new_nodes:
- AddSliceToNodes.__call__(AddSliceToNodes(self.api), auth, self['slice_id'], list(new_nodes))
- if stale_nodes:
- DeleteSliceFromNodes.__call__(DeleteSliceFromNodes(self.api), auth, self['slice_id'], list(stale_nodes))
- def associate_slice_attributes(self, auth, fields, value):
- """
- Deletes slice_attribute_ids not found in value list (using DeleteSliceAttribute).
- Adds slice_attributes if slice_fields w/o slice_id is found (using AddSliceAttribute).
- Updates slice_attribute if slice_fields w/ slice_id is found (using UpdateSlceiAttribute).
- """
-
- assert 'slice_attribute_ids' in self
- assert isinstance(value, list)
-
- (attribute_ids, blank, attributes) = self.separate_types(value)
-
- # There is no way to add attributes by id. They are
- # associated with a slice when they are created.
- # So we are only looking to delete here
- if self['slice_attribute_ids'] != attribute_ids:
- from PLC.Methods.DeleteSliceAttribute import DeleteSliceAttribute
- stale_attributes = set(self['slice_attribute_ids']).difference(attribute_ids)
-
- for stale_attribute in stale_attributes:
- DeleteSliceAttribute.__call__(DeleteSliceAttribute(self.api), auth, stale_attribute['slice_attribute_id'])
-
- # If dictionary exists, we are either adding new
+ assert 'node_ids' in self
+ assert 'slice_id' in self
+ assert isinstance(value, list)
+
+ (node_ids, hostnames) = self.separate_types(value)[0:2]
+
+ # Translate hostnames into node_ids
+ if hostnames:
+ nodes = Nodes(self.api, hostnames, ['node_id']).dict('node_id')
+ node_ids += nodes.keys()
+
+ # Add new ids, remove stale ids
+ if self['node_ids'] != node_ids:
+ from PLC.Methods.AddSliceToNodes import AddSliceToNodes
+ from PLC.Methods.DeleteSliceFromNodes import DeleteSliceFromNodes
+ new_nodes = set(node_ids).difference(self['node_ids'])
+ stale_nodes = set(self['node_ids']).difference(node_ids)
+
+ if new_nodes:
+ AddSliceToNodes.__call__(AddSliceToNodes(self.api), auth, self['slice_id'], list(new_nodes))
+ if stale_nodes:
+ DeleteSliceFromNodes.__call__(DeleteSliceFromNodes(self.api), auth, self['slice_id'], list(stale_nodes))
+ def associate_slice_tags(self, auth, fields, value):
+ """
+ Deletes slice_tag_ids not found in value list (using DeleteSliceTag).
+ Adds slice_tags if slice_fields w/o slice_id is found (using AddSliceTag).
+ Updates slice_tag if slice_fields w/ slice_id is found (using UpdateSlceiAttribute).
+ """
+
+ assert 'slice_tag_ids' in self
+ assert isinstance(value, list)
+
+ (attribute_ids, blank, attributes) = self.separate_types(value)
+
+ # There is no way to add attributes by id. They are
+ # associated with a slice when they are created.
+ # So we are only looking to delete here
+ if self['slice_tag_ids'] != attribute_ids:
+ from PLC.Methods.DeleteSliceTag import DeleteSliceTag
+ stale_attributes = set(self['slice_tag_ids']).difference(attribute_ids)
+
+ for stale_attribute in stale_attributes:
+ DeleteSliceTag.__call__(DeleteSliceTag(self.api), auth, stale_attribute['slice_tag_id'])
+
+ # If dictionary exists, we are either adding new