Ensure created symlink is in $PATH

With "sudo", the $PATH is overriden an really basic:
PATH=/sbin:/bin:/usr/sbin:/usr/bin
It doesn't list the /usr/local/(s)bin, hence the created
symlink wasn't seen by the script.

It also push that symlink creation in the __new__ special
method in order to make it cleaner.

Finaly, it takes care of lint/pep8 failures, not related to
this change (how is that even possible?!)

Co-Authored-By: Natal Ngétal <hobbestigrou@erakis.eu>
Closes-Bug: 1817365
Partial-Bug: 1816446

Change-Id: If09eb32f43b2c26c8cd8a89f2e862db1dd91dfed
This commit is contained in:
Cédric Jeanneret 2019-02-25 13:16:28 +01:00 committed by Emilien Macchi
parent 5a3d6572b5
commit 88d3dfd5e7
5 changed files with 41 additions and 31 deletions

View File

@ -45,12 +45,11 @@ class DeprecatedActionStore(_StoreAction):
if len(self.option_strings) == 1:
message = 'The option {option} is deprecated, it will be removed'\
' in a future version'.format(
option=self.option_strings[0])
option=self.option_strings[0])
else:
option = ', '.join(self.option_strings)
message = 'The options {option} is deprecated, it will be removed'\
' in a future version'.format(
option=option)
' in a future version'.format(option=option)
self.log.warning(message)
super(DeprecatedActionStore, self).__call__(

View File

@ -187,12 +187,14 @@ class TestContainerImagePrepare(TestPluginV1):
mock_bsf.return_value = set(['OS::TripleO::Services::AodhEvaluator'])
resource_registry = {
'parameter_defaults': {
'NeutronMechanismDrivers': 'ovn',
}, 'resource_registry': {
'OS::TripleO::Services::AodhEvaluator': aodh_file,
'OS::TripleO::Services::AodhApi': aodh_file
}}
'parameter_defaults': {
'NeutronMechanismDrivers': 'ovn',
},
'resource_registry': {
'OS::TripleO::Services::AodhEvaluator': aodh_file,
'OS::TripleO::Services::AodhApi': aodh_file
}
}
pmef.return_value = None, resource_registry
arglist = [

View File

@ -107,11 +107,12 @@ class UpdateRun(command.Command):
"a specific node or list (comma separated string) of nodes.")
)
nodes_or_roles_or_limit.add_argument(
'--limit', action='store', help=_(
"A string that identifies a single node or comma-separated"
" list of nodes to be upgraded in parallel in this upgrade"
" run invocation. For example: --limit \"compute-0,"
" compute-1, compute-5\"."))
'--limit', action='store', help=_(
"A string that identifies a single node or comma-separated"
" list of nodes to be upgraded in parallel in this upgrade"
" run invocation. For example: --limit \"compute-0,"
" compute-1, compute-5\".")
)
parser.add_argument('--playbook',
action="store",
default="all",

View File

@ -127,11 +127,12 @@ class UpgradeRun(command.Command):
"a specific node or list (comma separated string) of nodes.")
)
nodes_or_roles_or_limit.add_argument(
'--limit', action='store', help=_(
"A string that identifies a single node or comma-separated"
"list of nodes to be upgraded in parallel in this upgrade"
" run invocation. For example: --limit \"compute-0,"
" compute-1, compute-5\"."))
'--limit', action='store', help=_(
"A string that identifies a single node or comma-separated"
"list of nodes to be upgraded in parallel in this upgrade"
" run invocation. For example: --limit \"compute-0,"
" compute-1, compute-5\".")
)
parser.add_argument('--playbook',
action="store",
default="all",

View File

@ -106,19 +106,26 @@ class Deploy(command.Command):
ansible_playbook_cmd = "ansible-playbook-{}".format(python_version)
python_cmd = "python{}".format(python_version)
# https://bugs.launchpad.net/tripleo/+bug/1812837
if os.getuid() == 0:
if not os.path.exists('/usr/bin/ansible-playbook'):
if os.path.exists('/usr/bin/' + ansible_playbook_cmd):
if not os.path.exists('/usr/local/bin/ansible-playbook'):
os.symlink('/usr/bin/' + ansible_playbook_cmd,
'/usr/local/bin/ansible-playbook')
def __new__(cls, *args, **kwargs):
# https://bugs.launchpad.net/tripleo/+bug/1812837
if os.getuid() != 0:
cls.log.warning('Will not consider symlink creation (E_NOROOT).')
else:
if not os.path.exists('/usr/bin/' + ansible_playbook_cmd):
if not os.path.exists(
'/usr/local/bin/' + ansible_playbook_cmd):
os.symlink('/usr/bin/ansible-playbook',
'/usr/local/bin/' + ansible_playbook_cmd)
if not os.path.exists('/usr/bin/ansible-playbook'):
if os.path.exists('/usr/bin/' + cls.ansible_playbook_cmd):
if not os.path.exists('/usr/bin/ansible-playbook'):
os.symlink('/usr/bin/' + cls.ansible_playbook_cmd,
'/usr/bin/ansible-playbook')
else:
if not os.path.exists('/usr/bin/' + cls.ansible_playbook_cmd):
if not os.path.exists(
'/usr/bin/' + cls.ansible_playbook_cmd):
os.symlink('/usr/bin/ansible-playbook',
'/usr/bin/' + cls.ansible_playbook_cmd)
if cls.python_version == 3:
return super().__new__(cls)
else:
return super(Deploy, cls).__new__(cls, *args, **kwargs)
def _is_undercloud_deploy(self, parsed_args):
return parsed_args.standalone_role == 'Undercloud' and \