Merge "Add support for watcher osclient and watcher related types"
This commit is contained in:
commit
f0adca5c4b
3
.gitignore
vendored
3
.gitignore
vendored
@ -46,3 +46,6 @@ doc/source/_build/
|
|||||||
.idea
|
.idea
|
||||||
.pydevproject
|
.pydevproject
|
||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
|
# Mac Desktop Service Store
|
||||||
|
*.DS_Store
|
||||||
|
@ -113,6 +113,7 @@ class _Service(utils.ImmutableMixin, utils.EnumMixin):
|
|||||||
IRONIC = "ironic"
|
IRONIC = "ironic"
|
||||||
GNOCCHI = "gnocchi"
|
GNOCCHI = "gnocchi"
|
||||||
MAGNUM = "magnum"
|
MAGNUM = "magnum"
|
||||||
|
WATCHER = "watcher"
|
||||||
|
|
||||||
|
|
||||||
class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
|
class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
|
||||||
@ -141,6 +142,7 @@ class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
|
|||||||
BARE_METAL = "baremetal"
|
BARE_METAL = "baremetal"
|
||||||
METRIC = "metric"
|
METRIC = "metric"
|
||||||
CONTAINER_INFRA = "container-infra"
|
CONTAINER_INFRA = "container-infra"
|
||||||
|
INFRA_OPTIM = "infra-optim"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__names = {
|
self.__names = {
|
||||||
@ -167,6 +169,7 @@ class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
|
|||||||
self.BARE_METAL: _Service.IRONIC,
|
self.BARE_METAL: _Service.IRONIC,
|
||||||
self.METRIC: _Service.GNOCCHI,
|
self.METRIC: _Service.GNOCCHI,
|
||||||
self.CONTAINER_INFRA: _Service.MAGNUM,
|
self.CONTAINER_INFRA: _Service.MAGNUM,
|
||||||
|
self.INFRA_OPTIM: _Service.WATCHER,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __getitem__(self, service_type):
|
def __getitem__(self, service_type):
|
||||||
|
@ -720,6 +720,27 @@ class FuelEnvironment(base.ResourceManager):
|
|||||||
futils.FuelScenario)]
|
futils.FuelScenario)]
|
||||||
|
|
||||||
|
|
||||||
|
# WATCHER
|
||||||
|
|
||||||
|
@base.resource("watcher", "audit_template", order=1500,
|
||||||
|
admin_required=True, tenant_resource=True)
|
||||||
|
class WatcherTemplate(SynchronizedDeletion, base.ResourceManager):
|
||||||
|
|
||||||
|
def id(self):
|
||||||
|
return self.raw_resource.uuid
|
||||||
|
|
||||||
|
def is_deleted(self):
|
||||||
|
from watcherclient.common.apiclient import exceptions
|
||||||
|
try:
|
||||||
|
self._manager().get(self.id())
|
||||||
|
return False
|
||||||
|
except exceptions.NotFound:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def list(self):
|
||||||
|
return self._manager().list(limit=0)
|
||||||
|
|
||||||
|
|
||||||
# KEYSTONE
|
# KEYSTONE
|
||||||
|
|
||||||
_keystone_order = get_order(9000)
|
_keystone_order = get_order(9000)
|
||||||
|
@ -32,6 +32,7 @@ python-saharaclient>=0.13.0 # Apache-2.0
|
|||||||
python-troveclient>=2.2.0 # Apache-2.0
|
python-troveclient>=2.2.0 # Apache-2.0
|
||||||
python-zaqarclient>=1.0.0 # Apache-2.0
|
python-zaqarclient>=1.0.0 # Apache-2.0
|
||||||
python-swiftclient>=2.2.0 # Apache-2.0
|
python-swiftclient>=2.2.0 # Apache-2.0
|
||||||
|
python-watcherclient>=0.23.0 # Apache-2.0
|
||||||
python-subunit>=0.0.18 # Apache-2.0/BSD
|
python-subunit>=0.0.18 # Apache-2.0/BSD
|
||||||
requests>=2.10.0 # Apache-2.0
|
requests>=2.10.0 # Apache-2.0
|
||||||
SQLAlchemy<1.1.0,>=1.0.10 # MIT
|
SQLAlchemy<1.1.0,>=1.0.10 # MIT
|
||||||
|
@ -208,6 +208,26 @@ class Cinder(ResourceManager):
|
|||||||
search_opts={"all_tenants": True})
|
search_opts={"all_tenants": True})
|
||||||
|
|
||||||
|
|
||||||
|
class Watcher(ResourceManager):
|
||||||
|
|
||||||
|
REQUIRED_SERVICE = consts.Service.WATCHER
|
||||||
|
|
||||||
|
def list_audits(self):
|
||||||
|
return self.client.audit.list()
|
||||||
|
|
||||||
|
def list_audit_templates(self):
|
||||||
|
return self.client.audit_template.list()
|
||||||
|
|
||||||
|
def list_goals(self):
|
||||||
|
return self.client.goal.list()
|
||||||
|
|
||||||
|
def list_action_plans(self):
|
||||||
|
return self.client.action_plan.list()
|
||||||
|
|
||||||
|
def list_actions(self):
|
||||||
|
return self.client.action.list()
|
||||||
|
|
||||||
|
|
||||||
class CloudResources(object):
|
class CloudResources(object):
|
||||||
"""List and compare cloud resources.
|
"""List and compare cloud resources.
|
||||||
|
|
||||||
|
@ -127,6 +127,14 @@ class FakeImage(FakeResource):
|
|||||||
self.update = mock.MagicMock()
|
self.update = mock.MagicMock()
|
||||||
|
|
||||||
|
|
||||||
|
class FakeStrategy(FakeResource):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FakeGoal(FakeResource):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FakeMurano(FakeResource):
|
class FakeMurano(FakeResource):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -425,6 +433,18 @@ class FakeImageManager(FakeManager):
|
|||||||
self.resources_order.remove(resource)
|
self.resources_order.remove(resource)
|
||||||
|
|
||||||
|
|
||||||
|
class FakeStrategyManager(FakeManager):
|
||||||
|
|
||||||
|
def create(self):
|
||||||
|
return FakeStrategy(self)
|
||||||
|
|
||||||
|
|
||||||
|
class FakeGoalManager(FakeManager):
|
||||||
|
|
||||||
|
def create(self):
|
||||||
|
return FakeGoal(self)
|
||||||
|
|
||||||
|
|
||||||
class FakePackageManager(FakeManager):
|
class FakePackageManager(FakeManager):
|
||||||
|
|
||||||
def create(self, package_descr, package_arch, package_class=FakeMurano):
|
def create(self, package_descr, package_arch, package_class=FakeMurano):
|
||||||
@ -1493,6 +1513,13 @@ class FakeMagnumClient(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FakeWatcherClient(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.strategy = FakeStrategyManager()
|
||||||
|
self.goal = FakeGoalManager()
|
||||||
|
|
||||||
|
|
||||||
class FakeClients(object):
|
class FakeClients(object):
|
||||||
|
|
||||||
def __init__(self, credential_=None):
|
def __init__(self, credential_=None):
|
||||||
@ -1513,6 +1540,7 @@ class FakeClients(object):
|
|||||||
self._monasca = None
|
self._monasca = None
|
||||||
self._ec2 = None
|
self._ec2 = None
|
||||||
self._senlin = None
|
self._senlin = None
|
||||||
|
self._watcher = None
|
||||||
self._credential = credential_ or objects.Credential(
|
self._credential = credential_ or objects.Credential(
|
||||||
"http://fake.example.org:5000/v2.0/",
|
"http://fake.example.org:5000/v2.0/",
|
||||||
"fake_username",
|
"fake_username",
|
||||||
@ -1607,6 +1635,11 @@ class FakeClients(object):
|
|||||||
self._senlin = FakeSenlinClient()
|
self._senlin = FakeSenlinClient()
|
||||||
return self._senlin
|
return self._senlin
|
||||||
|
|
||||||
|
def watcher(self):
|
||||||
|
if not self._watcher:
|
||||||
|
self._watcher = FakeWatcherClient()
|
||||||
|
return self._watcher
|
||||||
|
|
||||||
|
|
||||||
class FakeRunner(object):
|
class FakeRunner(object):
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ 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 novaclient import exceptions as nova_exc
|
||||||
|
from watcherclient.common.apiclient import exceptions as watcher_exceptions
|
||||||
|
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally.plugins.openstack.cleanup import resources
|
from rally.plugins.openstack.cleanup import resources
|
||||||
@ -753,3 +754,29 @@ class FuelEnvironmentTestCase(test.TestCase):
|
|||||||
|
|
||||||
fres = resources.FuelEnvironment()
|
fres = resources.FuelEnvironment()
|
||||||
self.assertEqual(envs[:-1], fres.list())
|
self.assertEqual(envs[:-1], fres.list())
|
||||||
|
|
||||||
|
|
||||||
|
class WatcherTemplateTestCase(test.TestCase):
|
||||||
|
|
||||||
|
def test_id(self):
|
||||||
|
watcher = resources.WatcherTemplate()
|
||||||
|
watcher.raw_resource = mock.MagicMock(uuid=100)
|
||||||
|
self.assertEqual(100, watcher.id())
|
||||||
|
|
||||||
|
@mock.patch("%s.WatcherTemplate._manager" % BASE)
|
||||||
|
def test_is_deleted(self, mock__manager):
|
||||||
|
mock__manager.return_value.get.return_value = None
|
||||||
|
watcher = resources.WatcherTemplate()
|
||||||
|
watcher.id = mock.Mock()
|
||||||
|
self.assertFalse(watcher.is_deleted())
|
||||||
|
mock__manager.side_effect = [watcher_exceptions.NotFound()]
|
||||||
|
self.assertTrue(watcher.is_deleted())
|
||||||
|
|
||||||
|
def test_list(self):
|
||||||
|
watcher = resources.WatcherTemplate()
|
||||||
|
watcher._manager = mock.MagicMock()
|
||||||
|
|
||||||
|
watcher.list()
|
||||||
|
|
||||||
|
self.assertEqual("audit_template", watcher._resource)
|
||||||
|
watcher._manager().list.assert_called_once_with(limit=0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user