Merge "Use flavor name for checking flavor existence"
This commit is contained in:
commit
c1947930f0
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
from boto import exception as boto_exception
|
from boto import exception as boto_exception
|
||||||
from neutronclient.common import exceptions as neutron_exceptions
|
from neutronclient.common import exceptions as neutron_exceptions
|
||||||
|
from novaclient import exceptions as nova_exc
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from saharaclient.api import base as saharaclient_base
|
from saharaclient.api import base as saharaclient_base
|
||||||
|
|
||||||
@ -146,6 +147,14 @@ class NovaFlavors(base.ResourceManager):
|
|||||||
return [r for r in self._manager().list()
|
return [r for r in self._manager().list()
|
||||||
if utils.name_matches_object(r.name, nova_utils.NovaScenario)]
|
if utils.name_matches_object(r.name, nova_utils.NovaScenario)]
|
||||||
|
|
||||||
|
def is_deleted(self):
|
||||||
|
try:
|
||||||
|
self._manager().get(self.name())
|
||||||
|
except nova_exc.NotFound:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
@base.resource("nova", "floating_ips_bulk", order=next(_nova_order),
|
@base.resource("nova", "floating_ips_bulk", order=next(_nova_order),
|
||||||
admin_required=True)
|
admin_required=True)
|
||||||
|
@ -17,6 +17,7 @@ from boto import exception as boto_exception
|
|||||||
import ddt
|
import ddt
|
||||||
import mock
|
import mock
|
||||||
from neutronclient.common import exceptions as neutron_exceptions
|
from neutronclient.common import exceptions as neutron_exceptions
|
||||||
|
from novaclient import exceptions as nova_exc
|
||||||
|
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally.plugins.openstack.cleanup import resources
|
from rally.plugins.openstack.cleanup import resources
|
||||||
@ -132,6 +133,21 @@ class NovaFlavorsTestCase(test.TestCase):
|
|||||||
mock_name_matches_object.assert_has_calls(
|
mock_name_matches_object.assert_has_calls(
|
||||||
[mock.call(r.name, nutils.NovaScenario) for r in flavors])
|
[mock.call(r.name, nutils.NovaScenario) for r in flavors])
|
||||||
|
|
||||||
|
@mock.patch("%s.base.ResourceManager._manager" % BASE)
|
||||||
|
def test_is_deleted(self, mock_resource_manager__manager):
|
||||||
|
exc = nova_exc.NotFound(404)
|
||||||
|
mock_resource_manager__manager().get.side_effect = exc
|
||||||
|
flavor = resources.NovaFlavors()
|
||||||
|
flavor.raw_resource = mock.MagicMock()
|
||||||
|
self.assertEqual(True, flavor.is_deleted())
|
||||||
|
|
||||||
|
@mock.patch("%s.base.ResourceManager._manager" % BASE)
|
||||||
|
def test_is_deleted_fail(self, mock_resource_manager__manager):
|
||||||
|
mock_resource_manager__manager().get.side_effect = TypeError()
|
||||||
|
flavor = resources.NovaFlavors()
|
||||||
|
flavor.raw_resource = mock.MagicMock()
|
||||||
|
self.assertRaises(TypeError, flavor.is_deleted)
|
||||||
|
|
||||||
|
|
||||||
class NovaSecurityGroupTestCase(test.TestCase):
|
class NovaSecurityGroupTestCase(test.TestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user