def validateIpaAndHttpdStatus(conf):
    """"
    This function serve as a pre-condition to the ports group. This function will always return True,
    Therefore the ports group will always be handled, but this function may changes the flow dynamically
    according to http & ipa rpm status.
    So, there are two purposes for this function:
    1. check whether the relevant httpd configuration files were changed,
    As it's an indication for the setup that the httpd application is being actively used,
    Therefore we may need to ask (dynamic change) the user whether to override this configuration.
    2. Check if IPA is installed and drop port 80/443 support.
    """
    controller = Controller()

    # Check if IPA installed
    if utils.installed(basedefs.IPA_RPM) or utils.installed(basedefs.FREEIPA_RPM):
        # Change default ports
        logging.debug("IPA rpms detected, disabling http proxy")
        print output_messages.WARN_IPA_INSTALLED
        utils.setHttpPortsToNonProxyDefault(controller)

        # Don't use http proxy
        paramToChange = controller.getParamByName("OVERRIDE_HTTPD_CONFIG")
        paramToChange.setKey("DEFAULT_VALUE", "no")
    else:
        if wereHttpdConfFilesChanged:
            # If conf files were changed, the user should be asked if he really wants to use ports 80/443
            paramToChange = controller.getParamByName("OVERRIDE_HTTPD_CONFIG")
            paramToChange.setKey("USE_DEFAULT", False)

    # This validator must return true, so ports will always be handled
    return True
예제 #2
0
def validateIpaAndHttpdStatus(conf):
    """"
    This function serve as a pre-condition to the ports group. This function will always return True,
    Therefore the ports group will always be handled, but this function may changes the flow dynamically
    according to http & ipa rpm status.
    So, there are two purposes for this function:
    1. check whether the relevant httpd configuration files were changed,
    As it's an indication for the setup that the httpd application is being actively used,
    Therefore we may need to ask (dynamic change) the user whether to override this configuration.
    2. Check if IPA is installed and drop port 80/443 support.
    """
    controller = Controller()

    # Check if IPA installed
    if utils.installed(basedefs.IPA_RPM) or utils.installed(basedefs.FREEIPA_RPM):
        # Change default ports
        logging.debug("IPA rpms detected, disabling http proxy")
        print output_messages.WARN_IPA_INSTALLED
        utils.setHttpPortsToNonProxyDefault(controller)

        # Don't use http proxy
        paramToChange = controller.getParamByName("OVERRIDE_HTTPD_CONFIG")
        paramToChange.setKey("DEFAULT_VALUE", "no")
    else:
        if wereHttpdConfFilesChanged:
            # If conf files were changed, the user should be asked if he really wants to use ports 80/443
            paramToChange = controller.getParamByName("OVERRIDE_HTTPD_CONFIG")
            paramToChange.setKey("USE_DEFAULT", False)

    # This validator must return true, so ports will always be handled
    return True
예제 #3
0
def validatePort(param, options=[]):
    #TODO: add actual port check with socket open
    logging.debug("Validating %s as a valid TCP Port" % (param))
    minVal = 0
    controller = Controller()
    isProxyEnabled = utils.compareStrIgnoreCase(
        controller.CONF["OVERRIDE_HTTPD_CONFIG"], "yes")
    if not isProxyEnabled:
        minVal = 1024
    if not validateInteger(param, options):
        return False
    port = int(param)
    if not (port > minVal and port < 65535):
        logging.warn(output_messages.INFO_VAL_PORT_NOT_RANGE % (minVal))
        print output_messages.INFO_VAL_PORT_NOT_RANGE % (minVal)
        return False
    (portOpen, process, pid) = utils.isTcpPortOpen(param)
    if portOpen:
        logging.warn(output_messages.INFO_VAL_PORT_OCCUPIED %
                     (param, process, pid))
        print output_messages.INFO_VAL_PORT_OCCUPIED % (param, process, pid)
        return False
    if isProxyEnabled and not checkAndSetHttpdPortPolicy(param):
        logging.warn(output_messages.INFO_VAL_FAILED_ADD_PORT_TO_HTTP_POLICY,
                     port)
        print output_messages.INFO_VAL_FAILED_ADD_PORT_TO_HTTP_POLICY % port
        return False
    return True
예제 #4
0
def validateOverrideHttpdConfAndChangePortsAccordingly(param, options=[]):
    """
    This validation function is specific for the OVERRIDE_HTTPD_CONF param and it does more than validating the answer.
    It actually changes the default HTTP/S ports in case the user choose not to override the httpd configuration.
    """
    logging.info("validateOverrideHttpdConfAndChangePortsAccordingly %s as part of %s"%(param, options))
    retval = validateOptions(param, options)
    if retval and param.lower() == "no":
        logging.debug("Changing HTTP_PORT & HTTPS_PORT to the default jboss values (8700 & 8701)")
        controller = Controller()
        utils.setHttpPortsToNonProxyDefault(controller)
    elif retval:
        #stopping httpd service (in case it's up) when the configuration can be overridden
        logging.debug("stopping httpd service")
        utils.Service(basedefs.HTTPD_SERVICE_NAME).stop()
    return retval
예제 #5
0
import textwrap

from optparse import OptionParser, OptionGroup

import basedefs
import validators
from . import utils
import processors
import output_messages
from .exceptions import FlagValidationError, ParamValidationError

from packstack import version
from packstack.modules.ospluginutils import gethostlist
from setup_controller import Controller

controller = Controller()
commandLineValues = {}

# List to hold all values to be masked in logging (i.e. passwords and sensitive data)
#TODO: read default values from conf_param?
masked_value_set = set()


def initLogging(debug):
    global logFile

    try:
        logFilename = "openstack-setup.log"
        logFile = os.path.join(basedefs.DIR_LOG, logFilename)

        # Create the log file with specific permissions, puppet has a habbit of putting
예제 #6
0
from StringIO import StringIO
import traceback
import types
import uuid


from optparse import OptionParser, OptionGroup

import basedefs
import common_utils as utils
import engine_validators as validate
import output_messages

from setup_controller import Controller

controller = Controller()
logFile = os.path.join(basedefs.DIR_LOG,basedefs.FILE_INSTALLER_LOG)
commandLineValues = {}

# List to hold all values to be masked in logging (i.e. passwords and sensitive data)
#TODO: read default values from conf_param?
masked_value_set = set()

def initLogging():
    global logFile
    try:
        #in order to use UTC date for the log file, send True to getCurrentDateTime(True)
        logFilename = "openstack-setup_%s.log" %(utils.getCurrentDateTime())
        logFile = os.path.join(basedefs.DIR_LOG,logFilename)
        if not os.path.isdir(os.path.dirname(logFile)):
            os.makedirs(os.path.dirname(logFile))