Add security_group_find to neutron driver

Add security_group_find to neutron driver

Change-Id: I69f74e5572f42a8768b15258727ab6d47983c6b1
This commit is contained in:
Ethan Lynn 2017-01-19 14:23:06 +08:00
parent 8d072dc3ca
commit 52953fac09
2 changed files with 15 additions and 0 deletions

View File

@ -31,6 +31,11 @@ class NeutronClient(base.DriverBase):
port = self.conn.network.find_port(name_or_id, ignore_missing)
return port
@sdk.translate_exception
def security_group_find(self, name_or_id, ignore_missing=False):
sg = self.conn.network.find_security_group(name_or_id, ignore_missing)
return sg
@sdk.translate_exception
def subnet_get(self, name_or_id, ignore_missing=False):
subnet = self.conn.network.find_subnet(name_or_id, ignore_missing)

View File

@ -53,6 +53,16 @@ class TestNeutronV2Driver(base.SenlinTestCase):
self.conn.network.find_port.assert_called_once_with(port_id, False)
self.assertEqual(port_obj, res)
def test_security_group_find(self):
sg_id = 'sg_identifier'
sg_obj = mock.Mock()
self.conn.network.find_security_group.return_value = sg_obj
res = self.nc.security_group_find(sg_id)
self.conn.network.find_security_group.assert_called_once_with(
sg_id, False)
self.assertEqual(sg_obj, res)
def test_subnet_get(self):
subnet_id = 'subnet_identifier'
subnet_obj = mock.Mock()