| #os.environ.setdefault("DJANGO_SETTINGS_MODULE", "planetstack.settings") |
| from core.models.sliver import Sliver |
| from openstack.manager import OpenStackManager |
| manager = OpenStackManager() |
| # exit if openstack is disable or unavailable |
| if not manager.enabled or not manager.has_openstack: |
| # fill in null ip addresses |
| slivers = Sliver.objects.filter(ip=None) |
| manager.client.connect(username=manager.client.keystone.username, |
| password=manager.client.keystone.password, |
| tenant=sliver.slice.name) |
| sliver.os_manager = manager |
| servers = manager.client.nova.servers.findall(id=sliver.instance_id) |
| ips = server.addresses.get(sliver.slice.name, []) |
| sliver.ip = ips[0]['addr'] |
| if __name__ == '__main__': |