def test_delete_container_success(self): swift_utils.empty_container(self.swiftclient, self.container_name) mock_calls = [ mock.call('overcloud', 'some-name.yaml'), mock.call('overcloud', 'some-other-name.yaml'), mock.call('overcloud', 'yet-some-other-name.yaml'), mock.call('overcloud', 'finally-another-name.yaml') ] self.swiftclient.delete_object.assert_has_calls( mock_calls, any_order=True) self.swiftclient.get_account.assert_called() self.swiftclient.get_container.assert_called_with(self.container_name)
def update_plan_from_templates(clients, name, tht_root, roles_file=None, generate_passwords=True, plan_env_file=None, networks_file=None): swift_client = clients.tripleoclient.object_store # If the plan environment was migrated to Swift, save the generated # 'passwords' if they exist as they can't be recreated from the # templates content. passwords = [] try: env = yaml.safe_load( swift_client.get_object(name, constants.PLAN_ENVIRONMENT)[1]) passwords = env.get('passwords', []) except swift_exc.ClientException: pass # TODO(dmatthews): Removing the existing plan files should probably be # a Mistral action. print("Removing the current plan files") swiftutils.empty_container(swift_client, name) # Until we have a well defined plan update workflow in # tripleo-common we need to manually reset the environments and # parameter_defaults here. This is to ensure that no environments # are in the plan environment but not actually in swift. # See bug: https://bugs.launchpad.net/tripleo/+bug/1623431 # # Currently this is being done incidentally because we overwrite # the existing plan-environment.yaml with the skeleton one in THT # when updating the templates. Once LP#1623431 is resolved we may # need to special-case plan-environment.yaml to avoid this. print("Uploading new plan files") _upload_templates(swift_client, name, tht_root, roles_file, plan_env_file, networks_file) _update_passwords(swift_client, name, passwords) update_deployment_plan(clients, container=name, generate_passwords=generate_passwords, source_url=None)
def update_plan_from_templates(clients, name, tht_root, roles_file=None, generate_passwords=True, plan_env_file=None, networks_file=None, keep_env=False, validate_stack=True): swift_client = clients.tripleoclient.object_store passwords = None keep_file_contents = {} roles_file = utils.rel_or_abs_path(roles_file, tht_root) if keep_env: # Dict items are (remote_name, local_name). local_name may be # None in which case we only try to load from Swift (remote). keep_map = { constants.PLAN_ENVIRONMENT: plan_env_file, constants.USER_ENVIRONMENT: None, constants.OVERCLOUD_ROLES_FILE: roles_file, constants.OVERCLOUD_NETWORKS_FILE: networks_file, } # Also try to fetch any files under 'user-files/' # dir. local_name is always None for these keep_map.update( dict( map(lambda path: (path, None), _list_user_files(swift_client, name)))) keep_file_contents = _load_content_or_file(swift_client, name, keep_map) else: passwords = _load_passwords(swift_client, name) # TODO(dmatthews): Removing the existing plan files should probably be # a Mistral action. print("Removing the current plan files") swiftutils.empty_container(swift_client, name) # Until we have a well defined plan update workflow in # tripleo-common we need to manually reset the environments and # parameter_defaults here. This is to ensure that no environments # are in the plan environment but not actually in swift. # See bug: https://bugs.launchpad.net/tripleo/+bug/1623431 # # Currently this is being done incidentally because we overwrite # the existing plan-environment.yaml with the skeleton one in THT # when updating the templates. Once LP#1623431 is resolved we may # need to special-case plan-environment.yaml to avoid this. print("Uploading new plan files") if keep_env: _upload_templates(swift_client, name, tht_root) for filename in keep_file_contents: _upload_file_content(swift_client, name, filename, keep_file_contents[filename]) else: _upload_templates(swift_client, name, tht_root, roles_file, plan_env_file, networks_file) _update_passwords(swift_client, name, passwords) update_deployment_plan(clients, container=name, generate_passwords=generate_passwords, source_url=None, validate_stack=validate_stack)