Merge "undercloud: introduce deployment_user parameter"

This commit is contained in:
Zuul 2018-02-15 21:55:19 +00:00 committed by Gerrit Code Review
commit fedd1b26f8
4 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,7 @@
---
features:
- |
Introduce deployment_user parameter, default to the current user,
will feed DeploymentUser parameter in THT, primarly used to add the
user to the 'docker' group, so our operators can run the `overcloud
container` commands when the undercloud is containerized.

View File

@ -204,6 +204,12 @@ class TestEnsureRunAsNormalUser(TestCase):
self.assertRaises(exceptions.RootUserExecution,
utils.ensure_run_as_normal_user)
@mock.patch('getpass.getuser')
def test_get_deployment_user(self, mock_getpass):
mock_getpass.return_value = 'stack'
u = utils.get_deployment_user()
self.assertEqual('stack', u)
class TestCreateOvercloudRC(TestCase):

View File

@ -16,6 +16,7 @@
from __future__ import print_function
import csv
import datetime
import getpass
import glob
import hashlib
import logging
@ -428,6 +429,11 @@ def ensure_run_as_normal_user():
' Switch to a normal user.')
def get_deployment_user():
"""Return the user name which is used to deploy the cloud"""
return getpass.getuser()
def capabilities_to_dict(caps):
"""Convert the Node's capabilities into a dictionary."""
if not caps:

View File

@ -23,6 +23,7 @@ import logging
import netaddr
import os
from oslo_config import cfg
from tripleoclient import utils
from tripleoclient.v1 import undercloud_preflight
import yaml
@ -65,6 +66,11 @@ PATHS = Paths()
# When adding new options to the lists below, make sure to regenerate the
# sample config by running "tox -e genconfig" in the project root.
_opts = [
cfg.StrOpt('deployment_user',
help=('User used to run openstack undercloud install command '
'which will be used to add the user to the docker group, '
'required to upload containers'),
),
cfg.StrOpt('undercloud_hostname',
help=('Fully qualified hostname (including domain) to set on '
'the Undercloud. If left unset, the '
@ -602,6 +608,9 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False):
tht_templates,
'environments/services-docker/undercloud-keepalived.yaml')]
u = CONF.get('deployment_user') or utils.get_deployment_user()
env_data['DeploymentUser'] = u
deploy_args += [
"-e", os.path.join(tht_templates, "environments/docker.yaml"),
"-e",