Merge "Enable several PEP8 checks"
This commit is contained in:
@@ -52,8 +52,6 @@ DIR_PROJECT_DIR = os.environ.get('INSTALLER_PROJECT_DIR', os.path.join(os.getcwd
|
||||
DIR_PLUGINS = os.path.join(DIR_PROJECT_DIR, "plugins")
|
||||
DIR_MODULES = os.path.join(DIR_PROJECT_DIR, "modules")
|
||||
|
||||
|
||||
|
||||
EXEC_RPM = "rpm"
|
||||
EXEC_SEMANAGE = "semanage"
|
||||
EXEC_NSLOOKUP = "nslookup"
|
||||
|
||||
@@ -24,8 +24,8 @@ class SshTarballTransferMixin(object):
|
||||
script.append("scp %(pack_path)s root@%(node)s:%(pack_dest)s"
|
||||
% args)
|
||||
script.append("ssh -o StrictHostKeyChecking=no "
|
||||
"-o UserKnownHostsFile=/dev/null root@%(node)s "
|
||||
"tar -C %(res_dir)s -xpzf %(pack_dest)s" % args)
|
||||
"-o UserKnownHostsFile=/dev/null root@%(node)s "
|
||||
"tar -C %(res_dir)s -xpzf %(pack_dest)s" % args)
|
||||
try:
|
||||
script.execute()
|
||||
except ScriptRuntimeError as ex:
|
||||
@@ -124,15 +124,15 @@ class Drone(object):
|
||||
# remote host IP or hostname
|
||||
self.node = node
|
||||
# working directories on remote host
|
||||
self.resource_dir = resource_dir or \
|
||||
'/tmp/drone%s' % uuid.uuid4().hex[:8]
|
||||
self.recipe_dir = recipe_dir or \
|
||||
os.path.join(self.resource_dir, 'recipes')
|
||||
self.resource_dir = (resource_dir or
|
||||
'/tmp/drone%s' % uuid.uuid4().hex[:8])
|
||||
self.recipe_dir = (recipe_dir or
|
||||
os.path.join(self.resource_dir, 'recipes'))
|
||||
# temporary directories
|
||||
self.remote_tmpdir = remote_tmpdir or \
|
||||
'/tmp/drone%s' % uuid.uuid4().hex[:8]
|
||||
self.local_tmpdir = local_tmpdir or \
|
||||
tempfile.mkdtemp(prefix='drone')
|
||||
self.remote_tmpdir = (remote_tmpdir or
|
||||
'/tmp/drone%s' % uuid.uuid4().hex[:8])
|
||||
self.local_tmpdir = (local_tmpdir or
|
||||
tempfile.mkdtemp(prefix='drone'))
|
||||
|
||||
def init_node(self):
|
||||
"""
|
||||
@@ -335,7 +335,7 @@ class PackstackDrone(SshTarballTransferMixin, Drone):
|
||||
server = utils.ScriptRunner(self.node)
|
||||
for pkg in ("puppet", "openssh-clients", "tar"):
|
||||
server.append("rpm -q --whatprovides %(pkg)s || "
|
||||
"yum install -y %(pkg)s" % locals())
|
||||
"yum install -y %(pkg)s" % locals())
|
||||
server.execute()
|
||||
|
||||
def add_resource(self, path, resource_type=None):
|
||||
@@ -352,8 +352,8 @@ class PackstackDrone(SshTarballTransferMixin, Drone):
|
||||
recipe_base.replace(".finished", ".log"))
|
||||
local = utils.ScriptRunner()
|
||||
local.append('scp -o StrictHostKeyChecking=no '
|
||||
'-o UserKnownHostsFile=/dev/null '
|
||||
'root@%s:%s %s' % (self.node, recipe, log))
|
||||
'-o UserKnownHostsFile=/dev/null '
|
||||
'root@%s:%s %s' % (self.node, recipe, log))
|
||||
try:
|
||||
# once a remote puppet run has finished, we retrieve
|
||||
# the log file and check it for errors
|
||||
@@ -390,8 +390,8 @@ class PackstackDrone(SshTarballTransferMixin, Drone):
|
||||
mdir = self._module_dir
|
||||
server.append(
|
||||
"( flock %(rdir)s/ps.lock "
|
||||
"puppet apply %(loglevel)s --modulepath %(mdir)s "
|
||||
"%(recipe)s > %(running)s 2>&1 < /dev/null; "
|
||||
"puppet apply %(loglevel)s --modulepath %(mdir)s "
|
||||
"%(recipe)s > %(running)s 2>&1 < /dev/null; "
|
||||
"mv %(running)s %(finished)s ) "
|
||||
"> /dev/null 2>&1 < /dev/null &" % locals())
|
||||
server.execute()
|
||||
|
||||
@@ -48,7 +48,6 @@ class Step(object):
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
|
||||
class Sequence(object):
|
||||
"""
|
||||
Wrapper for sequence of setup steps.
|
||||
|
||||
@@ -52,8 +52,8 @@ INFO_REMOVE_REMOTE_VAR = "Removing %s on %s (if it is a remote host)"
|
||||
|
||||
WARN_WEAK_PASS = "Warning: Weak Password."
|
||||
WARN_NM_ENABLED = ("Warning: NetworkManager is active on %s. OpenStack "
|
||||
"networking currently does not work on systems that have "
|
||||
"the Network Manager service enabled.")
|
||||
"networking currently does not work on systems that have "
|
||||
"the Network Manager service enabled.")
|
||||
|
||||
ERR_PING = "Error: the provided hostname is unreachable"
|
||||
ERR_SSH = "Error: could not connect to the ssh server: %s"
|
||||
|
||||
@@ -77,7 +77,7 @@ def _getInputFromUser(param):
|
||||
else:
|
||||
while loop:
|
||||
# If the value was not supplied by the command line flags
|
||||
if not commandLineValues.has_key(param.CONF_NAME):
|
||||
if param.CONF_NAME not in commandLineValues:
|
||||
message = StringIO()
|
||||
message.write(param.PROMPT)
|
||||
|
||||
@@ -121,11 +121,11 @@ def _getInputFromUser(param):
|
||||
controller.CONF[param.CONF_NAME] = userInput
|
||||
continue
|
||||
else:
|
||||
if commandLineValues.has_key(param.CONF_NAME):
|
||||
if param.CONF_NAME in commandLineValues:
|
||||
del commandLineValues[param.CONF_NAME]
|
||||
else:
|
||||
# Delete value from commandLineValues so that we will prompt the user for input
|
||||
if commandLineValues.has_key(param.CONF_NAME):
|
||||
if param.CONF_NAME in commandLineValues:
|
||||
del commandLineValues[param.CONF_NAME]
|
||||
loop = True
|
||||
except KeyboardInterrupt:
|
||||
@@ -144,7 +144,7 @@ def input_param(param):
|
||||
"""
|
||||
# We need to check if a param needs confirmation, (i.e. ask user twice)
|
||||
# Do not validate if it was given from the command line
|
||||
if (param.NEED_CONFIRM and not commandLineValues.has_key(param.CONF_NAME)):
|
||||
if param.NEED_CONFIRM and param.CONF_NAME not in commandLineValues:
|
||||
# create a copy of the param so we can call it twice
|
||||
confirmedParam = copy.deepcopy(param)
|
||||
confirmedParamName = param.CONF_NAME + "_CONFIRMED"
|
||||
@@ -492,9 +492,9 @@ def _handleInteractiveParams():
|
||||
# we clear the value of all params in the group
|
||||
# in order to re-input them by the user
|
||||
for param in group.parameters.itervalues():
|
||||
if controller.CONF.has_key(param.CONF_NAME):
|
||||
if param.CONF_NAME in controller.CONF:
|
||||
del controller.CONF[param.CONF_NAME]
|
||||
if commandLineValues.has_key(param.CONF_NAME):
|
||||
if param.CONF_NAME in commandLineValues:
|
||||
del commandLineValues[param.CONF_NAME]
|
||||
else:
|
||||
inputLoop = False
|
||||
@@ -529,7 +529,7 @@ def _getConditionValue(matchMember):
|
||||
elif isinstance(matchMember, types.StringType):
|
||||
# we assume that if we get a string as a member it is the name
|
||||
# of a member of conf_params
|
||||
if not controller.CONF.has_key(matchMember):
|
||||
if matchMember not in controller.CONF:
|
||||
param = controller.getParamByName(matchMember)
|
||||
input_param(param)
|
||||
returnValue = controller.CONF[matchMember]
|
||||
@@ -546,7 +546,7 @@ def _displaySummary():
|
||||
logging.info("*** User input summary ***")
|
||||
for group in controller.getAllGroups():
|
||||
for param in group.parameters.itervalues():
|
||||
if not param.USE_DEFAULT and controller.CONF.has_key(param.CONF_NAME):
|
||||
if not param.USE_DEFAULT and param.CONF_NAME in controller.CONF:
|
||||
cmdOption = param.CMD_OPTION
|
||||
l = 30 - len(cmdOption)
|
||||
maskParam = param.MASK_INPUT
|
||||
@@ -564,14 +564,14 @@ def _displaySummary():
|
||||
logging.debug("user chose to re-enter the user parameters")
|
||||
for group in controller.getAllGroups():
|
||||
for param in group.parameters.itervalues():
|
||||
if controller.CONF.has_key(param.CONF_NAME):
|
||||
if param.CONF_NAME in controller.CONF:
|
||||
if not param.MASK_INPUT:
|
||||
param.DEFAULT_VALUE = controller.CONF[param.CONF_NAME]
|
||||
# Remove the string from mask_value_set in order
|
||||
# to remove values that might be over overwritten.
|
||||
removeMaskString(controller.CONF[param.CONF_NAME])
|
||||
del controller.CONF[param.CONF_NAME]
|
||||
if commandLineValues.has_key(param.CONF_NAME):
|
||||
if param.CONF_NAME in commandLineValues:
|
||||
del commandLineValues[param.CONF_NAME]
|
||||
print ""
|
||||
logging.debug("calling handleParams in interactive mode")
|
||||
@@ -602,7 +602,7 @@ def _summaryParamsToLog():
|
||||
logging.debug("*** The following params were used as user input:")
|
||||
for group in controller.getAllGroups():
|
||||
for param in group.parameters.itervalues():
|
||||
if controller.CONF.has_key(param.CONF_NAME):
|
||||
if param.CONF_NAME in controller.CONF:
|
||||
maskedValue = mask(controller.CONF[param.CONF_NAME])
|
||||
logging.debug("%s: %s" % (param.CMD_OPTION, maskedValue))
|
||||
|
||||
@@ -725,7 +725,7 @@ def generateAnswerFile(outputFile, overrides={}):
|
||||
|
||||
|
||||
def single_step_aio_install(options, logFile):
|
||||
""" Installs an All in One host on this host"""
|
||||
"""Installs an All in One host on this host."""
|
||||
|
||||
options.install_hosts = utils.get_localhost_ip()
|
||||
|
||||
@@ -788,15 +788,15 @@ def initCmdLineParser():
|
||||
usage = "usage: %prog [options] [--help]"
|
||||
parser = OptionParser(usage=usage, version="%prog {0} {1}".format(version.release_string(), version.version_string()))
|
||||
parser.add_option("--gen-answer-file", help="Generate a template of an answer file, using this option excludes all other options")
|
||||
parser.add_option("--answer-file", help="Runs the configuration in non-interactive mode, extracting all information from the \
|
||||
configuration file. using this option excludes all other options")
|
||||
parser.add_option("--answer-file", help="Runs the configuration in non-interactive mode, extracting all information from the"
|
||||
"configuration file. using this option excludes all other options")
|
||||
parser.add_option("--install-hosts", help="Install on a set of hosts in a single step. The format should be a comma separated list "
|
||||
"of hosts, the first is setup as a controller, and the others are setup as compute nodes."
|
||||
"if only a single host is supplied then it is setup as an all in one installation. An answerfile "
|
||||
"will also be generated and should be used if Packstack needs to be run a second time ")
|
||||
"of hosts, the first is setup as a controller, and the others are setup as compute nodes."
|
||||
"if only a single host is supplied then it is setup as an all in one installation. An answerfile "
|
||||
"will also be generated and should be used if Packstack needs to be run a second time ")
|
||||
parser.add_option("--allinone", action="store_true", help="Shorthand for --install-hosts=<local ipaddr> --novanetwork-pubif=<dev> "
|
||||
"--novacompute-privif=lo --novanetwork-privif=lo --os-swift-install=y --nagios-install=y "
|
||||
", this option can be used to install an all in one OpenStack on this host")
|
||||
"--novacompute-privif=lo --novanetwork-privif=lo --os-swift-install=y --nagios-install=y "
|
||||
", this option can be used to install an all in one OpenStack on this host")
|
||||
|
||||
parser.add_option("-t", "--timeout", default=300, help="The timeout for puppet Exec calls")
|
||||
parser.add_option("-o", "--options", action="store_true", dest="options", help="Print details on options available in answer file(rst format)")
|
||||
|
||||
@@ -90,8 +90,7 @@ class ScriptRunner(object):
|
||||
environ = os.environ
|
||||
environ['LANG'] = 'en_US.UTF8'
|
||||
obj = subprocess.Popen(cmd, stdin=_PIPE, stdout=_PIPE, stderr=_PIPE,
|
||||
close_fds=True, shell=False,
|
||||
env=environ)
|
||||
close_fds=True, shell=False, env=environ)
|
||||
|
||||
script = "function t(){ exit $? ; } \n trap t ERR \n" + script
|
||||
out, err = obj.communicate(script)
|
||||
|
||||
Reference in New Issue
Block a user