Ejemplo n.º 1
0
 def _call_main(self, fake_args):
     # make sure we don't run forever!
     if '--one-time' not in fake_args:
         fake_args.append('--one-time')
     collector_kwargs_map = {
         'ec2': {
             'requests_impl': test_ec2.FakeRequests
         },
         'cfn': {
             'requests_impl': test_cfn.FakeRequests(self)
         },
         'heat': {
             'keystoneclient': test_heat.FakeKeystoneClient(self),
             'heatclient': test_heat.FakeHeatClient(self),
             'discover_class': test_heat.FakeKeystoneDiscover
         },
         'request': {
             'requests_impl': test_request.FakeRequests
         },
         'zaqar': {
             'keystoneclient': test_zaqar.FakeKeystoneClient(self),
             'zaqarclient': test_zaqar.FakeZaqarClient(self),
             'discover_class': test_heat.FakeKeystoneDiscover
         },
     }
     with mock.patch.object(config_drive, 'get_metadata') as gm:
         gm.return_value = {}
         return collect.__main__(args=fake_args,
                                 collector_kwargs_map=collector_kwargs_map)
Ejemplo n.º 2
0
 def _call_collect_all(self,
                       store,
                       collector_kwargs_map=None,
                       collectors=None):
     if collector_kwargs_map is None:
         collector_kwargs_map = {
             'ec2': {
                 'requests_impl': test_ec2.FakeRequests
             },
             'cfn': {
                 'requests_impl': test_cfn.FakeRequests(self)
             },
             'heat': {
                 'keystoneclient': test_heat.FakeKeystoneClient(self),
                 'heatclient': test_heat.FakeHeatClient(self),
                 'discover_class': test_heat.FakeKeystoneDiscover
             },
             'request': {
                 'requests_impl': test_request.FakeRequests
             },
             'zaqar': {
                 'keystoneclient': test_zaqar.FakeKeystoneClient(self),
                 'zaqarclient': test_zaqar.FakeZaqarClient(self),
                 'discover_class': test_heat.FakeKeystoneDiscover
             },
         }
     if collectors is None:
         collectors = cfg.CONF.collectors
     with mock.patch.object(config_drive, 'get_metadata') as gm:
         gm.return_value = {}
         return collect.collect_all(
             collectors,
             store=store,
             collector_kwargs_map=collector_kwargs_map)
Ejemplo n.º 3
0
 def test_collect_all_ec2_unavailable(self):
     collector_kwargs_map = {
         'ec2': {'requests_impl': test_ec2.FakeFailRequests},
         'cfn': {'requests_impl': test_cfn.FakeRequests(self)}
     }
     (changed_keys, content) = self._call_collect_all(
         store=False, collector_kwargs_map=collector_kwargs_map)
     self.assertEqual(set(), changed_keys)
     self.assertThat(content, matchers.IsInstance(dict))
     self.assertNotIn('ec2', content)
Ejemplo n.º 4
0
 def test_collect_all_cfn_unconfigured(self):
     collector_kwargs_map = {
         'cfn': {'requests_impl': test_cfn.FakeRequests(self)}
     }
     cfg.CONF.cfn.metadata_url = None
     (changed_keys, content) = self._call_collect_all(
         store=False, collector_kwargs_map=collector_kwargs_map,
         collectors=['heat_local', 'cfn'])
     self.assertIn('No metadata_url configured', self.log.output)
     self.assertNotIn('cfn', content)
     self.assertIn('heat_local', content)
     self.assertEqual(test_heat_local.META_DATA, content['heat_local'])
Ejemplo n.º 5
0
 def _call_main(self, fake_args):
     # make sure we don't run forever!
     if '--one-time' not in fake_args:
         fake_args.append('--one-time')
     collector_kwargs_map = {
         'ec2': {'requests_impl': test_ec2.FakeRequests},
         'cfn': {'requests_impl': test_cfn.FakeRequests(self)},
         'heat': {
             'keystoneclient': test_heat.FakeKeystoneClient(self),
             'heatclient': test_heat.FakeHeatClient(self)
         },
         'request': {'requests_impl': test_request.FakeRequests},
         'zaqar': {
             'keystoneclient': test_zaqar.FakeKeystoneClient(self),
             'zaqarclient': test_zaqar.FakeZaqarClient(self)
         },
     }
     return collect.__main__(args=fake_args,
                             collector_kwargs_map=collector_kwargs_map)
Ejemplo n.º 6
0
 def _call_collect_all(self, mock_url_for, mock___init__, store,
                       collector_kwargs_map=None, collectors=None):
     mock___init__.return_value = None
     mock_url_for.return_value = cfg.CONF.heat.auth_url
     if collector_kwargs_map is None:
         collector_kwargs_map = {
             'ec2': {'requests_impl': test_ec2.FakeRequests},
             'cfn': {'requests_impl': test_cfn.FakeRequests(self)},
             'heat': {
                 'keystoneclient': test_heat.FakeKeystoneClient(self),
                 'heatclient': test_heat.FakeHeatClient(self)
             },
             'request': {'requests_impl': test_request.FakeRequests},
             'zaqar': {
                 'keystoneclient': test_zaqar.FakeKeystoneClient(self),
                 'zaqarclient': test_zaqar.FakeZaqarClient(self)
             },
         }
     if collectors is None:
         collectors = cfg.CONF.collectors
     return collect.collect_all(
         collectors,
         store=store,
         collector_kwargs_map=collector_kwargs_map)