def test_live_migration_all_checks_pass(self): # Test live migration when all checks pass. self.mox.StubOutWithMock(servicegroup.API, 'service_is_up') self.mox.StubOutWithMock(db, 'service_get_by_compute_host') self.mox.StubOutWithMock(db, 'instance_get_all_by_host') self.mox.StubOutWithMock(rpc, 'call') self.mox.StubOutWithMock(rpc, 'cast') self.mox.StubOutWithMock(self.driver.compute_rpcapi, 'live_migration') dest = 'fake_host2' block_migration = True disk_over_commit = True instance = jsonutils.to_primitive(self._live_migration_instance()) # Source checks db.service_get_by_compute_host(self.context, instance['host']).AndReturn('fake_service2') self.servicegroup_api.service_is_up('fake_service2').AndReturn(True) # Destination checks (compute is up, enough memory, disk) db.service_get_by_compute_host(self.context, dest).AndReturn('fake_service3') self.servicegroup_api.service_is_up('fake_service3').AndReturn(True) # assert_compute_node_has_enough_memory() db.service_get_by_compute_host(self.context, dest).AndReturn( {'compute_node': [{'memory_mb': 2048, 'hypervisor_version': 1}]}) db.instance_get_all_by_host(self.context, dest).AndReturn( [dict(memory_mb=256), dict(memory_mb=512)]) # Common checks (same hypervisor, etc) db.service_get_by_compute_host(self.context, dest).AndReturn( {'compute_node': [{'hypervisor_type': 'xen', 'hypervisor_version': 1}]}) db.service_get_by_compute_host(self.context, instance['host']).AndReturn( {'compute_node': [{'hypervisor_type': 'xen', 'hypervisor_version': 1, 'cpu_info': 'fake_cpu_info'}]}) rpc.call(self.context, "compute.fake_host2", {"method": 'check_can_live_migrate_destination', "args": {'instance': instance, 'block_migration': block_migration, 'disk_over_commit': disk_over_commit}, "version": compute_rpcapi.ComputeAPI.BASE_RPC_API_VERSION}, None).AndReturn({}) self.driver.compute_rpcapi.live_migration(self.context, host=instance['host'], instance=instance, dest=dest, block_migration=block_migration, migrate_data={}) self.mox.ReplayAll() result = self.driver.schedule_live_migration(self.context, instance=instance, dest=dest, block_migration=block_migration, disk_over_commit=disk_over_commit) self.assertEqual(result, None)
def disassociate_floating_ip(self, context, instance, address, affect_auto_assigned=False): """Disassociates a floating ip from fixed ip it is associated with.""" rpc.call(context, FLAGS.network_topic, {'method': 'disassociate_floating_ip', 'args': {'address': address}})
def add_fixed_ip_to_instance(self, context, instance, network_id): """Adds a fixed ip to instance from specified network.""" args = {'instance_id': instance['id'], 'host': instance['host'], 'network_id': network_id} rpc.call(context, FLAGS.network_topic, {'method': 'add_fixed_ip_to_instance', 'args': args})
def release_floating_ip(self, context, address, affect_auto_assigned=False): """Removes floating ip with address from a project. (deallocates)""" rpc.call(context, FLAGS.network_topic, {'method': 'deallocate_floating_ip', 'args': {'address': address, 'affect_auto_assigned': affect_auto_assigned}})
def deallocate_for_instance(self, context, instance, **kwargs): """Deallocates all network structures related to instance.""" args = kwargs args['instance_id'] = instance['id'] args['project_id'] = instance['project_id'] args['host'] = instance['host'] rpc.call(context, FLAGS.network_topic, {'method': 'deallocate_for_instance', 'args': args})
def remove_fixed_ip_from_instance(self, context, instance, address): """Removes a fixed ip from instance from specified network.""" args = {'instance_id': instance['id'], 'host': instance['host'], 'address': address} rpc.call(context, FLAGS.network_topic, {'method': 'remove_fixed_ip_from_instance', 'args': args})
def add_network_to_project(self, context, project_id, network_uuid=None): """Force adds another network to a project.""" rpc.call( context, FLAGS.network_topic, { 'method': 'add_network_to_project', 'args': { 'project_id': project_id, 'network_uuid': network_uuid } })
def delete_network(self, context, fixed_range, uuid): """Lookup network by uuid, delete both the IPAM subnet and the corresponding Quantum network. The fixed_range parameter is kept here for interface compatibility but is not used. """ net_ref = db.network_get_by_uuid(context.elevated(), uuid) project_id = net_ref['project_id'] q_tenant_id = project_id or FLAGS.quantum_default_tenant_id net_uuid = net_ref['uuid'] # Check for any attached ports on the network and fail the deletion if # there is anything but the gateway port attached. If it is only the # gateway port, unattach and delete it. ports = self.q_conn.get_attached_ports(q_tenant_id, net_uuid) num_ports = len(ports) gw_interface_id = self.driver.get_dev(net_ref) gw_port_uuid = None if gw_interface_id is not None: gw_port_uuid = self.q_conn.get_port_by_attachment( q_tenant_id, net_uuid, gw_interface_id) if gw_port_uuid: num_ports -= 1 if num_ports > 0: raise exception.NetworkBusy(network=net_uuid) # only delete gw ports if we are going to finish deleting network if gw_port_uuid: self.q_conn.detach_and_delete_port(q_tenant_id, net_uuid, gw_port_uuid) self.l3driver.remove_gateway(net_ref) # Now we can delete the network self.q_conn.delete_network(q_tenant_id, net_uuid) LOG.debug("Deleting network %s for tenant: %s" % (net_uuid, q_tenant_id)) self.ipam.delete_subnets_by_net_id(context, net_uuid, project_id) # Get rid of dnsmasq if FLAGS.quantum_use_dhcp: if net_ref['host'] == self.host: self.kill_dhcp(net_ref) else: topic = rpc.queue_get_for(context, FLAGS.network_topic, net_ref['host']) rpc.call(context, topic, { 'method': 'kill_dhcp', 'args': { 'net_ref': net_ref } })
def test_block_migration_dest_check_service_lack_disk(self): """Confirms exception raises when dest doesn't have enough disk.""" self.mox.StubOutWithMock(db, 'instance_get') self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') self.mox.StubOutWithMock(utils, 'service_is_up') self.mox.StubOutWithMock(self.driver, 'assert_compute_node_has_enough_memory') self.mox.StubOutWithMock(self.driver, '_get_compute_info') self.mox.StubOutWithMock(db, 'instance_get_all_by_host') self.mox.StubOutWithMock(rpc, 'queue_get_for') self.mox.StubOutWithMock(rpc, 'call') dest = 'fake_host2' block_migration = True disk_over_commit = True instance = self._live_migration_instance() db.instance_get(self.context, instance['id']).AndReturn(instance) self.driver._live_migration_src_check(self.context, instance) db.service_get_all_compute_by_host(self.context, dest).AndReturn(['fake_service3']) utils.service_is_up('fake_service3').AndReturn(True) # Enough memory self.driver.assert_compute_node_has_enough_memory(self.context, instance, dest) # Not enough disk self.driver._get_compute_info(self.context, dest, 'disk_available_least').AndReturn(1023) rpc.queue_get_for(self.context, FLAGS.compute_topic, instance['host']).AndReturn('src_queue') instance_disk_info_msg = { 'method': 'get_instance_disk_info', 'args': { 'instance_name': instance['name'], }, 'version': compute_rpcapi.ComputeAPI.BASE_RPC_API_VERSION, } instance_disk_info = [{'disk_size': 1024 * (1024 ** 3)}] rpc.call(self.context, 'src_queue', instance_disk_info_msg, None).AndReturn(jsonutils.dumps(instance_disk_info)) self.mox.ReplayAll() self.assertRaises(exception.MigrationError, self.driver.schedule_live_migration, self.context, instance_id=instance['id'], dest=dest, block_migration=block_migration, disk_over_commit=disk_over_commit)
def test_live_migration_dest_check_service_memory_overcommit(self): instance = self._live_migration_instance() # Live-migration should work since default is to overcommit memory. self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(db, 'service_get_by_compute_host') self.mox.StubOutWithMock(servicegroup.API, 'service_is_up') self.mox.StubOutWithMock(self.driver, '_get_compute_info') self.mox.StubOutWithMock(self.driver, '_live_migration_common_check') self.mox.StubOutWithMock(rpc, 'call') self.mox.StubOutWithMock(self.driver.compute_rpcapi, 'live_migration') dest = 'fake_host2' block_migration = False disk_over_commit = False self.driver._live_migration_src_check(self.context, instance) db.service_get_by_compute_host(self.context, dest).AndReturn('fake_service3') self.servicegroup_api.service_is_up('fake_service3').AndReturn(True) self.driver._get_compute_info(self.context, dest).AndReturn( {'memory_mb': 2048, 'free_disk_gb': 512, 'local_gb_used': 512, 'free_ram_mb': 512, 'local_gb': 1024, 'vcpus': 4, 'vcpus_used': 2, 'updated_at': None}) self.driver._live_migration_common_check(self.context, instance, dest) rpc.call(self.context, "compute.fake_host2", {"method": 'check_can_live_migrate_destination', "namespace": None, "args": {'instance': instance, 'block_migration': block_migration, 'disk_over_commit': disk_over_commit}, "version": compute_rpcapi.ComputeAPI.BASE_RPC_API_VERSION}, None).AndReturn({}) self.driver.compute_rpcapi.live_migration(self.context, host=instance['host'], instance=instance, dest=dest, block_migration=block_migration, migrate_data={}) self.mox.ReplayAll() result = self.driver.schedule_live_migration(self.context, instance=instance, dest=dest, block_migration=block_migration, disk_over_commit=disk_over_commit) self.assertEqual(result, None)
def delete_network(self, context, fixed_range, uuid): """Lookup network by uuid, delete both the IPAM subnet and the corresponding Quantum network. The fixed_range parameter is kept here for interface compatibility but is not used. """ net_ref = db.network_get_by_uuid(context.elevated(), uuid) project_id = net_ref['project_id'] q_tenant_id = project_id or FLAGS.quantum_default_tenant_id net_uuid = net_ref['uuid'] # Check for any attached ports on the network and fail the deletion if # there is anything but the gateway port attached. If it is only the # gateway port, unattach and delete it. ports = self.q_conn.get_attached_ports(q_tenant_id, net_uuid) num_ports = len(ports) gw_interface_id = self.driver.get_dev(net_ref) gw_port_uuid = None if gw_interface_id is not None: gw_port_uuid = self.q_conn.get_port_by_attachment(q_tenant_id, net_uuid, gw_interface_id) if gw_port_uuid: num_ports -= 1 if num_ports > 0: raise exception.NetworkBusy(network=net_uuid) # only delete gw ports if we are going to finish deleting network if gw_port_uuid: self.q_conn.detach_and_delete_port(q_tenant_id, net_uuid, gw_port_uuid) self.l3driver.remove_gateway(net_ref) # Now we can delete the network self.q_conn.delete_network(q_tenant_id, net_uuid) LOG.debug("Deleting network %s for tenant: %s" % (net_uuid, q_tenant_id)) self.ipam.delete_subnets_by_net_id(context, net_uuid, project_id) # Get rid of dnsmasq if FLAGS.quantum_use_dhcp: if net_ref['host'] == self.host: self.kill_dhcp(net_ref) else: topic = rpc.queue_get_for(context, FLAGS.network_topic, net_ref['host']) rpc.call(context, topic, {'method': 'kill_dhcp', 'args': {'net_ref': net_ref}})
def _mock_rpc_call(self, expected_message, result=None): if result is None: result = 'fake-result' # Wrapped with cells call expected_message = {'method': 'proxy_rpc_to_manager', 'args': {'topic': 'compute.fake_host', 'rpc_message': expected_message, 'call': True, 'timeout': None}, 'version': '1.2'} self.mox.StubOutWithMock(rpc, 'call') rpc.call(self.ctxt, 'cells', expected_message, None).AndReturn(result)
def associate_floating_ip(self, context, instance, floating_address, fixed_address, affect_auto_assigned=False): """Associates a floating ip with a fixed ip. ensures floating ip is allocated to the project in context """ rpc.call(context, FLAGS.network_topic, {'method': 'associate_floating_ip', 'args': {'floating_address': floating_address, 'fixed_address': fixed_address, 'affect_auto_assigned': affect_auto_assigned}})
def _mock_rpc_call(self, expected_message, result=None): if result is None: result = 'fake-result' # Wrapped with cells call expected_message = {'method': 'proxy_rpc_to_manager', 'namespace': None, 'args': {'topic': 'compute.fake_host', 'rpc_message': expected_message, 'call': True, 'timeout': None}, 'version': '1.2'} self.mox.StubOutWithMock(rpc, 'call') rpc.call(self.ctxt, 'cells', expected_message, None).AndReturn(result)
def disassociate_floating_ip(self, context, instance, address, affect_auto_assigned=False): """Disassociates a floating ip from fixed ip it is associated with.""" host = None if instance: host = instance.get('host') if host: topic = rpc.queue_get_for(context, FLAGS.network_topic, host) else: topic = FLAGS.network_topic rpc.call(context, topic, {'method': 'disassociate_floating_ip', 'args': {'address': address}})
def create_private_dns_domain(self, context, domain, availability_zone): """Create a private DNS domain with nova availability zone.""" args = {'domain': domain, 'av_zone': availability_zone} return rpc.call(context, FLAGS.network_topic, { 'method': 'create_private_dns_domain', 'args': args })
def get_dns_entries_by_name(self, context, name, domain): """Get entries for name and domain""" args = {'name': name, 'domain': domain} return rpc.call(context, FLAGS.network_topic, { 'method': 'get_dns_entries_by_name', 'args': args })
def get_dns_entries_by_address(self, context, address, domain): """Get entries for address and domain""" args = {'address': address, 'domain': domain} return rpc.call(context, FLAGS.network_topic, { 'method': 'get_dns_entries_by_address', 'args': args })
def query(self, req, id, body): if not (id): raise webob.exc.HTTPNotFound() context = req.environ["nova.context"] authorize(context) # Extract the query arguments. args = body.get('args', {}) # Construct the query. kwargs = {'method': 'query', 'args': args} parts = id.split(':', 1) if len(parts) == 2: instance = db.instance_get_by_uuid(context, parts[1]) kwargs['args']['target'] = instance['name'] queue = rpc.queue_get_for(context, CONF.canary_topic, parts[0]) else: queue = rpc.queue_get_for(context, CONF.canary_topic, id) try: # Send it along. result = rpc.call(context, queue, kwargs) except Exception, e: raise webob.exc.HTTPBadRequest(explanation=unicode(e))
def delete_dns_entry(self, context, name, domain): """Delete the specified dns entry.""" args = {'name': name, 'domain': domain} return rpc.call(context, FLAGS.network_topic, { 'method': 'delete_dns_entry', 'args': args })
def modify_dns_entry(self, context, name, address, domain): """Create specified DNS entry for address""" args = {'address': address, 'name': name, 'domain': domain} return rpc.call(context, FLAGS.network_topic, { 'method': 'modify_dns_entry', 'args': args })
def initialize_connection(self, context, volume, connector): host = volume['host'] queue = rpc.queue_get_for(context, FLAGS.volume_topic, host) return rpc.call(context, queue, {"method": "initialize_connection", "args": {"volume_id": volume['id'], "connector": connector}})
def query(self, req, id, body): if not(id): raise webob.exc.HTTPNotFound() context = req.environ["nova.context"] authorize(context) # Extract the query arguments. args = body.get('args', {}) # Construct the query. kwargs = { 'method' : 'query', 'args' : args } parts = id.split(':', 1) if len(parts) == 2: instance = db.instance_get_by_uuid(context, parts[1]) kwargs['args']['target'] = instance['name'] queue = rpc.queue_get_for(context, FLAGS.canary_topic, parts[0]) else: queue = rpc.queue_get_for(context, FLAGS.canary_topic, id) try: # Send it along. result = rpc.call(context, queue, kwargs) except Exception, e: raise webob.exc.HTTPBadRequest(explanation=unicode(e))
def create_public_dns_domain(self, context, domain, project=None): """Create a private DNS domain with optional nova project.""" args = {'domain': domain, 'project': project} return rpc.call(context, FLAGS.network_topic, { 'method': 'create_public_dns_domain', 'args': args })
def get_floating_ip_by_address(self, context, address): return rpc.call(context, FLAGS.network_topic, { 'method': 'get_floating_ip_by_address', 'args': { 'address': address } })
def associate_floating_ip(self, context, instance, floating_address, fixed_address, affect_auto_assigned=False): """Associates a floating ip with a fixed ip. ensures floating ip is allocated to the project in context """ host = instance.get('host') if host: topic = rpc.queue_get_for(context, FLAGS.network_topic, host) else: topic = FLAGS.network_topic orig_instance_uuid = rpc.call(context, topic, {'method': 'associate_floating_ip', 'args': {'floating_address': floating_address, 'fixed_address': fixed_address, 'affect_auto_assigned': affect_auto_assigned}}) if orig_instance_uuid: msg_dict = dict(address=floating_address, instance_id=orig_instance_uuid) LOG.info(_('re-assign floating IP %(address)s from ' 'instance %(instance_id)s') % msg_dict) orig_instance = self.db.instance_get_by_uuid(context, orig_instance_uuid) # purge cached nw info for the original instance update_instance_cache_with_nw_info(self, context, orig_instance)
def proxy_rpc_to_manager(self, message, host_name, rpc_message, topic, timeout): """Proxy RPC to the given compute topic.""" # Check that the host exists. self.db.service_get_by_compute_host(message.ctxt, host_name) if message.need_response: return rpc.call(message.ctxt, topic, rpc_message, timeout=timeout) rpc.cast(message.ctxt, topic, rpc_message)
def get(self, context, network_uuid): return rpc.call(context, FLAGS.network_topic, { 'method': 'get_network', 'args': { 'network_uuid': network_uuid } })
def associate_floating_ip(self, context, instance, floating_address, fixed_address, affect_auto_assigned=False): """Associates a floating ip with a fixed ip. ensures floating ip is allocated to the project in context """ orig_instance_uuid = rpc.call( context, FLAGS.network_topic, { 'method': 'associate_floating_ip', 'args': { 'floating_address': floating_address, 'fixed_address': fixed_address, 'affect_auto_assigned': affect_auto_assigned } }) if orig_instance_uuid: msg_dict = dict(address=floating_address, instance_id=orig_instance_uuid) LOG.info( _('re-assign floating IP %(address)s from ' 'instance %(instance_id)s') % msg_dict) orig_instance = self.db.instance_get_by_uuid( context, orig_instance_uuid) # purge cached nw info for the original instance update_instance_cache_with_nw_info(self, context, orig_instance)
def test_utilization_query(self): vm_list = self.get_single_vm() self.mock.StubOutWithMock(api, 'vm_get_by_ids') api.vm_get_by_ids(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(vm_list) self.mock.StubOutWithMock(rpc, 'call') rpc.call(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(self.get_resource_utilization()) self.mock.ReplayAll() request = webob.Request.blank('/v2.0/vm/vm-01.xml?utilization', base_url='http://localhost:8774/v2.0/') request.environ['nova.context'] = self.admin_context resp = VMController().show(request, 'vm-01') self.assertNotEqual(resp, None, 'Return xml response for vm-01')
def _confirm_service_failure(self, ctxt, service): """ confirm wether service is failure by send a rpc call to the service :param service: service info got from db :returns: False if service is ok, True if confirm service failed """ host = service['host'] service_topic = service['topic'] service_binary = service['binary'] try: topic = FLAGS.get('%s_topic' % service_topic, None) rpc_topic = rpc.queue_get_for(ctxt, topic, host) msg = {'method': 'service_version'} if service_topic == 'compute': msg['version'] = '2.0' service_version = rpc.call(ctxt, rpc_topic, msg) LOG.info(_('confirm service %(service_binary)s on %(host)s normal,' ' version : %(service_version)s!'), locals()) return False except Exception as ex: LOG.info(_('confirm service %(service_binary)s on %(host)s ' 'abnormal!'), locals()) return True
def get_vifs_by_instance(self, context, instance): # NOTE(vish): When the db calls are converted to store network # data by instance_uuid, this should pass uuid instead. return rpc.call(context, FLAGS.network_topic, {'method': 'get_vifs_by_instance', 'args': {'instance_id': instance['id']}})
def get_floating_ip(self, context, id): return rpc.call(context, FLAGS.network_topic, { 'method': 'get_floating_ip', 'args': { 'id': id } })
def delete_dns_domain(self, context, domain): """Delete the specified dns domain.""" args = {'domain': domain} return rpc.call(context, FLAGS.network_topic, { 'method': 'delete_dns_domain', 'args': args })
def get_dns_domains(self, context): """Returns a list of available dns domains. These can be used to create DNS entries for floating ips. """ return rpc.call(context, FLAGS.network_topic, {'method': 'get_dns_domains'})
def setup_networks_on_host(self, context, instance, host=None, teardown=False): """Setup or teardown the network structures on hosts related to instance""" host = host or instance['host'] # NOTE(tr3buchet): host is passed in cases where we need to setup # or teardown the networks on a host which has been migrated to/from # and instance['host'] is not yet or is no longer equal to args = {'instance_id': instance['id'], 'host': host, 'teardown': teardown} # NOTE(tr3buchet): the call is just to wait for completion rpc.call(context, FLAGS.network_topic, {'method': 'setup_networks_on_host', 'args': args})
def terminate_connection(self, context, volume, connector): self.unreserve_volume(context, volume) host = volume['host'] queue = rpc.queue_get_for(context, FLAGS.volume_topic, host) return rpc.call(context, queue, {"method": "terminate_connection", "args": {"volume_id": volume['id'], "connector": connector}})
def attach(self, context, volume, instance_uuid, mountpoint): host = volume['host'] queue = rpc.queue_get_for(context, FLAGS.volume_topic, host) return rpc.call(context, queue, {"method": "attach_volume", "args": {"volume_id": volume['id'], "instance_uuid": instance_uuid, "mountpoint": mountpoint}})
def modify_dns_entry(self, context, name, address, domain): """Create specified DNS entry for address""" args = {'address': address, 'name': name, 'domain': domain} return rpc.call(context, FLAGS.network_topic, {'method': 'modify_dns_entry', 'args': args})
def get_instance_uuids_by_ip_filter(self, context, filters): """Returns a list of dicts in the form of {'instance_uuid': uuid, 'ip': ip} that matched the ip_filter """ args = {'filters': filters} return rpc.call(context, FLAGS.network_topic, {'method': 'get_instance_uuids_by_ip_filter', 'args': args})
def disassociate(self, context, network_uuid): return rpc.call( context, FLAGS.network_topic, { 'method': 'disassociate_network', 'args': { 'network_uuid': network_uuid } })
def validate_networks(self, context, requested_networks): """validate the networks passed at the time of creating the server """ args = {'networks': requested_networks} return rpc.call(context, FLAGS.network_topic, {'method': 'validate_networks', 'args': args})
def get_vif_by_mac_address(self, context, mac_address): return rpc.call( context, FLAGS.network_topic, { 'method': 'get_vif_by_mac_address', 'args': { 'mac_address': mac_address } })
def modify_network_qos(self, context, instance_id, qtype, spec, flavor_id=None): """modify network qos for an instance """ args = {'instance_id': instance_id, 'qtype': qtype, 'spec': spec, 'flavor_id': flavor_id} return rpc.call(context, FLAGS.network_topic, {'method': 'modify_network_qos', 'args': args})
def delete_address_network_qos(self, context, instance_id, qtype, address): """delete network qos for for an address""" args = { 'instance_id': instance_id, 'qtype': qtype, 'address': address, } return rpc.call(context, FLAGS.network_topic, {'method': 'delete_address_network_qos', 'args': args})
def test_live_migration_dest_host_incompatable_cpu_raises(self): self.mox.StubOutWithMock(db, 'instance_get') self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(self.driver, '_live_migration_dest_check') self.mox.StubOutWithMock(rpc, 'queue_get_for') self.mox.StubOutWithMock(rpc, 'call') self.mox.StubOutWithMock(rpc, 'cast') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') dest = 'fake_host2' block_migration = False disk_over_commit = False instance = self._live_migration_instance() db.instance_get(self.context, instance['id']).AndReturn(instance) self.driver._live_migration_src_check(self.context, instance) self.driver._live_migration_dest_check(self.context, instance, dest, block_migration, disk_over_commit) self._check_shared_storage(dest, instance, True) db.service_get_all_compute_by_host(self.context, dest).AndReturn( [{'compute_node': [{'hypervisor_type': 'xen', 'hypervisor_version': 1}]}]) db.service_get_all_compute_by_host(self.context, instance['host']).AndReturn( [{'compute_node': [{'hypervisor_type': 'xen', 'hypervisor_version': 1, 'cpu_info': 'fake_cpu_info'}]}]) rpc.queue_get_for(self.context, FLAGS.compute_topic, dest).AndReturn('dest_queue') rpc.call(self.context, 'dest_queue', {'method': 'compare_cpu', 'args': {'cpu_info': 'fake_cpu_info'}, 'version': compute_rpcapi.ComputeAPI.BASE_RPC_API_VERSION}, None).AndRaise(rpc_common.RemoteError()) self.mox.ReplayAll() self.assertRaises(rpc_common.RemoteError, self.driver.schedule_live_migration, self.context, instance_id=instance['id'], dest=dest, block_migration=block_migration)
def allocate_floating_ip(self, context, pool=None): """Adds a floating ip to a project from a pool. (allocates)""" # NOTE(vish): We don't know which network host should get the ip # when we allocate, so just send it to any one. This # will probably need to move into a network supervisor # at some point. return rpc.call(context, FLAGS.network_topic, {'method': 'allocate_floating_ip', 'args': {'project_id': context.project_id, 'pool': pool}})