Fix bugs. Reefactor.
diff --git a/planetstack/openstack_observer/steps/__init__.py b/planetstack/openstack_observer/steps/__init__.py
index 3f074a5..3f8dca4 100644
--- a/planetstack/openstack_observer/steps/__init__.py
+++ b/planetstack/openstack_observer/steps/__init__.py
@@ -1,16 +1,14 @@
-##from .sync_external_routes import SyncExternalRoutes
-#from .sync_network_slivers import SyncNetworkSlivers
-#from .sync_networks import SyncNetworks
-#from .sync_controller_networks import SyncControllerNetworks
-#from .sync_site_privileges import SyncSitePrivileges
-#from .sync_sites import SyncSites
-#from .sync_slice_memberships import SyncSliceMemberships
-#from .sync_slices import SyncSlices
-##from .sync_sliver_ips import SyncSliverIps
-#from .sync_slivers import SyncSlivers
-#from .sync_users import SyncUsers
-#from .sync_roles import SyncRoles
-#from .sync_nodes import SyncNodes
-#from .sync_images import SyncImages
-#from .sync_controller_images import SyncControllerImages
-#from .garbage_collector import GarbageCollector
+from .sync_controller_site_deployments import SyncControllerSiteDeployments
+from .sync_network_slivers import SyncNetworkSlivers
+from .sync_networks import SyncNetworks
+from .sync_controller_networks import SyncControllerNetworks
+from .sync_site_privileges import SyncSitePrivileges
+from .sync_sites import SyncSites
+from .sync_slice_memberships import SyncSliceMemberships
+from .sync_slices import SyncSlices
+from .sync_slivers import SyncSlivers
+from .sync_users import SyncUsers
+from .sync_roles import SyncRoles
+from .sync_nodes import SyncNodes
+from .sync_images import SyncImages
+from .sync_controller_images import SyncControllerImages
diff --git a/planetstack/openstack_observer/steps/sync_controller_site_deployments.py b/planetstack/openstack_observer/steps/sync_controller_site_deployments.py
index a923608..907325a 100644
--- a/planetstack/openstack_observer/steps/sync_controller_site_deployments.py
+++ b/planetstack/openstack_observer/steps/sync_controller_site_deployments.py
@@ -10,6 +10,10 @@
requested_interval=0
provides=[SiteDeployments]
+ def fetch_pending(self, deleted=False):
+ pending = super(OpenStackSyncStep, self).fetch_pending(deleted)
+ return pending.filter(controller__isnull=False)
+
def sync_record(self, site_deployment):
template = os_template_env.get_template('sync_controller_site_deployments.yaml')
@@ -17,7 +21,7 @@
'admin_user': site_deployment.controller.admin_user,
'admin_password': site_deployment.controller.admin_password,
'admin_tenant': site_deployment.controller.admin_tenant,
- 'ansible_tag': '%s@%s'%(site_deployment.site.login_base,site_deployment.site_deployment.deployment.name), # name of ansible playbook
+ 'ansible_tag': '%s@%s'%(site_deployment.site.login_base,site_deployment.deployment.name), # name of ansible playbook
'tenant': site_deployment.site.login_base,
'tenant_description': site_deployment.site.name}
diff --git a/planetstack/openstack_observer/steps/sync_controller_users.py b/planetstack/openstack_observer/steps/sync_controller_users.py
index 113869e..1b57b81 100644
--- a/planetstack/openstack_observer/steps/sync_controller_users.py
+++ b/planetstack/openstack_observer/steps/sync_controller_users.py
@@ -4,7 +4,7 @@
from django.db.models import F, Q
from planetstack.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.site import Controller, SiteDeployments, ControllerSiteDeployments
+from core.models.site import Controller, SiteDeployments, SiteDeployments
from core.models.user import User
from core.models.controllerusers import ControllerUsers
from util.logger import Logger, logging
@@ -44,7 +44,7 @@
raise Exception('Siteless user %s'%controller_user.user.email)
else:
# look up tenant id for the user's site at the controller
- #ctrl_site_deployments = ControllerSiteDeployments.objects.filter(
+ #ctrl_site_deployments = SiteDeployments.objects.filter(
# site_deployment__site=controller_user.user.site,
# controller=controller_user.controller)
diff --git a/planetstack/openstack_observer/steps/sync_nodes.py b/planetstack/openstack_observer/steps/sync_nodes.py
index 8702a21..9d51073 100644
--- a/planetstack/openstack_observer/steps/sync_nodes.py
+++ b/planetstack/openstack_observer/steps/sync_nodes.py
@@ -6,7 +6,7 @@
from planetstack.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
from core.models.node import Node
-from core.models.site import SiteDeployments, Controller, ControllerSiteDeployments
+from core.models.site import SiteDeployments, Controller, SiteDeployments
from util.logger import Logger, logging
logger = Logger(level=logging.INFO)
@@ -30,7 +30,7 @@
new_nodes = []
for controller in controllers:
try:
- controller_site_deployments = ControllerSiteDeployments.objects.filter(controller=controller)[0]
+ controller_site_deployments = SiteDeployments.objects.filter(controller=controller)[0]
except IndexError:
raise Exception("Controller %s not bound to any site deployments"%controller.name)
diff --git a/planetstack/openstack_observer/steps/sync_site_privileges.py b/planetstack/openstack_observer/steps/sync_site_privileges.py
index 9dcd07e..6354d1f 100644
--- a/planetstack/openstack_observer/steps/sync_site_privileges.py
+++ b/planetstack/openstack_observer/steps/sync_site_privileges.py
@@ -3,7 +3,7 @@
from django.db.models import F, Q
from planetstack.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
-from core.models import User, ControllerUsers, SitePrivilege, ControllerSiteDeployments
+from core.models import User, ControllerUsers, SitePrivilege, SiteDeployments
class SyncSitePrivileges(OpenStackSyncStep):
requested_interval=0
@@ -18,7 +18,7 @@
def sync_record(self, site_priv):
# sync site privileges at all site controllers
- ctrl_site_deployments = ControllerSiteDeployments.objects.filter(site_deployment__site=site_priv.site)
+ ctrl_site_deployments = SiteDeployments.objects.filter(site_deployment__site=site_priv.site)
for ctrl_site_deployment in ctrl_site_deployments:
controller_users = ControllerUsers.objects.filter(controller=ctrl_site_deployment.controller,
user=site_priv.user)
diff --git a/planetstack/openstack_observer/steps/sync_sites.py b/planetstack/openstack_observer/steps/sync_sites.py
index e18e2f8..ea7df7e 100644
--- a/planetstack/openstack_observer/steps/sync_sites.py
+++ b/planetstack/openstack_observer/steps/sync_sites.py
@@ -3,7 +3,7 @@
from django.db.models import F, Q
from planetstack.config import Config
from observer.openstacksyncstep import OpenStackSyncStep
-from core.models.site import Site, SiteDeployments, ControllerSiteDeployments
+from core.models.site import Site, SiteDeployments, SiteDeployments
from observer.steps.sync_controller_site_deployments import *
class SyncSites(OpenStackSyncStep):
@@ -15,15 +15,11 @@
def delete_record(self, site):
# delete associated controllers site deployments
- ctrl_site_deployments = ControllerSiteDeployments.objects.filter(site_deployment__site=site)
- ctrl_site_deploy_deleter = SyncControllerSiteDeployments().delete_record
- for ctrl_site_deployment in ctrl_site_deployments:
- ctrl_site_deployment_deleter(ctrl_site_deployment)
-
- # delete site deployments
site_deployments = SiteDeployments.objects.filter(site=site)
+ site_deploy_deleter = SyncControllerSiteDeployments().delete_record
for site_deployment in site_deployments:
- site_deployment.delete()
+ site_deployment_deleter(site_deployment)
+