Merge "Hostname support"

This commit is contained in:
Jenkins 2015-10-05 16:04:18 +00:00 committed by Gerrit Code Review
commit 5d6deea816
27 changed files with 138 additions and 92 deletions

View File

@ -87,13 +87,13 @@ Global Options
Specify 'y' if you want to run OpenStack services in debug mode; otherwise, specify 'n'. ['y', 'n']
**CONFIG_CONTROLLER_HOST**
IP address of the server on which to install OpenStack services specific to the controller role (for example, API servers or dashboard).
Server on which to install OpenStack services specific to the controller role (for example, API servers or dashboard).
**CONFIG_COMPUTE_HOSTS**
List of IP addresses of the servers on which to install the Compute service.
List the servers on which to install the Compute service.
**CONFIG_NETWORK_HOSTS**
List of IP addresses of the server on which to install the network service such as Compute networking (nova network) or OpenStack Networking (neutron).
List of servers on which to install the network service such as Compute networking (nova network) or OpenStack Networking (neutron).
**CONFIG_VMWARE_BACKEND**
Specify 'y' if you want to use VMware vCenter as hypervisor and storage; otherwise, specify 'n'. ['y', 'n']
@ -160,10 +160,10 @@ Global unsupported options
--------------------------
**CONFIG_STORAGE_HOST**
(Unsupported!) IP address of the server on which to install OpenStack services specific to storage servers such as Image or Block Storage services.
(Unsupported!) Server on which to install OpenStack services specific to storage servers such as Image or Block Storage services.
**CONFIG_SAHARA_HOST**
(Unsupported!) IP address of the server on which to install OpenStack services specific to OpenStack Data Processing (sahara).
(Unsupported!) Server on which to install OpenStack services specific to OpenStack Data Processing (sahara).
Server Prepare Configs
-----------------------

View File

@ -20,6 +20,7 @@ except ImportError:
import re
import socket
import logging
from ..exceptions import NetworkError
from .shell import execute
from .shell import ScriptRunner
@ -57,23 +58,34 @@ def get_localhost_ip():
'nameserver correctly.')
_host_cache = {}
def host2ip(hostname, allow_localhost=False):
"""
Converts given hostname to IP address. Raises NetworkError
if conversion failed.
"""
key = '{}:{}'.format(hostname, allow_localhost)
if key in _host_cache:
return _host_cache[key]
try:
ip_list = socket.gethostbyaddr(hostname)[2]
ip_list = list(sockets[4][0] for sockets in
socket.getaddrinfo(hostname, 22, 0, 0, socket.IPPROTO_TCP))
if allow_localhost:
return ip_list[0]
ip = ip_list[0]
else:
local_ips = ('127.0.0.1', '::1')
for ip in ip_list:
if ip not in local_ips:
break
else:
raise NameError()
return ip
routable = [ip for ip in ip_list if ip not in ('127.0.0.1', '::1')]
if not routable:
raise NameError("Host %s is not routable, please fix"
"your /etc/hosts", host)
if len(routable) > 1:
logging.warn("Multiple IPs for host detected!")
ip = routable[0]
_host_cache[key] = ip
return ip
except NameError:
# given hostname is localhost, return appropriate IP address
return get_localhost_ip()
@ -92,7 +104,7 @@ def is_ipv6(host):
try:
return netaddr.IPAddress(host).version == 6
except netaddr.core.AddrFormatError:
# Most probably a hostname, no need for bracket everywhere.
# Most probably a hostname
return False
@ -105,7 +117,8 @@ def is_ipv4(host):
try:
return netaddr.IPAddress(host).version == 4
except netaddr.core.AddrFormatError:
return True
# Most probably a hostname
return False
def force_ip(host, allow_localhost=False):

View File

@ -254,10 +254,9 @@ def touch_port(host, port):
key = "%s:%d" % (host, port)
if key in _tested_ports:
return
s = socket.socket(validate_ip(host), socket.SOCK_STREAM)
s.connect((host, port))
s.shutdown(socket.SHUT_RDWR)
s.close()
sock = socket.create_connection((host, port))
sock.shutdown(socket.SHUT_RDWR)
sock.close()
_tested_ports.append(key)

View File

@ -50,7 +50,7 @@ def initConfig(controller):
"DEPRECATES": ['CONFIG_AMQP_SERVER']},
{"CMD_OPTION": "amqp-host",
"PROMPT": "Enter the IP address of the AMQP service",
"PROMPT": "Enter the host for the AMQP service",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),

View File

@ -79,7 +79,7 @@ def initConfig(controller):
"MONGODB": [
{"CMD_OPTION": "mongodb-host",
"PROMPT": "Enter the IP address of the MongoDB server",
"PROMPT": "Enter the host for the MongoDB server",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
@ -92,7 +92,7 @@ def initConfig(controller):
],
"REDIS": [
{"CMD_OPTION": "redis-master-host",
"PROMPT": "Enter the IP address of the redis master server",
"PROMPT": "Enter the host for the Redis master server",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
@ -126,7 +126,7 @@ def initConfig(controller):
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "redis-slaves",
"PROMPT": "Enter the IP addresses of the redis slave servers",
"PROMPT": "Enter the host for the redis slave servers",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_multi_ssh],
"DEFAULT_VALUE": "",
@ -137,7 +137,7 @@ def initConfig(controller):
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "redis-sentinels",
"PROMPT": "Enter the IP addresses of the redis sentinel servers",
"PROMPT": "Enter the host for the redis sentinel servers",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_multi_ssh],
"DEFAULT_VALUE": "",

View File

@ -331,10 +331,9 @@ def initConfig(controller):
{"CONF_NAME": "CONFIG_CONTROLLER_HOST",
"CMD_OPTION": "os-controller-host",
"PROMPT": "Enter the IP address of the controller host",
"PROMPT": "Enter the controller host",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_ip,
validators.validate_ssh],
"VALIDATORS": [validators.validate_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
@ -360,13 +359,9 @@ def initConfig(controller):
{"CONF_NAME": "CONFIG_COMPUTE_HOSTS",
"CMD_OPTION": "os-compute-hosts",
"PROMPT": (
"Enter list of IP addresses on which to install compute "
"service"
),
"PROMPT": "Enter list of compute hosts",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_multi_ip,
validators.validate_multi_ssh],
"VALIDATORS": [validators.validate_multi_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
@ -377,11 +372,9 @@ def initConfig(controller):
{"CONF_NAME": "CONFIG_NETWORK_HOSTS",
"CMD_OPTION": "os-network-hosts",
"PROMPT": ("Enter list of IP addresses on which to install "
"network service"),
"PROMPT": "Enter list of network hosts",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_multi_ip,
validators.validate_multi_ssh],
"VALIDATORS": [validators.validate_multi_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
@ -504,10 +497,9 @@ def initConfig(controller):
"UNSUPPORTED": [
{"CONF_NAME": "CONFIG_STORAGE_HOST",
"CMD_OPTION": "os-storage-host",
"PROMPT": "Enter the IP address of the storage host",
"PROMPT": "Enter the host for the storage services",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_ip,
validators.validate_ssh],
"VALIDATORS": [validators.validate_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
@ -517,10 +509,9 @@ def initConfig(controller):
{"CONF_NAME": "CONFIG_SAHARA_HOST",
"CMD_OPTION": "os-sahara-host",
"PROMPT": "Enter the IP address of the Sahara host",
"PROMPT": "Enter the host for the Sahara",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_ip,
validators.validate_ssh],
"VALIDATORS": [validators.validate_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
@ -1153,20 +1144,30 @@ def manage_rdo(host, config):
def choose_ip_version(config, messages):
use_ipv6 = False
use_ipv4 = False
use_ipv6 = None
use_ipv4 = None
for hostname in filtered_hosts(config):
if '/' in hostname:
hostname = hostname.split('/')[0]
use_ipv6 |= utils.network.is_ipv6(hostname)
use_ipv4 |= utils.network.is_ipv4(hostname)
if use_ipv6 is None and use_ipv4 is None:
use_ipv6 = utils.network.is_ipv6(hostname)
use_ipv4 = utils.network.is_ipv4(hostname)
# check consistency
if (use_ipv6 and not utils.network.is_ipv6(hostname) or
use_ipv4 and not utils.network.is_ipv4(hostname)):
raise ValueError(
"Inconsistent host format. Please use either IPv4 addresses, "
"IPv6 adresses or hostnames for all host variables. "
)
if use_ipv6 and use_ipv4:
msg = "IPv6 together with IPv4 installation is not supported"
raise exceptions.ParamValidationError(msg)
elif use_ipv6:
config['CONFIG_IP_VERSION'] = 'ipv6'
else:
elif use_ipv4:
config['CONFIG_IP_VERSION'] = 'ipv4'
else:
config['CONFIG_IP_VERSION'] = 'none'
def install_keys_on_host(hostname, sshkeydata):

View File

@ -260,6 +260,8 @@ def create_builder_manifest(config, messages):
# come up. Specifically the replicator crashes if the ring isn't present
def device_def(dev_type, host, dev_port, devicename, zone):
# device host has to be IP address
host = utils.force_ip(host)
fmt = ('\n@@%s { "%s:%s/%s":\n'
' zone => %s,\n'
' weight => 10, }\n')

View File

@ -0,0 +1,15 @@
require 'resolv'
module Puppet::Parser::Functions
newfunction(:force_ip, :type => :rvalue) do |args|
if args.size < 1
raise(
Puppet::ParseError,
"force_ip(): Wrong number of arguments given (#{args.size} for 1)"
)
end
Resolv.getaddress args[0]
end
end

View File

@ -13,8 +13,8 @@ define packstack::firewall (
$provider = $ip_version ? {
'ipv6' => 'ip6tables',
'ipv4' => 'iptables',
default => fail("IP version cannot be ${ip_version}")
default => 'iptables',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
$source = $host ? {

View File

@ -50,8 +50,9 @@ class { '::ceilometer::alarm::evaluator':
}
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
class { '::ceilometer::api':
host => $bind_host,

View File

@ -3,8 +3,9 @@ cinder_config {
}
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
class { '::cinder::api':

View File

@ -4,13 +4,15 @@ $glance_cfg_ctrl_host = hiera('CONFIG_KEYSTONE_HOST_URL')
# glance option bind_host requires address without brackets
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
# magical hack for magical config - glance option registry_host requires brackets
$registry_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '[::0]',
'ipv4' => '0.0.0.0',
'ipv6' => '[::0]',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
class { '::glance::api':

View File

@ -11,8 +11,9 @@ $is_django_debug = hiera('CONFIG_DEBUG_MODE') ? {
}
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
$horizon_ssl = hiera('CONFIG_HORIZON_SSL') ? {
@ -55,8 +56,9 @@ if hiera('CONFIG_KEYSTONE_SERVICE_NAME') == 'httpd' {
# hack for memcached, for now we bind to localhost on ipv6
# https://bugzilla.redhat.com/show_bug.cgi?id=1210658
$memcached_bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => 'localhost6',
'ipv4' => '0.0.0.0',
'ipv6' => 'localhost6',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
class { '::memcached':

View File

@ -7,8 +7,9 @@ $keystone_admin_url = hiera('CONFIG_KEYSTONE_ADMIN_URL')
$keystone_api_version = hiera('CONFIG_KEYSTONE_API_VERSION')
$keystone_versioned_admin_url = "${keystone_admin_url}/${keystone_api_version}"
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
if hiera('CONFIG_KEYSTONE_SERVICE_NAME') == 'keystone' {

View File

@ -3,8 +3,9 @@ manila_config {
}
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
class { '::manila::api':

View File

@ -5,8 +5,9 @@ package { 'mariadb-server':
}
$bind_address = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
# hack around galera packaging issue, they are duplicating
@ -52,4 +53,3 @@ if ($::fqdn != $::hostname and $::hostname != 'localhost') {
require => Class['mysql::server'],
}
}

View File

@ -14,9 +14,9 @@ class { '::mongodb::server':
ipv6 => hiera('CONFIG_IP_VERSION') ? {
'ipv6' => true,
default => false,
# TO-DO(mmagr): Add IPv6 support when hostnames are used
},
smallfiles => true,
bind_ip => $mongodb_host,
bind_ip => force_ip($mongodb_host),
config => $config_file,
}

View File

@ -3,6 +3,6 @@ class { '::neutron::agents::metadata':
auth_url => hiera('CONFIG_KEYSTONE_PUBLIC_URL'),
auth_region => hiera('CONFIG_KEYSTONE_REGION'),
shared_secret => hiera('CONFIG_NEUTRON_METADATA_PW'),
metadata_ip => hiera('CONFIG_KEYSTONE_HOST_URL'),
metadata_ip => force_ip(hiera('CONFIG_KEYSTONE_HOST_URL')),
debug => hiera('CONFIG_DEBUG_MODE'),
}

View File

@ -18,7 +18,7 @@ class { '::neutron::agents::ml2::ovs':
bridge_mappings => hiera_array('CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS'),
enable_tunneling => hiera('CONFIG_NEUTRON_OVS_TUNNELING'),
tunnel_types => hiera_array('CONFIG_NEUTRON_OVS_TUNNEL_TYPES'),
local_ip => $localip,
local_ip => force_ip($localip),
vxlan_udp_port => hiera('CONFIG_NEUTRON_OVS_VXLAN_UDP_PORT',undef),
l2_population => hiera('CONFIG_NEUTRON_USE_L2POPULATION'),
}

View File

@ -1,6 +1,7 @@
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
class { '::neutron':

View File

@ -1,6 +1,7 @@
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
$kombu_ssl_ca_certs = hiera('CONFIG_AMQP_SSL_CACERT_FILE', undef)

View File

@ -1,8 +1,9 @@
require 'keystone::python'
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
$config_use_neutron = hiera('CONFIG_NEUTRON_INSTALL')

View File

@ -4,5 +4,6 @@ Firewall <| |> -> Class['nova']
nova_config{
'DEFAULT/sql_connection': value => hiera('CONFIG_NOVA_SQL_CONN_PW');
'DEFAULT/metadata_host': value => hiera('CONFIG_CONTROLLER_HOST');
# metadata_host has to be IP
'DEFAULT/metadata_host': value => force_ip(hiera('CONFIG_CONTROLLER_HOST'));
}

View File

@ -19,8 +19,9 @@ exec { 'qemu-kvm':
}
$libvirt_vnc_bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
class { '::nova::compute::libvirt':

View File

@ -7,8 +7,9 @@ if hiera('CONFIG_HORIZON_SSL') == 'y' {
}
$vnc_bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
class { '::nova::vncproxy':
@ -25,4 +26,3 @@ firewall { '001 novncproxy incoming':
dport => ['6080'],
action => 'accept',
}

View File

@ -2,15 +2,17 @@
package { 'curl': ensure => present }
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
# hack for memcached, for now we bind to localhost on ipv6
# https://bugzilla.redhat.com/show_bug.cgi?id=1210658
$memcached_bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => 'localhost6',
'ipv4' => '0.0.0.0',
'ipv6' => 'localhost6',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
class { '::memcached':

View File

@ -1,6 +1,7 @@
$bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
'ipv4' => '0.0.0.0',
'ipv6' => '::0',
default => '0.0.0.0',
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
class { '::trove::api':