示例#1
0
    def test_run_show_detail(self, get_obj_client_mock):
        # setup swift
        swift = mock.MagicMock()
        swift.get_object.return_value = ({}, ROLES_DATA_YAML_CONTENTS)
        get_obj_client_mock.return_value = swift

        # Test
        action = plan.ListRolesAction(detail=True)
        result = action.run(self.ctx)

        # verify
        expected = [{
            u'CountDefault': 1,
            u'ServicesDefault': [u'OS::TripleO::Services::CACerts'],
            u'name': u'MyController'
        }, {
            u'HostnameFormatDefault':
            u'%stackname%-novacompute-%index%',
            u'ServicesDefault': [
                u'OS::TripleO::Services::NovaCompute',
                u'OS::TripleO::Services::DummyService'
            ],
            u'name':
            u'Compute'
        }, {
            u'ServicesDefault': [u'OS::TripleO::Services::Kernel'],
            u'name': u'CustomRole'
        }]

        self.assertEqual(expected, result)
示例#2
0
    def test_no_roles_data_file(self, get_obj_client_mock):

        swift = mock.MagicMock()
        swift.get_object.side_effect = swiftexceptions.ClientException("404")
        get_obj_client_mock.return_value = swift

        action = plan.ListRolesAction()
        result = action.run(self.ctx)

        error_str = ('Error retrieving roles data from deployment plan: 404')
        self.assertEqual(result.error, error_str)
示例#3
0
    def test_run(self, get_obj_client_mock):
        # setup swift
        swift = mock.MagicMock()
        swift.get_object.return_value = ({}, ROLES_DATA_YAML_CONTENTS)
        get_obj_client_mock.return_value = swift

        # Test
        action = plan.ListRolesAction()
        result = action.run(self.ctx)

        # verify
        expected = ['MyController', 'Compute', 'CustomRole']
        self.assertEqual(expected, result)
示例#4
0
def list_roles(clients, container, detail=False):
    """Return a list of roles.

    :param clients: openstack clients
    :type clients: Object

    :param container: Name of swift object container
    :type container: String

    :param detail: Enable or disable extra detail
    :type detail: Boolean

    :returns: List
    """

    context = clients.tripleoclient.create_mistral_context()
    LOG.info('Pulling roles from: {}'.format(container))
    return plan.ListRolesAction(container=container,
                                detail=detail).run(context=context)
示例#5
0
    def test_run(self, workflow_client_mock, get_obj_client_mock):

        # setup mistral
        mistral = mock.MagicMock()
        env_item = mock.Mock()
        mistral.environments.get.return_value = env_item
        workflow_client_mock.return_value = mistral

        env_item.variables = {
            'template': 'overcloud.yaml',
            'environments': [{
                'path': 'overcloud-resource-registry-puppet.yaml'
            }]
        }
        env_item.name = self.container
        env_item.description = None
        env_item.created_at = '2016-06-30 15:51:09'
        env_item.updated_at = None
        env_item.scope = 'private'
        env_item.id = '4b5e97d0-2f7a-4cdd-ab7c-71331cce477d'

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

        template_name = workflow_client_mock().environments.get(
            self.container).variables['template']

        # Test
        action = plan.ListRolesAction()
        result = action.run()

        # verify
        expected = ['Compute', 'Controller']
        result.sort()
        self.assertEqual(expected, result)
        self.assertEqual('overcloud.yaml', template_name)
        swift.get_object.assert_called_with(self.container, template_name)