Enable PEP8 checks for E121, E129, E231, E265, E302

* E121 continuation line under-indented for hanging indent
* E129 visually indented line with same indent as next logical line
* E302 expected 2 blank lines, found x
* E231 missing whitespace after ','
* E265 block comment should start with '# '

Change-Id: If22172e8a60e962ddbf43db01e7633c60af0a1bc
This commit is contained in:
Christian Berendt 2015-01-09 13:31:11 +01:00
parent 05a27ebb9c
commit b148189d18
11 changed files with 114 additions and 84 deletions

View File

@ -19,12 +19,12 @@ from packstack import version as packstackversion
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.')) # sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ----------------------------------------------------- # -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0' # needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions # Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
@ -37,7 +37,7 @@ templates_path = ['_templates']
source_suffix = '.rst' source_suffix = '.rst'
# The encoding of source files. # The encoding of source files.
#source_encoding = 'utf-8-sig' # source_encoding = 'utf-8-sig'
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = 'index'
@ -57,37 +57,37 @@ release = version
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
#language = None # language = None
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
#today = '' # today = ''
# Else, today_fmt is used as the format for a strftime call. # Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y' # today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
exclude_patterns = ['_build'] exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents. # The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None # default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True # add_function_parentheses = True
# If true, the current module name will be prepended to all description # If true, the current module name will be prepended to all description
# unit titles (such as .. function::). # unit titles (such as .. function::).
#add_module_names = True # add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the # If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default. # output. They are ignored by default.
#show_authors = False # show_authors = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting. # A list of ignored prefixes for module index sorting.
#modindex_common_prefix = [] # modindex_common_prefix = []
# -- Options for HTML output --------------------------------------------------- # -- Options for HTML output ---------------------------------------------------
@ -99,26 +99,26 @@ html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the
# documentation. # documentation.
#html_theme_options = {} # html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory. # Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = [] # html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to # The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". # "<project> v<release> documentation".
#html_title = None # html_title = None
# A shorter title for the navigation bar. Default is the same as html_title. # A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None # html_short_title = None
# The name of an image file (relative to this directory) to place at the top # The name of an image file (relative to this directory) to place at the top
# of the sidebar. # of the sidebar.
#html_logo = None # html_logo = None
# The name of an image file (within the static path) to use as favicon of the # The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large. # pixels large.
#html_favicon = None # html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
@ -127,44 +127,44 @@ html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y' # html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to # If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities. # typographically correct entities.
#html_use_smartypants = True # html_use_smartypants = True
# Custom sidebar templates, maps document names to template names. # Custom sidebar templates, maps document names to template names.
#html_sidebars = {} # html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to # Additional templates that should be rendered to pages, maps page names to
# template names. # template names.
#html_additional_pages = {} # html_additional_pages = {}
# If false, no module index is generated. # If false, no module index is generated.
#html_domain_indices = True # html_domain_indices = True
# If false, no index is generated. # If false, no index is generated.
#html_use_index = True # html_use_index = True
# If true, the index is split into individual pages for each letter. # If true, the index is split into individual pages for each letter.
#html_split_index = False # html_split_index = False
# If true, links to the reST sources are added to the pages. # If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True # html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True # html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True # html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will # If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the # contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served. # base URL from which the finished HTML is served.
#html_use_opensearch = '' # html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml"). # This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None # html_file_suffix = None
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'packstackdoc' htmlhelp_basename = 'packstackdoc'
@ -174,40 +174,40 @@ htmlhelp_basename = 'packstackdoc'
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
# (source start file, target name, title, author, documentclass [howto/manual]). # (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [ latex_documents = [
('index', 'packstack.tex', u'packstack Documentation', u'Derek Higgins', 'manual'), ('index', 'packstack.tex', u'packstack Documentation', u'Derek Higgins', 'manual'),
] ]
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
# the title page. # the title page.
#latex_logo = None # latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts, # For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters. # not chapters.
#latex_use_parts = False # latex_use_parts = False
# If true, show page references after internal links. # If true, show page references after internal links.
#latex_show_pagerefs = False # latex_show_pagerefs = False
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#latex_show_urls = False # latex_show_urls = False
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#latex_appendices = [] # latex_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#latex_domain_indices = True # latex_domain_indices = True
# -- Options for manual page output -------------------------------------------- # -- Options for manual page output --------------------------------------------
@ -219,7 +219,7 @@ man_pages = [
] ]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#man_show_urls = False # man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------ # -- Options for Texinfo output ------------------------------------------------
@ -228,16 +228,16 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# 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.
#texinfo_appendices = [] # texinfo_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#texinfo_domain_indices = True # texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'. # How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote' # texinfo_show_urls = 'footnote'

View File

@ -14,10 +14,6 @@ they are used in the engine-setup.py
import basedefs import basedefs
#####################
####INFO MESSAGES####
#####################
INFO_HEADER = "Welcome to the %s setup utility" % basedefs.APP_NAME INFO_HEADER = "Welcome to the %s setup utility" % basedefs.APP_NAME
INFO_INSTALL_SUCCESS = "\n **** Installation completed successfully ******\n" INFO_INSTALL_SUCCESS = "\n **** Installation completed successfully ******\n"
INFO_INSTALL = "Installing:" INFO_INSTALL = "Installing:"

View File

@ -77,6 +77,7 @@ def process_add_quotes_around_values(param, param_name, config=None):
param = ','.join(params_list) param = ','.join(params_list)
return param return param
def process_password(param, param_name, config=None): def process_password(param, param_name, config=None):
""" """
Process passwords, checking the following: Process passwords, checking the following:
@ -84,7 +85,7 @@ def process_password(param, param_name, config=None):
2- Otherwise, check for a global default password, and use it if available 2- Otherwise, check for a global default password, and use it if available
3- As a last resort, generate a random password 3- As a last resort, generate a random password
""" """
if not hasattr(process_password,"pw_dict"): if not hasattr(process_password, "pw_dict"):
process_password.pw_dict = {} process_password.pw_dict = {}
if param == "PW_PLACEHOLDER": if param == "PW_PLACEHOLDER":

View File

@ -28,10 +28,11 @@ controller = Controller()
commandLineValues = {} commandLineValues = {}
# List to hold all values to be masked in logging (i.e. passwords and sensitive data) # List to hold all values to be masked in logging (i.e. passwords and sensitive data)
#TODO: read default values from conf_param? # TODO: read default values from conf_param?
masked_value_set = set() masked_value_set = set()
tmpfiles = [] tmpfiles = []
def initLogging(debug): def initLogging(debug):
try: try:
logFile = os.path.join(basedefs.DIR_LOG, basedefs.FILE_LOG) logFile = os.path.join(basedefs.DIR_LOG, basedefs.FILE_LOG)
@ -60,6 +61,7 @@ def initLogging(debug):
return logFile return logFile
def _getInputFromUser(param): def _getInputFromUser(param):
""" """
this private func reads the data from the user this private func reads the data from the user
@ -89,7 +91,7 @@ def _getInputFromUser(param):
message.write(": ") message.write(": ")
message.seek(0) message.seek(0)
#mask password or hidden fields # mask password or hidden fields
if (param.MASK_INPUT): if (param.MASK_INPUT):
userInput = getpass.getpass("%s :" % (param.PROMPT)) userInput = getpass.getpass("%s :" % (param.PROMPT))
@ -133,6 +135,7 @@ def _getInputFromUser(param):
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
raise Exception(output_messages.ERR_EXP_READ_INPUT_PARAM % (param.CONF_NAME)) raise Exception(output_messages.ERR_EXP_READ_INPUT_PARAM % (param.CONF_NAME))
def input_param(param): def input_param(param):
""" """
this func will read input from user this func will read input from user
@ -141,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 not commandLineValues.has_key(param.CONF_NAME)):
#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"
confirmedParam.CONF_NAME = confirmedParamName confirmedParam.CONF_NAME = confirmedParamName
@ -160,6 +163,7 @@ def input_param(param):
return param return param
def _askYesNo(question=None): def _askYesNo(question=None):
message = StringIO() message = StringIO()
@ -182,6 +186,7 @@ def _askYesNo(question=None):
return answer == 'y' return answer == 'y'
def _addDefaultsToMaskedValueSet(): def _addDefaultsToMaskedValueSet():
""" """
For every param in conf_params For every param in conf_params
@ -195,6 +200,7 @@ def _addDefaultsToMaskedValueSet():
if ((param.MASK_INPUT == True) and param.DEFAULT_VALUE != ""): if ((param.MASK_INPUT == True) and param.DEFAULT_VALUE != ""):
masked_value_set.add(param.DEFAULT_VALUE) masked_value_set.add(param.DEFAULT_VALUE)
def _updateMaskedValueSet(): def _updateMaskedValueSet():
""" """
For every param in conf For every param in conf
@ -207,6 +213,7 @@ def _updateMaskedValueSet():
if (controller.getParamKeyValue(confName, "MASK_INPUT") == True): if (controller.getParamKeyValue(confName, "MASK_INPUT") == True):
masked_value_set.add(controller.CONF[confName]) masked_value_set.add(controller.CONF[confName])
def mask(input): def mask(input):
""" """
Gets a dict/list/str and search maksked values in them. Gets a dict/list/str and search maksked values in them.
@ -234,6 +241,7 @@ def mask(input):
return output return output
def removeMaskString(maskedString): def removeMaskString(maskedString):
""" """
remove an element from masked_value_set remove an element from masked_value_set
@ -252,6 +260,7 @@ def removeMaskString(maskedString):
if found: if found:
masked_value_set.remove(maskedString) masked_value_set.remove(maskedString)
def validate_param_value(param, value): def validate_param_value(param, value):
cname = param.CONF_NAME cname = param.CONF_NAME
logging.debug("Validating parameter %s." % cname) logging.debug("Validating parameter %s." % cname)
@ -265,6 +274,7 @@ def validate_param_value(param, value):
print 'Parameter %s failed validation: %s' % (cname, ex) print 'Parameter %s failed validation: %s' % (cname, ex)
raise raise
def process_param_value(param, value): def process_param_value(param, value):
_value = value _value = value
proclist = param.PROCESSORS or [] proclist = param.PROCESSORS or []
@ -287,6 +297,7 @@ def process_param_value(param, value):
raise raise
return _value return _value
def _handleGroupCondition(config, conditionName, conditionValue): def _handleGroupCondition(config, conditionName, conditionValue):
""" """
handle params group pre/post condition handle params group pre/post condition
@ -364,6 +375,7 @@ def _loadParamFromFile(config, section, param_name):
return value return value
def _handleAnswerFileParams(answerFile): def _handleAnswerFileParams(answerFile):
""" """
handle loading and validating handle loading and validating
@ -428,6 +440,7 @@ def _getanswerfilepath():
controller.MESSAGES.append(msg) controller.MESSAGES.append(msg)
return path return path
def _gettmpanswerfilepath(): def _gettmpanswerfilepath():
path = None path = None
msg = "Could not find a suitable path on which to create the temporary answerfile" msg = "Could not find a suitable path on which to create the temporary answerfile"
@ -441,6 +454,7 @@ def _gettmpanswerfilepath():
return path return path
def _handleInteractiveParams(): def _handleInteractiveParams():
try: try:
logging.debug("Groups: %s" % ', '.join([x.GROUP_NAME for x in controller.getAllGroups()])) logging.debug("Groups: %s" % ', '.join([x.GROUP_NAME for x in controller.getAllGroups()]))
@ -461,7 +475,7 @@ def _handleInteractiveParams():
for param in group.parameters.itervalues(): for param in group.parameters.itervalues():
if not param.CONDITION: if not param.CONDITION:
input_param(param) input_param(param)
#update password list, so we know to mask them # update password list, so we know to mask them
_updateMaskedValueSet() _updateMaskedValueSet()
postConditionValue = True postConditionValue = True
@ -474,8 +488,8 @@ def _handleInteractiveParams():
if postConditionValue == group.POST_CONDITION_MATCH: if postConditionValue == group.POST_CONDITION_MATCH:
inputLoop = False inputLoop = False
else: else:
#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 controller.CONF.has_key(param.CONF_NAME):
del controller.CONF[param.CONF_NAME] del controller.CONF[param.CONF_NAME]
@ -498,6 +512,7 @@ def _handleInteractiveParams():
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
raise Exception(output_messages.ERR_EXP_HANDLE_PARAMS) raise Exception(output_messages.ERR_EXP_HANDLE_PARAMS)
def _handleParams(configFile): def _handleParams(configFile):
_addDefaultsToMaskedValueSet() _addDefaultsToMaskedValueSet()
if configFile: if configFile:
@ -505,13 +520,14 @@ def _handleParams(configFile):
else: else:
_handleInteractiveParams() _handleInteractiveParams()
def _getConditionValue(matchMember): def _getConditionValue(matchMember):
returnValue = False returnValue = False
if type(matchMember) == types.FunctionType: if type(matchMember) == types.FunctionType:
returnValue = matchMember(controller.CONF) returnValue = matchMember(controller.CONF)
elif type(matchMember) == types.StringType: elif type(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 not controller.CONF.has_key(matchMember):
param = controller.getParamByName(matchMember) param = controller.getParamByName(matchMember)
input_param(param) input_param(param)
@ -521,6 +537,7 @@ def _getConditionValue(matchMember):
return returnValue return returnValue
def _displaySummary(): def _displaySummary():
print output_messages.INFO_DSPLY_PARAMS print output_messages.INFO_DSPLY_PARAMS
@ -561,12 +578,14 @@ def _displaySummary():
else: else:
logging.debug("user chose to accept user parameters") logging.debug("user chose to accept user parameters")
def _printAdditionalMessages(): def _printAdditionalMessages():
if len(controller.MESSAGES) > 0: if len(controller.MESSAGES) > 0:
print "\n",output_messages.INFO_ADDTIONAL_MSG print "\n", output_messages.INFO_ADDTIONAL_MSG
for msg in controller.MESSAGES: for msg in controller.MESSAGES:
print output_messages.INFO_ADDTIONAL_MSG_BULLET % (msg) print output_messages.INFO_ADDTIONAL_MSG_BULLET % (msg)
def _addFinalInfoMsg(logFile): def _addFinalInfoMsg(logFile):
""" """
add info msg to the user finalizing the add info msg to the user finalizing the
@ -590,6 +609,7 @@ def _summaryParamsToLog():
def runSequences(): def runSequences():
controller.runAllSequences() controller.runAllSequences()
def _main(options, configFile=None, logFile=None): def _main(options, configFile=None, logFile=None):
print output_messages.INFO_HEADER print output_messages.INFO_HEADER
print("") print("")
@ -611,7 +631,7 @@ def _main(options, configFile=None, logFile=None):
logging.debug(mask(controller.CONF)) logging.debug(mask(controller.CONF))
# Start configuration stage # Start configuration stage
print "\n",output_messages.INFO_INSTALL print "\n", output_messages.INFO_INSTALL
# Initialize Sequences # Initialize Sequences
initPluginsSequences() initPluginsSequences()
@ -620,7 +640,7 @@ def _main(options, configFile=None, logFile=None):
runSequences() runSequences()
# Lock rhevm version # Lock rhevm version
#_lockRpmVersion() # _lockRpmVersion()
# Print info # Print info
_addFinalInfoMsg(logFile) _addFinalInfoMsg(logFile)
@ -656,6 +676,7 @@ def remove_remote_var_dirs(options, config, messages):
logging.exception(e) logging.exception(e)
messages.append(utils.color_text(msg, 'red')) messages.append(utils.color_text(msg, 'red'))
def remove_temp_files(): def remove_temp_files():
""" """
Removes any temporary files generated during Removes any temporary files generated during
@ -701,6 +722,7 @@ def generateAnswerFile(outputFile, overrides={}):
'conf_name': param.CONF_NAME} 'conf_name': param.CONF_NAME}
ans_file.write(fmt % args) ans_file.write(fmt % args)
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"""
@ -717,12 +739,13 @@ def single_step_aio_install(options, logFile):
# If we are doing an all-in-one install, do demo provisioning # If we are doing an all-in-one install, do demo provisioning
# unless specifically told not to # unless specifically told not to
if (options.os_neutron_install != "n" and \ if (options.os_neutron_install != "n" and
not options.provision_all_in_one_ovs_bridge): not options.provision_all_in_one_ovs_bridge):
options.provision_all_in_one_ovs_bridge = "y" options.provision_all_in_one_ovs_bridge = "y"
single_step_install(options, logFile) single_step_install(options, logFile)
def single_step_install(options, logFile): def single_step_install(options, logFile):
answerfilepath = _gettmpanswerfilepath() answerfilepath = _gettmpanswerfilepath()
if not answerfilepath: if not answerfilepath:
@ -747,11 +770,12 @@ def single_step_install(options, logFile):
# We can also override defaults with command line options # We can also override defaults with command line options
_set_command_line_values(options) _set_command_line_values(options)
for key,value in commandLineValues.items(): for key, value in commandLineValues.items():
overrides[key] = value overrides[key] = value
generateAnswerFile(answerfilepath, overrides) generateAnswerFile(answerfilepath, overrides)
_main(options,answerfilepath, logFile) _main(options, answerfilepath, logFile)
def initCmdLineParser(): def initCmdLineParser():
""" """
@ -761,7 +785,7 @@ def initCmdLineParser():
# Init parser and all general flags # Init parser and all general flags
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")
@ -796,6 +820,7 @@ def initCmdLineParser():
return parser return parser
def printOptions(): def printOptions():
""" """
print and document the available options to the answer file (rst format) print and document the available options to the answer file (rst format)
@ -815,6 +840,7 @@ def printOptions():
print " %s %s" % (paramUsage, optionsList) print " %s %s" % (paramUsage, optionsList)
print print
def plugin_compare(x, y): def plugin_compare(x, y):
""" """
Used to sort the plugin file list Used to sort the plugin file list
@ -826,6 +852,7 @@ def plugin_compare(x, y):
y_cmp = y_match.group(1) y_cmp = y_match.group(1)
return int(x_cmp) - int(y_cmp) return int(x_cmp) - int(y_cmp)
def loadPlugins(): def loadPlugins():
""" """
Load All plugins from ./plugins Load All plugins from ./plugins
@ -852,8 +879,9 @@ def loadPlugins():
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
raise Exception("Failed to load plugin from file %s" % item) raise Exception("Failed to load plugin from file %s" % item)
def checkPlugin(plugin): def checkPlugin(plugin):
for funcName in ['initConfig','initSequences']: for funcName in ['initConfig', 'initSequences']:
if not hasattr(plugin, funcName): if not hasattr(plugin, funcName):
raise ImportError("Plugin %s does not contain the %s function" % (plugin.__class__, funcName)) raise ImportError("Plugin %s does not contain the %s function" % (plugin.__class__, funcName))
@ -877,7 +905,7 @@ def countCmdLineFlags(options, flag):
def validateSingleFlag(options, flag): def validateSingleFlag(options, flag):
counter = countCmdLineFlags(options, flag) counter = countCmdLineFlags(options, flag)
if counter > 0: if counter > 0:
flag = flag.replace("_","-") flag = flag.replace("_", "-")
msg = output_messages.ERR_ONLY_1_FLAG % ("--%s" % flag) msg = output_messages.ERR_ONLY_1_FLAG % ("--%s" % flag)
raise FlagValidationError(msg) raise FlagValidationError(msg)
@ -886,18 +914,21 @@ def initPluginsConfig():
for plugin in controller.getAllPlugins(): for plugin in controller.getAllPlugins():
plugin.initConfig(controller) plugin.initConfig(controller)
def initPluginsSequences(): def initPluginsSequences():
for plugin in controller.getAllPlugins(): for plugin in controller.getAllPlugins():
plugin.initSequences(controller) plugin.initSequences(controller)
def _set_command_line_values(options): def _set_command_line_values(options):
for key, value in options.__dict__.items(): for key, value in options.__dict__.items():
# Replace the _ with - in the string since optparse replace _ with - # Replace the _ with - in the string since optparse replace _ with -
for group in controller.getAllGroups(): for group in controller.getAllGroups():
param = group.search("CMD_OPTION", key.replace("_","-")) param = group.search("CMD_OPTION", key.replace("_", "-"))
if len(param) > 0 and value: if len(param) > 0 and value:
commandLineValues[param[0].CONF_NAME] = value commandLineValues[param[0].CONF_NAME] = value
def main(): def main():
try: try:
# Load Plugins # Load Plugins
@ -935,9 +966,9 @@ def main():
# We can also override defaults with command line options # We can also override defaults with command line options
overrides = {} overrides = {}
_set_command_line_values(options) _set_command_line_values(options)
for key,value in commandLineValues.items(): for key, value in commandLineValues.items():
overrides[key] = value overrides[key] = value
generateAnswerFile(answerfilepath,overrides) generateAnswerFile(answerfilepath, overrides)
_handleParams(answerfilepath) _handleParams(answerfilepath)
generateAnswerFile(options.gen_answer_file) generateAnswerFile(options.gen_answer_file)
# Are we installing an all in one # Are we installing an all in one
@ -957,7 +988,7 @@ def main():
validateSingleFlag(options, "answer_file") validateSingleFlag(options, "answer_file")
# If using an answer file, setting a default password # If using an answer file, setting a default password
# does not really make sense # does not really make sense
if getattr(options,'default_password',None): if getattr(options, 'default_password', None):
msg = ('Please do not set --default-password ' msg = ('Please do not set --default-password '
'when specifying an answer file.') 'when specifying an answer file.')
raise FlagValidationError(msg) raise FlagValidationError(msg)

View File

@ -208,6 +208,8 @@ def validate_multi_ping(param, options=None):
_tested_ports = [] _tested_ports = []
def touch_port(host, port): def touch_port(host, port):
""" """
Check that provided host is listening on provided port. Check that provided host is listening on provided port.

View File

@ -753,7 +753,7 @@ def create_manifest(config, messages):
fw_details = dict() fw_details = dict()
for host in split_hosts(config['CONFIG_COMPUTE_HOSTS']): for host in split_hosts(config['CONFIG_COMPUTE_HOSTS']):
if (config['CONFIG_NOVA_INSTALL'] == 'y' and if (config['CONFIG_NOVA_INSTALL'] == 'y' and
config['CONFIG_VMWARE_BACKEND'] == 'n'): config['CONFIG_VMWARE_BACKEND'] == 'n'):
key = "cinder_%s" % host key = "cinder_%s" % host
fw_details.setdefault(key, {}) fw_details.setdefault(key, {})
fw_details[key]['host'] = "%s" % host fw_details[key]['host'] = "%s" % host

View File

@ -254,11 +254,11 @@ def initConfig(controller):
{"CMD_OPTION": "os-trove-install", {"CMD_OPTION": "os-trove-install",
"USAGE": ( "USAGE": (
"Set to 'y' if you would like Packstack to install " "Set to 'y' if you would like Packstack to install "
"OpenStack Database (Trove)" "OpenStack Database (Trove)"
), ),
"PROMPT": ( "PROMPT": (
"Should Packstack install OpenStack Database (Trove)" "Should Packstack install OpenStack Database (Trove)"
), ),
"OPTION_LIST": ["y", "n"], "OPTION_LIST": ["y", "n"],
"VALIDATORS": [validators.validate_options], "VALIDATORS": [validators.validate_options],
@ -272,11 +272,11 @@ def initConfig(controller):
{"CMD_OPTION": "os-ironic-install", {"CMD_OPTION": "os-ironic-install",
"USAGE": ( "USAGE": (
"Set to 'y' if you would like Packstack to install " "Set to 'y' if you would like Packstack to install "
"OpenStack Bare Metal (Ironic)" "OpenStack Bare Metal (Ironic)"
), ),
"PROMPT": ( "PROMPT": (
"Should Packstack install OpenStack Bare Metal (Ironic)" "Should Packstack install OpenStack Bare Metal (Ironic)"
), ),
"OPTION_LIST": ["y", "n"], "OPTION_LIST": ["y", "n"],
"VALIDATORS": [validators.validate_options], "VALIDATORS": [validators.validate_options],

View File

@ -12,7 +12,7 @@ from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile, appendManifestFile,
createFirewallResources) createFirewallResources)
#------------------ Sahara installer initialization ------------------ # ------------------ Sahara installer initialization ------------------
PLUGIN_NAME = "OS-Sahara" PLUGIN_NAME = "OS-Sahara"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, "blue") PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, "blue")
@ -71,7 +71,7 @@ def initSequences(controller):
] ]
controller.addSequence("Installing Sahara", [], [], saharasteps) controller.addSequence("Installing Sahara", [], [], saharasteps)
#-------------------------- step functions -------------------------- # -------------------------- step functions --------------------------
def create_keystone_manifest(config, messages): def create_keystone_manifest(config, messages):

View File

@ -33,7 +33,7 @@ class SshTarballTransferMixinTestCase(PackstackTestCaseMixin, TestCase):
def tearDown(self): def tearDown(self):
# remove the temp directory # remove the temp directory
#shutil.rmtree(self.tempdir) # shutil.rmtree(self.tempdir)
pass pass
def setUp(self): def setUp(self):

View File

@ -38,4 +38,4 @@ class ProcessorsTestCase(PackstackTestCaseMixin, TestCase):
# 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
#self.assertEquals(True, os.path.isfile(path)) # self.assertEquals(True, os.path.isfile(path))

View File

@ -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,E265,F401,F841,E129,E231,E501,E302,E272,E111,E502,E202,W601,E271,E721,E712,E261,E131,E126,E303,E711,E241,E713,E121,E122,E401,H402,H302,H303,H304,H301,H306,H234,H405,H404,H904,H201,H305,H307,H501,H102,H233,H101,H233,H401,H232 ignore = E123,E125,H803,E128,F403,F821,E127,F811,F401,F841,E501,E272,E111,E502,E202,W601,E271,E721,E712,E261,E131,E126,E303,E711,E241,E713,E122,E401,H402,H302,H303,H304,H301,H306,H234,H405,H404,H904,H201,H305,H307,H501,H102,H233,H101,H233,H401,H232
show-source = True show-source = True
exclude=.venv,.git,.tox exclude=.venv,.git,.tox