Add declaration of 'refresh_instance_security_rules' to virt driver
The method 'refresh_instance_security_rules' was not defined in the virt driver ComputeDriver class. In cases where the underlying virt driver does not support security groups an exception would be encountered indication that the driver class does not have the specific attribute. In addition to adding the method the patch set also catches the exception NotImplementedError and logs a warning. Change-Id: Ia36b0dfb54a3ede86467d87f0650a0902adb6d46 Closes-bug: #1269448
This commit is contained in:
parent
c4b0c8ec1d
commit
5a98d7b61f
|
@ -1001,7 +1001,12 @@ class ComputeManager(manager.Manager):
|
|||
"""
|
||||
@utils.synchronized(instance['uuid'])
|
||||
def _sync_refresh():
|
||||
return self.driver.refresh_instance_security_rules(instance)
|
||||
try:
|
||||
return self.driver.refresh_instance_security_rules(instance)
|
||||
except NotImplementedError:
|
||||
LOG.warning(_('Hypervisor driver does not support '
|
||||
'security groups.'), instance=instance)
|
||||
|
||||
return _sync_refresh()
|
||||
|
||||
@wrap_exception()
|
||||
|
|
|
@ -1648,6 +1648,11 @@ class HyperVAPITestCase(HyperVAPIBaseTestCase):
|
|||
mock_destroy.assert_called_once_with(self._context,
|
||||
self._test_spawn_instance, [], None)
|
||||
|
||||
def test_refresh_instance_security_rules(self):
|
||||
self.assertRaises(NotImplementedError,
|
||||
self._conn.refresh_instance_security_rules,
|
||||
instance=None)
|
||||
|
||||
def test_get_rdp_console(self):
|
||||
self.flags(my_ip="192.168.1.1")
|
||||
|
||||
|
|
|
@ -1543,6 +1543,11 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
self.assertEqual(connector['initiator'], 'iscsi-name')
|
||||
self.assertNotIn('instance', connector)
|
||||
|
||||
def test_refresh_instance_security_rules(self):
|
||||
self.assertRaises(NotImplementedError,
|
||||
self.conn.refresh_instance_security_rules,
|
||||
instance=None)
|
||||
|
||||
|
||||
class VMwareAPIHostTestCase(test.NoDBTestCase):
|
||||
"""Unit tests for Vmware API host calls."""
|
||||
|
|
|
@ -814,6 +814,15 @@ class ComputeDriver(object):
|
|||
# TODO(Vek): Need to pass context in for access to auth_token
|
||||
raise NotImplementedError()
|
||||
|
||||
def refresh_instance_security_rules(self, instance):
|
||||
"""Refresh security group rules
|
||||
|
||||
Gets called when an instance gets added to or removed from
|
||||
the security group the instance is a member of or if the
|
||||
group gains or looses a rule.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def reset_network(self, instance):
|
||||
"""reset networking for specified instance."""
|
||||
# TODO(Vek): Need to pass context in for access to auth_token
|
||||
|
|
Loading…
Reference in New Issue