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
This commit is contained in:
Christian Berendt
2015-02-02 10:03:25 +01:00
parent d4be291913
commit d7916cec60
50 changed files with 708 additions and 147 deletions

View File

@@ -1,5 +1,17 @@
# -*- coding: utf-8 -*- # -*- 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 # packstack documentation build configuration file, created by
# sphinx-quickstart on Thu Nov 15 20:34:41 2012. # sphinx-quickstart on Thu Nov 15 20:34:41 2012.
# #

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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. 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" PACKSTACK_VAR_DIR = "/var/tmp/packstack"
try: try:
os.mkdir(PACKSTACK_VAR_DIR, 0700) os.mkdir(PACKSTACK_VAR_DIR, 0o700)
except OSError: except OSError:
# directory is already created, check ownership # directory is already created, check ownership
stat = os.stat(PACKSTACK_VAR_DIR) stat = os.stat(PACKSTACK_VAR_DIR)

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 os
import stat import stat

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Container set for groups and parameters

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Base class for steps & sequences

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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__ = ( __all__ = (
'PackStackError', 'PackStackError',

View File

@@ -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. external text file to hold all user visible text.
info messages begins with INFO_ and error msg with ERR_ info messages begins with INFO_ and error msg with ERR_

View File

@@ -1,11 +1,25 @@
# -*- coding: utf-8 -*- # -*- 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 netaddr
import os import os
import uuid import uuid
from .utils import ScriptRunner, force_ip from .utils import force_ip
from .exceptions import ParamProcessingError, NetworkError from .utils import ScriptRunner
from .exceptions import NetworkError
from .exceptions import ParamProcessingError
__all__ = ('ParamProcessingError', 'process_cidr', 'process_host', __all__ = ('ParamProcessingError', 'process_cidr', 'process_host',

View File

@@ -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 ConfigParser
import copy import copy
import datetime import datetime
@@ -11,14 +24,16 @@ import traceback
import types import types
import textwrap import textwrap
from optparse import OptionParser, OptionGroup from optparse import OptionGroup
from optparse import OptionParser
import basedefs import basedefs
import validators import validators
from . import utils from . import utils
import processors import processors
import output_messages import output_messages
from .exceptions import FlagValidationError, ParamValidationError from .exceptions import FlagValidationError
from .exceptions import ParamValidationError
from packstack import version from packstack import version
from packstack.modules.ospluginutils import gethostlist 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 # Create the log file with specific permissions, puppet has a habbit of putting
# passwords in logs # 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') hdlr = logging.FileHandler(filename=logFile, mode='w')
if (debug): if (debug):
@@ -82,8 +97,8 @@ def _getInputFromUser(param):
message.write(param.PROMPT) message.write(param.PROMPT)
val_list = param.VALIDATORS or [] val_list = param.VALIDATORS or []
if validators.validate_regexp not in val_list \ if(validators.validate_regexp not in val_list
and param.OPTION_LIST: and param.OPTION_LIST):
message.write(" [%s]" % "|".join(param.OPTION_LIST)) message.write(" [%s]" % "|".join(param.OPTION_LIST))
if param.DEFAULT_VALUE: if param.DEFAULT_VALUE:
@@ -130,7 +145,7 @@ def _getInputFromUser(param):
loop = True loop = True
except KeyboardInterrupt: except KeyboardInterrupt:
# add the new line so messages wont be displayed in the same line as the question # add the new line so messages wont be displayed in the same line as the question
print "" print("")
raise raise
except: except:
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
@@ -158,7 +173,7 @@ def input_param(param):
logging.debug("Param confirmation passed, value for both questions is identical") logging.debug("Param confirmation passed, value for both questions is identical")
break break
else: else:
print output_messages.INFO_VAL_PASSWORD_DONT_MATCH print(output_messages.INFO_VAL_PASSWORD_DONT_MATCH)
else: else:
_getInputFromUser(param) _getInputFromUser(param)
@@ -272,7 +287,7 @@ def validate_param_value(param, value):
try: try:
val_func(value, opt_list) val_func(value, opt_list)
except ParamValidationError as ex: except ParamValidationError as ex:
print 'Parameter %s failed validation: %s' % (cname, ex) print('Parameter %s failed validation: %s' % (cname, ex))
raise raise
@@ -287,13 +302,13 @@ def process_param_value(param, value):
if new_value != _value: if new_value != _value:
if param.MASK_INPUT is False: if param.MASK_INPUT is False:
msg = output_messages.INFO_CHANGED_VALUE msg = output_messages.INFO_CHANGED_VALUE
print msg % (_value, new_value) print(msg % (_value, new_value))
_value = new_value _value = new_value
else: else:
logging.debug("Processor returned the original " logging.debug("Processor returned the original "
"value: %s" % _value) "value: %s" % _value)
except processors.ParamProcessingError as ex: except processors.ParamProcessingError as ex:
print ("Value processing of parameter %s " print("Value processing of parameter %s "
"failed.\n%s" % (param.CONF_NAME, ex)) "failed.\n%s" % (param.CONF_NAME, ex))
raise raise
return _value return _value
@@ -541,8 +556,8 @@ def _getConditionValue(matchMember):
def _displaySummary(): def _displaySummary():
print output_messages.INFO_DSPLY_PARAMS print(output_messages.INFO_DSPLY_PARAMS)
print "=" * (len(output_messages.INFO_DSPLY_PARAMS) - 1) print("=" * (len(output_messages.INFO_DSPLY_PARAMS) - 1))
logging.info("*** User input summary ***") logging.info("*** User input summary ***")
for group in controller.getAllGroups(): for group in controller.getAllGroups():
for param in group.parameters.itervalues(): for param in group.parameters.itervalues():
@@ -553,11 +568,11 @@ def _displaySummary():
# Only call mask on a value if the param has MASK_INPUT set to True # Only call mask on a value if the param has MASK_INPUT set to True
if maskParam: if maskParam:
logging.info("%s: %s" % (cmdOption, mask(controller.CONF[param.CONF_NAME]))) 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: else:
# Otherwise, log & display it as it is # Otherwise, log & display it as it is
logging.info("%s: %s" % (cmdOption, str(controller.CONF[param.CONF_NAME]))) 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 ***") logging.info("*** User input summary ***")
answer = _askYesNo(output_messages.INFO_USE_PARAMS) answer = _askYesNo(output_messages.INFO_USE_PARAMS)
if not answer: if not answer:
@@ -573,7 +588,7 @@ def _displaySummary():
del controller.CONF[param.CONF_NAME] del controller.CONF[param.CONF_NAME]
if param.CONF_NAME in commandLineValues: if param.CONF_NAME in commandLineValues:
del commandLineValues[param.CONF_NAME] del commandLineValues[param.CONF_NAME]
print "" print("")
logging.debug("calling handleParams in interactive mode") logging.debug("calling handleParams in interactive mode")
return _handleParams(None) return _handleParams(None)
else: else:
@@ -582,9 +597,9 @@ def _displaySummary():
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):
@@ -612,7 +627,7 @@ def runSequences():
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("")
print(output_messages.INFO_LOG_FILE_PATH % logFile) print(output_messages.INFO_LOG_FILE_PATH % logFile)
@@ -632,7 +647,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()
@@ -645,7 +660,7 @@ def _main(options, configFile=None, logFile=None):
# Print info # Print info
_addFinalInfoMsg(logFile) _addFinalInfoMsg(logFile)
print output_messages.INFO_INSTALL_SUCCESS print(output_messages.INFO_INSTALL_SUCCESS)
def remove_remote_var_dirs(options, config, messages): def remove_remote_var_dirs(options, config, messages):
@@ -703,7 +718,7 @@ def generateAnswerFile(outputFile, overrides={}):
# the mode -rw------- # the mode -rw-------
if os.path.exists(outputFile): if os.path.exists(outputFile):
os.remove(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: with os.fdopen(fd, "w") as ans_file:
ans_file.write("[general]%s" % os.linesep) ans_file.write("[general]%s" % os.linesep)
@@ -829,17 +844,17 @@ def printOptions():
# For each group, create a group option # For each group, create a group option
for group in controller.getAllGroups(): for group in controller.getAllGroups():
print "%s" % group.DESCRIPTION print("%s" % group.DESCRIPTION)
print "-" * len(group.DESCRIPTION) print("-" * len(group.DESCRIPTION))
print print()
for param in group.parameters.itervalues(): for param in group.parameters.itervalues():
cmdOption = param.CONF_NAME cmdOption = param.CONF_NAME
paramUsage = param.USAGE paramUsage = param.USAGE
optionsList = param.OPTION_LIST or "" optionsList = param.OPTION_LIST or ""
print "%s" % (("**%s**" % str(cmdOption)).ljust(30)) print("%s" % (("**%s**" % str(cmdOption)).ljust(30)))
print " %s %s" % (paramUsage, optionsList) print(" %s %s" % (paramUsage, optionsList))
print print()
def plugin_compare(x, y): def plugin_compare(x, y):
@@ -1006,9 +1021,9 @@ def main():
optParser.error(str(ex)) optParser.error(str(ex))
except Exception as e: except Exception as e:
logging.error(traceback.format_exc()) logging.error(traceback.format_exc())
print print()
print utils.color_text("ERROR : " + str(e), 'red') print(utils.color_text("ERROR : " + str(e), 'red'))
print output_messages.ERR_CHECK_LOG_FILE_FOR_MORE_INFO % (logFile) print(output_messages.ERR_CHECK_LOG_FILE_FOR_MORE_INFO % (logFile))
sys.exit(1) sys.exit(1)
finally: finally:

View File

@@ -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, Controller class is a SINGLETON which handles all groups, params, sequences,
steps and replaces the CONF dictionary. steps and replaces the CONF dictionary.

View File

@@ -1,13 +1,35 @@
# -*- coding: utf-8 -*- # -*- 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 .datastructures import SortedDict
from .decorators import retry from .decorators import retry
from .network import get_localhost_ip, host2ip, force_ip, device_from_ip from .network import get_localhost_ip
from .shell import ScriptRunner, execute from .network import host2ip
from .shortcuts import (host_iter, hosts, get_current_user, from .network import force_ip
get_current_username, split_hosts) from .network import device_from_ip
from .strings import (COLORS, color_text, mask_string, state_format, from .shell import execute
state_message) 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', __all__ = ('SortedDict',

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 import copy
from types import GeneratorType from types import GeneratorType

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 import time

View File

@@ -1,10 +1,23 @@
# -*- coding: utf-8 -*- # -*- 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 re
import socket import socket
from ..exceptions import NetworkError from ..exceptions import NetworkError
from .shell import execute, ScriptRunner from .shell import execute
from .shell import ScriptRunner
def get_localhost_ip(): def get_localhost_ip():

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 re
import os import os
@@ -6,8 +18,9 @@ import types
import logging import logging
import subprocess import subprocess
from ..exceptions import (ExecuteRuntimeError, ScriptRuntimeError, from ..exceptions import ExecuteRuntimeError
NetworkError) from ..exceptions import NetworkError
from ..exceptions import ScriptRuntimeError
from .strings import mask_string from .strings import mask_string

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 grp
import os import os

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 re

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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. Contains all core validation functions.

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 from ..installer import utils

View File

@@ -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 os
import yaml import yaml
@@ -61,10 +73,10 @@ class ManifestFiles(object):
if not self.global_data: if not self.global_data:
with open(os.path.join(PUPPET_TEMPLATE_DIR, "global.pp")) as gfp: with open(os.path.join(PUPPET_TEMPLATE_DIR, "global.pp")) as gfp:
self.global_data = gfp.read() % controller.CONF 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(): for fname, data in self.data.items():
path = os.path.join(basedefs.PUPPET_MANIFEST_DIR, fname) 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: with os.fdopen(fd, 'w') as fp:
fp.write(self.global_data + data) fp.write(self.global_data + data)
manifestfiles = ManifestFiles() manifestfiles = ManifestFiles()
@@ -82,7 +94,7 @@ def appendManifestFile(manifest_name, data, marker=''):
def generateHieraDataFile(): def generateHieraDataFile():
os.mkdir(basedefs.HIERADATA_DIR, 0700) os.mkdir(basedefs.HIERADATA_DIR, 0o700)
with open(HIERA_DEFAULTS_YAML, 'w') as outfile: with open(HIERA_DEFAULTS_YAML, 'w') as outfile:
outfile.write(yaml.dump(controller.CONF, outfile.write(yaml.dump(controller.CONF,
explicit_start=True, explicit_start=True,

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 logging
import os import os

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures AMQP
@@ -9,10 +21,9 @@ from packstack.installer import processors
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.common import filtered_hosts from packstack.modules.common import filtered_hosts
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- AMQP Packstack Plugin Initialization -------------- # ------------- AMQP Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Ceilometer
@@ -11,10 +23,9 @@ from packstack.installer import validators
from packstack.installer import processors from packstack.installer import processors
from packstack.installer.utils import split_hosts from packstack.installer.utils import split_hosts
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- Ceilometer Packstack Plugin Initialization -------------- # ------------- Ceilometer Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Cinder
@@ -15,10 +27,9 @@ from packstack.installer import utils
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------------ Cinder Packstack Plugin initialization ------------------ # ------------------ Cinder Packstack Plugin initialization ------------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures OpenStack Horizon
@@ -11,9 +23,8 @@ from packstack.installer import validators
from packstack.installer import exceptions from packstack.installer import exceptions
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- Horizon Packstack Plugin Initialization -------------- # ------------- Horizon Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Glance
@@ -9,9 +21,9 @@ from packstack.installer import processors
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- Glance Packstack Plugin Initialization -------------- # ------------- Glance Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Heat
@@ -11,10 +23,9 @@ from packstack.installer import validators
from packstack.installer import processors from packstack.installer import processors
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- Heat Packstack Plugin Initialization -------------- # ------------- Heat Packstack Plugin Initialization --------------

View File

@@ -1,15 +1,29 @@
# -*- coding: utf-8 -*- # -*- 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 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.shortcuts import get_mq
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------------ Ironic Packstack Plugin initialization ------------------ # ------------------ Ironic Packstack Plugin initialization ------------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Keystone
@@ -10,10 +22,9 @@ from packstack.installer import validators
from packstack.installer import processors from packstack.installer import processors
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- Keystone Packstack Plugin Initialization -------------- # ------------- Keystone Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures MariaDB
@@ -9,10 +21,9 @@ from packstack.installer import processors
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.common import filtered_hosts from packstack.modules.common import filtered_hosts
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- MariaDB Packstack Plugin Initialization -------------- # ------------- MariaDB Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Nagios
@@ -9,10 +21,9 @@ from packstack.installer import processors
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.common import filtered_hosts from packstack.modules.common import filtered_hosts
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- Nagios Packstack Plugin Initialization -------------- # ------------- Nagios Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 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.common import filtered_hosts
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- Neutron Packstack Plugin Initialization -------------- # ------------- Neutron Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Nova
@@ -8,14 +20,18 @@ import os
import platform import platform
import socket 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.installer.exceptions import ScriptRuntimeError
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import (NovaConfig, getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, manifestfiles, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
from packstack.modules.ospluginutils import manifestfiles
from packstack.modules.ospluginutils import NovaConfig
# ------------- Nova Packstack Plugin Initialization -------------- # ------------- Nova Packstack Plugin Initialization --------------
@@ -426,8 +442,7 @@ def create_api_manifest(config, messages):
if config['CONFIG_NEUTRON_INSTALL'] != 'y': if config['CONFIG_NEUTRON_INSTALL'] != 'y':
config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = 'undef' config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = 'undef'
else: else:
config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = \ config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = "%s" % config['CONFIG_NEUTRON_METADATA_PW']
"%s" % config['CONFIG_NEUTRON_METADATA_PW']
manifestfile = "%s_api_nova.pp" % config['CONFIG_CONTROLLER_HOST'] manifestfile = "%s_api_nova.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("nova_api") manifestdata = getManifestTemplate("nova_api")

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures an OpenStack Client
@@ -8,9 +20,8 @@ import os
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- OpenStack Client Packstack Plugin Initialization -------------- # ------------- OpenStack Client Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Plugin responsible for post-installation configuration
@@ -7,9 +19,8 @@ Plugin responsible for post-installation configuration
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.common import filtered_hosts from packstack.modules.common import filtered_hosts
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- Postscript Packstack Plugin Initialization -------------- # ------------- Postscript Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Plugin responsible for setting OpenStack global options
@@ -9,13 +21,16 @@ import os
import re import re
import uuid import uuid
from packstack.installer import (basedefs, exceptions, processors, utils, from packstack.installer import basedefs
validators) from packstack.installer import exceptions
from packstack.installer import processors
from packstack.modules.common import filtered_hosts, is_all_in_one from packstack.installer import utils
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.installer import validators
appendManifestFile)
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 -------------- # ------------- Prescript Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 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.installer import processors
from packstack.modules.common import is_all_in_one from packstack.modules.common import is_all_in_one
from packstack.modules.ospluginutils import (appendManifestFile, from packstack.modules.ospluginutils import appendManifestFile
getManifestTemplate) from packstack.modules.ospluginutils import getManifestTemplate
# ------------- Provision Packstack Plugin Initialization -------------- # ------------- Provision Packstack Plugin Initialization --------------
@@ -307,7 +318,7 @@ def create_storage_manifest(config, messages):
def create_tempest_manifest(config, messages): def create_tempest_manifest(config, messages):
using_neutron(config) using_neutron(config)
manifest_file = '%s_provision_tempest.pp' % \ manifest_file = ('%s_provision_tempest.pp' %
config['CONFIG_CONTROLLER_HOST'] config['CONFIG_CONTROLLER_HOST'])
manifest_data = getManifestTemplate("provision_tempest") manifest_data = getManifestTemplate("provision_tempest")
appendManifestFile(manifest_file, manifest_data) appendManifestFile(manifest_file, manifest_data)

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Puppet
@@ -11,12 +23,14 @@ import time
from packstack.installer import utils from packstack.installer import utils
from packstack.installer import basedefs 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.common import filtered_hosts
from packstack.modules.ospluginutils import (manifestfiles, from packstack.modules.ospluginutils import generateHieraDataFile
generateHieraDataFile) from packstack.modules.ospluginutils import manifestfiles
from packstack.modules.puppet import scan_logfile, validate_logfile from packstack.modules.puppet import validate_logfile
from packstack.modules.puppet import scan_logfile
# ------------- Puppet Packstack Plugin Initialization -------------- # ------------- Puppet Packstack Plugin Initialization --------------
@@ -245,7 +259,7 @@ def apply_puppet_manifest(config, messages):
continue continue
host_dir = config['HOST_DETAILS'][hostname]['tmpdir'] host_dir = config['HOST_DETAILS'][hostname]['tmpdir']
print "Applying %s" % manifest print("Applying %s" % manifest)
server = utils.ScriptRunner(hostname) server = utils.ScriptRunner(hostname)
man_path = os.path.join(config['HOST_DETAILS'][hostname]['tmpdir'], man_path = os.path.join(config['HOST_DETAILS'][hostname]['tmpdir'],

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Sahara
@@ -8,9 +20,9 @@ from packstack.installer import utils
from packstack.installer import validators from packstack.installer import validators
from packstack.installer import processors from packstack.installer import processors
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------------ Sahara installer initialization ------------------ # ------------------ Sahara installer initialization ------------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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. Plugin responsible for Server Preparation.
@@ -13,8 +25,8 @@ from packstack.installer import exceptions
from packstack.installer import utils from packstack.installer import utils
from packstack.installer import validators 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 ------------- # ------------ Server Preparation Packstack Plugin Initialization -------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Swift
@@ -15,10 +27,10 @@ from packstack.installer.exceptions import ParamValidationError
from packstack.installer import utils from packstack.installer import utils
from packstack.installer.utils import split_hosts from packstack.installer.utils import split_hosts
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, manifestfiles, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
from packstack.modules.ospluginutils import manifestfiles
# ------------- Swift Packstack Plugin Initialization -------------- # ------------- Swift Packstack Plugin Initialization --------------

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 Installs and configures Trove
@@ -8,10 +20,9 @@ from packstack.installer import utils
from packstack.installer import validators from packstack.installer import validators
from packstack.installer import processors from packstack.installer import processors
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import appendManifestFile
appendManifestFile, from packstack.modules.ospluginutils import createFirewallResources
createFirewallResources) from packstack.modules.ospluginutils import getManifestTemplate
# ------------------ Trove Packstack Plugin initialization ------------------ # ------------------ Trove Packstack Plugin initialization ------------------

View File

@@ -1,5 +1,17 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- 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 contextlib
import inspect import inspect
@@ -14,7 +26,7 @@ import unittest
def execute(cmd_string, check_error=True, return_code=0, input=None, def execute(cmd_string, check_error=True, return_code=0, input=None,
block=True, error_msg='Error executing cmd'): block=True, error_msg='Error executing cmd'):
print cmd_string print(cmd_string)
cmd = cmd_string.split(' ') cmd = cmd_string.split(' ')
proc = subprocess.Popen(cmd, proc = subprocess.Popen(cmd,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,

View File

@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*- # -*- 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 os
import pkg_resources import pkg_resources

View File

@@ -1,11 +1,25 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- 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 os
import shutil import shutil
import subprocess 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 from packstack import version
@@ -42,11 +56,11 @@ class InstallModulesCommand(Command):
# install third-party modules from openstack-puppet-modules repo # install third-party modules from openstack-puppet-modules repo
if not os.path.exists(self.destination): if not os.path.exists(self.destination):
try: try:
os.makedirs(basedir, 0755) os.makedirs(basedir, 0o755)
except OSError: except OSError:
# base directory exists # base directory exists
pass 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; ' cmd = ('cd %(basedir)s; git clone %(repo)s %(repodir)s; '
'cd %(repodir)s; git checkout %(branch)s; ' % locals()) 'cd %(repodir)s; git checkout %(branch)s; ' % locals())
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
@@ -63,7 +77,7 @@ class InstallModulesCommand(Command):
continue continue
dest = os.path.join(self.destination, module) 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.rmtree(dest, ignore_errors=True)
shutil.copytree(source, dest) shutil.copytree(source, dest)

View File

@@ -82,8 +82,7 @@ class SshTarballTransferMixinTestCase(PackstackTestCaseMixin, TestCase):
tarball = tarfile.open(pack_path) tarball = tarfile.open(pack_path)
tarball.extractall(path=self.tempdir) tarball.extractall(path=self.tempdir)
# check content of files # check content of files
for path, content in \ for path, content in [('resources/res1.txt', 'resource one'),
[('resources/res1.txt', 'resource one'),
('resources/resdir/res2.txt', 'resource two'), ('resources/resdir/res2.txt', 'resource two'),
('recipes/rec1.pp', 'recipe one'), ('recipes/rec1.pp', 'recipe one'),
('recipes/rec2.pp', 'recipe two')]: ('recipes/rec2.pp', 'recipe two')]:

View File

@@ -21,10 +21,13 @@ import subprocess
import sys import sys
from unittest import TestCase from unittest import TestCase
from packstack.modules import ospluginutils, puppet from packstack.modules import ospluginutils
from packstack.installer import run_setup, basedefs 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): def makefile(path, content):

View File

@@ -48,8 +48,8 @@ class StepTestCase(PackstackTestCaseMixin, TestCase):
contents = sys.stdout.getvalue() contents = sys.stdout.getvalue()
state = '[ %s ]\n' % utils.color_text('DONE', 'green') state = '[ %s ]\n' % utils.color_text('DONE', 'green')
if not contents.startswith('Running test') or \ if(not contents.startswith('Running test') or
not contents.endswith(state): not contents.endswith(state)):
raise AssertionError('Step run test failed: %s' % contents) raise AssertionError('Step run test failed: %s' % contents)

View File

@@ -23,7 +23,8 @@ import shutil
import tempfile import tempfile
from unittest import TestCase 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 import *
from packstack.installer.utils.strings import STR_MASK from packstack.installer.utils.strings import STR_MASK
from packstack.installer.exceptions import ExecuteRuntimeError from packstack.installer.exceptions import ExecuteRuntimeError

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,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 show-source = True
exclude=.venv,.git,.tox exclude=.venv,.git,.tox