Merge "Add support for watcher osclient and watcher related types"

This commit is contained in:
Jenkins 2016-07-18 23:28:38 +00:00 committed by Gerrit Code Review
commit f0adca5c4b
7 changed files with 108 additions and 0 deletions

3
.gitignore vendored
View File

@ -46,3 +46,6 @@ doc/source/_build/
.idea
.pydevproject
*.swp
# Mac Desktop Service Store
*.DS_Store

View File

@ -113,6 +113,7 @@ class _Service(utils.ImmutableMixin, utils.EnumMixin):
IRONIC = "ironic"
GNOCCHI = "gnocchi"
MAGNUM = "magnum"
WATCHER = "watcher"
class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
@ -141,6 +142,7 @@ class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
BARE_METAL = "baremetal"
METRIC = "metric"
CONTAINER_INFRA = "container-infra"
INFRA_OPTIM = "infra-optim"
def __init__(self):
self.__names = {
@ -167,6 +169,7 @@ class _ServiceType(utils.ImmutableMixin, utils.EnumMixin):
self.BARE_METAL: _Service.IRONIC,
self.METRIC: _Service.GNOCCHI,
self.CONTAINER_INFRA: _Service.MAGNUM,
self.INFRA_OPTIM: _Service.WATCHER,
}
def __getitem__(self, service_type):

View File

@ -720,6 +720,27 @@ class FuelEnvironment(base.ResourceManager):
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_order = get_order(9000)

View File

@ -32,6 +32,7 @@ python-saharaclient>=0.13.0 # Apache-2.0
python-troveclient>=2.2.0 # Apache-2.0
python-zaqarclient>=1.0.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
requests>=2.10.0 # Apache-2.0
SQLAlchemy<1.1.0,>=1.0.10 # MIT

View File

@ -208,6 +208,26 @@ class Cinder(ResourceManager):
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):
"""List and compare cloud resources.

View File

@ -127,6 +127,14 @@ class FakeImage(FakeResource):
self.update = mock.MagicMock()
class FakeStrategy(FakeResource):
pass
class FakeGoal(FakeResource):
pass
class FakeMurano(FakeResource):
pass
@ -425,6 +433,18 @@ class FakeImageManager(FakeManager):
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):
def create(self, package_descr, package_arch, package_class=FakeMurano):
@ -1493,6 +1513,13 @@ class FakeMagnumClient(object):
pass
class FakeWatcherClient(object):
def __init__(self):
self.strategy = FakeStrategyManager()
self.goal = FakeGoalManager()
class FakeClients(object):
def __init__(self, credential_=None):
@ -1513,6 +1540,7 @@ class FakeClients(object):
self._monasca = None
self._ec2 = None
self._senlin = None
self._watcher = None
self._credential = credential_ or objects.Credential(
"http://fake.example.org:5000/v2.0/",
"fake_username",
@ -1607,6 +1635,11 @@ class FakeClients(object):
self._senlin = FakeSenlinClient()
return self._senlin
def watcher(self):
if not self._watcher:
self._watcher = FakeWatcherClient()
return self._watcher
class FakeRunner(object):

View File

@ -18,6 +18,7 @@ import ddt
import mock
from neutronclient.common import exceptions as neutron_exceptions
from novaclient import exceptions as nova_exc
from watcherclient.common.apiclient import exceptions as watcher_exceptions
from rally.common import utils
from rally.plugins.openstack.cleanup import resources
@ -753,3 +754,29 @@ class FuelEnvironmentTestCase(test.TestCase):
fres = resources.FuelEnvironment()
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)