Enable several PEP8 checks
* E122 continuation line missing indentation or outdented * E126 continuation line over-indented for hanging indent * E127 continuation line over-indented for visual indent * E128 continuation line under-indented for visual indent * E131 continuation line unaligned for hanging indent * E303 too many blank lines * W601 .has_key() is deprecated, use 'in' * H234 assertEquals is deprecated, use assertEqual * H401 docstring should not start with a space * H402 one line docstring needs punctuation. Change-Id: I1c264dba19bfe7cb9173e8999429827bd026b930
This commit is contained in:
parent
62e5e8c703
commit
c532db1461
16
docs/conf.py
16
docs/conf.py
@ -173,14 +173,14 @@ htmlhelp_basename = 'packstackdoc'
|
|||||||
# -- Options for LaTeX output --------------------------------------------------
|
# -- Options for LaTeX output --------------------------------------------------
|
||||||
|
|
||||||
latex_elements = {
|
latex_elements = {
|
||||||
# The paper size ('letterpaper' or 'a4paper').
|
# The paper size ('letterpaper' or 'a4paper').
|
||||||
# 'papersize': 'letterpaper',
|
# 'papersize': 'letterpaper',
|
||||||
|
|
||||||
# The font size ('10pt', '11pt' or '12pt').
|
# The font size ('10pt', '11pt' or '12pt').
|
||||||
# 'pointsize': '10pt',
|
# 'pointsize': '10pt',
|
||||||
|
|
||||||
# Additional stuff for the LaTeX preamble.
|
# Additional stuff for the LaTeX preamble.
|
||||||
# 'preamble': '',
|
# 'preamble': '',
|
||||||
}
|
}
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
@ -229,8 +229,8 @@ man_pages = [
|
|||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
('index', 'packstack', u'packstack Documentation',
|
('index', 'packstack', u'packstack Documentation',
|
||||||
u'Derek Higgins', 'packstack', 'One line description of project.',
|
u'Derek Higgins', 'packstack', 'One line description of project.',
|
||||||
'Miscellaneous'),
|
'Miscellaneous'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
# Documents to append as an appendix to all manuals.
|
||||||
|
@ -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_PLUGINS = os.path.join(DIR_PROJECT_DIR, "plugins")
|
||||||
DIR_MODULES = os.path.join(DIR_PROJECT_DIR, "modules")
|
DIR_MODULES = os.path.join(DIR_PROJECT_DIR, "modules")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EXEC_RPM = "rpm"
|
EXEC_RPM = "rpm"
|
||||||
EXEC_SEMANAGE = "semanage"
|
EXEC_SEMANAGE = "semanage"
|
||||||
EXEC_NSLOOKUP = "nslookup"
|
EXEC_NSLOOKUP = "nslookup"
|
||||||
|
@ -24,8 +24,8 @@ class SshTarballTransferMixin(object):
|
|||||||
script.append("scp %(pack_path)s root@%(node)s:%(pack_dest)s"
|
script.append("scp %(pack_path)s root@%(node)s:%(pack_dest)s"
|
||||||
% args)
|
% args)
|
||||||
script.append("ssh -o StrictHostKeyChecking=no "
|
script.append("ssh -o StrictHostKeyChecking=no "
|
||||||
"-o UserKnownHostsFile=/dev/null root@%(node)s "
|
"-o UserKnownHostsFile=/dev/null root@%(node)s "
|
||||||
"tar -C %(res_dir)s -xpzf %(pack_dest)s" % args)
|
"tar -C %(res_dir)s -xpzf %(pack_dest)s" % args)
|
||||||
try:
|
try:
|
||||||
script.execute()
|
script.execute()
|
||||||
except ScriptRuntimeError as ex:
|
except ScriptRuntimeError as ex:
|
||||||
@ -124,15 +124,15 @@ class Drone(object):
|
|||||||
# remote host IP or hostname
|
# remote host IP or hostname
|
||||||
self.node = node
|
self.node = node
|
||||||
# working directories on remote host
|
# working directories on remote host
|
||||||
self.resource_dir = resource_dir or \
|
self.resource_dir = (resource_dir or
|
||||||
'/tmp/drone%s' % uuid.uuid4().hex[:8]
|
'/tmp/drone%s' % uuid.uuid4().hex[:8])
|
||||||
self.recipe_dir = recipe_dir or \
|
self.recipe_dir = (recipe_dir or
|
||||||
os.path.join(self.resource_dir, 'recipes')
|
os.path.join(self.resource_dir, 'recipes'))
|
||||||
# temporary directories
|
# temporary directories
|
||||||
self.remote_tmpdir = remote_tmpdir or \
|
self.remote_tmpdir = (remote_tmpdir or
|
||||||
'/tmp/drone%s' % uuid.uuid4().hex[:8]
|
'/tmp/drone%s' % uuid.uuid4().hex[:8])
|
||||||
self.local_tmpdir = local_tmpdir or \
|
self.local_tmpdir = (local_tmpdir or
|
||||||
tempfile.mkdtemp(prefix='drone')
|
tempfile.mkdtemp(prefix='drone'))
|
||||||
|
|
||||||
def init_node(self):
|
def init_node(self):
|
||||||
"""
|
"""
|
||||||
@ -335,7 +335,7 @@ class PackstackDrone(SshTarballTransferMixin, Drone):
|
|||||||
server = utils.ScriptRunner(self.node)
|
server = utils.ScriptRunner(self.node)
|
||||||
for pkg in ("puppet", "openssh-clients", "tar"):
|
for pkg in ("puppet", "openssh-clients", "tar"):
|
||||||
server.append("rpm -q --whatprovides %(pkg)s || "
|
server.append("rpm -q --whatprovides %(pkg)s || "
|
||||||
"yum install -y %(pkg)s" % locals())
|
"yum install -y %(pkg)s" % locals())
|
||||||
server.execute()
|
server.execute()
|
||||||
|
|
||||||
def add_resource(self, path, resource_type=None):
|
def add_resource(self, path, resource_type=None):
|
||||||
@ -352,8 +352,8 @@ class PackstackDrone(SshTarballTransferMixin, Drone):
|
|||||||
recipe_base.replace(".finished", ".log"))
|
recipe_base.replace(".finished", ".log"))
|
||||||
local = utils.ScriptRunner()
|
local = utils.ScriptRunner()
|
||||||
local.append('scp -o StrictHostKeyChecking=no '
|
local.append('scp -o StrictHostKeyChecking=no '
|
||||||
'-o UserKnownHostsFile=/dev/null '
|
'-o UserKnownHostsFile=/dev/null '
|
||||||
'root@%s:%s %s' % (self.node, recipe, log))
|
'root@%s:%s %s' % (self.node, recipe, log))
|
||||||
try:
|
try:
|
||||||
# once a remote puppet run has finished, we retrieve
|
# once a remote puppet run has finished, we retrieve
|
||||||
# the log file and check it for errors
|
# the log file and check it for errors
|
||||||
@ -390,8 +390,8 @@ class PackstackDrone(SshTarballTransferMixin, Drone):
|
|||||||
mdir = self._module_dir
|
mdir = self._module_dir
|
||||||
server.append(
|
server.append(
|
||||||
"( flock %(rdir)s/ps.lock "
|
"( flock %(rdir)s/ps.lock "
|
||||||
"puppet apply %(loglevel)s --modulepath %(mdir)s "
|
"puppet apply %(loglevel)s --modulepath %(mdir)s "
|
||||||
"%(recipe)s > %(running)s 2>&1 < /dev/null; "
|
"%(recipe)s > %(running)s 2>&1 < /dev/null; "
|
||||||
"mv %(running)s %(finished)s ) "
|
"mv %(running)s %(finished)s ) "
|
||||||
"> /dev/null 2>&1 < /dev/null &" % locals())
|
"> /dev/null 2>&1 < /dev/null &" % locals())
|
||||||
server.execute()
|
server.execute()
|
||||||
|
@ -48,7 +48,6 @@ class Step(object):
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Sequence(object):
|
class Sequence(object):
|
||||||
"""
|
"""
|
||||||
Wrapper for sequence of setup steps.
|
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_WEAK_PASS = "Warning: Weak Password."
|
||||||
WARN_NM_ENABLED = ("Warning: NetworkManager is active on %s. OpenStack "
|
WARN_NM_ENABLED = ("Warning: NetworkManager is active on %s. OpenStack "
|
||||||
"networking currently does not work on systems that have "
|
"networking currently does not work on systems that have "
|
||||||
"the Network Manager service enabled.")
|
"the Network Manager service enabled.")
|
||||||
|
|
||||||
ERR_PING = "Error: the provided hostname is unreachable"
|
ERR_PING = "Error: the provided hostname is unreachable"
|
||||||
ERR_SSH = "Error: could not connect to the ssh server: %s"
|
ERR_SSH = "Error: could not connect to the ssh server: %s"
|
||||||
|
@ -77,7 +77,7 @@ def _getInputFromUser(param):
|
|||||||
else:
|
else:
|
||||||
while loop:
|
while loop:
|
||||||
# If the value was not supplied by the command line flags
|
# 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 = StringIO()
|
||||||
message.write(param.PROMPT)
|
message.write(param.PROMPT)
|
||||||
|
|
||||||
@ -121,11 +121,11 @@ def _getInputFromUser(param):
|
|||||||
controller.CONF[param.CONF_NAME] = userInput
|
controller.CONF[param.CONF_NAME] = userInput
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if commandLineValues.has_key(param.CONF_NAME):
|
if param.CONF_NAME in commandLineValues:
|
||||||
del commandLineValues[param.CONF_NAME]
|
del commandLineValues[param.CONF_NAME]
|
||||||
else:
|
else:
|
||||||
# Delete value from commandLineValues so that we will prompt the user for input
|
# 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]
|
del commandLineValues[param.CONF_NAME]
|
||||||
loop = True
|
loop = True
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
@ -144,7 +144,7 @@ def input_param(param):
|
|||||||
"""
|
"""
|
||||||
# We need to check if a param needs confirmation, (i.e. ask user twice)
|
# 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
|
# 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
|
# create a copy of the param so we can call it twice
|
||||||
confirmedParam = copy.deepcopy(param)
|
confirmedParam = copy.deepcopy(param)
|
||||||
confirmedParamName = param.CONF_NAME + "_CONFIRMED"
|
confirmedParamName = param.CONF_NAME + "_CONFIRMED"
|
||||||
@ -492,9 +492,9 @@ def _handleInteractiveParams():
|
|||||||
# we clear the value of all params in the group
|
# we clear the value of all params in the group
|
||||||
# in order to re-input them by the user
|
# in order to re-input them by the user
|
||||||
for param in group.parameters.itervalues():
|
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]
|
del controller.CONF[param.CONF_NAME]
|
||||||
if commandLineValues.has_key(param.CONF_NAME):
|
if param.CONF_NAME in commandLineValues:
|
||||||
del commandLineValues[param.CONF_NAME]
|
del commandLineValues[param.CONF_NAME]
|
||||||
else:
|
else:
|
||||||
inputLoop = False
|
inputLoop = False
|
||||||
@ -529,7 +529,7 @@ def _getConditionValue(matchMember):
|
|||||||
elif isinstance(matchMember, types.StringType):
|
elif isinstance(matchMember, types.StringType):
|
||||||
# we assume that if we get a string as a member it is the name
|
# we assume that if we get a string as a member it is the name
|
||||||
# of a member of conf_params
|
# of a member of conf_params
|
||||||
if not controller.CONF.has_key(matchMember):
|
if matchMember not in controller.CONF:
|
||||||
param = controller.getParamByName(matchMember)
|
param = controller.getParamByName(matchMember)
|
||||||
input_param(param)
|
input_param(param)
|
||||||
returnValue = controller.CONF[matchMember]
|
returnValue = controller.CONF[matchMember]
|
||||||
@ -546,7 +546,7 @@ def _displaySummary():
|
|||||||
logging.info("*** User input summary ***")
|
logging.info("*** User input summary ***")
|
||||||
for group in controller.getAllGroups():
|
for group in controller.getAllGroups():
|
||||||
for param in group.parameters.itervalues():
|
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
|
cmdOption = param.CMD_OPTION
|
||||||
l = 30 - len(cmdOption)
|
l = 30 - len(cmdOption)
|
||||||
maskParam = param.MASK_INPUT
|
maskParam = param.MASK_INPUT
|
||||||
@ -564,14 +564,14 @@ def _displaySummary():
|
|||||||
logging.debug("user chose to re-enter the user parameters")
|
logging.debug("user chose to re-enter the user parameters")
|
||||||
for group in controller.getAllGroups():
|
for group in controller.getAllGroups():
|
||||||
for param in group.parameters.itervalues():
|
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:
|
if not param.MASK_INPUT:
|
||||||
param.DEFAULT_VALUE = controller.CONF[param.CONF_NAME]
|
param.DEFAULT_VALUE = controller.CONF[param.CONF_NAME]
|
||||||
# Remove the string from mask_value_set in order
|
# Remove the string from mask_value_set in order
|
||||||
# to remove values that might be over overwritten.
|
# to remove values that might be over overwritten.
|
||||||
removeMaskString(controller.CONF[param.CONF_NAME])
|
removeMaskString(controller.CONF[param.CONF_NAME])
|
||||||
del 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]
|
del commandLineValues[param.CONF_NAME]
|
||||||
print ""
|
print ""
|
||||||
logging.debug("calling handleParams in interactive mode")
|
logging.debug("calling handleParams in interactive mode")
|
||||||
@ -602,7 +602,7 @@ def _summaryParamsToLog():
|
|||||||
logging.debug("*** The following params were used as user input:")
|
logging.debug("*** The following params were used as user input:")
|
||||||
for group in controller.getAllGroups():
|
for group in controller.getAllGroups():
|
||||||
for param in group.parameters.itervalues():
|
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])
|
maskedValue = mask(controller.CONF[param.CONF_NAME])
|
||||||
logging.debug("%s: %s" % (param.CMD_OPTION, maskedValue))
|
logging.debug("%s: %s" % (param.CMD_OPTION, maskedValue))
|
||||||
|
|
||||||
@ -725,7 +725,7 @@ def generateAnswerFile(outputFile, overrides={}):
|
|||||||
|
|
||||||
|
|
||||||
def single_step_aio_install(options, logFile):
|
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()
|
options.install_hosts = utils.get_localhost_ip()
|
||||||
|
|
||||||
@ -788,15 +788,15 @@ def initCmdLineParser():
|
|||||||
usage = "usage: %prog [options] [--help]"
|
usage = "usage: %prog [options] [--help]"
|
||||||
parser = OptionParser(usage=usage, version="%prog {0} {1}".format(version.release_string(), version.version_string()))
|
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("--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 \
|
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")
|
"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 "
|
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."
|
"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 "
|
"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 ")
|
"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> "
|
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 "
|
"--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")
|
", 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("-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)")
|
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 = os.environ
|
||||||
environ['LANG'] = 'en_US.UTF8'
|
environ['LANG'] = 'en_US.UTF8'
|
||||||
obj = subprocess.Popen(cmd, stdin=_PIPE, stdout=_PIPE, stderr=_PIPE,
|
obj = subprocess.Popen(cmd, stdin=_PIPE, stdout=_PIPE, stderr=_PIPE,
|
||||||
close_fds=True, shell=False,
|
close_fds=True, shell=False, env=environ)
|
||||||
env=environ)
|
|
||||||
|
|
||||||
script = "function t(){ exit $? ; } \n trap t ERR \n" + script
|
script = "function t(){ exit $? ; } \n trap t ERR \n" + script
|
||||||
out, err = obj.communicate(script)
|
out, err = obj.communicate(script)
|
||||||
|
@ -34,8 +34,8 @@ re_ignore = re.compile(
|
|||||||
'NetworkManager is not running'
|
'NetworkManager is not running'
|
||||||
)
|
)
|
||||||
re_notice = re.compile(r"notice: .*Notify\[packstack_info\]"
|
re_notice = re.compile(r"notice: .*Notify\[packstack_info\]"
|
||||||
"\/message: defined \'message\' as "
|
"\/message: defined \'message\' as "
|
||||||
"\'(?P<message>.*)\'")
|
"\'(?P<message>.*)\'")
|
||||||
|
|
||||||
surrogates = [
|
surrogates = [
|
||||||
# Value in /etc/sysctl.conf cannot be changed
|
# Value in /etc/sysctl.conf cannot be changed
|
||||||
|
@ -310,10 +310,10 @@ def create_redis_manifest(config, messages):
|
|||||||
|
|
||||||
slave_clients = set([config['CONFIG_CONTROLLER_HOST']]).union(
|
slave_clients = set([config['CONFIG_CONTROLLER_HOST']]).union(
|
||||||
split_hosts(config['CONFIG_REDIS_SLAVE_HOSTS'])).union(
|
split_hosts(config['CONFIG_REDIS_SLAVE_HOSTS'])).union(
|
||||||
split_hosts(config['CONFIG_REDIS_SENTINEL_HOSTS']))
|
split_hosts(config['CONFIG_REDIS_SENTINEL_HOSTS']))
|
||||||
config['FIREWALL_REDIS_SLAVE_RULES'] = (
|
config['FIREWALL_REDIS_SLAVE_RULES'] = (
|
||||||
_create_redis_firewall_rules(
|
_create_redis_firewall_rules(
|
||||||
slave_clients, config['CONFIG_REDIS_PORT']))
|
slave_clients, config['CONFIG_REDIS_PORT']))
|
||||||
|
|
||||||
manifestdata += createFirewallResources(
|
manifestdata += createFirewallResources(
|
||||||
'FIREWALL_REDIS_SLAVE_RULES')
|
'FIREWALL_REDIS_SLAVE_RULES')
|
||||||
|
@ -601,7 +601,7 @@ def create_manifests(config, messages):
|
|||||||
if use_openvswitch_vxlan(config) or use_openvswitch_gre(config):
|
if use_openvswitch_vxlan(config) or use_openvswitch_gre(config):
|
||||||
for n_host in network_hosts:
|
for n_host in network_hosts:
|
||||||
cf_fw_nt_key = ("FIREWALL_NEUTRON_TUNNEL_RULES_%s_%s"
|
cf_fw_nt_key = ("FIREWALL_NEUTRON_TUNNEL_RULES_%s_%s"
|
||||||
% (host, n_host))
|
% (host, n_host))
|
||||||
fw_details = dict()
|
fw_details = dict()
|
||||||
key = "neutron_tunnel_%s_%s" % (host, n_host)
|
key = "neutron_tunnel_%s_%s" % (host, n_host)
|
||||||
fw_details.setdefault(key, {})
|
fw_details.setdefault(key, {})
|
||||||
|
@ -117,8 +117,8 @@ class TestNetns(unittest.TestCase):
|
|||||||
# Check that iptables filtering and save/restore can be performed
|
# Check that iptables filtering and save/restore can be performed
|
||||||
try:
|
try:
|
||||||
iptables_filename = os.path.join(
|
iptables_filename = os.path.join(
|
||||||
tempfile.gettempdir(),
|
tempfile.gettempdir(),
|
||||||
'iptables-%s' % str(uuid.uuid4()))
|
'iptables-%s' % str(uuid.uuid4()))
|
||||||
e('%%(ns1)s iptables-save > %s' % iptables_filename)
|
e('%%(ns1)s iptables-save > %s' % iptables_filename)
|
||||||
e('%(ns1)s iptables -A INPUT -p icmp --icmp-type 8 -j DROP')
|
e('%(ns1)s iptables -A INPUT -p icmp --icmp-type 8 -j DROP')
|
||||||
e('%(ns2)s ping -c 1 -w 1 %(address1_1)s', return_code=1)
|
e('%(ns2)s ping -c 1 -w 1 %(address1_1)s', return_code=1)
|
||||||
|
@ -24,15 +24,15 @@ from ..test_base import PackstackTestCaseMixin
|
|||||||
|
|
||||||
class ProcessorsTestCase(PackstackTestCaseMixin, TestCase):
|
class ProcessorsTestCase(PackstackTestCaseMixin, TestCase):
|
||||||
def test_process_host(self):
|
def test_process_host(self):
|
||||||
"""Test packstack.installer.processors.process_host"""
|
"""Test packstack.installer.processors.process_host."""
|
||||||
proc_local = process_host('localhost', 'HOSTNAME')
|
proc_local = process_host('localhost', 'HOSTNAME')
|
||||||
self.assertIn(proc_local, ['127.0.0.1', '::1'])
|
self.assertIn(proc_local, ['127.0.0.1', '::1'])
|
||||||
|
|
||||||
def test_process_ssh_key(self):
|
def test_process_ssh_key(self):
|
||||||
"""Test packstack.installer.processors.process_ssh_key"""
|
"""Test packstack.installer.processors.process_ssh_key."""
|
||||||
path = process_ssh_key(os.path.join(self.tempdir, 'id_rsa'), 'SSH_KEY')
|
path = process_ssh_key(os.path.join(self.tempdir, 'id_rsa'), 'SSH_KEY')
|
||||||
# test if key was created
|
# test if key was created
|
||||||
self.assertEquals(True, bool(path))
|
self.assertEqual(True, bool(path))
|
||||||
# test if key exists
|
# test if key exists
|
||||||
# XXX: process_ssh_key does not create ssh key during test run
|
# XXX: process_ssh_key does not create ssh key during test run
|
||||||
# ... not sure why, nevertheless it works in normal run
|
# ... not sure why, nevertheless it works in normal run
|
||||||
|
@ -67,7 +67,7 @@ class SequenceTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
'title': 'Step 3'}]
|
'title': 'Step 3'}]
|
||||||
|
|
||||||
self.seq = Sequence('test', self.steps, condition='test',
|
self.seq = Sequence('test', self.steps, condition='test',
|
||||||
cond_match='test')
|
cond_match='test')
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(SequenceTestCase, self).tearDown()
|
super(SequenceTestCase, self).tearDown()
|
||||||
|
@ -44,7 +44,7 @@ class ParameterTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
shutil.rmtree(self.tempdir)
|
shutil.rmtree(self.tempdir)
|
||||||
|
|
||||||
def test_sorteddict(self):
|
def test_sorteddict(self):
|
||||||
"""Test packstack.installer.utils.datastructures.SortedDict"""
|
"""Test packstack.installer.utils.datastructures.SortedDict."""
|
||||||
sdict = SortedDict()
|
sdict = SortedDict()
|
||||||
sdict['1'] = 1
|
sdict['1'] = 1
|
||||||
sdict['2'] = 2
|
sdict['2'] = 2
|
||||||
@ -53,7 +53,7 @@ class ParameterTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
self.assertListEqual(sdict.values(), [1, 2, 3, 4, 5])
|
self.assertListEqual(sdict.values(), [1, 2, 3, 4, 5])
|
||||||
|
|
||||||
def test_retry(self):
|
def test_retry(self):
|
||||||
"""Test packstack.installer.utils.decorators.retry"""
|
"""Test packstack.installer.utils.decorators.retry."""
|
||||||
|
|
||||||
@retry(count=3, delay=0, retry_on=ValueError)
|
@retry(count=3, delay=0, retry_on=ValueError)
|
||||||
def test_sum():
|
def test_sum():
|
||||||
@ -72,12 +72,12 @@ class ParameterTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
self.assertRaises(ValueError, test_sum)
|
self.assertRaises(ValueError, test_sum)
|
||||||
|
|
||||||
def test_network(self):
|
def test_network(self):
|
||||||
"""Test packstack.installer.utils.network functions"""
|
"""Test packstack.installer.utils.network functions."""
|
||||||
self.assertIn(host2ip('localhost', allow_localhost=True),
|
self.assertIn(host2ip('localhost', allow_localhost=True),
|
||||||
['127.0.0.1', '::1'])
|
['127.0.0.1', '::1'])
|
||||||
|
|
||||||
def test_shell(self):
|
def test_shell(self):
|
||||||
"""Test packstack.installer.utils.shell functions"""
|
"""Test packstack.installer.utils.shell functions."""
|
||||||
rc, out = execute(['echo', 'this is test'])
|
rc, out = execute(['echo', 'this is test'])
|
||||||
self.assertEqual(out.strip(), 'this is test')
|
self.assertEqual(out.strip(), 'this is test')
|
||||||
rc, out = execute('echo "this is test"', use_shell=True)
|
rc, out = execute('echo "this is test"', use_shell=True)
|
||||||
@ -97,9 +97,9 @@ class ParameterTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
self.assertEqual(out.strip(), 'this is test')
|
self.assertEqual(out.strip(), 'this is test')
|
||||||
|
|
||||||
def test_strings(self):
|
def test_strings(self):
|
||||||
"""Test packstack.installer.utils.strings functions"""
|
"""Test packstack.installer.utils.strings functions."""
|
||||||
self.assertEqual(color_text('test text', 'red'),
|
self.assertEqual(color_text('test text', 'red'),
|
||||||
'\033[0;31mtest text\033[0m')
|
'\033[0;31mtest text\033[0m')
|
||||||
self.assertEqual(mask_string('test text', mask_list=['text']),
|
self.assertEqual(mask_string('test text', mask_list=['text']),
|
||||||
'test %s' % STR_MASK)
|
'test %s' % STR_MASK)
|
||||||
masked = mask_string("test '\\''text'\\''",
|
masked = mask_string("test '\\''text'\\''",
|
||||||
@ -108,9 +108,9 @@ class ParameterTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
self.assertEqual(masked, 'test %s' % STR_MASK)
|
self.assertEqual(masked, 'test %s' % STR_MASK)
|
||||||
|
|
||||||
def test_shortcuts(self):
|
def test_shortcuts(self):
|
||||||
"""Test packstack.installer.utils.shortcuts functions"""
|
"""Test packstack.installer.utils.shortcuts functions."""
|
||||||
conf = {"A_HOST": "1.1.1.1", "B_HOSTS": "2.2.2.2,1.1.1.1",
|
conf = {"A_HOST": "1.1.1.1", "B_HOSTS": "2.2.2.2,1.1.1.1",
|
||||||
"C_HOSTS": "3.3.3.3/vdc"}
|
"C_HOSTS": "3.3.3.3/vdc"}
|
||||||
hostlist = list(hosts(conf))
|
hostlist = list(hosts(conf))
|
||||||
hostlist.sort()
|
hostlist.sort()
|
||||||
self.assertEquals(['1.1.1.1', '2.2.2.2', '3.3.3.3'], hostlist)
|
self.assertEqual(['1.1.1.1', '2.2.2.2', '3.3.3.3'], hostlist)
|
||||||
|
@ -34,24 +34,24 @@ class ValidatorsTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
shutil.rmtree(self.tempdir)
|
shutil.rmtree(self.tempdir)
|
||||||
|
|
||||||
def test_validate_integer(self):
|
def test_validate_integer(self):
|
||||||
"""Test packstack.installer.validators.validate_integer"""
|
"""Test packstack.installer.validators.validate_integer."""
|
||||||
validate_integer('1')
|
validate_integer('1')
|
||||||
self.assertRaises(ParamValidationError, validate_integer, 'test')
|
self.assertRaises(ParamValidationError, validate_integer, 'test')
|
||||||
|
|
||||||
def test_validate_regexp(self):
|
def test_validate_regexp(self):
|
||||||
"""Test packstack.installer.validators.validate_regexp"""
|
"""Test packstack.installer.validators.validate_regexp."""
|
||||||
validate_regexp('Test_123', options=['\w'])
|
validate_regexp('Test_123', options=['\w'])
|
||||||
self.assertRaises(ParamValidationError, validate_regexp,
|
self.assertRaises(ParamValidationError, validate_regexp,
|
||||||
'!#$%', options=['\w'])
|
'!#$%', options=['\w'])
|
||||||
|
|
||||||
def test_validate_port(self):
|
def test_validate_port(self):
|
||||||
"""Test packstack.installer.validators.validate_port"""
|
"""Test packstack.installer.validators.validate_port."""
|
||||||
validate_port('666')
|
validate_port('666')
|
||||||
self.assertRaises(ParamValidationError, validate_port, 'test')
|
self.assertRaises(ParamValidationError, validate_port, 'test')
|
||||||
self.assertRaises(ParamValidationError, validate_port, '-3')
|
self.assertRaises(ParamValidationError, validate_port, '-3')
|
||||||
|
|
||||||
def test_validate_not_empty(self):
|
def test_validate_not_empty(self):
|
||||||
"""Test packstack.installer.validators.validate_not_empty"""
|
"""Test packstack.installer.validators.validate_not_empty."""
|
||||||
validate_not_empty('test')
|
validate_not_empty('test')
|
||||||
validate_not_empty(False)
|
validate_not_empty(False)
|
||||||
self.assertRaises(ParamValidationError, validate_not_empty, '')
|
self.assertRaises(ParamValidationError, validate_not_empty, '')
|
||||||
@ -59,20 +59,20 @@ class ValidatorsTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
self.assertRaises(ParamValidationError, validate_not_empty, {})
|
self.assertRaises(ParamValidationError, validate_not_empty, {})
|
||||||
|
|
||||||
def test_validate_options(self):
|
def test_validate_options(self):
|
||||||
"""Test packstack.installer.validators.validate_options"""
|
"""Test packstack.installer.validators.validate_options."""
|
||||||
validate_options('a', options=['a', 'b'])
|
validate_options('a', options=['a', 'b'])
|
||||||
validate_options('b', options=['a', 'b'])
|
validate_options('b', options=['a', 'b'])
|
||||||
self.assertRaises(ParamValidationError, validate_options,
|
self.assertRaises(ParamValidationError, validate_options,
|
||||||
'c', options=['a', 'b'])
|
'c', options=['a', 'b'])
|
||||||
|
|
||||||
def test_validate_ip(self):
|
def test_validate_ip(self):
|
||||||
"""Test packstack.installer.validators.validate_ip"""
|
"""Test packstack.installer.validators.validate_ip."""
|
||||||
validate_ip('127.0.0.1')
|
validate_ip('127.0.0.1')
|
||||||
validate_ip('::1')
|
validate_ip('::1')
|
||||||
self.assertRaises(ParamValidationError, validate_ip, 'test')
|
self.assertRaises(ParamValidationError, validate_ip, 'test')
|
||||||
|
|
||||||
def test_validate_file(self):
|
def test_validate_file(self):
|
||||||
"""Test packstack.installer.validators.validate_file"""
|
"""Test packstack.installer.validators.validate_file."""
|
||||||
fname = os.path.join(self.tempdir, '.test_validate_file')
|
fname = os.path.join(self.tempdir, '.test_validate_file')
|
||||||
bad_name = os.path.join(self.tempdir, '.me_no_exists')
|
bad_name = os.path.join(self.tempdir, '.me_no_exists')
|
||||||
with open(fname, 'w') as f:
|
with open(fname, 'w') as f:
|
||||||
@ -81,18 +81,18 @@ class ValidatorsTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
self.assertRaises(ParamValidationError, validate_file, bad_name)
|
self.assertRaises(ParamValidationError, validate_file, bad_name)
|
||||||
|
|
||||||
def test_validate_ping(self):
|
def test_validate_ping(self):
|
||||||
"""Test packstack.installer.validators.validate_ping"""
|
"""Test packstack.installer.validators.validate_ping."""
|
||||||
# ping to broadcast fails
|
# ping to broadcast fails
|
||||||
self.assertRaises(ParamValidationError, validate_ping,
|
self.assertRaises(ParamValidationError, validate_ping,
|
||||||
'255.255.255.255')
|
'255.255.255.255')
|
||||||
|
|
||||||
def test_validate_ssh(self):
|
def test_validate_ssh(self):
|
||||||
"""Test packstack.installer.validators.validate_ssh"""
|
"""Test packstack.installer.validators.validate_ssh."""
|
||||||
# ssh to broadcast fails
|
# ssh to broadcast fails
|
||||||
self.assertRaises(ParamValidationError, validate_ssh,
|
self.assertRaises(ParamValidationError, validate_ssh,
|
||||||
'255.255.255.255')
|
'255.255.255.255')
|
||||||
|
|
||||||
def test_validate_float(self):
|
def test_validate_float(self):
|
||||||
"""Test packstack.installer.validators.validate_float"""
|
"""Test packstack.installer.validators.validate_float."""
|
||||||
validate_float('5.3')
|
validate_float('5.3')
|
||||||
self.assertRaises(ParamValidationError, validate_float, 'test')
|
self.assertRaises(ParamValidationError, validate_float, 'test')
|
||||||
|
@ -27,4 +27,4 @@ class OSPluginUtilsTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
"C_HOSTS": "3.3.3.3/vdc"}
|
"C_HOSTS": "3.3.3.3/vdc"}
|
||||||
hosts = gethostlist(conf)
|
hosts = gethostlist(conf)
|
||||||
hosts.sort()
|
hosts.sort()
|
||||||
self.assertEquals(['1.1.1.1', '2.2.2.2', '3.3.3.3'], hosts)
|
self.assertEqual(['1.1.1.1', '2.2.2.2', '3.3.3.3'], hosts)
|
||||||
|
@ -27,7 +27,7 @@ from packstack.modules.puppet import validate_logfile
|
|||||||
class PuppetTestCase(PackstackTestCaseMixin, TestCase):
|
class PuppetTestCase(PackstackTestCaseMixin, TestCase):
|
||||||
|
|
||||||
def test_validate_logfile(self):
|
def test_validate_logfile(self):
|
||||||
"""Test packstack.modules.validate_logfile"""
|
"""Test packstack.modules.validate_logfile."""
|
||||||
filename = os.path.join(self.tempdir, "puppet.log")
|
filename = os.path.join(self.tempdir, "puppet.log")
|
||||||
# test valid run
|
# test valid run
|
||||||
with open(filename, "w") as fp:
|
with open(filename, "w") as fp:
|
||||||
|
@ -22,7 +22,7 @@ from packstack.plugins import serverprep_001
|
|||||||
|
|
||||||
class OSPluginUtilsTestCase(PackstackTestCaseMixin, TestCase):
|
class OSPluginUtilsTestCase(PackstackTestCaseMixin, TestCase):
|
||||||
def test_rhn_creds_quoted(self):
|
def test_rhn_creds_quoted(self):
|
||||||
"""Make sure RHN password is quoted"""
|
"""Make sure RHN password is quoted."""
|
||||||
|
|
||||||
# On non-RHEL, the CONFIG_{RH,SATELLITE} options are never set,
|
# On non-RHEL, the CONFIG_{RH,SATELLITE} options are never set,
|
||||||
# i.e. this test would always fail. Therefore, only run it on RHEL.
|
# i.e. this test would always fail. Therefore, only run it on RHEL.
|
||||||
|
2
tox.ini
2
tox.ini
@ -33,6 +33,6 @@ commands = python setup.py build_sphinx
|
|||||||
# E123, E125 skipped as they are invalid PEP-8.
|
# E123, E125 skipped as they are invalid PEP-8.
|
||||||
#
|
#
|
||||||
# All other checks should be enabled in the future.
|
# All other checks should be enabled in the future.
|
||||||
ignore = E123,E125,H803,E128,F403,F821,E127,F811,F841,E501,W601,E131,E126,E303,E122,H402,H302,H303,H304,H301,H306,H234,H405,H404,H904,H201,H305,H307,H501,H102,H233,H101,H233,H401,H232
|
ignore = E123,E125,H803,F403,F821,F811,F841,E501,H302,H303,H304,H301,H306,H405,H404,H904,H201,H305,H307,H501,H102,H233,H101,H233,H232
|
||||||
show-source = True
|
show-source = True
|
||||||
exclude=.venv,.git,.tox
|
exclude=.venv,.git,.tox
|
||||||
|
Loading…
Reference in New Issue
Block a user