- def instance_to_sliver(self, instance, slice_xrn=None):
- # should include?
- # * instance.image_ref
- # * instance.kernel_id
- # * instance.ramdisk_id
- import nova.db.sqlalchemy.models
- name=None
- type=None
- sliver_id = None
- if isinstance(instance, dict):
- # this is an isntance type dict
- name = instance['name']
- type = instance['name']
- elif isinstance(instance, nova.db.sqlalchemy.models.Instance):
- # this is an object that describes a running instance
- name = instance.display_name
- type = instance.instance_type.name
- else:
- raise SfaAPIError("instnace must be an instance_type dict or" + \
- " a nova.db.sqlalchemy.models.Instance object")
- if slice_xrn:
- xrn = Xrn(slice_xrn, 'slice')
- sliver_id = xrn.get_sliver_id(instance.project_id, instance.hostname, instance.id)
-
- sliver = Sliver({'slice_id': sliver_id,
- 'name': name,
- 'type': 'plos-' + type,
- 'tags': []})
- return sliver
-
-