def _get_vm_mdo(vm_ref): """Gets the Virtual Machine with the ref from the db.""" if _db_content.get("VirtualMachine", None) is None: raise exception.NotFound(_("There is no VM registered")) if vm_ref not in _db_content.get("VirtualMachine"): raise exception.NotFound(_("Virtual Machine with ref %s is not " "there") % vm_ref) return _db_content.get("VirtualMachine")[vm_ref]
def _set_power_state(self, method, vm_ref, pwr_state="poweredOn"): """Sets power state for the VM.""" if _db_content.get("VirtualMachine", None) is None: raise exception.NotFound(_(" No Virtual Machine has been " "registered yet")) if vm_ref not in _db_content.get("VirtualMachine"): raise exception.NotFound(_("Virtual Machine with ref %s is not " "there") % vm_ref) vm_mdo = _db_content.get("VirtualMachine").get(vm_ref) vm_mdo.set("runtime.powerState", pwr_state) task_mdo = create_task(method, "success") return task_mdo.obj
def test_report_state_newly_disconnected(self): host = 'foo' binary = 'bar' topic = 'test' service_create = {'host': host, 'binary': binary, 'topic': topic, 'report_count': 0, 'availability_zone': 'engine'} service_ref = {'host': host, 'binary': binary, 'topic': topic, 'report_count': 0, 'availability_zone': 'engine', 'id': 1} service.db.service_get_by_args(mox.IgnoreArg(), host, binary).AndRaise(exception.NotFound()) service.db.service_create(mox.IgnoreArg(), service_create).AndReturn(service_ref) service.db.service_get(mox.IgnoreArg(), mox.IgnoreArg()).AndRaise(Exception()) self.mox.ReplayAll() serv = service.Service(host, binary, topic, 'engine.tests.test_service.FakeManager') serv.start() serv.report_state() self.assert_(serv.model_disconnected)
def index(self, req, server_id): context = req.environ["engine.context"] compute_api = compute.API() try: instance = compute_api.get(context, id) except exception.NotFound(): raise webob.exc.HTTPNotFound(_("Instance not found")) return compute_api.get_diagnostics(context, instance)
def get_network_id_by_cidr(self, context, cidr, project_id): """Find the Quantum UUID associated with a IPv4 CIDR address for the specified tenant. """ tenant_id = project_id or FLAGS.quantum_default_tenant_id all_blocks = self.m_conn.get_blocks(tenant_id) for b in all_blocks['ip_blocks']: LOG.debug("block: %s" % b) if b['cidr'] == cidr: return b['network_id'] raise exception.NotFound(_("No network found for cidr %s" % cidr))
def return_server_by_uuid_not_found(context, uuid): raise exception.NotFound()
def detach_and_delete_port(self, tenant_id, net_id, port_id): if not self.network_exists(tenant_id, net_id): raise exception.NotFound( _("network %(net_id)s does not exist " "for tenant %(tenant_id)s" % locals())) del self.nets[net_id]['ports'][port_id]
def return_non_existing_server_by_address(context, address, *args, **kwarg): raise exception.NotFound()
def return_security_group(context, group_id): if group_id == db1['id']: return db1 if group_id == db2['id']: return db2 raise exception.NotFound()
def fake_get_not_found(self, context, instance_uuid): raise exception.NotFound()