slice_urn = hrn_to_urn(slice_hrn, 'slice')
user_cred = self.get_user_cred()
slice_cred = self.get_slice_cred(slice_hrn).save_to_string(save_parents=True)
-
- if hasattr(opts, 'aggregate') and opts.aggregate:
- delegated_cred = None
- else:
- # delegate the cred to the callers root authority
- delegated_cred = self.delegate_cred(slice_cred, get_authority(self.authority)+'.slicemanager')
- #delegated_cred = self.delegate_cred(slice_cred, get_authority(slice_hrn))
- #creds.append(delegated_cred)
-
+ delegated_cred = None
+ if server_version.get('interface') == 'slicemgr':
+ # delegate our cred to the slice manager
+ # do not delegate cred to slicemgr...not working at the moment
+ pass
+ #if server_version.get('hrn'):
+ # delegated_cred = self.delegate_cred(slice_cred, server_version['hrn'])
+ #elif server_version.get('urn'):
+ # delegated_cred = self.delegate_cred(slice_cred, urn_to_hrn(server_version['urn']))
+
rspec_file = self.get_rspec_file(args[1])
rspec = open(rspec_file).read()
return attributes
- def add_sliver_attribute(self, hostname, name, value, network=None):
- nodes = self.get_nodes({'component_id': '*%s*' % hostname})
- if not nodes:
+ def add_sliver_attribute(self, component_id, name, value, network=None):
+ nodes = self.get_nodes({'component_id': '*%s*' % component_id})
+ if nodes is not None and isinstance(nodes, list) and len(nodes) > 0:
node = nodes[0]
slivers = SFAv1Sliver.get_slivers(node)
if slivers:
sliver = slivers[0]
- SFAv1Sliver.add_attribute(sliver, name, value)
+ SFAv1Sliver.add_sliver_attribute(sliver, name, value)
+ else:
+ # should this be an assert / raise an exception?
+ print "WARNING: failed to find component_id", component_id
- def get_sliver_attributes(self, hostname, network=None):
- nodes = self.get_nodes({'component_id': '*%s*' %hostname})
+ def get_sliver_attributes(self, component_id, network=None):
+ nodes = self.get_nodes({'component_id': '*%s*' % component_id})
attribs = []
if nodes is not None and isinstance(nodes, list) and len(nodes) > 0:
node = nodes[0]
attribs = SFAv1Sliver.get_sliver_attributes(sliver.element)
return attribs
- def remove_sliver_attribute(self, hostname, name, value, network=None):
- attribs = self.get_sliver_attributes(hostname)
+ def remove_sliver_attribute(self, component_id, name, value, network=None):
+ attribs = self.get_sliver_attributes(component_id)
for attrib in attribs:
if attrib['name'] == name and attrib['value'] == value:
- attrib.element.delete()
+ #attrib.element.delete()
+ parent = attrib.element.getparent()
+ parent.remove(attrib.element)
def add_default_sliver_attribute(self, name, value, network=None):
if network:
return SFAv1Sliver.get_sliver_attributes(defaults[0])
def remove_default_sliver_attribute(self, name, value, network=None):
- if network:
- defaults = self.xml.xpath("//network[@name='%s']/sliver_defaults" % network)
- else:
- defaults = self.xml.xpath("//sliver_defaults" % network)
- attribs = SFAv1Sliver.get_sliver_attributes(defaults)
+ attribs = self.get_default_sliver_attributes(network)
for attrib in attribs:
if attrib['name'] == name and attrib['value'] == value:
- attrib.element.delete()
+ #attrib.element.delete()
+ parent = attrib.element.getparent()
+ parent.remove(attrib.element)
# Links
self.namespaces['default'] = 'default'
self.root = XmlElement(root, self.namespaces)
- # set schema
+ # set schema
for key in self.root.attrib.keys():
if key.endswith('schemaLocation'):
# schema location should be at the end of the list
if element is None:
if self.root is None:
self.parse_xml('<%s/>' % root_tag_name)
- element = self.root
+ element = self.root.element
if 'text' in d:
text = d.pop('text')
self.parse_dict(val, key, child_element)
elif isinstance(val, basestring):
child_element = etree.SubElement(element, key).text = val
-
+
elif isinstance(value, int):
- d[key] = unicode(d[key])
+ d[key] = unicode(d[key])
elif value is None:
d.pop(key)