blob: 4421ca5f768a4fc6f834f094bdc4c3d4acefbc16 [file] [log] [blame]
Sapan Bhatia24836f12013-08-27 10:16:05 -04001import os
2import base64
3from planetstack.config import Config
4
5class SyncSliverIps(OpenStackSyncStep):
6 provides=[Sliver]
7 def fetch_pending(self):
8 slivers = Sliver.objects.filter(ip=None)
9 return slivers
10
11 def sync_record(self, sliver):
12 self.manager.init_admin(tenant=sliver.slice.name)
13 servers = self.manager.driver.shell.nova.servers.findall(id=sliver.instance_id)
14 if not servers:
15 continue
16 server = servers[0]
17 ips = server.addresses.get(sliver.slice.name, [])
18 if not ips:
19 continue
20 sliver.ip = ips[0]['addr']
21 sliver.save()
22 logger.info("saved sliver ip: %s %s" % (sliver, ips[0]))