def setUp(self): super(TestNovaWrapper, self).setUp() self.addCleanup(mock.patch.stopall) patch = mock.patch('novaclient.client.Client') self.client = mock.Mock() self.client_cls = patch.start() self.client_cls.return_value = self.client self.fake_instance_provider = mock.Mock(create_instance=mock.Mock()) fake_instance_provider_cls = mock.Mock(name='fake_provider_class') fake_instance_provider_cls.return_value = \ self.fake_instance_provider get_instance_provider_p = mock.patch.object( nova, 'get_instance_provider').start() get_instance_provider_p.return_value = fake_instance_provider_cls self.nova = nova.Nova(FakeConf) self.INSTANCE_INFO = nova.InstanceInfo( instance_id='fake_instance_id', name='fake_name', image_uuid='fake_image_id', status='ACTIVE', last_boot=(datetime.utcnow() - timedelta(minutes=15)), ports=[fake_int_port, fake_ext_port, fake_mgt_port], management_port=fake_mgt_port, )
def take_action(self, parsed_args): uuid = parsed_args.image_uuid if uuid: nova_client = nova.Nova(cfg.CONF).client try: nova_client.images.get(uuid) except exceptions.NotFound: self.log.exception( 'could not retrieve custom image %s from Glance:' % uuid) raise return super(ResourceRebuild, self).take_action(parsed_args)
def __init__(self, conf, db, workers): self.db = db self.conn = sqlite3.connect(self.db) self.conn.row_factory = RouterRow.from_cursor self.nova = nova_api.Nova(conf) self.neutron = neutron_api.Neutron(conf) self.nova_queue = Queue.Queue() self.save_queue = Queue.Queue() # Create X threads to perform Nova calls and put results into a queue threads = [ threading.Thread( name='fetcher-t%02d' % i, target=self.fetch_router_metadata, ) for i in six.moves.range(workers) ] for t in threads: t.setDaemon(True) t.start()
def test_no_provider_not_none(self): NoProviderConf = copy.deepcopy(FakeConf) del NoProviderConf.instance_provider self.nova = nova.Nova(NoProviderConf) self.assertIsNotNone(self.nova.instance_provider.create_instance)
def __init__(self, management_address=None): self.neutron = neutron.Neutron(cfg.CONF) self.nova_client = nova.Nova(cfg.CONF) self.management_address = management_address
def __init__(self): self.nova_client = nova.Nova(cfg.CONF) self.neutron_client = neutron.Neutron(cfg.CONF)