Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
diff --git a/planetstack/core/migrations/0011_sliver_instance_uuid.py b/planetstack/core/migrations/0011_sliver_instance_uuid.py
new file mode 100644
index 0000000..dd8d05c
--- /dev/null
+++ b/planetstack/core/migrations/0011_sliver_instance_uuid.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('core', '0010_auto_20150118_1926'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='sliver',
+ name='instance_uuid',
+ field=models.CharField(help_text=b'Nova instance uuid', max_length=200, null=True, blank=True),
+ preserve_default=True,
+ ),
+ ]
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()