class PortNotFound(NotFound):
+ message = _("Port %(port_id)s could not be found")
+
+
+class PortNotFoundOnNetwork(NotFound):
message = _("Port %(port_id)s could not be found "
"on network %(net_id)s")
try:
port = self._get_by_id(context, models_v2.Port, id)
except exc.NoResultFound:
- # NOTE(jkoelker) The PortNotFound exceptions requires net_id
- # kwarg in order to set the message correctly
- raise q_exc.PortNotFound(port_id=id, net_id=None)
+ raise q_exc.PortNotFound(port_id=id)
return port
def _get_dns_by_subnet(self, context, subnet_id):
do_request(HTTP_DELETE, uri, cluster=cluster)
except exception.NotFound:
LOG.exception(_("Port or Network not found"))
- raise exception.PortNotFound(net_id=switch,
- port_id=port)
+ raise exception.PortNotFoundOnNetwork(
+ net_id=switch, port_id=port)
except NvpApiClient.NvpApiException:
raise exception.NeutronException()
return do_request(HTTP_GET, uri, cluster=cluster)
except exception.NotFound as e:
LOG.error(_("Port or Network not found, Error: %s"), str(e))
- raise exception.PortNotFound(port_id=port, net_id=network)
+ raise exception.PortNotFoundOnNetwork(
+ port_id=port, net_id=network)
def _configure_extensions(lport_obj, mac_address, fixed_ips,
return result
except exception.NotFound as e:
LOG.error(_("Port or Network not found, Error: %s"), str(e))
- raise exception.PortNotFound(port_id=lport_uuid, net_id=lswitch_uuid)
+ raise exception.PortNotFoundOnNetwork(
+ port_id=lport_uuid, net_id=lswitch_uuid)
def create_lport(cluster, lswitch_uuid, tenant_id, neutron_port_id,
(lswitch_id, port_id), cluster=cluster)
except exception.NotFound as e:
LOG.error(_("Port not found, Error: %s"), str(e))
- raise exception.PortNotFound(port_id=port_id, net_id=lswitch_id)
+ raise exception.PortNotFoundOnNetwork(
+ port_id=port_id, net_id=lswitch_id)
if r['link_status_up'] is True:
return constants.PORT_STATUS_ACTIVE
else:
session.merge(port)
session.flush()
except orm_exc.NoResultFound:
- raise q_exc.PortNotFound(port_id=port_id, net_id=None)
+ raise q_exc.PortNotFound(port_id=port_id)
self.assertEqual(constants.PORT_STATUS_ACTIVE, status)
def test_get_port_status_non_existent_raises(self):
- self.assertRaises(exceptions.PortNotFound,
+ self.assertRaises(exceptions.PortNotFoundOnNetwork,
nvplib.get_port_status,
self.fake_cluster,
'boo', 'boo')
self.assertIn('vm_id', port_tags)
def test_update_non_existent_port_raises(self):
- self.assertRaises(exceptions.PortNotFound,
+ self.assertRaises(exceptions.PortNotFoundOnNetwork,
nvplib.update_port, self.fake_cluster,
'boo', 'boo', 'boo', 'boo', 'boo', 'boo', False)
lswitch, lport = self._create_switch_and_port()
nvplib.delete_port(self.fake_cluster,
lswitch['uuid'], lport['uuid'])
- self.assertRaises(exceptions.PortNotFound,
+ self.assertRaises(exceptions.PortNotFoundOnNetwork,
nvplib.get_port, self.fake_cluster,
lswitch['uuid'], lport['uuid'])
def test_delete_non_existent_port_raises(self):
lswitch = self._create_switch_and_port()[0]
- self.assertRaises(exceptions.PortNotFound,
+ self.assertRaises(exceptions.PortNotFoundOnNetwork,
nvplib.delete_port, self.fake_cluster,
lswitch['uuid'], 'bad_port_uuid')