Revert "Fix _get_id_for"
This reverts commit 873ae308d0
.
This patch was using an api in neutron-lib that isn't present
in the mitaka branch.
Change-Id: Ie34a4fcd90f2c397868dc532aee9b19beb0a68b8
Closes-Bug: #1600281
This commit is contained in:
parent
2db5aeaaf5
commit
cda226b9da
|
@ -23,7 +23,6 @@ from sqlalchemy import orm
|
|||
from sqlalchemy.orm import aliased
|
||||
from sqlalchemy.orm import exc as sa_exc
|
||||
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as lib_consts
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
|
@ -309,14 +308,11 @@ class BgpDbMixin(common_db.CommonDbMixin):
|
|||
|
||||
def _get_id_for(self, resource, id_name):
|
||||
try:
|
||||
uuid = resource[id_name]
|
||||
msg = validators.validate_uuid(uuid)
|
||||
except KeyError:
|
||||
return resource.get(id_name)
|
||||
except AttributeError:
|
||||
msg = _("%s must be specified") % id_name
|
||||
if msg:
|
||||
raise n_exc.BadRequest(resource=bgp_ext.BGP_SPEAKER_RESOURCE_NAME,
|
||||
msg=msg)
|
||||
return uuid
|
||||
|
||||
def _get_bgp_peers_by_bgp_speaker_binding(self, context, bgp_speaker_id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
|
|
|
@ -29,7 +29,6 @@ from neutron.tests.unit.plugins.ml2 import test_plugin
|
|||
_uuid = uuidutils.generate_uuid
|
||||
|
||||
ADVERTISE_FIPS_KEY = 'advertise_floating_ip_host_routes'
|
||||
IMAGINARY = '2b2334c8-adfe-42d9-82c6-ad866c7fc5d8' # non existent resource id
|
||||
|
||||
|
||||
class BgpEntityCreationMixin(object):
|
||||
|
@ -305,7 +304,7 @@ class BgpTests(test_plugin.Ml2PluginV2TestCase,
|
|||
{'bgp_peer_id': peer['id']})
|
||||
|
||||
def test_remove_non_existent_bgp_peer(self):
|
||||
bgp_peer_id = IMAGINARY
|
||||
bgp_peer_id = "imaginary"
|
||||
with self.subnetpool_with_address_scope(4,
|
||||
prefixes=['8.0.0.0/8']) as sp:
|
||||
with self.bgp_speaker(sp['ip_version'], 1234) as speaker:
|
||||
|
@ -316,7 +315,7 @@ class BgpTests(test_plugin.Ml2PluginV2TestCase,
|
|||
{'bgp_peer_id': bgp_peer_id})
|
||||
|
||||
def test_add_non_existent_bgp_peer(self):
|
||||
bgp_peer_id = IMAGINARY
|
||||
bgp_peer_id = "imaginary"
|
||||
with self.subnetpool_with_address_scope(4,
|
||||
prefixes=['8.0.0.0/8']) as sp:
|
||||
with self.bgp_speaker(sp['ip_version'], 1234) as speaker:
|
||||
|
@ -326,36 +325,6 @@ class BgpTests(test_plugin.Ml2PluginV2TestCase,
|
|||
speaker['id'],
|
||||
{'bgp_peer_id': bgp_peer_id})
|
||||
|
||||
def test_add_bgp_peer_without_id(self):
|
||||
with self.subnetpool_with_address_scope(4,
|
||||
prefixes=['8.0.0.0/8']) as sp:
|
||||
with self.bgp_speaker(sp['ip_version'], 1234) as speaker:
|
||||
self.assertRaises(n_exc.BadRequest,
|
||||
self.bgp_plugin.add_bgp_peer,
|
||||
self.context,
|
||||
speaker['id'],
|
||||
{})
|
||||
|
||||
def test_add_bgp_peer_with_bad_id(self):
|
||||
with self.subnetpool_with_address_scope(4,
|
||||
prefixes=['8.0.0.0/8']) as sp:
|
||||
with self.bgp_speaker(sp['ip_version'], 1234) as speaker:
|
||||
self.assertRaises(n_exc.BadRequest,
|
||||
self.bgp_plugin.add_bgp_peer,
|
||||
self.context,
|
||||
speaker['id'],
|
||||
{'bgp_peer_id': 'aaa'})
|
||||
|
||||
def test_add_bgp_peer_with_none_id(self):
|
||||
with self.subnetpool_with_address_scope(4,
|
||||
prefixes=['8.0.0.0/8']) as sp:
|
||||
with self.bgp_speaker(sp['ip_version'], 1234) as speaker:
|
||||
self.assertRaises(n_exc.BadRequest,
|
||||
self.bgp_plugin.add_bgp_peer,
|
||||
self.context,
|
||||
speaker['id'],
|
||||
{'bgp_peer_id': None})
|
||||
|
||||
def test_add_gateway_network(self):
|
||||
with self.subnetpool_with_address_scope(4,
|
||||
prefixes=['8.0.0.0/8']) as sp:
|
||||
|
@ -402,7 +371,7 @@ class BgpTests(test_plugin.Ml2PluginV2TestCase,
|
|||
self.assertEqual(1, len(new_speaker['networks']))
|
||||
|
||||
def test_add_non_existent_gateway_network(self):
|
||||
network_id = IMAGINARY
|
||||
network_id = "imaginary"
|
||||
with self.subnetpool_with_address_scope(4,
|
||||
prefixes=['8.0.0.0/8']) as sp:
|
||||
with self.bgp_speaker(sp['ip_version'], 1234) as speaker:
|
||||
|
@ -412,7 +381,7 @@ class BgpTests(test_plugin.Ml2PluginV2TestCase,
|
|||
{'network_id': network_id})
|
||||
|
||||
def test_remove_non_existent_gateway_network(self):
|
||||
network_id = IMAGINARY
|
||||
network_id = "imaginary"
|
||||
with self.subnetpool_with_address_scope(4,
|
||||
prefixes=['8.0.0.0/8']) as sp:
|
||||
with self.bgp_speaker(sp['ip_version'], 1234) as speaker:
|
||||
|
|
Loading…
Reference in New Issue