Пример #1
0
    def setUp(self):
        super(TestInventory, self).setUp()
        self.outputs_data = {'outputs': [
            {'output_key': 'EnabledServices',
             'output_value': {
                 'Controller': ['sa', 'sb'],
                 'Compute': ['sd', 'se', 'ceph_client'],
                 'CustomRole': ['sg', 'sh']}},
            {'output_key': 'KeystoneURL',
             'output_value': 'xyz://keystone'},
            {'output_key': 'ServerIdData',
             'output_value': {
                 'server_ids': {
                     'Controller': ['a', 'b', 'c'],
                     'Compute': ['d'],
                     'CustomRole': ['e']},
                 'bootstrap_server_id': 'a'}},
            {'output_key': 'RoleNetHostnameMap',
             'output_value': {
                 'Controller': {
                     'ctlplane': ['c-0.ctlplane.localdomain',
                                  'c-1.ctlplane.localdomain',
                                  'c-2.ctlplane.localdomain'],
                     'internal_api': ['c-0.internal_api.localdomain',
                                      'c-1.internal_api.localdomain',
                                      'c-2.internal_api.localdomain']},
                 'Compute': {
                     'ctlplane': ['cp-0.ctlplane.localdomain']},
                 'CustomRole': {
                     'ctlplane': ['cs-0.ctlplane.localdomain']}}},
            {'output_key': 'RoleNetIpMap',
             'output_value': {
                 'Controller': {
                     'ctlplane': ['x.x.x.1',
                                  'x.x.x.2',
                                  'x.x.x.3'],
                     'internal_api': ['x.x.x.4',
                                      'x.x.x.5',
                                      'x.x.x.6']},
                 'Compute': {
                     'ctlplane': ['y.y.y.1']},
                 'CustomRole': {
                     'ctlplane': ['z.z.z.1']}}},
            {'output_key': 'VipMap',
             'output_value': {
                 'ctlplane': 'x.x.x.4',
                 'redis': 'x.x.x.6'}},
            {'output_key': 'RoleData',
             'output_value': {
                 'Controller': {'config_settings': 'foo1'},
                 'Compute': {'config_settings': 'foo2'},
                 'CustomRole': {'config_settings': 'foo3'}}}]}
        self.plan_name = 'overcloud'

        self.hclient = MagicMock()
        self.hclient.stacks.environment.return_value = {
            'parameter_defaults': {'AdminPassword': '******',
                                   'ContainerCli': 'podman'}}
        self.mock_stack = MagicMock()
        self.mock_stack.outputs = self.outputs_data['outputs']
        self.hclient.stacks.get.return_value = self.mock_stack

        self.session = MagicMock()
        self.session.get_token.return_value = 'atoken'
        self.session.get_endpoint.return_value = 'anendpoint'

        self.outputs = StackOutputs(self.mock_stack)
        self.inventory = TripleoInventory(
            session=self.session,
            hclient=self.hclient,
            plan_name=self.plan_name,
            auth_url='xyz://keystone.local',
            cacert='acacert',
            project_name='admin',
            username='******',
            ansible_ssh_user='******')
        self.inventory.stack_outputs = self.outputs
Пример #2
0
 def test_outputs_are_empty_if_stack_doesnt_exist(self):
     self.hclient.stacks.get.side_effect = HTTPNotFound('not found')
     stack_outputs = StackOutputs('no-plan', self.hclient)
     self.assertEqual(list(stack_outputs), [])