bugfixes and cleanup
diff --git a/planetstack/openstack/client.py b/planetstack/openstack/client.py
index df340f6..72c5cb4 100644
--- a/planetstack/openstack/client.py
+++ b/planetstack/openstack/client.py
@@ -176,7 +176,7 @@
token = self.keystone.client.tokens.authenticate(username=self.keystone.username, password=self.keystone.password, tenant_name=self.keystone.tenant)
#self.glance = GlanceClient(*args, **kwds)
- self.glanceclient = GlanceClientNew('1', endpoint='http://%s:9292' % hostname, token=token.id, **kwds)
+ self.glanceclient = GlanceClientNew('1', endpoint='https://%s:9292' % hostname, token=token.id, **kwds)
self.nova = NovaClient(*args, **kwds)
# self.nova_db = NovaDB(*args, **kwds)
self.quantum = QuantumClient(*args, **kwds)
diff --git a/planetstack/openstack_observer/steps/__init__.py b/planetstack/openstack_observer/steps/__init__.py
index 72b0b12..6eec315 100644
--- a/planetstack/openstack_observer/steps/__init__.py
+++ b/planetstack/openstack_observer/steps/__init__.py
@@ -3,3 +3,4 @@
from .sync_controller_users import SyncControllerUsers
from .sync_controller_site_privileges import SyncControllerSitePrivileges
from .sync_controller_slice_privileges import SyncControllerSlicePrivileges
+from .sync_controller_networks import SyncControllerNetworks
diff --git a/planetstack/openstack_observer/steps/sync_controller_networks.py b/planetstack/openstack_observer/steps/sync_controller_networks.py
index fa1f439..c90e4df 100644
--- a/planetstack/openstack_observer/steps/sync_controller_networks.py
+++ b/planetstack/openstack_observer/steps/sync_controller_networks.py
@@ -13,7 +13,7 @@
logger = Logger(level=logging.INFO)
-class SyncControllerNetwork(OpenStackSyncStep):
+class SyncControllerNetworks(OpenStackSyncStep):
requested_interval = 0
provides=[Network, ControllerNetwork, Sliver]
@@ -42,8 +42,8 @@
network_fields = {'endpoint':controller_network.controller.auth_url,
'admin_user':slice.creator.email, # XXX: FIXME
- 'tenant_name':slice.slicename, # XXX: FIXME
- 'admin_password':controller_network.controller.admin_password,
+ 'tenant_name':slice.name, # XXX: FIXME
+ 'admin_password':slice.creator.remote_password,
'name':network_name,
'subnet_name':subnet_name,
'ansible_tag':'%s-%s@%s'%(network_name,slice.slicename,controller_network.controller.name),
diff --git a/planetstack/openstack_observer/steps/sync_controller_networks.yaml b/planetstack/openstack_observer/steps/sync_controller_networks.yaml
index c85ec55..9b42ea6 100644
--- a/planetstack/openstack_observer/steps/sync_controller_networks.yaml
+++ b/planetstack/openstack_observer/steps/sync_controller_networks.yaml
@@ -6,6 +6,7 @@
auth_url={{ endpoint }}
login_username={{ admin_user }}
tenant_name={{ tenant_name }}
+ login_tenant_name={{ tenant_name }}
login_password={{ admin_password }}
name={{ name }}
{% if delete %}
@@ -13,11 +14,12 @@
{% else %}
state=present
{% endif %}
- shared: true
+ shared=true
- quantum_subnet:
auth_url={{ endpoint }}
login_username={{ admin_user }}
tenant_name={{ tenant_name }}
+ login_tenant_name={{ tenant_name }}
login_password={{ admin_password }}
name={{ subnet_name }}
network_name={{ name }}
@@ -25,5 +27,5 @@
state=absent
{% else %}
state=present
- cidr = {{ cidr }}
+ cidr={{ cidr }}
{% endif %}
diff --git a/planetstack/openstack_observer/steps/sync_images.py b/planetstack/openstack_observer/steps/sync_images.py
deleted file mode 100644
index 9b915fb..0000000
--- a/planetstack/openstack_observer/steps/sync_images.py
+++ /dev/null
@@ -1,42 +0,0 @@
-import os
-import base64
-from django.db.models import F, Q
-from planetstack.config import Config
-from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.image import Image
-
-class SyncImages(OpenStackSyncStep):
- provides=[Image]
- requested_interval=0
-
- def fetch_pending(self, deleted):
- # Images come from the back end
- # You can't delete them
- if (deleted):
- return []
-
- # get list of images on disk
- images_path = Config().observer_images_directory
- available_images = {}
- for f in os.listdir(images_path):
- if os.path.isfile(os.path.join(images_path ,f)):
- available_images[f] = os.path.join(images_path ,f)
-
- images = Image.objects.all()
- image_names = [image.name for image in images]
-
- for image_name in available_images:
- #remove file extension
- clean_name = ".".join(image_name.split('.')[:-1])
- if clean_name not in image_names:
- image = Image(name=clean_name,
- disk_format='raw',
- container_format='bare',
- path = available_images[image_name])
- image.save()
-
-
- return Image.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
-
- def sync_record(self, image):
- image.save()
diff --git a/planetstack/openstack_observer/steps/sync_networks.py b/planetstack/openstack_observer/steps/sync_networks.py
deleted file mode 100644
index 9f36ed5..0000000
--- a/planetstack/openstack_observer/steps/sync_networks.py
+++ /dev/null
@@ -1,26 +0,0 @@
-import os
-import base64
-from django.db.models import F, Q
-from planetstack.config import Config
-from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.network import *
-from util.logger import Logger, logging
-from observer.steps.sync_controller_networks import *
-
-logger = Logger(level=logging.INFO)
-
-class SyncNetworks(OpenStackSyncStep):
- provides=[Network]
- requested_interval = 0
-
- def sync_record(self, network):
- network.save()
-
- def delete_record(self, network):
- controller_networks_deleter = SyncControllerNetwork().delete_record
- for controller_network in ControllerNetwork.objects.filter(network=network):
- try:
- controller_network_deleter(controller_network)
- except Exception,e:
- logger.log_exc("Failed to delete controller network %s" % controller_network)
- raise e
diff --git a/planetstack/openstack_observer/steps/sync_roles.py b/planetstack/openstack_observer/steps/sync_roles.py
deleted file mode 100644
index f08a693..0000000
--- a/planetstack/openstack_observer/steps/sync_roles.py
+++ /dev/null
@@ -1,41 +0,0 @@
-import os
-import base64
-from django.db.models import F, Q
-from planetstack.config import Config
-from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.role import Role
-from core.models.site import SiteRole, Controller, ControllerRole
-from core.models.slice import SliceRole
-
-class SyncRoles(OpenStackSyncStep):
- provides=[Role]
- requested_interval=0
-
- def fetch_pending(self, deleted):
- # Deleting roles is not supported yet
- if (deleted):
- return []
-
- site_roles = SiteRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- slice_roles = SliceRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- controller_roles = ControllerRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
-
- roles = []
- for site_role in site_roles:
- roles.append(site_role)
- for slice_role in slice_roles:
- roles.append(slice_role)
- for controller_role in controller_roles:
- roles.append(controller_role)
-
- return roles
-
-
- def sync_record(self, role):
- if not role.enacted:
- controllers = Controller.objects.all()
- for controller in controllers:
- driver = self.driver.admin_driver(controller=controller)
- driver.create_role(role.role)
- role.save()
-
diff --git a/planetstack/openstack_observer/steps/sync_site_privileges.py b/planetstack/openstack_observer/steps/sync_site_privileges.py
deleted file mode 100644
index bfc04b3..0000000
--- a/planetstack/openstack_observer/steps/sync_site_privileges.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import os
-import base64
-from django.db.models import F, Q
-from planetstack.config import Config
-from observer.openstacksyncstep import OpenStackSyncStep
-from core.models import User, ControllerUser, SitePrivilege, SiteDeployment
-
-class SyncSitePrivilege(OpenStackSyncStep):
- requested_interval=0
- provides=[SitePrivilege]
-
- def fetch_pending(self, deleted):
- # Deleting site privileges is not supported yet
- if (deleted):
- return []
-
- return SitePrivilege.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
-
- def sync_record(self, site_priv):
- # sync site privileges at all site controllers
- ctrl_site_deployments = SiteDeployment.objects.filter(site_deployment__site=site_priv.site)
- for ctrl_site_deployment in ctrl_site_deployments:
- controller_users = ControllerUser.objects.filter(controller=ctrl_site_deployment.controller,
- user=site_priv.user)
- if controller_users:
- kuser_id = controller_users[0].kuser_id
- driver = self.driver.admin_driver(controller=ctrl_site_deployment.controller)
- driver.add_user_role(kuser_id,
- ctrl_site_deployment.controller.tenant_id,
- site_priv.role.role)
diff --git a/planetstack/openstack_observer/steps/sync_slice_memberships.py b/planetstack/openstack_observer/steps/sync_slice_memberships.py
deleted file mode 100644
index e95c533..0000000
--- a/planetstack/openstack_observer/steps/sync_slice_memberships.py
+++ /dev/null
@@ -1,36 +0,0 @@
-import os
-import base64
-from django.db.models import F, Q
-from planetstack.config import Config
-from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.slice import *
-from core.models.controllerusers import ControllerUser
-from util.logger import Logger, logging
-
-logger = Logger(level=logging.INFO)
-
-class SyncSliceMemberships(OpenStackSyncStep):
- requested_interval=0
- provides=[SlicePrivilege]
-
- def fetch_pending(self, deleted):
- # Deleting site memberships is not supported yet
- if (deleted):
- return []
- return SlicePrivilege.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
-
- def sync_record(self, slice_memb):
- # sync slice memberships at all slice controllers
- logger.info("syncing slice privilege: %s %s" % (slice_memb.slice.name, slice_memb.user.email))
- slice_controllers = ControllerSlice.objects.filter(slice=slice_memb.slice)
- for slice_controller in slice_controllers:
- if not slice_controller.tenant_id:
- continue
- controller_users = ControllerUser.objects.filter(controller=slice_controller.controller,
- user=slice_memb.user)
- if controller_users:
- kuser_id = controller_users[0].kuser_id
- driver = self.driver.admin_driver(controller=slice_controller.controller.name)
- driver.add_user_role(kuser_id,
- slice_controller.tenant_id,
- slice_memb.role.role)
diff --git a/planetstack/openstack_observer/steps/sync_slices.py b/planetstack/openstack_observer/steps/sync_slices.py
deleted file mode 100644
index 99ed44c..0000000
--- a/planetstack/openstack_observer/steps/sync_slices.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import os
-import base64
-from netaddr import IPAddress, IPNetwork
-from django.db.models import F, Q
-from planetstack.config import Config
-from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.slice import Slice, ControllerSlice
-from util.logger import Logger, logging
-from observer.steps.sync_controller_slices import *
-
-logger = Logger(level=logging.INFO)
-
-class SyncSlices(OpenStackSyncStep):
- provides=[Slice]
- requested_interval=0
-
- def sync_record(self, slice):
- for controller_slice in ControllerSlice.objects.filter(slice=slice):
- # bump the 'updated' timestamp and trigger observer to update
- # slice across all controllers
- controller_slice.save()
-
- def delete_record(self, slice):
- controller_slice_deleter = SyncControllerSlice().delete_record
- for controller_slice in ControllerSlice.objects.filter(slice=slice):
- try:
- controller_slice_deleter(controller_slice)
- except Exception,e:
- logger.log_exc("Failed to delete controller_slice %s" % controller_slice)
- raise e
diff --git a/planetstack/openstack_observer/steps/sync_slivers.py b/planetstack/openstack_observer/steps/sync_slivers.py
index 8adb50c..8488b66 100644
--- a/planetstack/openstack_observer/steps/sync_slivers.py
+++ b/planetstack/openstack_observer/steps/sync_slivers.py
@@ -58,7 +58,7 @@
if network.template.shared_network_name]
#driver = self.driver.client_driver(caller=sliver.creator, tenant=sliver.slice.name, controller=sliver.controllerNetwork)
- driver = self.driver.admin_driver(tenant='admin', controller=sliver.controllerNetwork)
+ driver = self.driver.admin_driver(tenant='admin', controller=sliver.node.site_deployment.controller)
nets = driver.shell.quantum.list_networks()['networks']
for net in nets:
if net['name'] in network_templates:
@@ -70,7 +70,7 @@
nics.append(net['id'])
# look up image id
- controller_driver = self.driver.admin_driver(controller=sliver.controllerNetwork)
+ controller_driver = self.driver.admin_driver(controller=sliver.node.site_deployment.controller)
image_id = None
images = controller_driver.shell.glanceclient.images.list()
for image in images:
@@ -102,7 +102,7 @@
if sliver.userData:
userData = sliver.userData
- controller = sliver.controllerNetwork
+ controller = sliver.node.site_deployment.controller
tenant_fields = {'endpoint':controller.auth_url,
'admin_user': sliver.creator.username,
'admin_password': sliver.creator.password,
diff --git a/planetstack/openstack_observer/steps/sync_users.py b/planetstack/openstack_observer/steps/sync_users.py
deleted file mode 100644
index 4cb1a26..0000000
--- a/planetstack/openstack_observer/steps/sync_users.py
+++ /dev/null
@@ -1,24 +0,0 @@
-import os
-import base64
-import hashlib
-from django.db.models import F, Q
-from planetstack.config import Config
-from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.user import User
-from core.models.controllerusers import ControllerUser
-from observer.steps.sync_controller_users import SyncControllerUser
-
-class SyncUsers(OpenStackSyncStep):
- provides=[User]
- requested_interval=0
-
- def sync_record(self, user):
- for controller_user in ControllerUser.objects.filter(user=user):
- # bump the 'updated' field so user account are updated across
- # controllers.
- controller_user.save()
-
- def delete_record(self, user):
- controller_user_deleter = SyncControllerUser().delete_record
- for controller_user in ControllerUser.objects.filter(user=user):
- controller_user_deleter(controller_user)