Merge "Stop using os-cloud-config"

This commit is contained in:
Jenkins
2017-03-28 17:37:57 +00:00
committed by Gerrit Code Review
4 changed files with 9 additions and 220 deletions

View File

@@ -0,0 +1,7 @@
---
other:
- |
Remove all usage of os-cloud-config.
Indeed, os-cloud-config has been deprecated in Ocata and is not useful anymore
from tripleoclient. Let's stop using it and remove all the code that used it,
including the tests.

View File

@@ -12,7 +12,6 @@ python-ironicclient>=1.11.0 # Apache-2.0
python-mistralclient>=2.0.0 # Apache-2.0
python-openstackclient>=3.3.0 # Apache-2.0
six>=1.9.0 # MIT
os-cloud-config # Apache-2.0
osc-lib>=1.2.0 # Apache-2.0
websocket-client>=0.32.0 # LGPLv2+
tripleo-common>=5.7.0 # Apache-2.0

View File

@@ -20,7 +20,6 @@ import tempfile
import yaml
from heatclient import exc as hc_exc
from keystoneclient import exceptions as kscexc
import mock
from osc_lib import exceptions as oscexc
from swiftclient.exceptions import ClientException as ObjectClientException
@@ -68,9 +67,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
autospec=True)
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
@mock.patch('os_cloud_config.keystone.setup_endpoints', autospec=True)
@mock.patch('time.sleep', return_value=None)
@mock.patch('os_cloud_config.keystone.initialize', autospec=True)
@mock.patch('tripleoclient.utils.remove_known_hosts', autospec=True)
@mock.patch('tripleoclient.utils.wait_for_stack_ready',
autospec=True)
@@ -85,8 +81,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_check_hypervisor_stats,
mock_get_template_contents,
wait_for_stack_ready_mock,
mock_remove_known_hosts, mock_keystone_initialize,
mock_sleep, mock_setup_endpoints,
mock_remove_known_hosts,
mock_write_overcloudrc,
mock_create_tempest_deployer_input,
mock_deploy_postconfig,
@@ -181,13 +176,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
autospec=True)
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
@mock.patch('os_cloud_config.utils.clients.get_nova_bm_client',
autospec=True)
@mock.patch('os_cloud_config.utils.clients.get_keystone_client',
autospec=True)
@mock.patch('os_cloud_config.keystone.setup_endpoints', autospec=True)
@mock.patch('time.sleep', return_value=None)
@mock.patch('os_cloud_config.keystone.initialize', autospec=True)
@mock.patch('tripleoclient.utils.remove_known_hosts', autospec=True)
@mock.patch('tripleoclient.utils.wait_for_stack_ready',
autospec=True)
@@ -204,9 +192,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_check_hypervisor_stats,
mock_get_template_contents,
wait_for_stack_ready_mock,
mock_remove_known_hosts, mock_keystone_initialize,
mock_sleep, mock_setup_endpoints,
mock_get_keystone_client, mock_get_nova_bm_client,
mock_remove_known_hosts,
mock_write_overcloudrc,
mock_create_tempest_deployer_input,
mock_create_parameters_env, mock_validate_args,
@@ -309,9 +295,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
autospec=True)
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
@mock.patch('os_cloud_config.keystone.setup_endpoints', autospec=True)
@mock.patch('time.sleep', return_value=None)
@mock.patch('os_cloud_config.keystone.initialize', autospec=True)
@mock.patch('tripleoclient.utils.remove_known_hosts', autospec=True)
@mock.patch('tripleoclient.utils.wait_for_stack_ready',
autospec=True)
@@ -325,8 +308,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_get_template_contents,
wait_for_stack_ready_mock,
mock_remove_known_hosts,
mock_keystone_initialize,
mock_sleep, mock_setup_endpoints,
mock_write_overcloudrc,
mock_create_tempest_deployer_input,
mock_deploy_postconfig,
@@ -621,7 +602,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.assertTrue(mock_deploy_tht.called)
self.assertTrue(mock_oc_endpoint.called)
self.assertTrue(mock_create_ocrc.called)
mock_create_tempest_deployer_input.assert_called_with()
@@ -636,9 +616,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
autospec=True)
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
@mock.patch('os_cloud_config.keystone.setup_endpoints', autospec=True)
@mock.patch('time.sleep', return_value=None)
@mock.patch('os_cloud_config.keystone.initialize', autospec=True)
@mock.patch('tripleoclient.utils.remove_known_hosts', autospec=True)
@mock.patch('tripleoclient.utils.wait_for_stack_ready',
autospec=True)
@@ -657,8 +634,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_process_env,
wait_for_stack_ready_mock,
mock_remove_known_hosts,
mock_keystone_initialize,
mock_sleep, mock_setup_endpoints,
mock_write_overcloudrc,
mock_create_tempest_deployer_input,
mock_deploy_postconfig,
@@ -811,7 +786,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.assertFalse(mock_deploy_tht.called)
self.assertFalse(mock_oc_endpoint.called)
self.assertFalse(mock_create_ocrc.called)
self.assertFalse(mock_create_tempest_deployer_input.called)
@@ -879,7 +853,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
self.cmd.take_action(parsed_args)
self.assertTrue(mock_heat_deploy.called)
self.assertTrue(mock_oc_endpoint.called)
self.assertTrue(mock_create_ocrc.called)
self.assertTrue(mock_create_tempest_deployer_input.called)
@@ -897,79 +870,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_create_tempest_deployer_input.assert_called_with()
@mock.patch('tripleoclient.workflows.parameters.get_overcloud_passwords')
@mock.patch('tripleoclient.constants.SERVICE_LIST',
{'nova': {'password_field': 'NovaPassword'}})
@mock.patch('os_cloud_config.keystone.initialize')
@mock.patch('os_cloud_config.utils.clients.get_keystone_client')
def test_keystone_init(self, mock_gkc, mock_init, mock_gp):
mock_gp.return_value = {
"AdminPassword": "password",
"AdminToken": "token",
"NovaPassword": "nova-password"
}
mock_ksc = mock.Mock()
mock_gkc.return_value = mock_ksc
mock_ksc.services.find.return_value = True
stack = mock.MagicMock()
stack.to_dict.return_value = fakes.FAKE_STACK
ip = '192.0.2.1'
self.cmd._keystone_init(ip, ip, None, stack)
self.assertFalse(mock_init.called)
@mock.patch('tripleoclient.workflows.parameters.get_overcloud_passwords')
@mock.patch('tripleoclient.constants.SERVICE_LIST',
{'nova': {'password_field': 'NovaPassword'}})
@mock.patch('os_cloud_config.keystone.setup_endpoints')
@mock.patch('os_cloud_config.keystone.initialize')
@mock.patch('os_cloud_config.utils.clients.get_keystone_client')
def test_keystone_init_occ(self, mock_gkc, mock_init, mock_se, mock_gp):
mock_gp.return_value = {
"AdminPassword": "password",
"AdminToken": "token",
"NovaPassword": "nova-password"
}
mock_ksc = mock.Mock()
mock_gkc.return_value = mock_ksc
mock_ksc.services.find.side_effect = kscexc.NotFound()
stack = mock.Mock()
stack.to_dict.return_value = fakes.FAKE_STACK
ip = '192.0.2.1'
args = mock.Mock()
self.cmd._keystone_init(ip, ip, args, stack)
self.assertTrue(mock_init.called)
@mock.patch('tripleoclient.workflows.parameters.get_overcloud_passwords')
@mock.patch('tripleoclient.constants.SERVICE_LIST',
{'nova': {'password_field': 'NovaPassword'},
'unexistent': {'password_field': 'NovaPassword'}})
@mock.patch('os_cloud_config.keystone.setup_endpoints')
@mock.patch('os_cloud_config.keystone.initialize')
@mock.patch('os_cloud_config.utils.clients.get_keystone_client')
def test_keystone_init_occ_w_entry_not_in_endpoint_map(
self, mock_gkc, mock_init, mock_se, mock_gp):
mock_gp.return_value = {
"AdminPassword": "password",
"AdminToken": "token",
"NovaPassword": "nova-password"
}
mock_ksc = mock.Mock()
mock_gkc.return_value = mock_ksc
mock_ksc.services.find.side_effect = kscexc.NotFound()
stack = mock.Mock()
stack.to_dict.return_value = fakes.FAKE_STACK
ip = '192.0.2.1'
args = mock.Mock()
self.cmd._keystone_init(ip, ip, args, stack)
self.assertTrue(mock_init.called)
self.assertEqual(mock_gp.call_count, 1)
@mock.patch('tripleoclient.utils.check_nodes_count')
@mock.patch('tripleoclient.utils.check_hypervisor_stats')
@mock.patch('tripleoclient.utils.assign_and_verify_profiles')
@@ -1097,13 +997,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
autospec=True)
@mock.patch('tripleoclient.utils.write_overcloudrc')
@mock.patch('os_cloud_config.utils.clients.get_nova_bm_client',
autospec=True)
@mock.patch('os_cloud_config.utils.clients.get_keystone_client',
autospec=True)
@mock.patch('os_cloud_config.keystone.setup_endpoints', autospec=True)
@mock.patch('time.sleep', return_value=None)
@mock.patch('os_cloud_config.keystone.initialize', autospec=True)
@mock.patch('tripleoclient.utils.remove_known_hosts', autospec=True)
@mock.patch('tripleoclient.utils.wait_for_stack_ready',
autospec=True)
@@ -1123,10 +1016,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_process_env,
wait_for_stack_ready_mock,
mock_remove_known_hosts,
mock_keystone_initialize,
mock_sleep, mock_setup_endpoints,
mock_get_keystone_client,
mock_get_nova_bm_client,
mock_write_overcloudrc,
mock_create_tempest_deployer_input,
mock_create_parameters_env,

View File

@@ -29,7 +29,6 @@ import yaml
from heatclient.common import template_utils
from heatclient import exc as hc_exc
from keystoneclient import exceptions as kscexc
from osc_lib.command import command
from osc_lib import exceptions as oscexc
from osc_lib.i18n import _
@@ -45,13 +44,6 @@ from tripleoclient.workflows import parameters as workflow_params
from tripleoclient.workflows import plan_management
level = logging.getLogger('os_cloud_config').getEffectiveLevel()
logging.getLogger('os_cloud_config').setLevel(logging.ERROR)
from os_cloud_config import keystone
from os_cloud_config.utils import clients as occ_clients
logging.getLogger('os_cloud_config').setLevel(level)
class DeployOvercloud(command.Command):
"""Deploy Overcloud"""
@@ -476,89 +468,6 @@ class DeployOvercloud(command.Command):
return self._password_cache[password_name]
def _keystone_init(self, overcloud_endpoint, overcloud_ip_or_fqdn,
parsed_args, stack):
keystone_admin_ip = utils.get_endpoint('KeystoneAdmin', stack)
keystone_admin_ip = utils.unbracket_ipv6(keystone_admin_ip)
keystone_internal_ip = utils.get_endpoint('KeystoneInternal', stack)
keystone_internal_ip = utils.unbracket_ipv6(keystone_internal_ip)
tls_enabled = self._is_tls_enabled(overcloud_endpoint)
keystone_tls_host = None
if tls_enabled:
# NOTE(jaosorior): This triggers set up the keystone endpoint with
# the https protocol and the required port set in
# keystone.initialize.
keystone_tls_host = overcloud_ip_or_fqdn
keystone_client = occ_clients.get_keystone_client(
'admin',
self._get_password(stack.stack_name, "AdminPassword"),
'admin',
overcloud_endpoint)
services = {}
for service, data in six.iteritems(constants.SERVICE_LIST):
try:
keystone_client.services.find(name=service)
except kscexc.NotFound:
service_data = self._set_service_data(service, data, stack)
if service_data:
services.update({service: service_data})
if services:
# This was deprecated in Newton. The deprecation message and
# os-cloud-config keystone init should remain until at least the
# Pike release to ensure users have a chance to update their
# templates, including ones for the previous release.
self.log.warning('DEPRECATED: '
'It appears Keystone was not initialized by '
'Puppet. Will do initialization via '
'os-cloud-config, but this behavior is '
'deprecated. Please update your templates to a '
'version that has Puppet initialization of '
'Keystone.'
)
# NOTE(jaosorior): These ports will be None if the templates
# don't support the EndpointMap as an output yet. And so the
# default values will be taken.
public_port = None
admin_port = None
internal_port = None
endpoint_map = utils.get_endpoint_map(stack)
if endpoint_map:
public_port = endpoint_map.get('KeystonePublic').get('port')
admin_port = endpoint_map.get('KeystoneAdmin').get('port')
internal_port = endpoint_map.get(
'KeystoneInternal').get('port')
# TODO(rbrady): check usages of get_password
keystone.initialize(
keystone_admin_ip,
self._get_password(stack.stack_name, "AdminToken"),
'admin@example.com',
self._get_password(stack.stack_name, "AdminPassword"),
ssl=keystone_tls_host,
public=overcloud_ip_or_fqdn,
user=parsed_args.overcloud_ssh_user,
admin=keystone_admin_ip,
internal=keystone_internal_ip,
public_port=public_port,
admin_port=admin_port,
internal_port=internal_port)
if not tls_enabled:
# NOTE(bcrochet): Bad hack. Remove the ssl_port info from the
# os_cloud_config.SERVICES dictionary
for service_name, data in keystone.SERVICES.items():
data.pop('ssl_port', None)
keystone.setup_endpoints(
services,
client=keystone_client,
os_auth_url=overcloud_endpoint,
public_host=overcloud_ip_or_fqdn)
# End of deprecated Keystone init
def _set_service_data(self, service, data, stack):
self.log.debug("Setting data for service '%s'" % service)
service_data = data.copy()
@@ -616,14 +525,6 @@ class DeployOvercloud(command.Command):
return re.sub('v[0-9]+', '',
service.capitalize() + interface.capitalize())
def _endpoints_managed(self, stack):
for output in stack.to_dict().get('outputs', {}):
if output['output_key'] == 'ManagedEndpoints':
# NOTE(jaosorior): We don't really care about the value as
# long as the key is there.
return output['output_value']
return False
def _deploy_postconfig(self, stack, parsed_args):
self.log.debug("_deploy_postconfig(%s)" % parsed_args)
@@ -645,13 +546,6 @@ class DeployOvercloud(command.Command):
utils.remove_known_hosts(overcloud_ip_or_fqdn)
if not self._endpoints_managed(stack):
self._keystone_init(overcloud_endpoint, overcloud_ip_or_fqdn,
parsed_args, stack)
else:
self.log.debug("Keystone endpoints and services are managed by "
"puppet. Skipping post-config.")
def _validate_args(self, parsed_args):
if parsed_args.templates is None and parsed_args.answers_file is None:
raise oscexc.CommandError(