add delete identifier in nimbus when user delete a stage
delete stage before delete env and fix unloaded exception from create identifer function
raise exception instead od swallow it
remove teletraan exception import
add get all envs again after delete envs for get updated len of envs
MODIFY
deploy-board/deploy_board/webapp/env_views.py
deploy-board/deploy_board/webapp/env_views.py
@@ -832,7 +832,7 @@ def create_identifier_for_new_stage(request, env_name, stage_name):
else:
# retrieve Nimbus identifier for existing_stage
existing_stage_identifier = environs_helper.get_nimbus_identifier(stage_with_external_id['externalId'])
-
+ new_stage_identifier = None
# create Nimbus Identifier for the new stage
if existing_stage_identifier is not None:
nimbus_request_data = existing_stage_identifier.copy()
@@ -865,10 +865,18 @@ def post_add_stage(request, name):
def remove_stage(request, name, stage):
# TODO so we need to make sure the capacity is empty???
- environs_helper.delete_env(request, name, stage)
-
envs = environs_helper.get_all_env_stages(request, name)
+ current_env_stage_with_external_id = None
+ for env_stage in envs:
+ if env_stage['externalId'] is not None and env_stage['stageName'] == stage:
+ current_env_stage_with_external_id = env_stage
+ break
+
+ if current_env_stage_with_external_id is not None and current_env_stage_with_external_id['externalId'] is not None:
+ environs_helper.delete_nimbus_identifier(current_env_stage_with_external_id['externalId'])
+ environs_helper.delete_env(request, name, stage)
+ envs = environs_helper.get_all_env_stages(request, name)
response = redirect('/env/' + name)
if len(envs) == 0:

MODIFY
deploy-board/deploy_board/webapp/helpers/environs_helper.py
deploy-board/deploy_board/webapp/helpers/environs_helper.py
@@ -66,6 +66,9 @@ def get_nimbus_identifier(name):
def create_nimbus_identifier(data):
return nimbusclient.create_one_identifier(data)
+def delete_nimbus_identifier(name):
+ return nimbusclient.delete_one_identifier(name)
+
# Teletraan Deploy client helpers

MODIFY
deploy-board/deploy_board/webapp/helpers/nimbusclient.py
deploy-board/deploy_board/webapp/helpers/nimbusclient.py
@@ -56,3 +56,7 @@ class NimbusClient(object):
response = requests.post('{}/api/{}/identifiers'.format(NIMBUS_SERVICE_URL, NIMBUS_SERVICE_VERSION), json=payload)
return self.handle_response(response)
+
+ def delete_one_identifier(self, name):
+ response = requests.delete('{}/api/{}/identifiers/{}'.format(NIMBUS_SERVICE_URL, NIMBUS_SERVICE_VERSION, name))
+ return self.handle_response(response)
\ No newline at end of file

add delete identifier in nimbus when user delete a stage (#642)

delete stage before delete env and fix unloaded exception from create identifer function

raise exception instead od swallow it

remove teletraan exception import

add get all envs again after delete envs for get updated len of envs