Merge "Move more functions to utils.py"
This commit is contained in:
commit
dfa236730a
@ -56,11 +56,10 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
'_create_parameters_env')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_postconfig')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_create_tempest_deployer_input', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.generate_overcloud_passwords')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_create_overcloudrc')
|
||||
@mock.patch('tripleoclient.utils.create_overcloudrc')
|
||||
@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)
|
||||
@ -196,7 +195,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
('/usr/share/openstack-tripleo-heat-templates/overcloud-without-'
|
||||
'mergepy.yaml'))
|
||||
|
||||
mock_create_tempest_deployer_input.assert_called_with(self.cmd)
|
||||
mock_create_tempest_deployer_input.assert_called_with()
|
||||
mock_process_multiple_env.assert_called_with(
|
||||
[self.parameter_defaults_env_file])
|
||||
|
||||
@ -207,11 +206,10 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
'_create_parameters_env')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_postconfig')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_create_tempest_deployer_input', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.generate_overcloud_passwords')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_create_overcloudrc')
|
||||
@mock.patch('tripleoclient.utils.create_overcloudrc')
|
||||
@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)
|
||||
@ -360,7 +358,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
('/usr/share/openstack-tripleo-heat-templates/overcloud-without-'
|
||||
'mergepy.yaml'))
|
||||
|
||||
mock_create_tempest_deployer_input.assert_called_with(self.cmd)
|
||||
mock_create_tempest_deployer_input.assert_called_with()
|
||||
mock_process_multiple_env.assert_called_with(
|
||||
['/usr/share/openstack-tripleo-heat-templates/overcloud-resource-'
|
||||
'registry-puppet.yaml', '/fake/path',
|
||||
@ -371,11 +369,10 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_postconfig')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_create_tempest_deployer_input', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.generate_overcloud_passwords')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_create_overcloudrc')
|
||||
@mock.patch('tripleoclient.utils.create_overcloudrc')
|
||||
@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)
|
||||
@ -458,7 +455,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
'/home/stack/tripleo-heat-templates/overcloud-without-mergepy.yaml'
|
||||
)
|
||||
|
||||
mock_create_tempest_deployer_input.assert_called_with(self.cmd)
|
||||
mock_create_tempest_deployer_input.assert_called_with()
|
||||
mock_process_multiple_env.assert_called_with(
|
||||
[self.parameter_defaults_env_file])
|
||||
|
||||
@ -484,10 +481,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
self.assertFalse(result)
|
||||
self.assertFalse(mock_deploy_tht.called)
|
||||
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_create_tempest_deployer_input', autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_create_overcloudrc', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.create_overcloudrc', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_tripleo_heat_templates', autospec=True)
|
||||
@ -518,7 +514,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
self.assertTrue(mock_oc_endpoint.called)
|
||||
self.assertTrue(mock_create_ocrc.called)
|
||||
|
||||
mock_create_tempest_deployer_input.assert_called_with(self.cmd)
|
||||
mock_create_tempest_deployer_input.assert_called_with()
|
||||
|
||||
def test_validate_args_correct(self):
|
||||
arglist = ['--templates',
|
||||
|
@ -27,6 +27,8 @@ import sys
|
||||
import time
|
||||
|
||||
from heatclient.exc import HTTPNotFound
|
||||
from six.moves import configparser
|
||||
from six.moves import urllib
|
||||
|
||||
from tripleoclient import exceptions
|
||||
|
||||
@ -72,6 +74,77 @@ def generate_overcloud_passwords(output_file="tripleo-overcloud-passwords"):
|
||||
return passwords
|
||||
|
||||
|
||||
def create_overcloudrc(stack, no_proxy, config_directory='.'):
|
||||
"""Given proxy settings and stack, create the overcloudrc
|
||||
|
||||
stack: Heat stack containing the deployed overcloud
|
||||
no_proxy: a comma-separated string of hosts that shouldn't be proxied
|
||||
"""
|
||||
overcloud_endpoint = get_overcloud_endpoint(stack)
|
||||
overcloud_ip = urllib.parse.urlparse(overcloud_endpoint).hostname
|
||||
|
||||
rc_params = {
|
||||
'NOVA_VERSION': '1.1',
|
||||
'COMPUTE_API_VERSION': '1.1',
|
||||
'OS_USERNAME': 'admin',
|
||||
'OS_TENANT_NAME': 'admin',
|
||||
'OS_NO_CACHE': 'True',
|
||||
'OS_CLOUDNAME': stack.stack_name,
|
||||
'no_proxy': "%(no_proxy)s,%(overcloud_ip)s" % {
|
||||
'no_proxy': no_proxy,
|
||||
'overcloud_ip': overcloud_ip,
|
||||
}
|
||||
}
|
||||
rc_params.update({
|
||||
'OS_PASSWORD': get_password('OVERCLOUD_ADMIN_PASSWORD'),
|
||||
'OS_AUTH_URL': overcloud_endpoint,
|
||||
})
|
||||
|
||||
config_path = os.path.join(config_directory, '%src' % stack.stack_name)
|
||||
|
||||
with open(config_path, 'w') as f:
|
||||
for key, value in rc_params.items():
|
||||
f.write("export %(key)s=%(value)s\n" %
|
||||
{'key': key, 'value': value})
|
||||
|
||||
|
||||
def create_tempest_deployer_input(config_name='tempest-deployer-input.conf'):
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
config.add_section('compute-feature-enabled')
|
||||
# Does the test environment support obtaining instance serial console
|
||||
# output? (default: true)
|
||||
# set in [nova.serial_console]->enabled
|
||||
config.set('compute-feature-enabled', 'console_output', 'false')
|
||||
|
||||
config.add_section('object-storage')
|
||||
# Role to add to users created for swift tests to enable creating
|
||||
# containers (default: 'Member')
|
||||
# keystone role-list returns this role
|
||||
config.set('object-storage', 'operator_role', 'swiftoperator')
|
||||
|
||||
config.add_section('orchestration')
|
||||
# Role required for users to be able to manage stacks
|
||||
# (default: 'heat_stack_owner')
|
||||
# keystone role-list returns this role
|
||||
config.set('orchestration', 'stack_owner_role', 'heat_stack_user')
|
||||
|
||||
config.add_section('volume')
|
||||
# Name of the backend1 (must be declared in cinder.conf)
|
||||
# (default: 'BACKEND_1')
|
||||
# set in [cinder]->enabled_backends
|
||||
config.set('volume', 'backend1_name', 'tripleo_iscsi')
|
||||
|
||||
config.add_section('volume-feature-enabled')
|
||||
# Update bootable status of a volume Not implemented on icehouse
|
||||
# (default: false)
|
||||
# python-cinderclient supports set-bootable
|
||||
config.set('volume-feature-enabled', 'bootable', 'true')
|
||||
|
||||
with open(config_name, 'w+') as config_file:
|
||||
config.write(config_file)
|
||||
|
||||
|
||||
def check_hypervisor_stats(compute_client, nodes=1, memory=0, vcpu=0):
|
||||
"""Check the Hypervisor stats meet a minimum value
|
||||
|
||||
|
@ -33,7 +33,6 @@ from openstackclient.i18n import _
|
||||
from os_cloud_config import keystone
|
||||
from os_cloud_config import keystone_pki
|
||||
from os_cloud_config.utils import clients
|
||||
from six.moves import configparser
|
||||
from tripleo_common import update
|
||||
|
||||
from tripleoclient import constants
|
||||
@ -58,7 +57,7 @@ class DeployOvercloud(command.Command):
|
||||
undercloud_ceilometer_snmpd_password = utils.get_config_value(
|
||||
"auth", "undercloud_ceilometer_snmpd_password")
|
||||
|
||||
self.passwords = passwords = utils.generate_overcloud_passwords()
|
||||
passwords = utils.generate_overcloud_passwords()
|
||||
ceilometer_pass = passwords['OVERCLOUD_CEILOMETER_PASSWORD']
|
||||
ceilometer_secret = passwords['OVERCLOUD_CEILOMETER_SECRET']
|
||||
parameters['AdminPassword'] = passwords['OVERCLOUD_ADMIN_PASSWORD']
|
||||
@ -330,68 +329,6 @@ class DeployOvercloud(command.Command):
|
||||
self._heat_deploy(stack, parsed_args.stack, overcloud_yaml, parameters,
|
||||
environments, parsed_args.timeout)
|
||||
|
||||
def _create_overcloudrc(self, stack, parsed_args):
|
||||
overcloud_endpoint = utils.get_overcloud_endpoint(stack)
|
||||
overcloud_ip = six.moves.urllib.parse.urlparse(
|
||||
overcloud_endpoint).hostname
|
||||
|
||||
rc_params = {
|
||||
'NOVA_VERSION': '1.1',
|
||||
'COMPUTE_API_VERSION': '1.1',
|
||||
'OS_USERNAME': 'admin',
|
||||
'OS_TENANT_NAME': 'admin',
|
||||
'OS_NO_CACHE': 'True',
|
||||
'OS_CLOUDNAME': stack.stack_name,
|
||||
'no_proxy': "%(no_proxy)s,%(overcloud_ip)s" % {
|
||||
'no_proxy': parsed_args.no_proxy,
|
||||
'overcloud_ip': overcloud_ip,
|
||||
}
|
||||
}
|
||||
rc_params.update({
|
||||
'OS_PASSWORD': utils.get_password('OVERCLOUD_ADMIN_PASSWORD'),
|
||||
'OS_AUTH_URL': utils.get_overcloud_endpoint(stack),
|
||||
})
|
||||
with open('%src' % stack.stack_name, 'w') as f:
|
||||
for key, value in rc_params.items():
|
||||
f.write("export %(key)s=%(value)s\n" %
|
||||
{'key': key, 'value': value})
|
||||
|
||||
def _create_tempest_deployer_input(self):
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
config.add_section('compute-feature-enabled')
|
||||
# Does the test environment support obtaining instance serial console
|
||||
# output? (default: true)
|
||||
# set in [nova.serial_console]->enabled
|
||||
config.set('compute-feature-enabled', 'console_output', 'false')
|
||||
|
||||
config.add_section('object-storage')
|
||||
# Role to add to users created for swift tests to enable creating
|
||||
# containers (default: 'Member')
|
||||
# keystone role-list returns this role
|
||||
config.set('object-storage', 'operator_role', 'swiftoperator')
|
||||
|
||||
config.add_section('orchestration')
|
||||
# Role required for users to be able to manage stacks
|
||||
# (default: 'heat_stack_owner')
|
||||
# keystone role-list returns this role
|
||||
config.set('orchestration', 'stack_owner_role', 'heat_stack_owner')
|
||||
|
||||
config.add_section('volume')
|
||||
# Name of the backend1 (must be declared in cinder.conf)
|
||||
# (default: 'BACKEND_1')
|
||||
# set in [cinder]->enabled_backends
|
||||
config.set('volume', 'backend1_name', 'tripleo_iscsi')
|
||||
|
||||
config.add_section('volume-feature-enabled')
|
||||
# Update bootable status of a volume Not implemented on icehouse
|
||||
# (default: false)
|
||||
# python-cinderclient supports set-bootable
|
||||
config.set('volume-feature-enabled', 'bootable', 'true')
|
||||
|
||||
with open('tempest-deployer-input.conf', 'w+') as config_file:
|
||||
config.write(config_file)
|
||||
|
||||
def _deploy_postconfig(self, stack, parsed_args):
|
||||
self.log.debug("_deploy_postconfig(%s)" % parsed_args)
|
||||
|
||||
@ -941,8 +878,8 @@ class DeployOvercloud(command.Command):
|
||||
# a create then the previous stack object would be None.
|
||||
stack = utils.get_stack(orchestration_client, parsed_args.stack)
|
||||
|
||||
self._create_overcloudrc(stack, parsed_args)
|
||||
self._create_tempest_deployer_input()
|
||||
utils.create_overcloudrc(stack, parsed_args.no_proxy)
|
||||
utils.create_tempest_deployer_input()
|
||||
|
||||
if stack_create:
|
||||
self._deploy_postconfig(stack, parsed_args)
|
||||
|
Loading…
Reference in New Issue
Block a user