From d7916cec6004df0184763dc82a5726de04bc4487 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Mon, 2 Feb 2015 10:03:25 +0100 Subject: [PATCH] Enable PEP8 checks H102, H232, H233, H301, H904 * H102 Apache 2.0 license header not found * H232 Python 3.x incompatible octal xxx should be written as 0oxxx * H233 Python 3.x incompatible use of print operator * H301 one import per line * H904 Wrap long lines in parentheses instead of a backslash Change-Id: I07003acb76eaa719daabc451239067494efa2bba --- docs/conf.py | 12 +++ packstack/installer/basedefs.py | 14 +++- packstack/installer/core/drones.py | 12 +++ packstack/installer/core/parameters.py | 12 +++ packstack/installer/core/sequences.py | 12 +++ packstack/installer/exceptions.py | 12 +++ packstack/installer/output_messages.py | 13 ++++ packstack/installer/processors.py | 18 ++++- packstack/installer/run_setup.py | 77 +++++++++++-------- packstack/installer/setup_controller.py | 13 ++++ packstack/installer/utils/__init__.py | 34 ++++++-- packstack/installer/utils/datastructures.py | 12 +++ packstack/installer/utils/decorators.py | 12 +++ packstack/installer/utils/network.py | 15 +++- packstack/installer/utils/shell.py | 17 +++- packstack/installer/utils/shortcuts.py | 12 +++ packstack/installer/utils/strings.py | 12 +++ packstack/installer/validators.py | 12 +++ packstack/modules/common.py | 12 +++ packstack/modules/ospluginutils.py | 18 ++++- packstack/modules/puppet.py | 12 +++ packstack/plugins/amqp_002.py | 19 ++++- packstack/plugins/ceilometer_800.py | 19 ++++- packstack/plugins/cinder_250.py | 19 ++++- packstack/plugins/dashboard_500.py | 17 +++- packstack/plugins/glance_200.py | 18 ++++- packstack/plugins/heat_650.py | 19 ++++- packstack/plugins/ironic_275.py | 22 +++++- packstack/plugins/keystone_100.py | 19 ++++- packstack/plugins/mariadb_003.py | 19 ++++- packstack/plugins/nagios_910.py | 19 ++++- packstack/plugins/neutron_350.py | 19 ++++- packstack/plugins/nova_300.py | 29 +++++-- packstack/plugins/openstack_client_400.py | 17 +++- packstack/plugins/postscript_948.py | 17 +++- packstack/plugins/prescript_000.py | 27 +++++-- packstack/plugins/provision_700.py | 21 +++-- packstack/plugins/puppet_950.py | 24 ++++-- packstack/plugins/sahara_800.py | 18 ++++- packstack/plugins/serverprep_001.py | 16 +++- packstack/plugins/swift_600.py | 20 ++++- packstack/plugins/trove_850.py | 19 ++++- .../modules/packstack/lib/facter/netns.py | 14 +++- packstack/version.py | 12 +++ setup.py | 22 +++++- tests/installer/test_drones.py | 9 +-- tests/installer/test_run_setup.py | 9 ++- tests/installer/test_sequences.py | 4 +- tests/installer/test_utils.py | 3 +- tox.ini | 2 +- 50 files changed, 708 insertions(+), 147 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index f062349bd..08e20631b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,17 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # packstack documentation build configuration file, created by # sphinx-quickstart on Thu Nov 15 20:34:41 2012. # diff --git a/packstack/installer/basedefs.py b/packstack/installer/basedefs.py index 2a8cbaf72..f0649c742 100644 --- a/packstack/installer/basedefs.py +++ b/packstack/installer/basedefs.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ This module provides all the predefined variables. @@ -18,7 +30,7 @@ FILE_YUM_VERSION_LOCK = "/etc/yum/pluginconf.d/versionlock.list" PACKSTACK_VAR_DIR = "/var/tmp/packstack" try: - os.mkdir(PACKSTACK_VAR_DIR, 0700) + os.mkdir(PACKSTACK_VAR_DIR, 0o700) except OSError: # directory is already created, check ownership stat = os.stat(PACKSTACK_VAR_DIR) diff --git a/packstack/installer/core/drones.py b/packstack/installer/core/drones.py index 4c874cc66..98c5c243e 100644 --- a/packstack/installer/core/drones.py +++ b/packstack/installer/core/drones.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import os import stat diff --git a/packstack/installer/core/parameters.py b/packstack/installer/core/parameters.py index e27c5e0c1..7450f9d4a 100644 --- a/packstack/installer/core/parameters.py +++ b/packstack/installer/core/parameters.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Container set for groups and parameters diff --git a/packstack/installer/core/sequences.py b/packstack/installer/core/sequences.py index 64c76cbb6..224fd384d 100644 --- a/packstack/installer/core/sequences.py +++ b/packstack/installer/core/sequences.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Base class for steps & sequences diff --git a/packstack/installer/exceptions.py b/packstack/installer/exceptions.py index cf0dc4d4c..a37b7b005 100644 --- a/packstack/installer/exceptions.py +++ b/packstack/installer/exceptions.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. __all__ = ( 'PackStackError', diff --git a/packstack/installer/output_messages.py b/packstack/installer/output_messages.py index 840028e28..295d6fdde 100644 --- a/packstack/installer/output_messages.py +++ b/packstack/installer/output_messages.py @@ -1,3 +1,16 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + ''' external text file to hold all user visible text. info messages begins with INFO_ and error msg with ERR_ diff --git a/packstack/installer/processors.py b/packstack/installer/processors.py index 2c6d530d3..948abbed6 100644 --- a/packstack/installer/processors.py +++ b/packstack/installer/processors.py @@ -1,11 +1,25 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import netaddr import os import uuid -from .utils import ScriptRunner, force_ip -from .exceptions import ParamProcessingError, NetworkError +from .utils import force_ip +from .utils import ScriptRunner +from .exceptions import NetworkError +from .exceptions import ParamProcessingError __all__ = ('ParamProcessingError', 'process_cidr', 'process_host', diff --git a/packstack/installer/run_setup.py b/packstack/installer/run_setup.py index 233920e67..c3503ca45 100644 --- a/packstack/installer/run_setup.py +++ b/packstack/installer/run_setup.py @@ -1,3 +1,16 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import ConfigParser import copy import datetime @@ -11,14 +24,16 @@ import traceback import types import textwrap -from optparse import OptionParser, OptionGroup +from optparse import OptionGroup +from optparse import OptionParser import basedefs import validators from . import utils import processors import output_messages -from .exceptions import FlagValidationError, ParamValidationError +from .exceptions import FlagValidationError +from .exceptions import ParamValidationError from packstack import version from packstack.modules.ospluginutils import gethostlist @@ -39,7 +54,7 @@ def initLogging(debug): # Create the log file with specific permissions, puppet has a habbit of putting # passwords in logs - os.close(os.open(logFile, os.O_CREAT | os.O_EXCL, 0600)) + os.close(os.open(logFile, os.O_CREAT | os.O_EXCL, 0o600)) hdlr = logging.FileHandler(filename=logFile, mode='w') if (debug): @@ -82,8 +97,8 @@ def _getInputFromUser(param): message.write(param.PROMPT) val_list = param.VALIDATORS or [] - if validators.validate_regexp not in val_list \ - and param.OPTION_LIST: + if(validators.validate_regexp not in val_list + and param.OPTION_LIST): message.write(" [%s]" % "|".join(param.OPTION_LIST)) if param.DEFAULT_VALUE: @@ -130,7 +145,7 @@ def _getInputFromUser(param): loop = True except KeyboardInterrupt: # add the new line so messages wont be displayed in the same line as the question - print "" + print("") raise except: logging.error(traceback.format_exc()) @@ -158,7 +173,7 @@ def input_param(param): logging.debug("Param confirmation passed, value for both questions is identical") break else: - print output_messages.INFO_VAL_PASSWORD_DONT_MATCH + print(output_messages.INFO_VAL_PASSWORD_DONT_MATCH) else: _getInputFromUser(param) @@ -272,7 +287,7 @@ def validate_param_value(param, value): try: val_func(value, opt_list) except ParamValidationError as ex: - print 'Parameter %s failed validation: %s' % (cname, ex) + print('Parameter %s failed validation: %s' % (cname, ex)) raise @@ -287,14 +302,14 @@ def process_param_value(param, value): if new_value != _value: if param.MASK_INPUT is False: msg = output_messages.INFO_CHANGED_VALUE - print msg % (_value, new_value) + print(msg % (_value, new_value)) _value = new_value else: logging.debug("Processor returned the original " "value: %s" % _value) except processors.ParamProcessingError as ex: - print ("Value processing of parameter %s " - "failed.\n%s" % (param.CONF_NAME, ex)) + print("Value processing of parameter %s " + "failed.\n%s" % (param.CONF_NAME, ex)) raise return _value @@ -541,8 +556,8 @@ def _getConditionValue(matchMember): def _displaySummary(): - print output_messages.INFO_DSPLY_PARAMS - print "=" * (len(output_messages.INFO_DSPLY_PARAMS) - 1) + print(output_messages.INFO_DSPLY_PARAMS) + print("=" * (len(output_messages.INFO_DSPLY_PARAMS) - 1)) logging.info("*** User input summary ***") for group in controller.getAllGroups(): for param in group.parameters.itervalues(): @@ -553,11 +568,11 @@ def _displaySummary(): # Only call mask on a value if the param has MASK_INPUT set to True if maskParam: logging.info("%s: %s" % (cmdOption, mask(controller.CONF[param.CONF_NAME]))) - print "%s:" % (cmdOption) + " " * l + mask(controller.CONF[param.CONF_NAME]) + print("%s:" % (cmdOption) + " " * l + mask(controller.CONF[param.CONF_NAME])) else: # Otherwise, log & display it as it is logging.info("%s: %s" % (cmdOption, str(controller.CONF[param.CONF_NAME]))) - print "%s:" % (cmdOption) + " " * l + str(controller.CONF[param.CONF_NAME]) + print("%s:" % (cmdOption) + " " * l + str(controller.CONF[param.CONF_NAME])) logging.info("*** User input summary ***") answer = _askYesNo(output_messages.INFO_USE_PARAMS) if not answer: @@ -573,7 +588,7 @@ def _displaySummary(): del controller.CONF[param.CONF_NAME] if param.CONF_NAME in commandLineValues: del commandLineValues[param.CONF_NAME] - print "" + print("") logging.debug("calling handleParams in interactive mode") return _handleParams(None) else: @@ -582,9 +597,9 @@ def _displaySummary(): def _printAdditionalMessages(): if len(controller.MESSAGES) > 0: - print "\n", output_messages.INFO_ADDTIONAL_MSG + print("\n", output_messages.INFO_ADDTIONAL_MSG) for msg in controller.MESSAGES: - print output_messages.INFO_ADDTIONAL_MSG_BULLET % (msg) + print(output_messages.INFO_ADDTIONAL_MSG_BULLET % (msg)) def _addFinalInfoMsg(logFile): @@ -612,7 +627,7 @@ def runSequences(): def _main(options, configFile=None, logFile=None): - print output_messages.INFO_HEADER + print(output_messages.INFO_HEADER) print("") print(output_messages.INFO_LOG_FILE_PATH % logFile) @@ -632,7 +647,7 @@ def _main(options, configFile=None, logFile=None): logging.debug(mask(controller.CONF)) # Start configuration stage - print "\n", output_messages.INFO_INSTALL + print("\n", output_messages.INFO_INSTALL) # Initialize Sequences initPluginsSequences() @@ -645,7 +660,7 @@ def _main(options, configFile=None, logFile=None): # Print info _addFinalInfoMsg(logFile) - print output_messages.INFO_INSTALL_SUCCESS + print(output_messages.INFO_INSTALL_SUCCESS) def remove_remote_var_dirs(options, config, messages): @@ -703,7 +718,7 @@ def generateAnswerFile(outputFile, overrides={}): # the mode -rw------- if os.path.exists(outputFile): os.remove(outputFile) - fd = os.open(outputFile, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0600) + fd = os.open(outputFile, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600) with os.fdopen(fd, "w") as ans_file: ans_file.write("[general]%s" % os.linesep) @@ -829,17 +844,17 @@ def printOptions(): # For each group, create a group option for group in controller.getAllGroups(): - print "%s" % group.DESCRIPTION - print "-" * len(group.DESCRIPTION) - print + print("%s" % group.DESCRIPTION) + print("-" * len(group.DESCRIPTION)) + print() for param in group.parameters.itervalues(): cmdOption = param.CONF_NAME paramUsage = param.USAGE optionsList = param.OPTION_LIST or "" - print "%s" % (("**%s**" % str(cmdOption)).ljust(30)) - print " %s %s" % (paramUsage, optionsList) - print + print("%s" % (("**%s**" % str(cmdOption)).ljust(30))) + print(" %s %s" % (paramUsage, optionsList)) + print() def plugin_compare(x, y): @@ -1006,9 +1021,9 @@ def main(): optParser.error(str(ex)) except Exception as e: logging.error(traceback.format_exc()) - print - print utils.color_text("ERROR : " + str(e), 'red') - print output_messages.ERR_CHECK_LOG_FILE_FOR_MORE_INFO % (logFile) + print() + print(utils.color_text("ERROR : " + str(e), 'red')) + print(output_messages.ERR_CHECK_LOG_FILE_FOR_MORE_INFO % (logFile)) sys.exit(1) finally: diff --git a/packstack/installer/setup_controller.py b/packstack/installer/setup_controller.py index 6429d0753..34b78a05e 100644 --- a/packstack/installer/setup_controller.py +++ b/packstack/installer/setup_controller.py @@ -1,3 +1,16 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """ Controller class is a SINGLETON which handles all groups, params, sequences, steps and replaces the CONF dictionary. diff --git a/packstack/installer/utils/__init__.py b/packstack/installer/utils/__init__.py index 92031e65f..76f4db297 100644 --- a/packstack/installer/utils/__init__.py +++ b/packstack/installer/utils/__init__.py @@ -1,13 +1,35 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. from .datastructures import SortedDict from .decorators import retry -from .network import get_localhost_ip, host2ip, force_ip, device_from_ip -from .shell import ScriptRunner, execute -from .shortcuts import (host_iter, hosts, get_current_user, - get_current_username, split_hosts) -from .strings import (COLORS, color_text, mask_string, state_format, - state_message) +from .network import get_localhost_ip +from .network import host2ip +from .network import force_ip +from .network import device_from_ip +from .shell import execute +from .shell import ScriptRunner +from .shortcuts import host_iter +from .shortcuts import hosts +from .shortcuts import get_current_user +from .shortcuts import get_current_username +from .shortcuts import split_hosts +from .strings import COLORS +from .strings import color_text +from .strings import mask_string +from .strings import state_format +from .strings import state_message __all__ = ('SortedDict', diff --git a/packstack/installer/utils/datastructures.py b/packstack/installer/utils/datastructures.py index 542f18dcb..a451ff247 100644 --- a/packstack/installer/utils/datastructures.py +++ b/packstack/installer/utils/datastructures.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import copy from types import GeneratorType diff --git a/packstack/installer/utils/decorators.py b/packstack/installer/utils/decorators.py index 1f9a1fdf7..dcf1d7758 100644 --- a/packstack/installer/utils/decorators.py +++ b/packstack/installer/utils/decorators.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import time diff --git a/packstack/installer/utils/network.py b/packstack/installer/utils/network.py index 89e64ddcc..be2118bb7 100644 --- a/packstack/installer/utils/network.py +++ b/packstack/installer/utils/network.py @@ -1,10 +1,23 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import re import socket from ..exceptions import NetworkError -from .shell import execute, ScriptRunner +from .shell import execute +from .shell import ScriptRunner def get_localhost_ip(): diff --git a/packstack/installer/utils/shell.py b/packstack/installer/utils/shell.py index 33c8b5854..0a9d3349e 100644 --- a/packstack/installer/utils/shell.py +++ b/packstack/installer/utils/shell.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import re import os @@ -6,8 +18,9 @@ import types import logging import subprocess -from ..exceptions import (ExecuteRuntimeError, ScriptRuntimeError, - NetworkError) +from ..exceptions import ExecuteRuntimeError +from ..exceptions import NetworkError +from ..exceptions import ScriptRuntimeError from .strings import mask_string diff --git a/packstack/installer/utils/shortcuts.py b/packstack/installer/utils/shortcuts.py index 4371d48bd..52b380abb 100644 --- a/packstack/installer/utils/shortcuts.py +++ b/packstack/installer/utils/shortcuts.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import grp import os diff --git a/packstack/installer/utils/strings.py b/packstack/installer/utils/strings.py index 5c46eb16a..b49724bda 100644 --- a/packstack/installer/utils/strings.py +++ b/packstack/installer/utils/strings.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import re diff --git a/packstack/installer/validators.py b/packstack/installer/validators.py index 91555131b..cfa3264bb 100644 --- a/packstack/installer/validators.py +++ b/packstack/installer/validators.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Contains all core validation functions. diff --git a/packstack/modules/common.py b/packstack/modules/common.py index 539be2912..df2aad6ca 100644 --- a/packstack/modules/common.py +++ b/packstack/modules/common.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. from ..installer import utils diff --git a/packstack/modules/ospluginutils.py b/packstack/modules/ospluginutils.py index 9e7a7df7e..63cffe054 100644 --- a/packstack/modules/ospluginutils.py +++ b/packstack/modules/ospluginutils.py @@ -1,3 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import os import yaml @@ -61,10 +73,10 @@ class ManifestFiles(object): if not self.global_data: with open(os.path.join(PUPPET_TEMPLATE_DIR, "global.pp")) as gfp: self.global_data = gfp.read() % controller.CONF - os.mkdir(basedefs.PUPPET_MANIFEST_DIR, 0700) + os.mkdir(basedefs.PUPPET_MANIFEST_DIR, 0o700) for fname, data in self.data.items(): path = os.path.join(basedefs.PUPPET_MANIFEST_DIR, fname) - fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0600) + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600) with os.fdopen(fd, 'w') as fp: fp.write(self.global_data + data) manifestfiles = ManifestFiles() @@ -82,7 +94,7 @@ def appendManifestFile(manifest_name, data, marker=''): def generateHieraDataFile(): - os.mkdir(basedefs.HIERADATA_DIR, 0700) + os.mkdir(basedefs.HIERADATA_DIR, 0o700) with open(HIERA_DEFAULTS_YAML, 'w') as outfile: outfile.write(yaml.dump(controller.CONF, explicit_start=True, diff --git a/packstack/modules/puppet.py b/packstack/modules/puppet.py index ddec2cac0..bbc76137d 100644 --- a/packstack/modules/puppet.py +++ b/packstack/modules/puppet.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import logging import os diff --git a/packstack/plugins/amqp_002.py b/packstack/plugins/amqp_002.py index 07155a822..9ed18734c 100644 --- a/packstack/plugins/amqp_002.py +++ b/packstack/plugins/amqp_002.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures AMQP @@ -9,10 +21,9 @@ from packstack.installer import processors from packstack.installer import utils from packstack.modules.common import filtered_hosts -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------- AMQP Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/ceilometer_800.py b/packstack/plugins/ceilometer_800.py index 3d43e85a1..c27161b3e 100644 --- a/packstack/plugins/ceilometer_800.py +++ b/packstack/plugins/ceilometer_800.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Ceilometer @@ -11,10 +23,9 @@ from packstack.installer import validators from packstack.installer import processors from packstack.installer.utils import split_hosts from packstack.modules.shortcuts import get_mq -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------- Ceilometer Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/cinder_250.py b/packstack/plugins/cinder_250.py index 8156fbfa4..368bc4946 100644 --- a/packstack/plugins/cinder_250.py +++ b/packstack/plugins/cinder_250.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Cinder @@ -15,10 +27,9 @@ from packstack.installer import utils from packstack.modules.shortcuts import get_mq -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------------ Cinder Packstack Plugin initialization ------------------ diff --git a/packstack/plugins/dashboard_500.py b/packstack/plugins/dashboard_500.py index abd7d5938..3e87af391 100644 --- a/packstack/plugins/dashboard_500.py +++ b/packstack/plugins/dashboard_500.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures OpenStack Horizon @@ -11,9 +23,8 @@ from packstack.installer import validators from packstack.installer import exceptions from packstack.installer import utils -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import getManifestTemplate # ------------- Horizon Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/glance_200.py b/packstack/plugins/glance_200.py index 062b1b971..88b0a9a3a 100644 --- a/packstack/plugins/glance_200.py +++ b/packstack/plugins/glance_200.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Glance @@ -9,9 +21,9 @@ from packstack.installer import processors from packstack.installer import utils from packstack.modules.shortcuts import get_mq -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------- Glance Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/heat_650.py b/packstack/plugins/heat_650.py index 26182dc21..83e9512d6 100644 --- a/packstack/plugins/heat_650.py +++ b/packstack/plugins/heat_650.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Heat @@ -11,10 +23,9 @@ from packstack.installer import validators from packstack.installer import processors from packstack.modules.shortcuts import get_mq -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------- Heat Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/ironic_275.py b/packstack/plugins/ironic_275.py index c67aab442..da66b391f 100644 --- a/packstack/plugins/ironic_275.py +++ b/packstack/plugins/ironic_275.py @@ -1,15 +1,29 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Ironic """ -from packstack.installer import utils, validators, processors +from packstack.installer import utils +from packstack.installer import validators +from packstack.installer import processors from packstack.modules.shortcuts import get_mq -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------------ Ironic Packstack Plugin initialization ------------------ diff --git a/packstack/plugins/keystone_100.py b/packstack/plugins/keystone_100.py index 2dd1d31b7..f716a1d57 100644 --- a/packstack/plugins/keystone_100.py +++ b/packstack/plugins/keystone_100.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Keystone @@ -10,10 +22,9 @@ from packstack.installer import validators from packstack.installer import processors from packstack.installer import utils -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------- Keystone Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/mariadb_003.py b/packstack/plugins/mariadb_003.py index e3ed62b73..99a06d9c0 100644 --- a/packstack/plugins/mariadb_003.py +++ b/packstack/plugins/mariadb_003.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures MariaDB @@ -9,10 +21,9 @@ from packstack.installer import processors from packstack.installer import utils from packstack.modules.common import filtered_hosts -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------- MariaDB Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/nagios_910.py b/packstack/plugins/nagios_910.py index a33b278eb..26f9acbf3 100644 --- a/packstack/plugins/nagios_910.py +++ b/packstack/plugins/nagios_910.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Nagios @@ -9,10 +21,9 @@ from packstack.installer import processors from packstack.installer import utils from packstack.modules.common import filtered_hosts -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------- Nagios Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/neutron_350.py b/packstack/plugins/neutron_350.py index f102f1c63..0c597fd0e 100644 --- a/packstack/plugins/neutron_350.py +++ b/packstack/plugins/neutron_350.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Neutron @@ -12,10 +24,9 @@ from packstack.installer.utils import split_hosts from packstack.modules.common import filtered_hosts from packstack.modules.shortcuts import get_mq -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------- Neutron Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/nova_300.py b/packstack/plugins/nova_300.py index 6553ca9e5..1c13cf129 100644 --- a/packstack/plugins/nova_300.py +++ b/packstack/plugins/nova_300.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Nova @@ -8,14 +20,18 @@ import os import platform import socket -from packstack.installer import basedefs, processors, utils, validators +from packstack.installer import basedefs +from packstack.installer import processors +from packstack.installer import utils +from packstack.installer import validators from packstack.installer.exceptions import ScriptRuntimeError from packstack.modules.shortcuts import get_mq -from packstack.modules.ospluginutils import (NovaConfig, getManifestTemplate, - appendManifestFile, manifestfiles, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate +from packstack.modules.ospluginutils import manifestfiles +from packstack.modules.ospluginutils import NovaConfig # ------------- Nova Packstack Plugin Initialization -------------- @@ -426,8 +442,7 @@ def create_api_manifest(config, messages): if config['CONFIG_NEUTRON_INSTALL'] != 'y': config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = 'undef' else: - config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = \ - "%s" % config['CONFIG_NEUTRON_METADATA_PW'] + config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = "%s" % config['CONFIG_NEUTRON_METADATA_PW'] manifestfile = "%s_api_nova.pp" % config['CONFIG_CONTROLLER_HOST'] manifestdata = getManifestTemplate("nova_api") diff --git a/packstack/plugins/openstack_client_400.py b/packstack/plugins/openstack_client_400.py index fca78d8a3..f3c966ca6 100644 --- a/packstack/plugins/openstack_client_400.py +++ b/packstack/plugins/openstack_client_400.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures an OpenStack Client @@ -8,9 +20,8 @@ import os from packstack.installer import utils -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import getManifestTemplate # ------------- OpenStack Client Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/postscript_948.py b/packstack/plugins/postscript_948.py index 74c7f9724..9dd6f6da2 100644 --- a/packstack/plugins/postscript_948.py +++ b/packstack/plugins/postscript_948.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Plugin responsible for post-installation configuration @@ -7,9 +19,8 @@ Plugin responsible for post-installation configuration from packstack.installer import utils from packstack.modules.common import filtered_hosts -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import getManifestTemplate # ------------- Postscript Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/prescript_000.py b/packstack/plugins/prescript_000.py index e3a32368f..c00586ce1 100644 --- a/packstack/plugins/prescript_000.py +++ b/packstack/plugins/prescript_000.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Plugin responsible for setting OpenStack global options @@ -9,13 +21,16 @@ import os import re import uuid -from packstack.installer import (basedefs, exceptions, processors, utils, - validators) - -from packstack.modules.common import filtered_hosts, is_all_in_one -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile) +from packstack.installer import basedefs +from packstack.installer import exceptions +from packstack.installer import processors +from packstack.installer import utils +from packstack.installer import validators +from packstack.modules.common import filtered_hosts +from packstack.modules.common import is_all_in_one +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import getManifestTemplate # ------------- Prescript Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/provision_700.py b/packstack/plugins/provision_700.py index 0be3f0c4e..44b1e236b 100644 --- a/packstack/plugins/provision_700.py +++ b/packstack/plugins/provision_700.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Provisioning for demo usage and testing @@ -9,9 +21,8 @@ from packstack.installer import validators from packstack.installer import processors from packstack.modules.common import is_all_in_one -from packstack.modules.ospluginutils import (appendManifestFile, - getManifestTemplate) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import getManifestTemplate # ------------- Provision Packstack Plugin Initialization -------------- @@ -307,7 +318,7 @@ def create_storage_manifest(config, messages): def create_tempest_manifest(config, messages): using_neutron(config) - manifest_file = '%s_provision_tempest.pp' % \ - config['CONFIG_CONTROLLER_HOST'] + manifest_file = ('%s_provision_tempest.pp' % + config['CONFIG_CONTROLLER_HOST']) manifest_data = getManifestTemplate("provision_tempest") appendManifestFile(manifest_file, manifest_data) diff --git a/packstack/plugins/puppet_950.py b/packstack/plugins/puppet_950.py index 957df0506..982172b3f 100644 --- a/packstack/plugins/puppet_950.py +++ b/packstack/plugins/puppet_950.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Puppet @@ -11,12 +23,14 @@ import time from packstack.installer import utils from packstack.installer import basedefs -from packstack.installer.exceptions import ScriptRuntimeError, PuppetError +from packstack.installer.exceptions import PuppetError +from packstack.installer.exceptions import ScriptRuntimeError from packstack.modules.common import filtered_hosts -from packstack.modules.ospluginutils import (manifestfiles, - generateHieraDataFile) -from packstack.modules.puppet import scan_logfile, validate_logfile +from packstack.modules.ospluginutils import generateHieraDataFile +from packstack.modules.ospluginutils import manifestfiles +from packstack.modules.puppet import validate_logfile +from packstack.modules.puppet import scan_logfile # ------------- Puppet Packstack Plugin Initialization -------------- @@ -245,7 +259,7 @@ def apply_puppet_manifest(config, messages): continue host_dir = config['HOST_DETAILS'][hostname]['tmpdir'] - print "Applying %s" % manifest + print("Applying %s" % manifest) server = utils.ScriptRunner(hostname) man_path = os.path.join(config['HOST_DETAILS'][hostname]['tmpdir'], diff --git a/packstack/plugins/sahara_800.py b/packstack/plugins/sahara_800.py index 08478795e..8824b6011 100644 --- a/packstack/plugins/sahara_800.py +++ b/packstack/plugins/sahara_800.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Sahara @@ -8,9 +20,9 @@ from packstack.installer import utils from packstack.installer import validators from packstack.installer import processors from packstack.modules.shortcuts import get_mq -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------------ Sahara installer initialization ------------------ diff --git a/packstack/plugins/serverprep_001.py b/packstack/plugins/serverprep_001.py index c408922e7..04b7a9ae8 100644 --- a/packstack/plugins/serverprep_001.py +++ b/packstack/plugins/serverprep_001.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Plugin responsible for Server Preparation. @@ -13,8 +25,8 @@ from packstack.installer import exceptions from packstack.installer import utils from packstack.installer import validators -from packstack.modules.common import filtered_hosts, is_all_in_one - +from packstack.modules.common import filtered_hosts +from packstack.modules.common import is_all_in_one # ------------ Server Preparation Packstack Plugin Initialization ------------- diff --git a/packstack/plugins/swift_600.py b/packstack/plugins/swift_600.py index 2a58aac03..160e2a479 100644 --- a/packstack/plugins/swift_600.py +++ b/packstack/plugins/swift_600.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Swift @@ -15,10 +27,10 @@ from packstack.installer.exceptions import ParamValidationError from packstack.installer import utils from packstack.installer.utils import split_hosts -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, manifestfiles, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate +from packstack.modules.ospluginutils import manifestfiles # ------------- Swift Packstack Plugin Initialization -------------- diff --git a/packstack/plugins/trove_850.py b/packstack/plugins/trove_850.py index 60a92a03d..7ff3ca41e 100644 --- a/packstack/plugins/trove_850.py +++ b/packstack/plugins/trove_850.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Installs and configures Trove @@ -8,10 +20,9 @@ from packstack.installer import utils from packstack.installer import validators from packstack.installer import processors from packstack.modules.shortcuts import get_mq -from packstack.modules.ospluginutils import (getManifestTemplate, - appendManifestFile, - createFirewallResources) - +from packstack.modules.ospluginutils import appendManifestFile +from packstack.modules.ospluginutils import createFirewallResources +from packstack.modules.ospluginutils import getManifestTemplate # ------------------ Trove Packstack Plugin initialization ------------------ diff --git a/packstack/puppet/modules/packstack/lib/facter/netns.py b/packstack/puppet/modules/packstack/lib/facter/netns.py index 14f2f82d6..e8bd553be 100644 --- a/packstack/puppet/modules/packstack/lib/facter/netns.py +++ b/packstack/puppet/modules/packstack/lib/facter/netns.py @@ -1,5 +1,17 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import contextlib import inspect @@ -14,7 +26,7 @@ import unittest def execute(cmd_string, check_error=True, return_code=0, input=None, block=True, error_msg='Error executing cmd'): - print cmd_string + print(cmd_string) cmd = cmd_string.split(' ') proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, diff --git a/packstack/version.py b/packstack/version.py index f7ce34bb4..06f83e753 100644 --- a/packstack/version.py +++ b/packstack/version.py @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import os import pkg_resources diff --git a/setup.py b/setup.py index 312fbe81c..2510942fc 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,25 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. import os import shutil import subprocess -from setuptools import setup, find_packages, Command +from setuptools import setup +from setuptools import find_packages +from setuptools import Command from packstack import version @@ -42,11 +56,11 @@ class InstallModulesCommand(Command): # install third-party modules from openstack-puppet-modules repo if not os.path.exists(self.destination): try: - os.makedirs(basedir, 0755) + os.makedirs(basedir, 0o755) except OSError: # base directory exists pass - print 'Cloning %(repo)s to %(destination)s' % locals() + print('Cloning %(repo)s to %(destination)s' % locals()) cmd = ('cd %(basedir)s; git clone %(repo)s %(repodir)s; ' 'cd %(repodir)s; git checkout %(branch)s; ' % locals()) proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, @@ -63,7 +77,7 @@ class InstallModulesCommand(Command): continue dest = os.path.join(self.destination, module) - print 'Copying module %(module)s to %(dest)s' % locals() + print('Copying module %(module)s to %(dest)s' % locals()) shutil.rmtree(dest, ignore_errors=True) shutil.copytree(source, dest) diff --git a/tests/installer/test_drones.py b/tests/installer/test_drones.py index 9df86f7ed..5251027db 100644 --- a/tests/installer/test_drones.py +++ b/tests/installer/test_drones.py @@ -82,11 +82,10 @@ class SshTarballTransferMixinTestCase(PackstackTestCaseMixin, TestCase): tarball = tarfile.open(pack_path) tarball.extractall(path=self.tempdir) # check content of files - for path, content in \ - [('resources/res1.txt', 'resource one'), - ('resources/resdir/res2.txt', 'resource two'), - ('recipes/rec1.pp', 'recipe one'), - ('recipes/rec2.pp', 'recipe two')]: + for path, content in [('resources/res1.txt', 'resource one'), + ('resources/resdir/res2.txt', 'resource two'), + ('recipes/rec1.pp', 'recipe one'), + ('recipes/rec2.pp', 'recipe two')]: with open(os.path.join(self.tempdir, path)) as f: fcont = f.read() self.assertEqual(fcont, content) diff --git a/tests/installer/test_run_setup.py b/tests/installer/test_run_setup.py index d104b1854..a74ee81d6 100644 --- a/tests/installer/test_run_setup.py +++ b/tests/installer/test_run_setup.py @@ -21,10 +21,13 @@ import subprocess import sys from unittest import TestCase -from packstack.modules import ospluginutils, puppet -from packstack.installer import run_setup, basedefs +from packstack.modules import ospluginutils +from packstack.modules import puppet +from packstack.installer import basedefs +from packstack.installer import run_setup -from ..test_base import PackstackTestCaseMixin, FakePopen +from ..test_base import FakePopen +from ..test_base import PackstackTestCaseMixin def makefile(path, content): diff --git a/tests/installer/test_sequences.py b/tests/installer/test_sequences.py index 6feea44ed..d00cc768e 100644 --- a/tests/installer/test_sequences.py +++ b/tests/installer/test_sequences.py @@ -48,8 +48,8 @@ class StepTestCase(PackstackTestCaseMixin, TestCase): contents = sys.stdout.getvalue() state = '[ %s ]\n' % utils.color_text('DONE', 'green') - if not contents.startswith('Running test') or \ - not contents.endswith(state): + if(not contents.startswith('Running test') or + not contents.endswith(state)): raise AssertionError('Step run test failed: %s' % contents) diff --git a/tests/installer/test_utils.py b/tests/installer/test_utils.py index 34dd69292..2826870eb 100644 --- a/tests/installer/test_utils.py +++ b/tests/installer/test_utils.py @@ -23,7 +23,8 @@ import shutil import tempfile from unittest import TestCase -from ..test_base import PackstackTestCaseMixin, FakePopen +from ..test_base import FakePopen +from ..test_base import PackstackTestCaseMixin from packstack.installer.utils import * from packstack.installer.utils.strings import STR_MASK from packstack.installer.exceptions import ExecuteRuntimeError diff --git a/tox.ini b/tox.ini index 584e0448e..eb334ce24 100644 --- a/tox.ini +++ b/tox.ini @@ -33,6 +33,6 @@ commands = python setup.py build_sphinx # E123, E125 skipped as they are invalid PEP-8. # # All other checks should be enabled in the future. -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 +ignore = E123,E125,H803,F403,F821,F811,F841,E501,H302,H303,H304,H306,H405,H404,H305,H307,H501,H201,H101 show-source = True exclude=.venv,.git,.tox