Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
authorScott Baker <smbaker@gmail.com>
Tue, 20 Jan 2015 21:30:49 +0000 (13:30 -0800)
committerScott Baker <smbaker@gmail.com>
Tue, 20 Jan 2015 21:30:49 +0000 (13:30 -0800)
planetstack/core/migrations/0011_sliver_instance_uuid.py [new file with mode: 0644]
planetstack/core/models/sliver.py
planetstack/openstack_observer/steps/sync_slivers.py

diff --git a/planetstack/core/migrations/0011_sliver_instance_uuid.py b/planetstack/core/migrations/0011_sliver_instance_uuid.py
new file mode 100644 (file)
index 0000000..dd8d05c
--- /dev/null
@@ -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,
+        ),
+    ]
index 4d89d9f..d2f794f 100644 (file)
@@ -81,6 +81,7 @@ class Sliver(PlCoreBase):
     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)
index a2d0e81..8155c10 100644 (file)
@@ -124,9 +124,18 @@ class SyncSlivers(OpenStackSyncStep):
         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()