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 = NITOSv1Sliver.get_slivers(node) if slivers: sliver = slivers[0] NITOSv1Sliver.add_sliver_attribute(sliver, name, value) else: # should this be an assert / raise an exception? logger.error("WARNING: failed to find component_id %s" % component_id)
def add_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") if not defaults: if network: network_tag = self.xml.xpath("//network[@name='%s']" % network) else: network_tag = self.xml.xpath("//network") if isinstance(network_tag, list): network_tag = network_tag[0] defaults = network_tag.add_element('sliver_defaults') elif isinstance(defaults, list): defaults = defaults[0] NITOSv1Sliver.add_sliver_attribute(defaults, name, value)