[API] Add API class
Current implementation requires additional steps before api usage: - setting(initialization) config; - logging configuration; - etc. All required steps already implemented on CLI level. This patch just moves it on API layer, so users will be able to use rally api right away. Change-Id: I806a6b5a915c751095f03ab128b41cb79ec5d3c5
This commit is contained in:
parent
793c7b9671
commit
9d28a15c7f
@ -15,8 +15,8 @@
|
||||
|
||||
import os_faults
|
||||
|
||||
from rally import api
|
||||
from rally.common import logging
|
||||
from rally.common import objects
|
||||
from rally import consts
|
||||
from rally.task import hook
|
||||
|
||||
@ -56,7 +56,7 @@ class FaultInjectionHook(hook.Hook):
|
||||
}
|
||||
|
||||
def get_cloud_config(self):
|
||||
deployment = api.Deployment.get(self.task["deployment_uuid"])
|
||||
deployment = objects.Deployment.get(self.task["deployment_uuid"])
|
||||
deployment_config = deployment["config"]
|
||||
if deployment_config["type"] != "ExistingCloud":
|
||||
return None
|
||||
|
@ -27,6 +27,7 @@ from novaclient import exceptions as nova_exceptions
|
||||
import six
|
||||
from swiftclient import exceptions as swift_exceptions
|
||||
|
||||
from rally import api
|
||||
from rally.common import objects
|
||||
from rally.common import utils as rally_utils
|
||||
from rally import consts
|
||||
@ -1847,3 +1848,18 @@ class FakeTask(dict):
|
||||
|
||||
def to_dict(self):
|
||||
return self
|
||||
|
||||
|
||||
class FakeAPI(object):
|
||||
|
||||
def __init__(self):
|
||||
self._deployment = mock.Mock(spec=api._Deployment)
|
||||
self._task = mock.Mock(spec=api._Task)
|
||||
|
||||
@property
|
||||
def deployment(self):
|
||||
return self._deployment
|
||||
|
||||
@property
|
||||
def task(self):
|
||||
return self._task
|
||||
|
@ -60,7 +60,7 @@ class FaultInjectionHookTestCase(test.TestCase):
|
||||
fault_injection.FaultInjectionHook.validate,
|
||||
config)
|
||||
|
||||
@mock.patch("rally.cli.commands.deployment.api.Deployment.get")
|
||||
@mock.patch("rally.common.objects.Deployment.get")
|
||||
@mock.patch("os_faults.human_api")
|
||||
@mock.patch("os_faults.connect")
|
||||
@mock.patch("rally.common.utils.Timer", side_effect=fakes.FakeTimer)
|
||||
@ -84,7 +84,7 @@ class FaultInjectionHookTestCase(test.TestCase):
|
||||
injector_inst.verify.assert_called_once_with()
|
||||
mock_human_api.assert_called_once_with(injector_inst, "foo")
|
||||
|
||||
@mock.patch("rally.cli.commands.deployment.api.Deployment.get")
|
||||
@mock.patch("rally.common.objects.Deployment.get")
|
||||
@mock.patch("os_faults.human_api")
|
||||
@mock.patch("os_faults.connect")
|
||||
@mock.patch("rally.common.utils.Timer", side_effect=fakes.FakeTimer)
|
||||
@ -109,7 +109,7 @@ class FaultInjectionHookTestCase(test.TestCase):
|
||||
mock_connect.assert_called_once_with({"conf": "foo_config"})
|
||||
mock_human_api.assert_called_once_with(injector_inst, "foo")
|
||||
|
||||
@mock.patch("rally.cli.commands.deployment.api.Deployment.get")
|
||||
@mock.patch("rally.common.objects.Deployment.get")
|
||||
@mock.patch("os_faults.human_api")
|
||||
@mock.patch("os_faults.connect")
|
||||
@mock.patch("rally.common.utils.Timer", side_effect=fakes.FakeTimer)
|
||||
|
Loading…
Reference in New Issue
Block a user