Example #1
0
    def test_run_yaml_error(self, get_obj_client_mock):
        # setup swift
        swift = mock.MagicMock()
        swift.get_object.return_value = mock.Mock(side_effect=ValueError)
        get_obj_client_mock.return_value = swift

        action = heat_capabilities.GetCapabilitiesAction(self.container_name)
        expected = mistral_workflow_utils.Result(
            data=None, error="Error parsing capabilities-map.yaml.")
        self.assertEqual(expected, action.run())
Example #2
0
    def test_run(self, get_workflow_client_mock, get_obj_client_mock):

        # setup swift
        swift = mock.MagicMock()
        swift.get_object.return_value = ({}, MAPPING_YAML_CONTENTS)
        swift_files_data = ({
            u'x-container-meta-usage-tripleo': u'plan',
            u'content-length': u'54271',
            u'x-container-object-count': u'3',
            u'accept-ranges': u'bytes',
            u'x-storage-policy': u'Policy-0',
            u'date': u'Wed, 31 Aug 2016 16:04:37 GMT',
            u'x-timestamp': u'1471025600.02126',
            u'x-trans-id': u'txebb37f980dbc4e4f991dc-0057c70015',
            u'x-container-bytes-used': u'970557',
            u'content-type': u'application/json; charset=utf-8'
        }, [{
            u'bytes': 808,
            u'last_modified': u'2016-08-12T18:13:22.231760',
            u'hash': u'2df2606ed8b866806b162ab3fa9a77ea',
            u'name': 'all-nodes-validation.yaml',
            u'content_type': u'application/octet-stream'
        }, {
            u'bytes': 1808,
            u'last_modified': u'2016-08-13T18:13:22.231760',
            u'hash': u'3df2606ed8b866806b162ab3fa9a77ea',
            u'name': '/path/to/environments/custom.yaml',
            u'content_type': u'application/octet-stream'
        }, {
            u'bytes': 2808,
            u'last_modified': u'2016-07-13T18:13:22.231760',
            u'hash': u'4df2606ed8b866806b162ab3fa9a77ea',
            u'name': '/path/to/environments/custom2.yaml',
            u'content_type': u'application/octet-stream'
        }])
        swift.get_container.return_value = swift_files_data
        get_obj_client_mock.return_value = swift

        # setup mistral
        mistral = mock.MagicMock()
        get_workflow_client_mock.return_value = mistral

        mock_env = mock.MagicMock()
        mock_env.name = self.container_name
        mock_env.variables = {
            'template': 'overcloud',
            'environments': [{
                'path': '/path/to/network-isolation.json'
            }]
        }
        mistral.environments.get.return_value = mock_env

        action = heat_capabilities.GetCapabilitiesAction(self.container_name)
        yaml_mapping = yaml.safe_load(MAPPING_JSON_CONTENTS)
        self.assertEqual(yaml_mapping, action.run())
Example #3
0
    def test_run_env_missing(self, get_obj_client_mock):

        mock_ctx = mock.MagicMock()
        # setup swift
        swift = mock.MagicMock()
        swift.get_object.side_effect = (({}, MAPPING_YAML_CONTENTS),
                                        swiftexceptions.ClientException(
                                            self.container_name))
        get_obj_client_mock.return_value = swift

        action = heat_capabilities.GetCapabilitiesAction(self.container_name)
        expected = actions.Result(
            data=None,
            error="Error retrieving environment for plan test-container: "
            "test-container")
        self.assertEqual(expected, action.run(mock_ctx))
Example #4
0
    def test_run_mistral_error(self, get_workflow_client_mock,
                               get_obj_client_mock):

        # setup swift
        swift = mock.MagicMock()
        swift.get_object.return_value = ({}, MAPPING_YAML_CONTENTS)
        get_obj_client_mock.return_value = swift

        # setup mistral
        mistral = mock.MagicMock()
        mistral.environments.get = mock.Mock(side_effect=Exception)
        get_workflow_client_mock.return_value = mistral

        action = heat_capabilities.GetCapabilitiesAction(self.container_name)
        expected = mistral_workflow_utils.Result(
            data=None, error="Error retrieving mistral environment. ")
        self.assertEqual(expected, action.run())
Example #5
0
    def test_run(self, get_workflow_client_mock, get_obj_client_mock):

        # setup swift
        swift = mock.MagicMock()
        swift.get_object.return_value = ({}, MAPPING_YAML_CONTENTS)
        get_obj_client_mock.return_value = swift

        # setup mistral
        mistral = mock.MagicMock()
        get_workflow_client_mock.return_value = mistral

        action = heat_capabilities.GetCapabilitiesAction(self.container_name)
        self.assertEqual(
            {
                '/path/to/ceph-storage-env.yaml': {
                    'enabled': False
                },
                '/path/to/network-isolation.json': {
                    'enabled': False
                },
                '/path/to/poc-custom-env.yaml': {
                    'enabled': False
                }
            }, action.run())