diff --git a/packstack/modules/ospluginutils.py b/packstack/modules/ospluginutils.py index d8ddbae93..48d295679 100644 --- a/packstack/modules/ospluginutils.py +++ b/packstack/modules/ospluginutils.py @@ -1,5 +1,5 @@ -import os +import os, socket from packstack.installer import basedefs from packstack.installer.setup_controller import Controller @@ -73,3 +73,16 @@ def gethostlist(CONF): if host not in hosts: hosts.append(host) return hosts + +class PackStackException(BaseException): + def __init__(self, msg): + self.msg = msg + +# return the ip address correcponding to a hostname +_ips = {} +def getIP(h): + if _ips.get(h): + return _ips.get(h) + _ips[h] = socket.gethostbyname(h) + return _ips[h] + diff --git a/packstack/plugins/global_000.py b/packstack/plugins/global_000.py index f6fdcf7a5..b65f74243 100644 --- a/packstack/plugins/global_000.py +++ b/packstack/plugins/global_000.py @@ -7,6 +7,8 @@ import logging import packstack.installer.engine_validators as validate import packstack.installer.common_utils as utils +from packstack.modules.ospluginutils import gethostlist, PackStackException, getIP + # Controller object will be initialized from main flow controller = None @@ -102,4 +104,40 @@ def initConfig(controllerObject): controller.addGroup(groupDict, paramsList) def initSequences(controller): - pass + preparesteps = [ + {'title': 'Sanitizing config variable', 'functions':[sanitize]} + ] + controller.addSequence("Global", [], [], preparesteps) + +# If either of localhost or 127.0.0.1 are anywhere in the list of hosts +# then this MUST be an all in one and all hosts MUST be loopback addresses +def dontMixloopback(): + hosts = gethostlist(controller.CONF) + + loopback = [h for h in hosts if h in ['127.0.0.1','localhost']] + if loopback: + if len(loopback) != len(hosts): + msg = "You must use 127.0.0.1 or localhost for All in One installs Only" + print msg + raise PackStackException(msg) + +# Parts of the puppet modules MUST have IP addresses, we translate them here +# availableto templates so they are +def translateIPs(): + hosts = [] + for key,value in controller.CONF.items(): + if key.endswith("_HOST"): + host = value.split('/')[0] # some host have devices in the name eg 1.1.1.1/vdb + controller.CONF[key.replace('_HOST','_IP')] = value.replace(host, getIP(host)) + + if key.endswith("_HOSTS"): + ips = [] + for host_dev in value.split(","): + host_dev = host_dev.strip() + host = host_dev.split('/')[0] + ips.append(host_dev.replace(host, getIP(host))) + controller.CONF[key.replace('_HOSTS','_IPS')] = ','.join(ips) + +def sanitize(): + dontMixloopback() + translateIPs() diff --git a/packstack/plugins/mysql_001.py b/packstack/plugins/mysql_001.py index 8acd4876e..029f2df59 100644 --- a/packstack/plugins/mysql_001.py +++ b/packstack/plugins/mysql_001.py @@ -80,6 +80,11 @@ def initSequences(controller): controller.addSequence("Installing MySQL", [], [], mysqlsteps) def createmanifest(): + # If localhost is used for the MySQL server, then mysql makes a socket connection + # we change this to a IP to force it to use TCP + if controller.CONF.get('CONFIG_MYSQL_HOST') == 'localhost': + controller.CONF['CONFIG_MYSQL_HOST'] = '127.0.0.1' + manifestfile = "%s_mysql.pp"%controller.CONF['CONFIG_MYSQL_HOST'] manifestdata = getManifestTemplate("mysql.pp") appendManifestFile(manifestfile, manifestdata, 'pre') diff --git a/packstack/plugins/nova_300.py b/packstack/plugins/nova_300.py index 91934368d..91b1ffb00 100644 --- a/packstack/plugins/nova_300.py +++ b/packstack/plugins/nova_300.py @@ -207,8 +207,10 @@ def createcertmanifest(): appendManifestFile(manifestfile, manifestdata) def createcomputemanifest(): - for host in controller.CONF["CONFIG_NOVA_COMPUTE_HOSTS"].split(","): + compute_ip_list = controller.CONF["CONFIG_NOVA_COMPUTE_IPS"].split(",") + for i, host in enumerate(controller.CONF["CONFIG_NOVA_COMPUTE_HOSTS"].split(",")): controller.CONF["CONFIG_NOVA_COMPUTE_HOST"] = host + controller.CONF["CONFIG_NOVA_COMPUTE_IP"] = compute_ip_list[i] manifestdata = getManifestTemplate("nova_compute.pp") manifestfile = "%s_nova.pp"%host diff --git a/packstack/plugins/swift_600.py b/packstack/plugins/swift_600.py index 980c43c6f..e52aba1b0 100644 --- a/packstack/plugins/swift_600.py +++ b/packstack/plugins/swift_600.py @@ -9,7 +9,7 @@ import packstack.installer.engine_validators as validate from packstack.installer import basedefs import packstack.installer.common_utils as utils -from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile, manifestfiles +from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile, manifestfiles, getIP # Controller object will be initialized from main flow controller = None @@ -26,8 +26,8 @@ def initConfig(controllerObject): logging.debug("Adding Openstack swift configuration") paramsList = [ {"CMD_OPTION" : "os-swift-proxy", - "USAGE" : "A comma seperated list of IP addresses on which to install the Swift proxy services", - "PROMPT" : "A comma seperated list of IP addresses on which to install the Swift proxy services", + "USAGE" : "The IP addresses on which to install the Swift proxy service", + "PROMPT" : "The IP addresses on which to install the Swift proxy service", "OPTION_LIST" : [], "VALIDATION_FUNC" : validate.validatePing, "DEFAULT_VALUE" : "127.0.0.1", @@ -138,14 +138,15 @@ def createbuildermanifest(): # Add each device to the ring devicename = 0 + for device in parseDevices(controller.CONF["CONFIG_SWIFT_STORAGE_HOSTS"]): host = device['host'] devicename = device['device_name'] zone = device['zone'] - manifestdata = manifestdata + '\n@@ring_object_device { "%s:6000/%s":\n zone => %s,\n weight => 10, }'%(host, devicename, zone) - manifestdata = manifestdata + '\n@@ring_container_device { "%s:6001/%s":\n zone => %s,\n weight => 10, }'%(host, devicename, zone) - manifestdata = manifestdata + '\n@@ring_account_device { "%s:6002/%s":\n zone => %s,\n weight => 10, }'%(host, devicename, zone) + manifestdata = manifestdata + '\n@@ring_object_device { "%s:6000/%s":\n zone => %s,\n weight => 10, }'%(getIP(host), devicename, zone) + manifestdata = manifestdata + '\n@@ring_container_device { "%s:6001/%s":\n zone => %s,\n weight => 10, }'%(getIP(host), devicename, zone) + manifestdata = manifestdata + '\n@@ring_account_device { "%s:6002/%s":\n zone => %s,\n weight => 10, }'%(getIP(host), devicename, zone) appendManifestFile(manifestfile, manifestdata, 'swiftbuilder') @@ -161,7 +162,7 @@ def createstoragemanifest(): # this need to happen once per storage host for host in set([device['host'] for device in devices]): - controller.CONF["CONFIG_SWIFT_STORAGE_CURRENT"] = host + controller.CONF["CONFIG_SWIFT_STORAGE_CURRENT"] = getIP(host) manifestfile = "%s_swift.pp"%host manifestdata = getManifestTemplate("swift_storage.pp") appendManifestFile(manifestfile, manifestdata) diff --git a/packstack/puppet/templates/nova_common.pp b/packstack/puppet/templates/nova_common.pp index 73ad8bf81..a00960f7d 100644 --- a/packstack/puppet/templates/nova_common.pp +++ b/packstack/puppet/templates/nova_common.pp @@ -1,5 +1,5 @@ nova_config{ - "metadata_host": value => "%(CONFIG_NOVA_API_HOST)s"; + "metadata_host": value => "%(CONFIG_NOVA_API_IP)s"; "qpid_hostname": value => "%(CONFIG_QPID_HOST)s"; "rpc_backend": value => "nova.rpc.impl_qpid"; } diff --git a/packstack/puppet/templates/nova_compute.pp b/packstack/puppet/templates/nova_compute.pp index 34f488988..d0b9fc327 100644 --- a/packstack/puppet/templates/nova_compute.pp +++ b/packstack/puppet/templates/nova_compute.pp @@ -1,6 +1,6 @@ nova_config{ - "network_host": value => "%(CONFIG_NOVA_NETWORK_HOST)s"; + "network_host": value => "%(CONFIG_NOVA_NETWORK_IP)s"; "libvirt_inject_partition": value => "-1"; } @@ -12,7 +12,7 @@ class {"nova::compute": class { 'nova::compute::libvirt': libvirt_type => "%(CONFIG_LIBVIRT_TYPE)s", - vncserver_listen => "%(CONFIG_NOVA_COMPUTE_HOST)s", + vncserver_listen => "%(CONFIG_NOVA_COMPUTE_IP)s", } if "%(CONFIG_LIBVIRT_TYPE)s" == "qemu" and $::operatingsystem == "RedHat" {