Controller-related updates to sync_controller_slices
Sapan Bhatia [Mon, 22 Dec 2014 06:44:38 +0000 (01:44 -0500)]
planetstack/openstack_observer/steps/sync_controller_slices.py

index 636d007..9b5957d 100644 (file)
@@ -9,6 +9,7 @@ from core.models.slice import Slice, ControllerSlices
 from core.models.controllerusers import ControllerUsers
 from util.logger import Logger, logging
 from observer.ansible import *
+import pdb
 
 logger = Logger(level=logging.INFO)
 
@@ -32,12 +33,12 @@ class SyncControllerSlices(OpenStackSyncStep):
        controller_users = ControllerUsers.objects.filter(user=controller_slice.slice.creator,
                                                              controller=controller_slice.controller)            
        if not controller_users:
-           logger.info("slice createor %s has not accout at controller %s" % (controller_slice.slice.creator, controller_slice.controller.name))
-           roles = []
+           raise Exception("slice createor %s has not accout at controller %s" % (controller_slice.slice.creator, controller_slice.controller.name))
        else:
            controller_user = controller_users[0]
            roles = ['admin']
            
+       pdb.set_trace()
        max_instances=int(controller_slice.slice.max_slivers)
        tenant_fields = {'endpoint':controller_slice.controller.auth_url,
                         'admin_user': controller_slice.controller.admin_user,
@@ -47,9 +48,10 @@ class SyncControllerSlices(OpenStackSyncStep):
                         'tenant_description': controller_slice.slice.description,
                         'roles':roles,
                         'name':controller_user.user.email,
+                        'ansible_tag':'%s@%s'%(controller_slice.slice.name,controller_slice.controller.name),
                         'max_instances':max_instances}
 
-       res = run_template('sync_controller_slices.yaml', tenant_fields)
+       res = run_template('sync_controller_slices.yaml', tenant_fields, path='controller_slices')
        expected_num = len(roles)+1
        if (len(res)!=expected_num):
            raise Exception('Could not sync tenants for slice %s'%controller_slice.slice.name)
@@ -61,6 +63,7 @@ class SyncControllerSlices(OpenStackSyncStep):
                result = handle.close()
                if (result):
                    logging.info('Could not update quota for %s'%controller_slice.slice.name)
+                   raise Exception('Could not update quota for %s'%controller_slice.slice.name)
                controller_slice.tenant_id = tenant_id
                controller_slice.save()