def rspec_to_omnispec(urn, rspec): # URN is that of the AM ospec = OmniSpec("rspec_sfa", urn) doc = ET.fromstring(rspec) for network in doc.findall('network'): for site in network.findall('site'): for node in site.findall('node'): net_name = network.get('name') site_id = site.get('id') site_name = site.find('name').text hostname = node.find('hostname').text r = OmniResource(hostname, '%s %s %s' % (net_name, site_id, hostname), 'vm') urn = 'urn:publicid:IDN+%s:%s+node+%s' % (net_name.replace( '.', ":"), site_name, hostname.split('.')[0]) misc = r['misc'] misc['site_id'] = site_id misc['site_name'] = site_name misc['hostname'] = hostname misc['net_name'] = net_name misc['node_id'] = node.get('id') if not node.find('sliver') is None: r.set_allocated(True) ospec.add_resource(urn, r) return ospec
def rspec_to_omnispec(urn, rspec): # URN is that of the AM ospec = OmniSpec("rspec_sfa", urn) doc = ET.fromstring(rspec) for network in doc.findall('network'): for site in network.findall('site'): for node in site.findall('node'): net_name = network.get('name') site_id = site.get('id') site_name = site.find('name').text hostname = node.find('hostname').text r = OmniResource(hostname, '%s %s %s' % (net_name, site_id, hostname), 'vm') urn = 'urn:publicid:IDN+%s:%s+node+%s' % (net_name.replace('.', ":"), site_name, hostname.split('.')[0]) misc = r['misc'] misc['site_id'] = site_id misc['site_name'] = site_name misc['hostname'] = hostname misc['net_name'] = net_name misc['node_id'] = node.get('id') if not node.find('sliver') is None: r.set_allocated(True) ospec.add_resource(urn, r) return ospec
def add_nodes(ospec, root): for res in root.findall(pg_tag('node')): name = res.attrib['component_name'] description = 'ProtoGENI Node' type = 'node' omni_res = OmniResource(name, description, type) available = res.find(pg_tag('available')).text.lower() == 'true' omni_res.set_allocated(not (available)) omni_res['orig_xml'] = ET.tostring(res) id = res.attrib['component_uuid'] ospec.add_resource(id, omni_res)
def add_links(ospec, root): for res in root.findall(pg_tag('link')): name = res.attrib['component_name'] description = 'ProtoGENI Link' type = 'link' omni_res = OmniResource(name, description, type) # Links appear to be always available available = True omni_res.set_allocated(not (available)) omni_res['orig_xml'] = ET.tostring(res) id = res.attrib['component_uuid'] ospec.add_resource(id, omni_res)
def add_links(ospec, root): for res in root.findall(pg_tag('link')): name = res.attrib['component_name'] description = 'ProtoGENI Link' type = 'link' omni_res = OmniResource(name, description, type) # Links appear to be always available available = True omni_res.set_allocated(not(available)) omni_res['orig_xml'] = ET.tostring(res) id = res.attrib['component_uuid'] ospec.add_resource(id, omni_res)
def add_nodes(ospec, root): for res in root.findall(pg_tag('node')): name = res.attrib['component_name'] description = 'ProtoGENI Node' type = 'node' omni_res = OmniResource(name, description, type) available = res.find(pg_tag('available')).text.lower() == 'true' omni_res.set_allocated(not(available)) omni_res['orig_xml'] = ET.tostring(res) id = res.attrib['component_uuid'] ospec.add_resource(id, omni_res)
def rspec_to_omnispec(urn, rspec): # URN is that of the AM ospec = OmniSpec("rspec_gcf", urn) doc = ET.fromstring(rspec) for res in doc.findall('resource'): type = res.find('type').text id = res.find('id').text rurn = res.find('urn').text available = res.find('available').text available = available.lower() == 'true' r = OmniResource(id, 'node ' + id, type) r.set_allocated(not available) ospec.add_resource(rurn, r) return ospec
def rspec_to_omnispec(urn, rspec): # URN is that of the AM ospec = OmniSpec("rspec_gcf", urn) doc = ET.fromstring(rspec) for res in doc.findall('resource'): type = res.find('type').text id = res.find('id').text rurn = res.find('urn').text available = res.find('available').text available = available.lower() == 'true' r = OmniResource(id, 'node ' + id, type) r.set_allocated(not available) ospec.add_resource(rurn, r) return ospec