Remove the orchestration property from tripleoclient class
Use the OSC-compatible orchestration client instead of the home-grown one. This reduces duplicate code, and relies on more thoroughly tested code elsewhere. Change-Id: Ib77d20086f86a260197c6f289fd9c270b766544c Depends-On: I7aa0fd7c152ee91b6e2b956f7e594f8c8aacafa7
This commit is contained in:
parent
f5016c9b52
commit
cdcf16ee45
tripleoclient
@ -63,43 +63,3 @@ class ClientWrapper(object):
|
||||
|
||||
def __init__(self, instance):
|
||||
self._instance = instance
|
||||
self._orchestration = None
|
||||
|
||||
@property
|
||||
def orchestration(self):
|
||||
"""Returns an orchestration service client"""
|
||||
|
||||
# TODO(d0ugal): This code is based on the upstream WIP implementation
|
||||
# and should be removed when it lands:
|
||||
# https://review.openstack.org/#/c/111786
|
||||
|
||||
if self._orchestration is not None:
|
||||
return self._orchestration
|
||||
|
||||
API_VERSIONS = {
|
||||
'1': 'heatclient.v1.client.Client',
|
||||
}
|
||||
|
||||
heat_client = utils.get_client_class(
|
||||
API_NAME,
|
||||
self._instance._api_version[API_NAME],
|
||||
API_VERSIONS)
|
||||
LOG.debug('Instantiating orchestration client: %s', heat_client)
|
||||
|
||||
endpoint = self._instance.get_endpoint_for_service_type(
|
||||
'orchestration')
|
||||
token = self._instance.auth.get_token(self._instance.session)
|
||||
|
||||
client = heat_client(
|
||||
endpoint=endpoint,
|
||||
auth_url=self._instance._auth_url,
|
||||
token=token,
|
||||
username=self._instance._username,
|
||||
password=self._instance._password,
|
||||
region_name=self._instance._region_name,
|
||||
insecure=self._instance._insecure,
|
||||
ca_file=self._instance._cli_options.os_cacert,
|
||||
)
|
||||
|
||||
self._orchestration = client
|
||||
return self._orchestration
|
||||
|
@ -26,14 +26,7 @@ class TestPlugin(base.TestCase):
|
||||
clientmgr._api_version.__getitem__.return_value = '1'
|
||||
clientmgr.get_endpoint_for_service_type.return_value = fakes.AUTH_URL
|
||||
|
||||
client = plugin.make_client(clientmgr)
|
||||
|
||||
# The client should have an orchestration property. Accessing it should
|
||||
# fetch it from the clientmanager:
|
||||
orchestration = client.orchestration
|
||||
# The second access should return the same client:
|
||||
self.assertIs(client.orchestration, orchestration)
|
||||
plugin.make_client(clientmgr)
|
||||
|
||||
# And the functions should only be called when the client is created:
|
||||
self.assertEqual(clientmgr.get_endpoint_for_service_type.call_count, 1)
|
||||
self.assertEqual(clientmgr.auth.get_token.call_count, 1)
|
||||
self.assertEqual(clientmgr.auth.get_token.call_count, 0)
|
||||
|
@ -94,11 +94,6 @@ class FakeClientWrapper(object):
|
||||
|
||||
def __init__(self):
|
||||
self._instance = mock.Mock()
|
||||
self._orchestration = mock.Mock()
|
||||
|
||||
@property
|
||||
def orchestration(self):
|
||||
return self._orchestration
|
||||
|
||||
|
||||
class TestDeployOvercloud(utils.TestCommand):
|
||||
@ -107,9 +102,10 @@ class TestDeployOvercloud(utils.TestCommand):
|
||||
super(TestDeployOvercloud, self).setUp()
|
||||
|
||||
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
|
||||
self.app.client_manager.tripleoclient = FakeClientWrapper()
|
||||
self.app.client_manager.baremetal = mock.Mock()
|
||||
self.app.client_manager.network = mock.Mock()
|
||||
self.app.client_manager.compute = mock.Mock()
|
||||
self.app.client_manager.identity = mock.Mock()
|
||||
self.app.client_manager.image = mock.Mock()
|
||||
self.app.client_manager.network = mock.Mock()
|
||||
self.app.client_manager.orchestration = mock.Mock()
|
||||
self.app.client_manager.tripleoclient = FakeClientWrapper()
|
||||
|
@ -117,7 +117,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
mock_generate_overcloud_passwords.return_value = self._get_passwords()
|
||||
|
||||
clients = self.app.client_manager
|
||||
orchestration_client = clients.tripleoclient.orchestration
|
||||
orchestration_client = clients.orchestration
|
||||
orchestration_client.stacks.get.return_value = fakes.create_tht_stack()
|
||||
mock_event = mock.Mock()
|
||||
mock_event.id = '1234'
|
||||
@ -273,7 +273,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
mock_generate_overcloud_passwords.return_value = self._get_passwords()
|
||||
|
||||
clients = self.app.client_manager
|
||||
orchestration_client = clients.tripleoclient.orchestration
|
||||
orchestration_client = clients.orchestration
|
||||
mock_stack = fakes.create_tht_stack()
|
||||
orchestration_client.stacks.get.return_value = None
|
||||
|
||||
@ -434,7 +434,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
mock_generate_overcloud_passwords.return_value = self._get_passwords()
|
||||
|
||||
clients = self.app.client_manager
|
||||
orchestration_client = clients.tripleoclient.orchestration
|
||||
orchestration_client = clients.orchestration
|
||||
orchestration_client.stacks.get.return_value = fakes.create_tht_stack()
|
||||
mock_events.return_value = []
|
||||
|
||||
@ -682,7 +682,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
wait_for_stack_ready_mock.return_value = True
|
||||
|
||||
clients = self.app.client_manager
|
||||
orchestration_client = clients.tripleoclient.orchestration
|
||||
orchestration_client = clients.orchestration
|
||||
orchestration_client.stacks.get.return_value = fakes.create_tht_stack()
|
||||
mock_events.return_value = []
|
||||
|
||||
|
@ -21,14 +21,6 @@ class FakeClientWrapper(object):
|
||||
|
||||
def __init__(self):
|
||||
self._instance = mock.Mock()
|
||||
self._orchestration = None
|
||||
|
||||
def orchestration(self):
|
||||
|
||||
if self._orchestration is None:
|
||||
self._orchestration = mock.Mock()
|
||||
|
||||
return self._orchestration
|
||||
|
||||
|
||||
class TestDeleteNode(utils.TestCommand):
|
||||
@ -37,4 +29,5 @@ class TestDeleteNode(utils.TestCommand):
|
||||
super(TestDeleteNode, self).setUp()
|
||||
|
||||
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
|
||||
self.app.client_manager.orchestration = mock.Mock()
|
||||
self.app.client_manager.tripleoclient = FakeClientWrapper()
|
||||
|
@ -21,14 +21,6 @@ class FakeClientWrapper(object):
|
||||
|
||||
def __init__(self):
|
||||
self._instance = mock.Mock()
|
||||
self._orchestration = None
|
||||
|
||||
def orchestration(self):
|
||||
|
||||
if self._orchestration is None:
|
||||
self._orchestration = mock.Mock()
|
||||
|
||||
return self._orchestration
|
||||
|
||||
|
||||
class TestOvercloudUpdate(utils.TestCommand):
|
||||
@ -37,4 +29,5 @@ class TestOvercloudUpdate(utils.TestCommand):
|
||||
super(TestOvercloudUpdate, self).setUp()
|
||||
|
||||
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
|
||||
self.app.client_manager.orchestration = mock.Mock()
|
||||
self.app.client_manager.tripleoclient = FakeClientWrapper()
|
||||
|
@ -21,14 +21,6 @@ class FakeClientWrapper(object):
|
||||
|
||||
def __init__(self):
|
||||
self._instance = mock.Mock()
|
||||
self._orchestration = None
|
||||
|
||||
def orchestration(self):
|
||||
|
||||
if self._orchestration is None:
|
||||
self._orchestration = mock.Mock()
|
||||
|
||||
return self._orchestration
|
||||
|
||||
|
||||
class TestOvercloudUpgrade(utils.TestCommand):
|
||||
@ -37,4 +29,5 @@ class TestOvercloudUpgrade(utils.TestCommand):
|
||||
super(TestOvercloudUpgrade, self).setUp()
|
||||
|
||||
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
|
||||
self.app.client_manager.orchestration = mock.Mock()
|
||||
self.app.client_manager.tripleoclient = FakeClientWrapper()
|
||||
|
@ -262,7 +262,7 @@ class DeployOvercloud(command.Command):
|
||||
files = dict(list(template_files.items()) + list(env_files.items()))
|
||||
|
||||
clients = self.app.client_manager
|
||||
orchestration_client = clients.tripleoclient.orchestration
|
||||
orchestration_client = clients.orchestration
|
||||
|
||||
self.log.debug("Deploying stack: %s", stack_name)
|
||||
self.log.debug("Deploying template: %s", template)
|
||||
@ -947,7 +947,7 @@ class DeployOvercloud(command.Command):
|
||||
"configuration, proceeding.")
|
||||
|
||||
clients = self.app.client_manager
|
||||
orchestration_client = clients.tripleoclient.orchestration
|
||||
orchestration_client = clients.orchestration
|
||||
|
||||
stack = utils.get_stack(orchestration_client, parsed_args.stack)
|
||||
stack_create = stack is None
|
||||
|
@ -51,11 +51,10 @@ class DeleteNode(command.Command):
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
osc_plugin = self.app.client_manager.tripleoclient
|
||||
clients = self.app.client_manager
|
||||
|
||||
orchestration = osc_plugin.orchestration
|
||||
scale_manager = scale.ScaleManager(
|
||||
heatclient=orchestration,
|
||||
heatclient=clients.orchestration,
|
||||
stack_id=parsed_args.stack,
|
||||
tht_dir=parsed_args.templates,
|
||||
environment_files=parsed_args.environment_files)
|
||||
|
@ -76,12 +76,11 @@ class UpdateOvercloud(command.Command):
|
||||
parsed_args.environment_files = answers['environments']
|
||||
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
osc_plugin = self.app.client_manager.tripleoclient
|
||||
clients = self.app.client_manager
|
||||
|
||||
orchestration = osc_plugin.orchestration
|
||||
update_manager = update.PackageUpdateManager(
|
||||
heatclient=orchestration,
|
||||
novaclient=self.app.client_manager.compute,
|
||||
heatclient=clients.orchestration,
|
||||
novaclient=clients.compute,
|
||||
stack_id=parsed_args.stack,
|
||||
tht_dir=parsed_args.templates,
|
||||
environment_files=parsed_args.environment_files)
|
||||
|
@ -78,11 +78,10 @@ class UpgradeOvercloud(command.Command):
|
||||
parsed_args.environment_files)
|
||||
parsed_args.environment_files = answers['environments']
|
||||
|
||||
osc_plugin = self.app.client_manager.tripleoclient
|
||||
clients = self.app.client_manager
|
||||
|
||||
orchestration = osc_plugin.orchestration
|
||||
upgrade_manager = upgrade.StackUpgradeManager(
|
||||
heatclient=orchestration,
|
||||
heatclient=clients.orchestration,
|
||||
stack_id=parsed_args.stack,
|
||||
tht_dir=parsed_args.templates,
|
||||
environment_files=parsed_args.environment_files)
|
||||
|
Loading…
x
Reference in New Issue
Block a user