- zones = self.get_availability_zones()
- name = hrn_to_os_slicename(slice_xrn)
- instances = self.driver.shell.nova_manager.servers.findall(name=name)
- node_dict = {}
- for instance in instances:
- # determine node urn
- node_xrn = instance.metadata.get('component_id')
- if not node_xrn:
- node_xrn = OSXrn('cloud', type='node')
- else:
- node_xrn = OSXrn(xrn=node_xrn, type='node')
-
- if not node_xrn.urn in node_dict:
- rspec_node = Node()
- rspec_node['component_id'] = node_xrn.urn
- rspec_node['component_name'] = node_xrn.name
- rspec_node['component_manager_id'] = Xrn(self.driver.hrn, 'authority+cm').get_urn()
- rspec_node['slivers'] = []
- node_dict[node_xrn.urn] = rspec_node
+ for private_ip in addresses.get('private', []):
+ if_xrn = PlXrn(auth=self.driver.hrn,
+ interface='node%s' % (instance.hostId))
+ if_client_id = Xrn(if_xrn.urn, type='interface', id="eth%s" %if_index).urn
+ if_sliver_id = Xrn(rspec_node['sliver_id'], type='slice', id="eth%s" %if_index).urn
+ interface = Interface({'component_id': if_xrn.urn,
+ 'client_id': if_client_id,
+ 'sliver_id': if_sliver_id})
+ interface['ips'] = [{'address': private_ip['addr'],
+ #'netmask': private_ip['network'],
+ 'type': private_ip['version']}]
+ rspec_node['interfaces'].append(interface)
+
+ # slivers always provide the ssh service
+ for public_ip in addresses.get('public', []):
+ login = Login({'authentication': 'ssh-keys',
+ 'hostname': public_ip['addr'],
+ 'port':'22', 'username': 'root'})
+ service = Services({'login': login})
+ rspec_node['services'].append(service)
+ return rspec_node
+
+
+ def instance_to_sliver(self, instance, xrn=None):
+ if xrn:
+ sliver_hrn = '%s.%s' % (self.driver.hrn, instance.id)
+ sliver_id = Xrn(sliver_hrn, type='sliver').urn
+
+ sliver = Sliver({'sliver_id': sliver_id,
+ 'name': instance.name,
+ 'type': instance.name,
+ 'cpus': str(instance.vcpus),
+ 'memory': str(instance.ram),
+ 'storage': str(instance.disk)})
+ return sliver
+
+ def instance_to_geni_sliver(self, instance, sliver_allocations = {}):
+ sliver_hrn = '%s.%s' % (self.driver.hrn, instance.id)
+ sliver_id = Xrn(sliver_hrn, type='sliver').urn
+
+ # set sliver allocation and operational status
+ sliver_allocation = sliver_allocations[sliver_id]
+ if sliver_allocation:
+ allocation_status = sliver_allocation.allocation_state
+ if allocation_status == 'geni_allocated':
+ op_status = 'geni_pending_allocation'
+ elif allocation_status == 'geni_provisioned':
+ state = instance.state.lower()
+ if state == 'active':
+ op_status = 'geni_ready'
+ elif state == 'building':
+ op_status = 'geni_notready'
+ elif state == 'failed':
+ op_status =' geni_failed'
+ else:
+ op_status = 'geni_unknown'