Add uuid field to sliver
diff --git a/planetstack/core/models/sliver.py b/planetstack/core/models/sliver.py
index 4d89d9f..d2f794f 100644
--- a/planetstack/core/models/sliver.py
+++ b/planetstack/core/models/sliver.py
@@ -81,6 +81,7 @@
objects = SliverManager()
deleted_objects = SliverDeletionManager()
instance_id = models.CharField(null=True, blank=True, max_length=200, help_text="Nova instance id")
+ instance_uuid = models.CharField(null=True, blank=True, max_length=200, help_text="Nova instance uuid")
name = models.CharField(max_length=200, help_text="Sliver name")
instance_name = models.CharField(blank=True, null=True, max_length=200, help_text="OpenStack generated name")
ip = models.GenericIPAddressField(help_text="Sliver ip address", blank=True, null=True)
diff --git a/planetstack/openstack_observer/steps/sync_slivers.py b/planetstack/openstack_observer/steps/sync_slivers.py
index a2d0e81..8155c10 100644
--- a/planetstack/openstack_observer/steps/sync_slivers.py
+++ b/planetstack/openstack_observer/steps/sync_slivers.py
@@ -124,9 +124,18 @@
if (len(res)!=2):
raise Exception('Could not sync sliver %s'%sliver.slice.name)
else:
- sliver_id = res[1]['id'] # 0 is for the key
+ sliver_id = res[1]['info']['OS-EXT-SRV-ATTR:instance_name'] # 0 is for the key
+ sliver_uuid = res[1]['id'] # 0 is for the key
+
+ try:
+ hostname = res[1]['info']['OS-EXT-SRV-ATTR:hypervisor_hostname']
+ ip = socket.gethostbyname(hostname)
+ sliver.ip = ip
+ except:
+ pass
sliver.instance_id = sliver_id
+ sliver.instance_uuid = sliver_uuid
sliver.instance_name = sliver_name
sliver.save()