Prevent failure when the sliver creator does not have an account at the
hosting deployment.
diff --git a/planetstack/openstack_observer/steps/sync_slice_deployments.py b/planetstack/openstack_observer/steps/sync_slice_deployments.py
index 4c358d7..617791e 100644
--- a/planetstack/openstack_observer/steps/sync_slice_deployments.py
+++ b/planetstack/openstack_observer/steps/sync_slice_deployments.py
@@ -48,41 +48,42 @@
logger.info("deployment %r has no admin_user, skipping" % slice_deployment.deployment)
return
- deployment_users = UserDeployments.objects.filter(user=slice_deployment.slice.creator,
- deployment=slice_deployment.deployment)
- if not deployment_users:
- logger.info("slice createor %s has not accout at deployment %s" % (slice_deployment.slice.creator, slice_deployment.deployment.name))
- roles = []
- else:
- deployment_user = deployment_users[0]
- roles = ['admin']
-
- max_instances=int(slice_deployment.slice.max_slivers)
- tenant_fields = {'endpoint':slice_deployment.deployment.auth_url,
- 'admin_user': slice_deployment.deployment.admin_user,
- 'admin_password': slice_deployment.deployment.admin_password,
- 'admin_tenant': 'admin',
- 'tenant': slice_deployment.slice.name,
- 'tenant_description': slice_deployment.slice.description,
- 'roles':roles,
- 'name':deployment_user.user.email,
- 'max_instances':max_instances}
+ deployment_users = UserDeployments.objects.filter(user=slice_deployment.slice.creator,
+ deployment=slice_deployment.deployment)
+ if not deployment_users:
+ logger.info("slice createor %s has not accout at deployment %s" % (slice_deployment.slice.creator, slice_deployment.deployment.name))
+ roles = ['admin']
+ deployment_user = 'Undefined'
+ else:
+ deployment_user = deployment_users[0].user.email
+ roles = ['admin']
- res = run_template('sync_slice_deployments.yaml', tenant_fields)
- expected_num = len(roles)+1
- if (len(res)!=expected_num):
- raise Exception('Could not sync tenants for slice %s'%slice_deployment.slice.name)
- else:
- tenant_id = res[0]['id']
- if (not slice_deployment.tenant_id):
- handle = os.popen('nova quota-update --instances %d %s'%(max_instances,tenant_id))
- output = handle.read()
- result = handle.close()
- if (result):
- logging.info('Could not update quota for %s'%slice_deployment.slice.name)
- slice_deployment.tenant_id = tenant_id
- slice_deployment.save()
-
+ max_instances=int(slice_deployment.slice.max_slivers)
+ tenant_fields = {'endpoint':slice_deployment.deployment.auth_url,
+ 'admin_user': slice_deployment.deployment.admin_user,
+ 'admin_password': slice_deployment.deployment.admin_password,
+ 'admin_tenant': 'admin',
+ 'tenant': slice_deployment.slice.name,
+ 'tenant_description': slice_deployment.slice.description,
+ 'roles':roles,
+ 'name':deployment_user
+ 'max_instances':max_instances}
+
+ res = run_template('sync_slice_deployments.yaml', tenant_fields)
+ expected_num = len(roles)+1
+ if (len(res)!=expected_num):
+ raise Exception('Could not sync tenants for slice %s'%slice_deployment.slice.name)
+ else:
+ tenant_id = res[0]['id']
+ if (not slice_deployment.tenant_id):
+ handle = os.popen('nova quota-update --instances %d %s'%(max_instances,tenant_id))
+ output = handle.read()
+ result = handle.close()
+ if (result):
+ logging.info('Could not update quota for %s'%slice_deployment.slice.name)
+ slice_deployment.tenant_id = tenant_id
+ slice_deployment.save()
+
def delete_record(self, slice_deployment):
@@ -96,10 +97,9 @@
client_driver.delete_router_interface(slice_deployment.router_id, slice_deployment.subnet_id)
if slice_deployment.subnet_id:
client_driver.delete_subnet(slice_deployment.subnet_id)
- if slice_deployment.router_id:
+ if slice_deployment.router_id:
client_driver.delete_router(slice_deployment.router_id)
if slice_deployment.network_id:
client_driver.delete_network(slice_deployment.network_id)
if slice_deployment.tenant_id:
driver.delete_tenant(slice_deployment.tenant_id)
-