コード例 #1
0
    def test_create_environment_file(self):

        json_file_path = "env.json"

        mock_open = mock.mock_open()

        with mock.patch('six.moves.builtins.open', mock_open):
            with mock.patch('json.dumps', return_value="JSON"):
                utils.create_environment_file(path=json_file_path)

                mock_open.assert_called_with('env.json', 'w+')

        mock_open().write.assert_called_with('JSON')
コード例 #2
0
    def test_create_environment_file(self):

        json_file_path = "env.json"

        mock_open = mock.mock_open()

        with mock.patch('six.moves.builtins.open', mock_open):
            with mock.patch('json.dumps', return_value="JSON"):
                utils.create_environment_file(path=json_file_path)

                mock_open.assert_called_with('env.json', 'w+')

        mock_open().write.assert_called_with('JSON')
コード例 #3
0
    def _deploy_tripleo_heat_templates(self, stack, parsed_args):
        """Deploy the fixed templates in TripleO Heat Templates"""
        clients = self.app.client_manager
        network_client = clients.network

        parameters = self._update_paramaters(parsed_args, network_client,
                                             stack)

        utils.check_nodes_count(
            self.app.client_manager.tripleoclient.baremetal(), stack,
            parameters, {
                'ControllerCount': 1,
                'ComputeCount': 1,
                'ObjectStorageCount': 0,
                'BlockStorageCount': 0,
                'CephStorageCount': 0,
            })

        tht_root = parsed_args.templates

        print("Deploying templates in the directory {0}".format(
            os.path.abspath(tht_root)))

        self.log.debug("Creating Environment file")
        # TODO(jprovazn): env file generated by create_environment_file()
        # is not very usable any more, scale params are included in
        # parameters and keystone cert is generated on create only
        env_path = utils.create_environment_file()
        environments = []
        add_registry = False

        if stack is None:
            self.log.debug("Creating Keystone certificates")
            keystone_pki.generate_certs_into_json(env_path, False)
            environments.append(env_path)
            add_registry = True

        environments.extend(self._create_parameters_env(parameters))
        if parsed_args.rhel_reg:
            reg_env = self._create_registration_env(parsed_args)
            environments.extend(reg_env)
            add_registry = True
        if parsed_args.environment_files:
            environments.extend(parsed_args.environment_files)
            add_registry = True

        if add_registry:
            # default resource registry file should be passed only
            # when creating a new stack, or when custom environments are
            # specified, otherwise it might overwrite
            # resource_registries in existing stack
            resource_registry_path = os.path.join(
                tht_root, constants.RESOURCE_REGISTRY_NAME)
            environments.insert(0, resource_registry_path)

        overcloud_yaml = os.path.join(tht_root, constants.OVERCLOUD_YAML_NAME)

        self._heat_deploy(stack, parsed_args.stack, overcloud_yaml, parameters,
                          environments, parsed_args.timeout)
コード例 #4
0
    def _deploy_tripleo_heat_templates(self, stack, parsed_args):
        """Deploy the fixed templates in TripleO Heat Templates"""
        clients = self.app.client_manager
        network_client = clients.network
        workflow_client = clients.workflow_engine

        parameters = self._update_parameters(
            parsed_args, network_client, stack)

        tht_root = os.path.abspath(parsed_args.templates)

        plans = plan_management.list_deployment_plans(workflow_client)

        # TODO(d0ugal): We need to put a more robust strategy in place here to
        #               handle updating plans.
        if parsed_args.stack in plans:
            # Upload the new plan templates to swift to replace the existing
            # templates.
            plan_management.update_plan_from_templates(
                clients, parsed_args.stack, tht_root)
        else:
            plan_management.create_plan_from_templates(
                clients, parsed_args.stack, tht_root)

        print("Deploying templates in the directory {0}".format(
            os.path.abspath(tht_root)))

        self.log.debug("Creating Environment file")
        # TODO(jprovazn): env file generated by create_environment_file()
        # is not very usable any more, scale params are included in
        # parameters and keystone cert is generated on create only
        env_path = utils.create_environment_file()
        env = {}
        created_env_files = []

        if stack is None:
            self.log.debug("Creating Keystone certificates")
            keystone_pki.generate_certs_into_json(env_path, False)
            created_env_files.append(env_path)

        if parsed_args.environment_directories:
            created_env_files.extend(self._load_environment_directories(
                parsed_args.environment_directories))
        env.update(self._create_parameters_env(parameters))

        if parsed_args.rhel_reg:
            reg_env_files, reg_env = self._create_registration_env(parsed_args)
            created_env_files.extend(reg_env_files)
            template_utils.deep_update(env, reg_env)
        if parsed_args.environment_files:
            created_env_files.extend(parsed_args.environment_files)

        self._try_overcloud_deploy_with_compat_yaml(
            tht_root, stack, parsed_args.stack, parameters, created_env_files,
            parsed_args.timeout, env)
コード例 #5
0
    def _deploy_tripleo_heat_templates(self, stack, parsed_args):
        """Deploy the fixed templates in TripleO Heat Templates"""
        clients = self.app.client_manager
        network_client = clients.network

        parameters = self._update_paramaters(
            parsed_args, network_client, stack)

        utils.check_nodes_count(
            self.app.client_manager.tripleoclient.baremetal(),
            stack,
            parameters,
            {
                'ControllerCount': 1,
                'ComputeCount': 1,
                'ObjectStorageCount': 0,
                'BlockStorageCount': 0,
                'CephStorageCount': 0,
            }
        )

        tht_root = parsed_args.templates

        print("Deploying templates in the directory {0}".format(
            os.path.abspath(tht_root)))

        self.log.debug("Creating Environment file")
        # TODO(jprovazn): env file generated by create_environment_file()
        # is not very usable any more, scale params are included in
        # parameters and keystone cert is generated on create only
        env_path = utils.create_environment_file()
        environments = []

        if stack is None:
            self.log.debug("Creating Keystone certificates")
            keystone_pki.generate_certs_into_json(env_path, False)
            # default resource registry file should be passed only
            # when creating a new stack, otherwise it might overwrite
            # resource_registries in existing stack
            resource_registry_path = os.path.join(tht_root,
                                                  RESOURCE_REGISTRY_NAME)
            environments.extend([resource_registry_path, env_path])

        environments.extend(self._create_parameters_env(parameters))
        if parsed_args.rhel_reg:
            reg_env = self._create_registration_env(parsed_args)
            environments.extend(reg_env)
        if parsed_args.environment_files:
            environments.extend(parsed_args.environment_files)

        overcloud_yaml = os.path.join(tht_root, OVERCLOUD_YAML_NAME)

        self._heat_deploy(stack, parsed_args.stack, overcloud_yaml, parameters,
                          environments, parsed_args.timeout)
コード例 #6
0
    def _deploy_tripleo_heat_templates(self, stack, parsed_args):
        """Deploy the fixed templates in TripleO Heat Templates"""
        clients = self.app.client_manager
        network_client = clients.network

        parameters = self._update_parameters(
            parsed_args, network_client, stack)

        tht_root = parsed_args.templates

        print("Deploying templates in the directory {0}".format(
            os.path.abspath(tht_root)))

        self.log.debug("Creating Environment file")
        # TODO(jprovazn): env file generated by create_environment_file()
        # is not very usable any more, scale params are included in
        # parameters and keystone cert is generated on create only
        env_path = utils.create_environment_file()
        environments = []
        add_registry = False

        if stack is None:
            self.log.debug("Creating Keystone certificates")
            keystone_pki.generate_certs_into_json(env_path, False)
            environments.append(env_path)
            add_registry = True

        if parsed_args.environment_directories:
            environments.extend(self._load_environment_directories(
                parsed_args.environment_directories))

        environments.extend(self._create_parameters_env(parameters))
        if parsed_args.rhel_reg:
            reg_env = self._create_registration_env(parsed_args)
            environments.extend(reg_env)
            add_registry = True
        if parsed_args.environment_files:
            environments.extend(parsed_args.environment_files)
            add_registry = True

        if add_registry:
            # default resource registry file should be passed only
            # when creating a new stack, or when custom environments are
            # specified, otherwise it might overwrite
            # resource_registries in existing stack
            resource_registry_path = os.path.join(
                tht_root, constants.RESOURCE_REGISTRY_NAME)
            environments.insert(0, resource_registry_path)

        self._try_overcloud_deploy_with_compat_yaml(
            tht_root, stack, parsed_args.stack, parameters, environments,
            parsed_args.timeout)
コード例 #7
0
    def _deploy_tripleo_heat_templates(self, stack, parsed_args,
                                       tht_root, user_tht_root):
        """Deploy the fixed templates in TripleO Heat Templates"""
        clients = self.app.client_manager
        network_client = clients.network
        workflow_client = clients.workflow_engine

        parameters = self._update_parameters(
            parsed_args, network_client, stack)

        plans = plan_management.list_deployment_plans(workflow_client)

        # TODO(d0ugal): We need to put a more robust strategy in place here to
        #               handle updating plans.
        if parsed_args.stack in plans:
            # Upload the new plan templates to swift to replace the existing
            # templates.
            plan_management.update_plan_from_templates(
                clients, parsed_args.stack, tht_root, parsed_args.roles_file)
        else:
            plan_management.create_plan_from_templates(
                clients, parsed_args.stack, tht_root, parsed_args.roles_file)

        # Get any missing (e.g j2 rendered) files from the plan to tht_root
        added_files = self._download_missing_files_from_plan(
            tht_root, parsed_args.stack)

        print("Deploying templates in the directory {0}".format(
            os.path.abspath(tht_root)))

        self.log.debug("Creating Environment file")
        # TODO(jprovazn): env file generated by create_environment_file()
        # is not very usable any more, scale params are included in
        # parameters and keystone cert is generated on create only
        env_path = utils.create_environment_file()
        env = {}
        created_env_files = []

        if stack is None:
            self.log.debug("Creating Keystone certificates")
            keystone_pki.generate_certs_into_json(env_path, False)
            created_env_files.append(env_path)

        if parsed_args.environment_directories:
            created_env_files.extend(self._load_environment_directories(
                parsed_args.environment_directories))
        env.update(self._create_parameters_env(parameters))

        if parsed_args.rhel_reg:
            reg_env_files, reg_env = self._create_registration_env(parsed_args)
            created_env_files.extend(reg_env_files)
            template_utils.deep_update(env, reg_env)
        if parsed_args.environment_files:
            created_env_files.extend(parsed_args.environment_files)

        self.log.debug("Processing environment files %s" % created_env_files)
        env_files, localenv = self._process_multiple_environments(
            created_env_files, added_files, tht_root, user_tht_root,
            cleanup=not parsed_args.no_cleanup)
        template_utils.deep_update(env, localenv)

        self._try_overcloud_deploy_with_compat_yaml(
            tht_root, stack, parsed_args.stack, parameters, env_files,
            parsed_args.timeout, env, parsed_args.update_plan_only)