Merge from lp:~openstack-charmers/.../next
This commit is contained in:
commit
2ab51d4272
94
config.yaml
94
config.yaml
@ -48,6 +48,13 @@ options:
|
||||
type: string
|
||||
default: ext_net
|
||||
description: Name of the external network for floating IP addresses provided by Neutron.
|
||||
network-device-mtu:
|
||||
type: int
|
||||
default:
|
||||
description: |
|
||||
The MTU size for interfaces managed by neutron. If unset or set to
|
||||
0, no value will be applied. This value will be provided to
|
||||
neutron-plugin-api relations.
|
||||
neutron-plugin:
|
||||
default: ovs
|
||||
type: string
|
||||
@ -79,6 +86,71 @@ options:
|
||||
type: string
|
||||
default:
|
||||
description: Optional URL to Neutron Plugin containing python packages.
|
||||
# Quota configuration settings
|
||||
quota-security-group:
|
||||
default: 10
|
||||
type: int
|
||||
description: |
|
||||
Number of security groups allowed per tenant. A negative value means
|
||||
unlimited.
|
||||
quota-security-group-rule:
|
||||
default: 100
|
||||
type: int
|
||||
description: |
|
||||
Number of security group rules allowed per tenant. A negative value means
|
||||
unlimited
|
||||
quota-network:
|
||||
default: 10
|
||||
type: int
|
||||
description: |
|
||||
Number of networks allowed per tenant. A negative value means unlimited.
|
||||
quota-subnet:
|
||||
default: 10
|
||||
type: int
|
||||
description: |
|
||||
Number of subnets allowed per tenant. A negative value means unlimited.
|
||||
quota-port:
|
||||
default: 50
|
||||
type: int
|
||||
description: |
|
||||
Number of ports allowed per tenant. A negative value means unlimited.
|
||||
quota-vip:
|
||||
default: 10
|
||||
type: int
|
||||
description: |
|
||||
Number of vips allowed per tenant. A negative value means unlimited.
|
||||
quota-pool:
|
||||
default: 10
|
||||
type: int
|
||||
description: |
|
||||
Number of pools allowed per tenant. A negative value means unlimited.
|
||||
quota-member:
|
||||
default: -1
|
||||
type: int
|
||||
description: |
|
||||
Number of pool members allowed per tenant. A negative value means unlimited.
|
||||
The default is unlimited because a member is not a real resource consumer
|
||||
on Openstack. However, on back-end, a member is a resource consumer
|
||||
and that is the reason why quota is possible.
|
||||
quota-health-monitors:
|
||||
default: -1
|
||||
type: int
|
||||
description: |
|
||||
Number of health monitors allowed per tenant. A negative value means
|
||||
unlimited.
|
||||
The default is unlimited because a health monitor is not a real resource
|
||||
consumer on Openstack. However, on back-end, a member is a resource consumer
|
||||
and that is the reason why quota is possible.
|
||||
quota-router:
|
||||
default: 10
|
||||
type: int
|
||||
description: |
|
||||
Number of routers allowed per tenant. A negative value means unlimited.
|
||||
quota-floatingip:
|
||||
default: 50
|
||||
type: int
|
||||
description: |
|
||||
Number of floating IPs allowed per tenant. A negative value means unlimited.
|
||||
# HA configuration settings
|
||||
vip:
|
||||
type: string
|
||||
@ -264,6 +336,28 @@ options:
|
||||
juju-myservice-0
|
||||
If you're running multiple environments with the same services in them
|
||||
this allows you to differentiate between them.
|
||||
enable-dvr:
|
||||
default: False
|
||||
type: boolean
|
||||
description: |
|
||||
Enable Distributed Virtual Routing (juno and above).
|
||||
enable-l3ha:
|
||||
default: False
|
||||
type: boolean
|
||||
description: |
|
||||
Enable L3 HA (juno and above).
|
||||
max-l3-agents-per-router:
|
||||
default: 2
|
||||
type: int
|
||||
description: |
|
||||
Maximum number of l3 agents to host a router. Only used when enable-l3ha
|
||||
is True
|
||||
min-l3-agents-per-router:
|
||||
default: 2
|
||||
type: int
|
||||
description: |
|
||||
Minimum number of l3 agents to host a router. Only used when enable-l3ha
|
||||
is True
|
||||
nagios_servicegroups:
|
||||
default: ""
|
||||
type: string
|
||||
|
@ -15,6 +15,7 @@
|
||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import six
|
||||
from collections import OrderedDict
|
||||
from charmhelpers.contrib.amulet.deployment import (
|
||||
AmuletDeployment
|
||||
)
|
||||
@ -100,12 +101,34 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||
"""
|
||||
(self.precise_essex, self.precise_folsom, self.precise_grizzly,
|
||||
self.precise_havana, self.precise_icehouse,
|
||||
self.trusty_icehouse) = range(6)
|
||||
self.trusty_icehouse, self.trusty_juno, self.trusty_kilo) = range(8)
|
||||
releases = {
|
||||
('precise', None): self.precise_essex,
|
||||
('precise', 'cloud:precise-folsom'): self.precise_folsom,
|
||||
('precise', 'cloud:precise-grizzly'): self.precise_grizzly,
|
||||
('precise', 'cloud:precise-havana'): self.precise_havana,
|
||||
('precise', 'cloud:precise-icehouse'): self.precise_icehouse,
|
||||
('trusty', None): self.trusty_icehouse}
|
||||
('trusty', None): self.trusty_icehouse,
|
||||
('trusty', 'cloud:trusty-juno'): self.trusty_juno,
|
||||
('trusty', 'cloud:trusty-kilo'): self.trusty_kilo}
|
||||
return releases[(self.series, self.openstack)]
|
||||
|
||||
def _get_openstack_release_string(self):
|
||||
"""Get openstack release string.
|
||||
|
||||
Return a string representing the openstack release.
|
||||
"""
|
||||
releases = OrderedDict([
|
||||
('precise', 'essex'),
|
||||
('quantal', 'folsom'),
|
||||
('raring', 'grizzly'),
|
||||
('saucy', 'havana'),
|
||||
('trusty', 'icehouse'),
|
||||
('utopic', 'juno'),
|
||||
('vivid', 'kilo'),
|
||||
])
|
||||
if self.openstack:
|
||||
os_origin = self.openstack.split(':')[1]
|
||||
return os_origin.split('%s-' % self.series)[1].split('/')[0]
|
||||
else:
|
||||
return releases[self.series]
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from base64 import b64decode
|
||||
from subprocess import check_call
|
||||
@ -46,8 +47,11 @@ from charmhelpers.core.hookenv import (
|
||||
)
|
||||
|
||||
from charmhelpers.core.sysctl import create as sysctl_create
|
||||
from charmhelpers.core.strutils import bool_from_string
|
||||
|
||||
from charmhelpers.core.host import (
|
||||
list_nics,
|
||||
get_nic_hwaddr,
|
||||
mkdir,
|
||||
write_file,
|
||||
)
|
||||
@ -64,16 +68,22 @@ from charmhelpers.contrib.hahelpers.apache import (
|
||||
)
|
||||
from charmhelpers.contrib.openstack.neutron import (
|
||||
neutron_plugin_attribute,
|
||||
parse_data_port_mappings,
|
||||
)
|
||||
from charmhelpers.contrib.openstack.ip import (
|
||||
resolve_address,
|
||||
INTERNAL,
|
||||
)
|
||||
from charmhelpers.contrib.network.ip import (
|
||||
get_address_in_network,
|
||||
get_ipv4_addr,
|
||||
get_ipv6_addr,
|
||||
get_netmask_for_address,
|
||||
format_ipv6_addr,
|
||||
is_address_in_network,
|
||||
is_bridge_member,
|
||||
)
|
||||
from charmhelpers.contrib.openstack.utils import get_host_ip
|
||||
|
||||
CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
|
||||
ADDRESS_TYPES = ['admin', 'internal', 'public']
|
||||
|
||||
@ -727,7 +737,14 @@ class ApacheSSLContext(OSContextGenerator):
|
||||
'endpoints': [],
|
||||
'ext_ports': []}
|
||||
|
||||
for cn in self.canonical_names():
|
||||
cns = self.canonical_names()
|
||||
if cns:
|
||||
for cn in cns:
|
||||
self.configure_cert(cn)
|
||||
else:
|
||||
# Expect cert/key provided in config (currently assumed that ca
|
||||
# uses ip for cn)
|
||||
cn = resolve_address(endpoint_type=INTERNAL)
|
||||
self.configure_cert(cn)
|
||||
|
||||
addresses = self.get_network_addresses()
|
||||
@ -899,6 +916,48 @@ class NeutronContext(OSContextGenerator):
|
||||
return ctxt
|
||||
|
||||
|
||||
class NeutronPortContext(OSContextGenerator):
|
||||
NIC_PREFIXES = ['eth', 'bond']
|
||||
|
||||
def resolve_ports(self, ports):
|
||||
"""Resolve NICs not yet bound to bridge(s)
|
||||
|
||||
If hwaddress provided then returns resolved hwaddress otherwise NIC.
|
||||
"""
|
||||
if not ports:
|
||||
return None
|
||||
|
||||
hwaddr_to_nic = {}
|
||||
hwaddr_to_ip = {}
|
||||
for nic in list_nics(self.NIC_PREFIXES):
|
||||
hwaddr = get_nic_hwaddr(nic)
|
||||
hwaddr_to_nic[hwaddr] = nic
|
||||
addresses = get_ipv4_addr(nic, fatal=False)
|
||||
addresses += get_ipv6_addr(iface=nic, fatal=False)
|
||||
hwaddr_to_ip[hwaddr] = addresses
|
||||
|
||||
resolved = []
|
||||
mac_regex = re.compile(r'([0-9A-F]{2}[:-]){5}([0-9A-F]{2})', re.I)
|
||||
for entry in ports:
|
||||
if re.match(mac_regex, entry):
|
||||
# NIC is in known NICs and does NOT hace an IP address
|
||||
if entry in hwaddr_to_nic and not hwaddr_to_ip[entry]:
|
||||
# If the nic is part of a bridge then don't use it
|
||||
if is_bridge_member(hwaddr_to_nic[entry]):
|
||||
continue
|
||||
|
||||
# Entry is a MAC address for a valid interface that doesn't
|
||||
# have an IP address assigned yet.
|
||||
resolved.append(hwaddr_to_nic[entry])
|
||||
else:
|
||||
# If the passed entry is not a MAC address, assume it's a valid
|
||||
# interface, and that the user put it there on purpose (we can
|
||||
# trust it to be the real external network).
|
||||
resolved.append(entry)
|
||||
|
||||
return resolved
|
||||
|
||||
|
||||
class OSConfigFlagContext(OSContextGenerator):
|
||||
"""Provides support for user-defined config flags.
|
||||
|
||||
@ -1120,3 +1179,145 @@ class SysctlContext(OSContextGenerator):
|
||||
sysctl_create(sysctl_dict,
|
||||
'/etc/sysctl.d/50-{0}.conf'.format(charm_name()))
|
||||
return {'sysctl': sysctl_dict}
|
||||
|
||||
|
||||
class NeutronAPIContext(OSContextGenerator):
|
||||
'''
|
||||
Inspects current neutron-plugin-api relation for neutron settings. Return
|
||||
defaults if it is not present.
|
||||
'''
|
||||
interfaces = ['neutron-plugin-api']
|
||||
|
||||
def __call__(self):
|
||||
self.neutron_defaults = {
|
||||
'l2_population': {
|
||||
'rel_key': 'l2-population',
|
||||
'default': False,
|
||||
},
|
||||
'overlay_network_type': {
|
||||
'rel_key': 'overlay-network-type',
|
||||
'default': 'gre',
|
||||
},
|
||||
'neutron_security_groups': {
|
||||
'rel_key': 'neutron-security-groups',
|
||||
'default': False,
|
||||
},
|
||||
'network_device_mtu': {
|
||||
'rel_key': 'network-device-mtu',
|
||||
'default': None,
|
||||
},
|
||||
'enable_dvr': {
|
||||
'rel_key': 'enable-dvr',
|
||||
'default': False,
|
||||
},
|
||||
'enable_l3ha': {
|
||||
'rel_key': 'enable-l3ha',
|
||||
'default': False,
|
||||
},
|
||||
}
|
||||
ctxt = self.get_neutron_options({})
|
||||
for rid in relation_ids('neutron-plugin-api'):
|
||||
for unit in related_units(rid):
|
||||
rdata = relation_get(rid=rid, unit=unit)
|
||||
if 'l2-population' in rdata:
|
||||
ctxt.update(self.get_neutron_options(rdata))
|
||||
|
||||
return ctxt
|
||||
|
||||
def get_neutron_options(self, rdata):
|
||||
settings = {}
|
||||
for nkey in self.neutron_defaults.keys():
|
||||
defv = self.neutron_defaults[nkey]['default']
|
||||
rkey = self.neutron_defaults[nkey]['rel_key']
|
||||
if rkey in rdata.keys():
|
||||
if type(defv) is bool:
|
||||
settings[nkey] = bool_from_string(rdata[rkey])
|
||||
else:
|
||||
settings[nkey] = rdata[rkey]
|
||||
else:
|
||||
settings[nkey] = defv
|
||||
return settings
|
||||
|
||||
|
||||
class ExternalPortContext(NeutronPortContext):
|
||||
|
||||
def __call__(self):
|
||||
ctxt = {}
|
||||
ports = config('ext-port')
|
||||
if ports:
|
||||
ports = [p.strip() for p in ports.split()]
|
||||
ports = self.resolve_ports(ports)
|
||||
if ports:
|
||||
ctxt = {"ext_port": ports[0]}
|
||||
napi_settings = NeutronAPIContext()()
|
||||
mtu = napi_settings.get('network_device_mtu')
|
||||
if mtu:
|
||||
ctxt['ext_port_mtu'] = mtu
|
||||
|
||||
return ctxt
|
||||
|
||||
|
||||
class DataPortContext(NeutronPortContext):
|
||||
|
||||
def __call__(self):
|
||||
ports = config('data-port')
|
||||
if ports:
|
||||
portmap = parse_data_port_mappings(ports)
|
||||
ports = portmap.values()
|
||||
resolved = self.resolve_ports(ports)
|
||||
normalized = {get_nic_hwaddr(port): port for port in resolved
|
||||
if port not in ports}
|
||||
normalized.update({port: port for port in resolved
|
||||
if port in ports})
|
||||
if resolved:
|
||||
return {bridge: normalized[port] for bridge, port in
|
||||
six.iteritems(portmap) if port in normalized.keys()}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class PhyNICMTUContext(DataPortContext):
|
||||
|
||||
def __call__(self):
|
||||
ctxt = {}
|
||||
mappings = super(PhyNICMTUContext, self).__call__()
|
||||
if mappings and mappings.values():
|
||||
ports = mappings.values()
|
||||
napi_settings = NeutronAPIContext()()
|
||||
mtu = napi_settings.get('network_device_mtu')
|
||||
if mtu:
|
||||
ctxt["devs"] = '\\n'.join(ports)
|
||||
ctxt['mtu'] = mtu
|
||||
|
||||
return ctxt
|
||||
|
||||
|
||||
class NetworkServiceContext(OSContextGenerator):
|
||||
|
||||
def __init__(self, rel_name='quantum-network-service'):
|
||||
self.rel_name = rel_name
|
||||
self.interfaces = [rel_name]
|
||||
|
||||
def __call__(self):
|
||||
for rid in relation_ids(self.rel_name):
|
||||
for unit in related_units(rid):
|
||||
rdata = relation_get(rid=rid, unit=unit)
|
||||
ctxt = {
|
||||
'keystone_host': rdata.get('keystone_host'),
|
||||
'service_port': rdata.get('service_port'),
|
||||
'auth_port': rdata.get('auth_port'),
|
||||
'service_tenant': rdata.get('service_tenant'),
|
||||
'service_username': rdata.get('service_username'),
|
||||
'service_password': rdata.get('service_password'),
|
||||
'quantum_host': rdata.get('quantum_host'),
|
||||
'quantum_port': rdata.get('quantum_port'),
|
||||
'quantum_url': rdata.get('quantum_url'),
|
||||
'region': rdata.get('region'),
|
||||
'service_protocol':
|
||||
rdata.get('service_protocol') or 'http',
|
||||
'auth_protocol':
|
||||
rdata.get('auth_protocol') or 'http',
|
||||
}
|
||||
if context_complete(ctxt):
|
||||
return ctxt
|
||||
return {}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
# Various utilies for dealing with Neutron and the renaming from Quantum.
|
||||
|
||||
import six
|
||||
from subprocess import check_output
|
||||
|
||||
from charmhelpers.core.hookenv import (
|
||||
@ -251,3 +252,72 @@ def network_manager():
|
||||
else:
|
||||
# ensure accurate naming for all releases post-H
|
||||
return 'neutron'
|
||||
|
||||
|
||||
def parse_mappings(mappings):
|
||||
parsed = {}
|
||||
if mappings:
|
||||
mappings = mappings.split(' ')
|
||||
for m in mappings:
|
||||
p = m.partition(':')
|
||||
if p[1] == ':':
|
||||
parsed[p[0].strip()] = p[2].strip()
|
||||
|
||||
return parsed
|
||||
|
||||
|
||||
def parse_bridge_mappings(mappings):
|
||||
"""Parse bridge mappings.
|
||||
|
||||
Mappings must be a space-delimited list of provider:bridge mappings.
|
||||
|
||||
Returns dict of the form {provider:bridge}.
|
||||
"""
|
||||
return parse_mappings(mappings)
|
||||
|
||||
|
||||
def parse_data_port_mappings(mappings, default_bridge='br-data'):
|
||||
"""Parse data port mappings.
|
||||
|
||||
Mappings must be a space-delimited list of bridge:port mappings.
|
||||
|
||||
Returns dict of the form {bridge:port}.
|
||||
"""
|
||||
_mappings = parse_mappings(mappings)
|
||||
if not _mappings:
|
||||
if not mappings:
|
||||
return {}
|
||||
|
||||
# For backwards-compatibility we need to support port-only provided in
|
||||
# config.
|
||||
_mappings = {default_bridge: mappings.split(' ')[0]}
|
||||
|
||||
bridges = _mappings.keys()
|
||||
ports = _mappings.values()
|
||||
if len(set(bridges)) != len(bridges):
|
||||
raise Exception("It is not allowed to have more than one port "
|
||||
"configured on the same bridge")
|
||||
|
||||
if len(set(ports)) != len(ports):
|
||||
raise Exception("It is not allowed to have the same port configured "
|
||||
"on more than one bridge")
|
||||
|
||||
return _mappings
|
||||
|
||||
|
||||
def parse_vlan_range_mappings(mappings):
|
||||
"""Parse vlan range mappings.
|
||||
|
||||
Mappings must be a space-delimited list of provider:start:end mappings.
|
||||
|
||||
Returns dict of the form {provider: (start, end)}.
|
||||
"""
|
||||
_mappings = parse_mappings(mappings)
|
||||
if not _mappings:
|
||||
return {}
|
||||
|
||||
mappings = {}
|
||||
for p, r in six.iteritems(_mappings):
|
||||
mappings[p] = tuple(r.split(':'))
|
||||
|
||||
return mappings
|
||||
|
13
hooks/charmhelpers/contrib/openstack/templates/git.upstart
Normal file
13
hooks/charmhelpers/contrib/openstack/templates/git.upstart
Normal file
@ -0,0 +1,13 @@
|
||||
description "{{ service_description }}"
|
||||
author "Juju {{ service_name }} Charm <juju@localhost>"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [!2345]
|
||||
|
||||
respawn
|
||||
|
||||
exec start-stop-daemon --start --chuid {{ user_name }} \
|
||||
--chdir {{ start_dir }} --name {{ process_name }} \
|
||||
--exec {{ executable_name }} -- \
|
||||
--config-file={{ config_file }} \
|
||||
--log-file={{ log_file }}
|
@ -0,0 +1,9 @@
|
||||
{% if auth_host -%}
|
||||
[keystone_authtoken]
|
||||
identity_uri = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/{{ auth_admin_prefix }}
|
||||
auth_uri = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/{{ service_admin_prefix }}
|
||||
admin_tenant_name = {{ admin_tenant_name }}
|
||||
admin_user = {{ admin_user }}
|
||||
admin_password = {{ admin_password }}
|
||||
signing_dir = {{ signing_dir }}
|
||||
{% endif -%}
|
@ -0,0 +1,22 @@
|
||||
{% if rabbitmq_host or rabbitmq_hosts -%}
|
||||
[oslo_messaging_rabbit]
|
||||
rabbit_userid = {{ rabbitmq_user }}
|
||||
rabbit_virtual_host = {{ rabbitmq_virtual_host }}
|
||||
rabbit_password = {{ rabbitmq_password }}
|
||||
{% if rabbitmq_hosts -%}
|
||||
rabbit_hosts = {{ rabbitmq_hosts }}
|
||||
{% if rabbitmq_ha_queues -%}
|
||||
rabbit_ha_queues = True
|
||||
rabbit_durable_queues = False
|
||||
{% endif -%}
|
||||
{% else -%}
|
||||
rabbit_host = {{ rabbitmq_host }}
|
||||
{% endif -%}
|
||||
{% if rabbit_ssl_port -%}
|
||||
rabbit_use_ssl = True
|
||||
rabbit_port = {{ rabbit_ssl_port }}
|
||||
{% if rabbit_ssl_ca -%}
|
||||
kombu_ssl_ca_certs = {{ rabbit_ssl_ca }}
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
{% endif -%}
|
@ -3,12 +3,12 @@
|
||||
rpc_backend = zmq
|
||||
rpc_zmq_host = {{ zmq_host }}
|
||||
{% if zmq_redis_address -%}
|
||||
rpc_zmq_matchmaker = oslo.messaging._drivers.matchmaker_redis.MatchMakerRedis
|
||||
rpc_zmq_matchmaker = redis
|
||||
matchmaker_heartbeat_freq = 15
|
||||
matchmaker_heartbeat_ttl = 30
|
||||
[matchmaker_redis]
|
||||
host = {{ zmq_redis_address }}
|
||||
{% else -%}
|
||||
rpc_zmq_matchmaker = oslo.messaging._drivers.matchmaker_ring.MatchMakerRing
|
||||
rpc_zmq_matchmaker = ring
|
||||
{% endif -%}
|
||||
{% endif -%}
|
@ -30,6 +30,10 @@ import yaml
|
||||
|
||||
from charmhelpers.contrib.network import ip
|
||||
|
||||
from charmhelpers.core import (
|
||||
unitdata,
|
||||
)
|
||||
|
||||
from charmhelpers.core.hookenv import (
|
||||
config,
|
||||
log as juju_log,
|
||||
@ -330,6 +334,21 @@ def configure_installation_source(rel):
|
||||
error_out("Invalid openstack-release specified: %s" % rel)
|
||||
|
||||
|
||||
def config_value_changed(option):
|
||||
"""
|
||||
Determine if config value changed since last call to this function.
|
||||
"""
|
||||
hook_data = unitdata.HookData()
|
||||
with hook_data():
|
||||
db = unitdata.kv()
|
||||
current = config(option)
|
||||
saved = db.get(option)
|
||||
db.set(option, current)
|
||||
if saved is None:
|
||||
return False
|
||||
return current != saved
|
||||
|
||||
|
||||
def save_script_rc(script_path="scripts/scriptrc", **env_vars):
|
||||
"""
|
||||
Write an rc file in the charm-delivered directory containing
|
||||
@ -469,82 +488,95 @@ def os_requires_version(ostack_release, pkg):
|
||||
|
||||
|
||||
def git_install_requested():
|
||||
"""Returns true if openstack-origin-git is specified."""
|
||||
return config('openstack-origin-git') != "None"
|
||||
"""
|
||||
Returns true if openstack-origin-git is specified.
|
||||
"""
|
||||
return config('openstack-origin-git') is not None
|
||||
|
||||
|
||||
requirements_dir = None
|
||||
|
||||
|
||||
def git_clone_and_install(file_name, core_project):
|
||||
"""Clone/install all OpenStack repos specified in yaml config file."""
|
||||
global requirements_dir
|
||||
def git_clone_and_install(projects_yaml, core_project):
|
||||
"""
|
||||
Clone/install all specified OpenStack repositories.
|
||||
|
||||
if file_name == "None":
|
||||
The expected format of projects_yaml is:
|
||||
repositories:
|
||||
- {name: keystone,
|
||||
repository: 'git://git.openstack.org/openstack/keystone.git',
|
||||
branch: 'stable/icehouse'}
|
||||
- {name: requirements,
|
||||
repository: 'git://git.openstack.org/openstack/requirements.git',
|
||||
branch: 'stable/icehouse'}
|
||||
directory: /mnt/openstack-git
|
||||
|
||||
The directory key is optional.
|
||||
"""
|
||||
global requirements_dir
|
||||
parent_dir = '/mnt/openstack-git'
|
||||
|
||||
if not projects_yaml:
|
||||
return
|
||||
|
||||
yaml_file = os.path.join(charm_dir(), file_name)
|
||||
projects = yaml.load(projects_yaml)
|
||||
_git_validate_projects_yaml(projects, core_project)
|
||||
|
||||
# clone/install the requirements project first
|
||||
installed = _git_clone_and_install_subset(yaml_file,
|
||||
whitelist=['requirements'])
|
||||
if 'requirements' not in installed:
|
||||
error_out('requirements git repository must be specified')
|
||||
if 'directory' in projects.keys():
|
||||
parent_dir = projects['directory']
|
||||
|
||||
# clone/install all other projects except requirements and the core project
|
||||
blacklist = ['requirements', core_project]
|
||||
_git_clone_and_install_subset(yaml_file, blacklist=blacklist,
|
||||
update_requirements=True)
|
||||
|
||||
# clone/install the core project
|
||||
whitelist = [core_project]
|
||||
installed = _git_clone_and_install_subset(yaml_file, whitelist=whitelist,
|
||||
update_requirements=True)
|
||||
if core_project not in installed:
|
||||
error_out('{} git repository must be specified'.format(core_project))
|
||||
for p in projects['repositories']:
|
||||
repo = p['repository']
|
||||
branch = p['branch']
|
||||
if p['name'] == 'requirements':
|
||||
repo_dir = _git_clone_and_install_single(repo, branch, parent_dir,
|
||||
update_requirements=False)
|
||||
requirements_dir = repo_dir
|
||||
else:
|
||||
repo_dir = _git_clone_and_install_single(repo, branch, parent_dir,
|
||||
update_requirements=True)
|
||||
|
||||
|
||||
def _git_clone_and_install_subset(yaml_file, whitelist=[], blacklist=[],
|
||||
update_requirements=False):
|
||||
"""Clone/install subset of OpenStack repos specified in yaml config file."""
|
||||
global requirements_dir
|
||||
installed = []
|
||||
def _git_validate_projects_yaml(projects, core_project):
|
||||
"""
|
||||
Validate the projects yaml.
|
||||
"""
|
||||
_git_ensure_key_exists('repositories', projects)
|
||||
|
||||
with open(yaml_file, 'r') as fd:
|
||||
projects = yaml.load(fd)
|
||||
for proj, val in projects.items():
|
||||
# The project subset is chosen based on the following 3 rules:
|
||||
# 1) If project is in blacklist, we don't clone/install it, period.
|
||||
# 2) If whitelist is empty, we clone/install everything else.
|
||||
# 3) If whitelist is not empty, we clone/install everything in the
|
||||
# whitelist.
|
||||
if proj in blacklist:
|
||||
continue
|
||||
if whitelist and proj not in whitelist:
|
||||
continue
|
||||
repo = val['repository']
|
||||
branch = val['branch']
|
||||
repo_dir = _git_clone_and_install_single(repo, branch,
|
||||
update_requirements)
|
||||
if proj == 'requirements':
|
||||
requirements_dir = repo_dir
|
||||
installed.append(proj)
|
||||
return installed
|
||||
for project in projects['repositories']:
|
||||
_git_ensure_key_exists('name', project.keys())
|
||||
_git_ensure_key_exists('repository', project.keys())
|
||||
_git_ensure_key_exists('branch', project.keys())
|
||||
|
||||
if projects['repositories'][0]['name'] != 'requirements':
|
||||
error_out('{} git repo must be specified first'.format('requirements'))
|
||||
|
||||
if projects['repositories'][-1]['name'] != core_project:
|
||||
error_out('{} git repo must be specified last'.format(core_project))
|
||||
|
||||
|
||||
def _git_clone_and_install_single(repo, branch, update_requirements=False):
|
||||
"""Clone and install a single git repository."""
|
||||
dest_parent_dir = "/mnt/openstack-git/"
|
||||
dest_dir = os.path.join(dest_parent_dir, os.path.basename(repo))
|
||||
def _git_ensure_key_exists(key, keys):
|
||||
"""
|
||||
Ensure that key exists in keys.
|
||||
"""
|
||||
if key not in keys:
|
||||
error_out('openstack-origin-git key \'{}\' is missing'.format(key))
|
||||
|
||||
if not os.path.exists(dest_parent_dir):
|
||||
juju_log('Host dir not mounted at {}. '
|
||||
'Creating directory there instead.'.format(dest_parent_dir))
|
||||
os.mkdir(dest_parent_dir)
|
||||
|
||||
def _git_clone_and_install_single(repo, branch, parent_dir, update_requirements):
|
||||
"""
|
||||
Clone and install a single git repository.
|
||||
"""
|
||||
dest_dir = os.path.join(parent_dir, os.path.basename(repo))
|
||||
|
||||
if not os.path.exists(parent_dir):
|
||||
juju_log('Directory already exists at {}. '
|
||||
'No need to create directory.'.format(parent_dir))
|
||||
os.mkdir(parent_dir)
|
||||
|
||||
if not os.path.exists(dest_dir):
|
||||
juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch))
|
||||
repo_dir = install_remote(repo, dest=dest_parent_dir, branch=branch)
|
||||
repo_dir = install_remote(repo, dest=parent_dir, branch=branch)
|
||||
else:
|
||||
repo_dir = dest_dir
|
||||
|
||||
@ -561,16 +593,39 @@ def _git_clone_and_install_single(repo, branch, update_requirements=False):
|
||||
|
||||
|
||||
def _git_update_requirements(package_dir, reqs_dir):
|
||||
"""Update from global requirements.
|
||||
"""
|
||||
Update from global requirements.
|
||||
|
||||
Update an OpenStack git directory's requirements.txt and
|
||||
test-requirements.txt from global-requirements.txt."""
|
||||
Update an OpenStack git directory's requirements.txt and
|
||||
test-requirements.txt from global-requirements.txt.
|
||||
"""
|
||||
orig_dir = os.getcwd()
|
||||
os.chdir(reqs_dir)
|
||||
cmd = "python update.py {}".format(package_dir)
|
||||
cmd = ['python', 'update.py', package_dir]
|
||||
try:
|
||||
subprocess.check_call(cmd.split(' '))
|
||||
subprocess.check_call(cmd)
|
||||
except subprocess.CalledProcessError:
|
||||
package = os.path.basename(package_dir)
|
||||
error_out("Error updating {} from global-requirements.txt".format(package))
|
||||
os.chdir(orig_dir)
|
||||
|
||||
|
||||
def git_src_dir(projects_yaml, project):
|
||||
"""
|
||||
Return the directory where the specified project's source is located.
|
||||
"""
|
||||
parent_dir = '/mnt/openstack-git'
|
||||
|
||||
if not projects_yaml:
|
||||
return
|
||||
|
||||
projects = yaml.load(projects_yaml)
|
||||
|
||||
if 'directory' in projects.keys():
|
||||
parent_dir = projects['directory']
|
||||
|
||||
for p in projects['repositories']:
|
||||
if p['name'] == project:
|
||||
return os.path.join(parent_dir, os.path.basename(p['repository']))
|
||||
|
||||
return None
|
||||
|
@ -566,3 +566,29 @@ class Hooks(object):
|
||||
def charm_dir():
|
||||
"""Return the root directory of the current charm"""
|
||||
return os.environ.get('CHARM_DIR')
|
||||
|
||||
|
||||
@cached
|
||||
def action_get(key=None):
|
||||
"""Gets the value of an action parameter, or all key/value param pairs"""
|
||||
cmd = ['action-get']
|
||||
if key is not None:
|
||||
cmd.append(key)
|
||||
cmd.append('--format=json')
|
||||
action_data = json.loads(subprocess.check_output(cmd).decode('UTF-8'))
|
||||
return action_data
|
||||
|
||||
|
||||
def action_set(values):
|
||||
"""Sets the values to be returned after the action finishes"""
|
||||
cmd = ['action-set']
|
||||
for k, v in list(values.items()):
|
||||
cmd.append('{}={}'.format(k, v))
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
|
||||
def action_fail(message):
|
||||
"""Sets the action status to failed and sets the error message.
|
||||
|
||||
The results set by action_set are preserved."""
|
||||
subprocess.check_call(['action-fail', message])
|
||||
|
@ -339,12 +339,16 @@ def lsb_release():
|
||||
def pwgen(length=None):
|
||||
"""Generate a random pasword."""
|
||||
if length is None:
|
||||
# A random length is ok to use a weak PRNG
|
||||
length = random.choice(range(35, 45))
|
||||
alphanumeric_chars = [
|
||||
l for l in (string.ascii_letters + string.digits)
|
||||
if l not in 'l0QD1vAEIOUaeiou']
|
||||
# Use a crypto-friendly PRNG (e.g. /dev/urandom) for making the
|
||||
# actual password
|
||||
random_generator = random.SystemRandom()
|
||||
random_chars = [
|
||||
random.choice(alphanumeric_chars) for _ in range(length)]
|
||||
random_generator.choice(alphanumeric_chars) for _ in range(length)]
|
||||
return(''.join(random_chars))
|
||||
|
||||
|
||||
|
@ -139,7 +139,7 @@ class MysqlRelation(RelationContext):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.required_keys = ['host', 'user', 'password', 'database']
|
||||
super(HttpRelation).__init__(self, *args, **kwargs)
|
||||
RelationContext.__init__(self, *args, **kwargs)
|
||||
|
||||
|
||||
class HttpRelation(RelationContext):
|
||||
@ -154,7 +154,7 @@ class HttpRelation(RelationContext):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.required_keys = ['host', 'port']
|
||||
super(HttpRelation).__init__(self, *args, **kwargs)
|
||||
RelationContext.__init__(self, *args, **kwargs)
|
||||
|
||||
def provide_data(self):
|
||||
return {
|
||||
|
@ -443,7 +443,7 @@ class HookData(object):
|
||||
data = hookenv.execution_environment()
|
||||
self.conf = conf_delta = self.kv.delta(data['conf'], 'config')
|
||||
self.rels = rels_delta = self.kv.delta(data['rels'], 'rels')
|
||||
self.kv.set('env', data['env'])
|
||||
self.kv.set('env', dict(data['env']))
|
||||
self.kv.set('unit', data['unit'])
|
||||
self.kv.set('relid', data.get('relid'))
|
||||
return conf_delta, rels_delta
|
||||
|
@ -3,12 +3,16 @@ from charmhelpers.core.hookenv import (
|
||||
relation_ids,
|
||||
related_units,
|
||||
relation_get,
|
||||
log,
|
||||
)
|
||||
from charmhelpers.contrib.openstack import context
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
determine_api_port,
|
||||
determine_apache_port,
|
||||
)
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
os_release,
|
||||
)
|
||||
|
||||
|
||||
def get_l2population():
|
||||
@ -23,6 +27,43 @@ def get_overlay_network_type():
|
||||
return overlay_net
|
||||
|
||||
|
||||
def get_l3ha():
|
||||
if config('enable-l3ha'):
|
||||
if os_release('neutron-server') < 'juno':
|
||||
log('Disabling L3 HA, enable-l3ha is not valid before Juno')
|
||||
return False
|
||||
if config('overlay-network-type') not in ['vlan', 'gre', 'vxlan']:
|
||||
log('Disabling L3 HA, enable-l3ha requires the use of the vxlan, '
|
||||
'vlan or gre overlay network')
|
||||
return False
|
||||
if get_l2population():
|
||||
log('Disabling L3 HA, l2-population must be disabled with L3 HA')
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def get_dvr():
|
||||
if config('enable-dvr'):
|
||||
if os_release('neutron-server') < 'juno':
|
||||
log('Disabling DVR, enable-dvr is not valid before Juno')
|
||||
return False
|
||||
if config('overlay-network-type') != 'vxlan':
|
||||
log('Disabling DVR, enable-dvr requires the use of the vxlan '
|
||||
'overlay network')
|
||||
return False
|
||||
if get_l3ha():
|
||||
log('Disabling DVR, enable-l3ha must be disabled with dvr')
|
||||
return False
|
||||
if not get_l2population():
|
||||
log('Disabling DVR, l2-population must be enabled to use dvr')
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
class ApacheSSLContext(context.ApacheSSLContext):
|
||||
|
||||
interfaces = ['https']
|
||||
@ -69,6 +110,14 @@ class NeutronCCContext(context.NeutronContext):
|
||||
def neutron_overlay_network_type(self):
|
||||
return get_overlay_network_type()
|
||||
|
||||
@property
|
||||
def neutron_dvr(self):
|
||||
return get_dvr()
|
||||
|
||||
@property
|
||||
def neutron_l3ha(self):
|
||||
return get_l3ha()
|
||||
|
||||
# Do not need the plugin agent installed on the api server
|
||||
def _ensure_packages(self):
|
||||
pass
|
||||
@ -91,6 +140,13 @@ class NeutronCCContext(context.NeutronContext):
|
||||
ctxt['nsx_controllers_list'] = \
|
||||
config('nsx-controllers').split()
|
||||
ctxt['l2_population'] = self.neutron_l2_population
|
||||
ctxt['enable_dvr'] = self.neutron_dvr
|
||||
ctxt['l3_ha'] = self.neutron_l3ha
|
||||
if self.neutron_l3ha:
|
||||
ctxt['max_l3_agents_per_router'] = \
|
||||
config('max-l3-agents-per-router')
|
||||
ctxt['min_l3_agents_per_router'] = \
|
||||
config('min-l3-agents-per-router')
|
||||
ctxt['overlay_network_type'] = self.neutron_overlay_network_type
|
||||
ctxt['external_network'] = config('neutron-external-network')
|
||||
if config('neutron-plugin') in ['vsp']:
|
||||
@ -108,6 +164,19 @@ class NeutronCCContext(context.NeutronContext):
|
||||
ctxt['neutron_bind_port'] = \
|
||||
determine_api_port(api_port('neutron-server'),
|
||||
singlenode_mode=True)
|
||||
ctxt['quota_security_group'] = config('quota-security-group')
|
||||
ctxt['quota_security_group_rule'] = \
|
||||
config('quota-security-group-rule')
|
||||
ctxt['quota_network'] = config('quota-network')
|
||||
ctxt['quota_subnet'] = config('quota-subnet')
|
||||
ctxt['quota_port'] = config('quota-port')
|
||||
ctxt['quota_vip'] = config('quota-vip')
|
||||
ctxt['quota_pool'] = config('quota-pool')
|
||||
ctxt['quota_member'] = config('quota-member')
|
||||
ctxt['quota_health_monitors'] = config('quota-health-monitors')
|
||||
ctxt['quota_router'] = config('quota-router')
|
||||
ctxt['quota_floatingip'] = config('quota-floatingip')
|
||||
|
||||
for rid in relation_ids('neutron-api'):
|
||||
for unit in related_units(rid):
|
||||
rdata = relation_get(rid=rid, unit=unit)
|
||||
|
@ -5,7 +5,11 @@ import uuid
|
||||
import os
|
||||
import mmap
|
||||
import re
|
||||
from subprocess import check_call, check_output
|
||||
from subprocess import (
|
||||
check_call,
|
||||
check_output,
|
||||
)
|
||||
|
||||
from charmhelpers.core.hookenv import (
|
||||
Hooks,
|
||||
UnregisteredHookError,
|
||||
@ -22,6 +26,7 @@ from charmhelpers.core.hookenv import (
|
||||
|
||||
from charmhelpers.core.host import (
|
||||
restart_on_change,
|
||||
service_reload,
|
||||
)
|
||||
|
||||
from charmhelpers.fetch import (
|
||||
@ -34,6 +39,7 @@ from charmhelpers.fetch import (
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
configure_installation_source,
|
||||
openstack_upgrade_available,
|
||||
os_requires_version,
|
||||
sync_db_with_multi_ipv6_addresses
|
||||
)
|
||||
|
||||
@ -43,14 +49,20 @@ from neutron_api_utils import (
|
||||
determine_packages,
|
||||
determine_ports,
|
||||
do_openstack_upgrade,
|
||||
dvr_router_present,
|
||||
l3ha_router_present,
|
||||
register_configs,
|
||||
restart_map,
|
||||
services,
|
||||
setup_ipv6
|
||||
setup_ipv6,
|
||||
get_topics,
|
||||
)
|
||||
from neutron_api_context import (
|
||||
get_dvr,
|
||||
get_l3ha,
|
||||
get_l2population,
|
||||
get_overlay_network_type,
|
||||
IdentityServiceContext,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
@ -96,6 +108,10 @@ def configure_https():
|
||||
cmd = ['a2dissite', 'openstack_https_frontend']
|
||||
check_call(cmd)
|
||||
|
||||
# TODO: improve this by checking if local CN certs are available
|
||||
# first then checking reload status (see LP #1433114).
|
||||
service_reload('apache2', restart_on_failure=True)
|
||||
|
||||
for rid in relation_ids('identity-service'):
|
||||
identity_joined(rid=rid)
|
||||
|
||||
@ -171,6 +187,16 @@ def save_vsd_address_to_config(vsd_address):
|
||||
@hooks.hook('config-changed')
|
||||
@restart_on_change(restart_map(), stopstart=True)
|
||||
def config_changed():
|
||||
if l3ha_router_present() and not get_l3ha():
|
||||
e = ('Cannot disable Router HA while ha enabled routers exist. Please'
|
||||
' remove any ha routers')
|
||||
log(e, level=ERROR)
|
||||
raise Exception(e)
|
||||
if dvr_router_present() and not get_dvr():
|
||||
e = ('Cannot disable dvr while dvr enabled routers exist. Please'
|
||||
' remove any distributed routers')
|
||||
log(e, level=ERROR)
|
||||
raise Exception(e)
|
||||
apt_install(filter_installed_packages(
|
||||
determine_packages(config('openstack-origin'))),
|
||||
fatal=True)
|
||||
@ -193,6 +219,8 @@ def config_changed():
|
||||
amqp_joined(relation_id=r_id)
|
||||
for r_id in relation_ids('identity-service'):
|
||||
identity_joined(rid=r_id)
|
||||
for rid in relation_ids('zeromq-configuration'):
|
||||
zeromq_configuration_relation_joined(rid)
|
||||
[cluster_joined(rid) for rid in relation_ids('cluster')]
|
||||
|
||||
|
||||
@ -296,6 +324,8 @@ def identity_changed():
|
||||
CONFIGS.write(NEUTRON_CONF)
|
||||
for r_id in relation_ids('neutron-api'):
|
||||
neutron_api_relation_joined(rid=r_id)
|
||||
for r_id in relation_ids('neutron-plugin-api'):
|
||||
neutron_plugin_api_relation_joined(rid=r_id)
|
||||
configure_https()
|
||||
|
||||
|
||||
@ -339,8 +369,34 @@ def neutron_plugin_api_relation_joined(rid=None):
|
||||
relation_data = {
|
||||
'neutron-security-groups': config('neutron-security-groups'),
|
||||
'l2-population': get_l2population(),
|
||||
'enable-dvr': get_dvr(),
|
||||
'enable-l3ha': get_l3ha(),
|
||||
'overlay-network-type': get_overlay_network_type(),
|
||||
}
|
||||
|
||||
# Provide this value to relations since it needs to be set in multiple
|
||||
# places e.g. neutron.conf, nova.conf
|
||||
net_dev_mtu = config('network-device-mtu')
|
||||
if net_dev_mtu:
|
||||
relation_data['network-device-mtu'] = net_dev_mtu
|
||||
|
||||
identity_ctxt = IdentityServiceContext()()
|
||||
if not identity_ctxt:
|
||||
identity_ctxt = {}
|
||||
|
||||
relation_data.update({
|
||||
'auth_host': identity_ctxt.get('auth_host'),
|
||||
'auth_port': identity_ctxt.get('auth_port'),
|
||||
'auth_protocol': identity_ctxt.get('auth_protocol'),
|
||||
'service_protocol': identity_ctxt.get('service_protocol'),
|
||||
'service_host': identity_ctxt.get('service_host'),
|
||||
'service_port': identity_ctxt.get('service_port'),
|
||||
'service_tenant': identity_ctxt.get('admin_tenant_name'),
|
||||
'service_username': identity_ctxt.get('admin_user'),
|
||||
'service_password': identity_ctxt.get('admin_password'),
|
||||
'region': config('region'),
|
||||
})
|
||||
|
||||
relation_set(relation_id=rid, **relation_data)
|
||||
|
||||
|
||||
@ -467,6 +523,20 @@ def update_config_file(config_file, key, value):
|
||||
mm.close()
|
||||
|
||||
|
||||
@hooks.hook('zeromq-configuration-relation-joined')
|
||||
@os_requires_version('kilo', 'neutron-server')
|
||||
def zeromq_configuration_relation_joined(relid=None):
|
||||
relation_set(relation_id=relid,
|
||||
topics=" ".join(get_topics()),
|
||||
users="neutron")
|
||||
|
||||
|
||||
@hooks.hook('zeromq-configuration-relation-changed')
|
||||
@restart_on_change(restart_map(), stopstart=True)
|
||||
def zeromq_configuration_relation_changed():
|
||||
CONFIGS.write_all()
|
||||
|
||||
|
||||
@hooks.hook('nrpe-external-master-relation-joined',
|
||||
'nrpe-external-master-relation-changed')
|
||||
def update_nrpe_config():
|
||||
|
@ -1,5 +1,6 @@
|
||||
from collections import OrderedDict
|
||||
from copy import deepcopy
|
||||
from functools import partial
|
||||
import os
|
||||
from base64 import b64encode
|
||||
from charmhelpers.contrib.openstack import context, templating
|
||||
@ -77,9 +78,13 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
database=config('database'),
|
||||
ssl_dir=NEUTRON_CONF_DIR),
|
||||
context.PostgresqlDBContext(database=config('database')),
|
||||
neutron_api_context.IdentityServiceContext(),
|
||||
neutron_api_context.IdentityServiceContext(
|
||||
service='neutron',
|
||||
service_user='neutron'),
|
||||
neutron_api_context.NeutronCCContext(),
|
||||
context.SyslogContext(),
|
||||
context.ZeroMQContext(),
|
||||
context.NotificationDriverContext(),
|
||||
context.BindHostContext(),
|
||||
context.WorkerConfigContext()],
|
||||
}),
|
||||
@ -228,6 +233,16 @@ def do_openstack_upgrade(configs):
|
||||
configs.set_release(openstack_release=new_os_rel)
|
||||
|
||||
|
||||
def get_topics():
|
||||
return ['q-l3-plugin',
|
||||
'q-firewall-plugin',
|
||||
'n-lbaas-plugin',
|
||||
'ipsec_driver',
|
||||
'q-metering-plugin',
|
||||
'q-plugin',
|
||||
'neutron']
|
||||
|
||||
|
||||
def setup_ipv6():
|
||||
ubuntu_rel = lsb_release()['DISTRIB_CODENAME'].lower()
|
||||
if ubuntu_rel < "trusty":
|
||||
@ -242,3 +257,28 @@ def setup_ipv6():
|
||||
' main')
|
||||
apt_update()
|
||||
apt_install('haproxy/trusty-backports', fatal=True)
|
||||
|
||||
|
||||
def router_feature_present(feature):
|
||||
''' Check For dvr enabled routers '''
|
||||
env = neutron_api_context.IdentityServiceContext()()
|
||||
if not env:
|
||||
log('Unable to check resources at this time')
|
||||
return
|
||||
|
||||
auth_url = '%(auth_protocol)s://%(auth_host)s:%(auth_port)s/v2.0' % env
|
||||
# Late import to avoid install hook failures when pkg hasnt been installed
|
||||
from neutronclient.v2_0 import client
|
||||
neutron_client = client.Client(username=env['admin_user'],
|
||||
password=env['admin_password'],
|
||||
tenant_name=env['admin_tenant_name'],
|
||||
auth_url=auth_url,
|
||||
region_name=env['region'])
|
||||
for router in neutron_client.list_routers()['routers']:
|
||||
if router.get(feature, False):
|
||||
return True
|
||||
return False
|
||||
|
||||
l3ha_router_present = partial(router_feature_present, feature='ha')
|
||||
|
||||
dvr_router_present = partial(router_feature_present, feature='distributed')
|
||||
|
1
hooks/zeromq-configuration-relation-changed
Symbolic link
1
hooks/zeromq-configuration-relation-changed
Symbolic link
@ -0,0 +1 @@
|
||||
neutron_api_hooks.py
|
1
hooks/zeromq-configuration-relation-joined
Symbolic link
1
hooks/zeromq-configuration-relation-joined
Symbolic link
@ -0,0 +1 @@
|
||||
neutron_api_hooks.py
|
@ -37,6 +37,9 @@ requires:
|
||||
vsd-rest-api:
|
||||
interface: http
|
||||
scope: global
|
||||
zeromq-configuration:
|
||||
interface: zeromq-configuration
|
||||
scope: container
|
||||
peers:
|
||||
cluster:
|
||||
interface: neutron-api-ha
|
||||
|
@ -1,3 +1,4 @@
|
||||
# icehouse
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
@ -11,7 +12,10 @@ state_path = /var/lib/neutron
|
||||
lock_path = $state_path/lock
|
||||
bind_host = {{ bind_host }}
|
||||
auth_strategy = keystone
|
||||
|
||||
{% if notifications == 'True' -%}
|
||||
notification_driver = neutron.openstack.common.notifier.rpc_notifier
|
||||
{% endif -%}
|
||||
api_workers = {{ workers }}
|
||||
rpc_workers = {{ workers }}
|
||||
|
||||
@ -50,13 +54,26 @@ nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0
|
||||
quota_driver = neutron.db.quota_db.DbQuotaDriver
|
||||
{% if neutron_security_groups -%}
|
||||
quota_items = network,subnet,port,security_group,security_group_rule
|
||||
quota_security_group = {{ quota_security_group }}
|
||||
quota_security_group_rule = {{ quota_security_group_rule }}
|
||||
{% else -%}
|
||||
quota_items = network,subnet,port
|
||||
{% endif -%}
|
||||
quota_network = {{ quota_network }}
|
||||
quota_subnet = {{ quota_subnet }}
|
||||
quota_port = {{ quota_port }}
|
||||
quota_vip = {{ quota_vip }}
|
||||
quota_pool = {{ quota_pool }}
|
||||
quota_member = {{ quota_member }}
|
||||
quota_health_monitors = {{ quota_health_monitors }}
|
||||
quota_router = {{ quota_router }}
|
||||
quota_floatingip = {{ quota_floatingip }}
|
||||
|
||||
[agent]
|
||||
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
|
||||
|
||||
[keystone_authtoken]
|
||||
signing_dir = /var/lib/neutron/keystone-signing
|
||||
signing_dir = {{ signing_dir }}
|
||||
{% if service_host -%}
|
||||
service_protocol = {{ service_protocol }}
|
||||
service_host = {{ service_host }}
|
||||
|
85
templates/juno/neutron.conf
Normal file
85
templates/juno/neutron.conf
Normal file
@ -0,0 +1,85 @@
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
## Restart trigger {{ restart_trigger }}
|
||||
###############################################################################
|
||||
[DEFAULT]
|
||||
verbose = {{ verbose }}
|
||||
debug = {{ debug }}
|
||||
use_syslog = {{ use_syslog }}
|
||||
state_path = /var/lib/neutron
|
||||
lock_path = $state_path/lock
|
||||
bind_host = {{ bind_host }}
|
||||
auth_strategy = keystone
|
||||
notification_driver = neutron.openstack.common.notifier.rpc_notifier
|
||||
api_workers = {{ workers }}
|
||||
rpc_workers = {{ workers }}
|
||||
|
||||
router_distributed = {{ enable_dvr }}
|
||||
|
||||
l3_ha = {{ l3_ha }}
|
||||
{% if l3_ha -%}
|
||||
max_l3_agents_per_router = {{ max_l3_agents_per_router }}
|
||||
min_l3_agents_per_router = {{ min_l3_agents_per_router }}
|
||||
{% endif -%}
|
||||
|
||||
{% if neutron_bind_port -%}
|
||||
bind_port = {{ neutron_bind_port }}
|
||||
{% else -%}
|
||||
bind_port = 9696
|
||||
{% endif -%}
|
||||
|
||||
{% if core_plugin -%}
|
||||
core_plugin = {{ core_plugin }}
|
||||
{% if neutron_plugin in ['ovs', 'ml2'] -%}
|
||||
service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin,neutron.services.firewall.fwaas_plugin.FirewallPlugin,neutron.services.loadbalancer.plugin.LoadBalancerPlugin,neutron.services.vpn.plugin.VPNDriverPlugin,neutron.services.metering.metering_plugin.MeteringPlugin
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
|
||||
{% if neutron_security_groups -%}
|
||||
allow_overlapping_ips = True
|
||||
neutron_firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
|
||||
{% endif -%}
|
||||
|
||||
{% include "parts/rabbitmq" %}
|
||||
|
||||
notify_nova_on_port_status_changes = True
|
||||
notify_nova_on_port_data_changes = True
|
||||
nova_url = {{ nova_url }}
|
||||
nova_region_name = {{ region }}
|
||||
{% if auth_host -%}
|
||||
nova_admin_username = {{ admin_user }}
|
||||
nova_admin_tenant_id = {{ admin_tenant_id }}
|
||||
nova_admin_password = {{ admin_password }}
|
||||
nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0
|
||||
{% endif -%}
|
||||
|
||||
[quotas]
|
||||
quota_driver = neutron.db.quota_db.DbQuotaDriver
|
||||
{% if neutron_security_groups -%}
|
||||
quota_items = network,subnet,port,security_group,security_group_rule
|
||||
{% endif -%}
|
||||
|
||||
[agent]
|
||||
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
|
||||
|
||||
[keystone_authtoken]
|
||||
signing_dir = {{ signing_dir }}
|
||||
{% if service_host -%}
|
||||
service_protocol = {{ service_protocol }}
|
||||
service_host = {{ service_host }}
|
||||
service_port = {{ service_port }}
|
||||
auth_host = {{ auth_host }}
|
||||
auth_port = {{ auth_port }}
|
||||
auth_protocol = {{ auth_protocol }}
|
||||
admin_tenant_name = {{ admin_tenant_name }}
|
||||
admin_user = {{ admin_user }}
|
||||
admin_password = {{ admin_password }}
|
||||
{% endif -%}
|
||||
|
||||
{% include "parts/section-database" %}
|
||||
|
||||
[service_providers]
|
||||
service_provider=LOADBALANCER:Haproxy:neutron.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
|
||||
service_provider=VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default
|
||||
service_provider=FIREWALL:Iptables:neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver:default
|
@ -1,3 +1,4 @@
|
||||
# kilo
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
@ -8,13 +9,20 @@ verbose = {{ verbose }}
|
||||
debug = {{ debug }}
|
||||
use_syslog = {{ use_syslog }}
|
||||
state_path = /var/lib/neutron
|
||||
lock_path = $state_path/lock
|
||||
bind_host = {{ bind_host }}
|
||||
auth_strategy = keystone
|
||||
notification_driver = neutron.openstack.common.notifier.rpc_notifier
|
||||
api_workers = {{ workers }}
|
||||
rpc_workers = {{ workers }}
|
||||
|
||||
router_distributed = {{ enable_dvr }}
|
||||
|
||||
l3_ha = {{ l3_ha }}
|
||||
{% if l3_ha -%}
|
||||
max_l3_agents_per_router = {{ max_l3_agents_per_router }}
|
||||
min_l3_agents_per_router = {{ min_l3_agents_per_router }}
|
||||
{% endif -%}
|
||||
|
||||
{% if neutron_bind_port -%}
|
||||
bind_port = {{ neutron_bind_port }}
|
||||
{% else -%}
|
||||
@ -33,8 +41,6 @@ allow_overlapping_ips = True
|
||||
neutron_firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
|
||||
{% endif -%}
|
||||
|
||||
{% include "parts/rabbitmq" %}
|
||||
|
||||
notify_nova_on_port_status_changes = True
|
||||
notify_nova_on_port_data_changes = True
|
||||
nova_url = {{ nova_url }}
|
||||
@ -46,32 +52,40 @@ nova_admin_password = {{ admin_password }}
|
||||
nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0
|
||||
{% endif -%}
|
||||
|
||||
{% include "section-zeromq" %}
|
||||
|
||||
[quotas]
|
||||
quota_driver = neutron.db.quota_db.DbQuotaDriver
|
||||
{% if neutron_security_groups -%}
|
||||
quota_items = network,subnet,port,security_group,security_group_rule
|
||||
quota_security_group = {{ quota_security_group }}
|
||||
quota_security_group_rule = {{ quota_security_group_rule }}
|
||||
{% else -%}
|
||||
quota_items = network,subnet,port
|
||||
{% endif -%}
|
||||
quota_network = {{ quota_network }}
|
||||
quota_subnet = {{ quota_subnet }}
|
||||
quota_port = {{ quota_port }}
|
||||
quota_vip = {{ quota_vip }}
|
||||
quota_pool = {{ quota_pool }}
|
||||
quota_member = {{ quota_member }}
|
||||
quota_health_monitors = {{ quota_health_monitors }}
|
||||
quota_router = {{ quota_router }}
|
||||
quota_floatingip = {{ quota_floatingip }}
|
||||
|
||||
[agent]
|
||||
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
|
||||
|
||||
[keystone_authtoken]
|
||||
signing_dir = /var/lib/neutron/keystone-signing
|
||||
{% if service_host -%}
|
||||
service_protocol = {{ service_protocol }}
|
||||
service_host = {{ service_host }}
|
||||
service_port = {{ service_port }}
|
||||
auth_host = {{ auth_host }}
|
||||
auth_port = {{ auth_port }}
|
||||
auth_protocol = {{ auth_protocol }}
|
||||
admin_tenant_name = {{ admin_tenant_name }}
|
||||
admin_user = {{ admin_user }}
|
||||
admin_password = {{ admin_password }}
|
||||
{% endif -%}
|
||||
{% include "section-keystone-authtoken" %}
|
||||
|
||||
{% include "parts/section-database" %}
|
||||
|
||||
{% include "section-rabbitmq-oslo" %}
|
||||
|
||||
[service_providers]
|
||||
service_provider=LOADBALANCER:Haproxy:neutron_lbaas.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
|
||||
service_provider=VPN:openswan:neutron_vpnaas.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default
|
||||
service_provider=FIREWALL:Iptables:neutron_fwaas.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver:default
|
||||
|
||||
[oslo_concurrency]
|
||||
lock_path = $state_path/lock
|
||||
|
@ -178,7 +178,6 @@ class NeutronAPIBasicDeployment(OpenStackAmuletDeployment):
|
||||
'auth_host': id_ip,
|
||||
'auth_port': "35357",
|
||||
'auth_protocol': 'http',
|
||||
'https_keystone': "False",
|
||||
'private-address': id_ip,
|
||||
'service_host': id_ip,
|
||||
}
|
||||
@ -294,7 +293,7 @@ class NeutronAPIBasicDeployment(OpenStackAmuletDeployment):
|
||||
'nova_admin_auth_url': nova_auth_url,
|
||||
},
|
||||
'keystone_authtoken': {
|
||||
'signing_dir': '/var/lib/neutron/keystone-signing',
|
||||
'signing_dir': '/var/cache/neutron',
|
||||
'service_protocol': ks_rel['service_protocol'],
|
||||
'service_host': ks_rel['service_host'],
|
||||
'service_port': ks_rel['service_port'],
|
||||
|
@ -15,6 +15,7 @@
|
||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import six
|
||||
from collections import OrderedDict
|
||||
from charmhelpers.contrib.amulet.deployment import (
|
||||
AmuletDeployment
|
||||
)
|
||||
@ -100,12 +101,34 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||
"""
|
||||
(self.precise_essex, self.precise_folsom, self.precise_grizzly,
|
||||
self.precise_havana, self.precise_icehouse,
|
||||
self.trusty_icehouse) = range(6)
|
||||
self.trusty_icehouse, self.trusty_juno, self.trusty_kilo) = range(8)
|
||||
releases = {
|
||||
('precise', None): self.precise_essex,
|
||||
('precise', 'cloud:precise-folsom'): self.precise_folsom,
|
||||
('precise', 'cloud:precise-grizzly'): self.precise_grizzly,
|
||||
('precise', 'cloud:precise-havana'): self.precise_havana,
|
||||
('precise', 'cloud:precise-icehouse'): self.precise_icehouse,
|
||||
('trusty', None): self.trusty_icehouse}
|
||||
('trusty', None): self.trusty_icehouse,
|
||||
('trusty', 'cloud:trusty-juno'): self.trusty_juno,
|
||||
('trusty', 'cloud:trusty-kilo'): self.trusty_kilo}
|
||||
return releases[(self.series, self.openstack)]
|
||||
|
||||
def _get_openstack_release_string(self):
|
||||
"""Get openstack release string.
|
||||
|
||||
Return a string representing the openstack release.
|
||||
"""
|
||||
releases = OrderedDict([
|
||||
('precise', 'essex'),
|
||||
('quantal', 'folsom'),
|
||||
('raring', 'grizzly'),
|
||||
('saucy', 'havana'),
|
||||
('trusty', 'icehouse'),
|
||||
('utopic', 'juno'),
|
||||
('vivid', 'kilo'),
|
||||
])
|
||||
if self.openstack:
|
||||
os_origin = self.openstack.split(':')[1]
|
||||
return os_origin.split('%s-' % self.series)[1].split('/')[0]
|
||||
else:
|
||||
return releases[self.series]
|
||||
|
@ -3,15 +3,131 @@ from mock import patch
|
||||
import neutron_api_context as context
|
||||
import charmhelpers
|
||||
TO_PATCH = [
|
||||
'config',
|
||||
'determine_api_port',
|
||||
'determine_apache_port',
|
||||
'log',
|
||||
'os_release',
|
||||
'relation_get',
|
||||
'relation_ids',
|
||||
'related_units',
|
||||
'config',
|
||||
'determine_api_port',
|
||||
'determine_apache_port'
|
||||
]
|
||||
|
||||
|
||||
class GeneralTests(CharmTestCase):
|
||||
def setUp(self):
|
||||
super(GeneralTests, self).setUp(context, TO_PATCH)
|
||||
self.relation_get.side_effect = self.test_relation.get
|
||||
self.config.side_effect = self.test_config.get
|
||||
|
||||
def test_l2population(self):
|
||||
self.test_config.set('l2-population', True)
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.assertEquals(context.get_l2population(), True)
|
||||
|
||||
def test_l2population_nonovs(self):
|
||||
self.test_config.set('l2-population', True)
|
||||
self.test_config.set('neutron-plugin', 'nsx')
|
||||
self.assertEquals(context.get_l2population(), False)
|
||||
|
||||
def test_get_overlay_network_type(self):
|
||||
self.test_config.set('overlay-network-type', 'gre')
|
||||
self.assertEquals(context.get_overlay_network_type(), 'gre')
|
||||
|
||||
def test_get_overlay_network_type_unsupported(self):
|
||||
self.test_config.set('overlay-network-type', 'tokenring')
|
||||
with self.assertRaises(Exception) as _exceptctxt:
|
||||
context.get_overlay_network_type()
|
||||
self.assertEqual(_exceptctxt.exception.message,
|
||||
'Unsupported overlay-network-type')
|
||||
|
||||
def test_get_l3ha(self):
|
||||
self.test_config.set('enable-l3ha', True)
|
||||
self.test_config.set('overlay-network-type', 'gre')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', False)
|
||||
self.os_release.return_value = 'juno'
|
||||
self.assertEquals(context.get_l3ha(), True)
|
||||
|
||||
def test_get_l3ha_prejuno(self):
|
||||
self.test_config.set('enable-l3ha', True)
|
||||
self.test_config.set('overlay-network-type', 'gre')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', False)
|
||||
self.os_release.return_value = 'icehouse'
|
||||
self.assertEquals(context.get_l3ha(), False)
|
||||
|
||||
def test_get_l3ha_l2pop(self):
|
||||
self.test_config.set('enable-l3ha', True)
|
||||
self.test_config.set('overlay-network-type', 'gre')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', True)
|
||||
self.os_release.return_value = 'juno'
|
||||
self.assertEquals(context.get_l3ha(), False)
|
||||
|
||||
def test_get_l3ha_badoverlay(self):
|
||||
self.test_config.set('enable-l3ha', True)
|
||||
self.test_config.set('overlay-network-type', 'tokenring')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', False)
|
||||
self.os_release.return_value = 'juno'
|
||||
self.assertEquals(context.get_l3ha(), False)
|
||||
|
||||
def test_get_dvr(self):
|
||||
self.test_config.set('enable-dvr', True)
|
||||
self.test_config.set('enable-l3ha', False)
|
||||
self.test_config.set('overlay-network-type', 'vxlan')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', True)
|
||||
self.os_release.return_value = 'juno'
|
||||
self.assertEquals(context.get_dvr(), True)
|
||||
|
||||
def test_get_dvr_explicit_off(self):
|
||||
self.test_config.set('enable-dvr', False)
|
||||
self.test_config.set('enable-l3ha', False)
|
||||
self.test_config.set('overlay-network-type', 'vxlan')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', True)
|
||||
self.os_release.return_value = 'juno'
|
||||
self.assertEquals(context.get_dvr(), False)
|
||||
|
||||
def test_get_dvr_prejuno(self):
|
||||
self.test_config.set('enable-dvr', True)
|
||||
self.test_config.set('enable-l3ha', False)
|
||||
self.test_config.set('overlay-network-type', 'vxlan')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', True)
|
||||
self.os_release.return_value = 'icehouse'
|
||||
self.assertEquals(context.get_dvr(), False)
|
||||
|
||||
def test_get_dvr_gre(self):
|
||||
self.test_config.set('enable-dvr', True)
|
||||
self.test_config.set('enable-l3ha', False)
|
||||
self.test_config.set('overlay-network-type', 'gre')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', True)
|
||||
self.os_release.return_value = 'juno'
|
||||
self.assertEquals(context.get_dvr(), False)
|
||||
|
||||
def test_get_dvr_l3ha_on(self):
|
||||
self.test_config.set('enable-dvr', True)
|
||||
self.test_config.set('enable-l3ha', True)
|
||||
self.test_config.set('overlay-network-type', 'vxlan')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', False)
|
||||
self.os_release.return_value = 'juno'
|
||||
self.assertEquals(context.get_dvr(), False)
|
||||
|
||||
def test_get_dvr_l2pop(self):
|
||||
self.test_config.set('enable-dvr', True)
|
||||
self.test_config.set('enable-l3ha', False)
|
||||
self.test_config.set('overlay-network-type', 'vxlan')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', False)
|
||||
self.os_release.return_value = 'juno'
|
||||
self.assertEquals(context.get_dvr(), False)
|
||||
|
||||
|
||||
class IdentityServiceContext(CharmTestCase):
|
||||
|
||||
def setUp(self):
|
||||
@ -157,11 +273,24 @@ class NeutronCCContextTest(CharmTestCase):
|
||||
plugin.return_value = None
|
||||
ctxt_data = {
|
||||
'debug': True,
|
||||
'enable_dvr': False,
|
||||
'l3_ha': False,
|
||||
'external_network': 'bob',
|
||||
'neutron_bind_port': self.api_port,
|
||||
'verbose': True,
|
||||
'l2_population': True,
|
||||
'overlay_network_type': 'gre',
|
||||
'quota_floatingip': 50,
|
||||
'quota_health_monitors': -1,
|
||||
'quota_member': -1,
|
||||
'quota_network': 10,
|
||||
'quota_pool': 10,
|
||||
'quota_port': 50,
|
||||
'quota_router': 10,
|
||||
'quota_security_group': 10,
|
||||
'quota_security_group_rule': 100,
|
||||
'quota_subnet': 10,
|
||||
'quota_vip': 10,
|
||||
}
|
||||
napi_ctxt = context.NeutronCCContext()
|
||||
with patch.object(napi_ctxt, '_ensure_packages'):
|
||||
@ -175,11 +304,61 @@ class NeutronCCContextTest(CharmTestCase):
|
||||
self.test_config.set('overlay-network-type', 'vxlan')
|
||||
ctxt_data = {
|
||||
'debug': True,
|
||||
'enable_dvr': False,
|
||||
'l3_ha': False,
|
||||
'external_network': 'bob',
|
||||
'neutron_bind_port': self.api_port,
|
||||
'verbose': True,
|
||||
'l2_population': True,
|
||||
'overlay_network_type': 'vxlan',
|
||||
'quota_floatingip': 50,
|
||||
'quota_health_monitors': -1,
|
||||
'quota_member': -1,
|
||||
'quota_network': 10,
|
||||
'quota_pool': 10,
|
||||
'quota_port': 50,
|
||||
'quota_router': 10,
|
||||
'quota_security_group': 10,
|
||||
'quota_security_group_rule': 100,
|
||||
'quota_subnet': 10,
|
||||
'quota_vip': 10,
|
||||
}
|
||||
napi_ctxt = context.NeutronCCContext()
|
||||
with patch.object(napi_ctxt, '_ensure_packages'):
|
||||
self.assertEquals(ctxt_data, napi_ctxt())
|
||||
|
||||
@patch.object(context.NeutronCCContext, 'network_manager')
|
||||
@patch.object(context.NeutronCCContext, 'plugin')
|
||||
@patch('__builtin__.__import__')
|
||||
def test_neutroncc_context_l3ha(self, _import, plugin, nm):
|
||||
plugin.return_value = None
|
||||
self.test_config.set('enable-l3ha', True)
|
||||
self.test_config.set('overlay-network-type', 'gre')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.test_config.set('l2-population', False)
|
||||
self.os_release.return_value = 'juno'
|
||||
ctxt_data = {
|
||||
'debug': True,
|
||||
'enable_dvr': False,
|
||||
'l3_ha': True,
|
||||
'external_network': 'bob',
|
||||
'neutron_bind_port': self.api_port,
|
||||
'verbose': True,
|
||||
'l2_population': False,
|
||||
'overlay_network_type': 'gre',
|
||||
'max_l3_agents_per_router': 2,
|
||||
'min_l3_agents_per_router': 2,
|
||||
'quota_floatingip': 50,
|
||||
'quota_health_monitors': -1,
|
||||
'quota_member': -1,
|
||||
'quota_network': 10,
|
||||
'quota_pool': 10,
|
||||
'quota_port': 50,
|
||||
'quota_router': 10,
|
||||
'quota_security_group': 10,
|
||||
'quota_security_group_rule': 100,
|
||||
'quota_subnet': 10,
|
||||
'quota_vip': 10,
|
||||
}
|
||||
napi_ctxt = context.NeutronCCContext()
|
||||
with patch.object(napi_ctxt, '_ensure_packages'):
|
||||
|
@ -33,14 +33,19 @@ TO_PATCH = [
|
||||
'determine_packages',
|
||||
'determine_ports',
|
||||
'do_openstack_upgrade',
|
||||
'dvr_router_present',
|
||||
'l3ha_router_present',
|
||||
'execd_preinstall',
|
||||
'filter_installed_packages',
|
||||
'get_dvr',
|
||||
'get_l3ha',
|
||||
'get_l2population',
|
||||
'get_overlay_network_type',
|
||||
'is_relation_made',
|
||||
'log',
|
||||
'open_port',
|
||||
'openstack_upgrade_available',
|
||||
'os_requires_version',
|
||||
'relation_get',
|
||||
'relation_ids',
|
||||
'relation_set',
|
||||
@ -49,6 +54,8 @@ TO_PATCH = [
|
||||
'get_netmask_for_address',
|
||||
'get_address_in_network',
|
||||
'update_nrpe_config',
|
||||
'service_reload',
|
||||
'IdentityServiceContext',
|
||||
'save_vsd_address_to_config',
|
||||
'update_config_file',
|
||||
]
|
||||
@ -59,6 +66,15 @@ NEUTRON_CONF = '%s/neutron.conf' % NEUTRON_CONF_DIR
|
||||
from random import randrange
|
||||
|
||||
|
||||
class DummyContext():
|
||||
|
||||
def __init__(self, return_value):
|
||||
self.return_value = return_value
|
||||
|
||||
def __call__(self):
|
||||
return self.return_value
|
||||
|
||||
|
||||
class NeutronAPIHooksTests(CharmTestCase):
|
||||
|
||||
def setUp(self):
|
||||
@ -120,6 +136,8 @@ class NeutronAPIHooksTests(CharmTestCase):
|
||||
@patch.object(hooks, 'configure_https')
|
||||
def test_config_changed(self, conf_https):
|
||||
self.openstack_upgrade_available.return_value = True
|
||||
self.dvr_router_present.return_value = False
|
||||
self.l3ha_router_present.return_value = False
|
||||
self.relation_ids.side_effect = self._fake_relids
|
||||
_n_api_rel_joined = self.patch('neutron_api_relation_joined')
|
||||
_n_plugin_api_rel_joined =\
|
||||
@ -127,12 +145,14 @@ class NeutronAPIHooksTests(CharmTestCase):
|
||||
_amqp_rel_joined = self.patch('amqp_joined')
|
||||
_id_rel_joined = self.patch('identity_joined')
|
||||
_id_cluster_joined = self.patch('cluster_joined')
|
||||
_zmq_joined = self.patch('zeromq_configuration_relation_joined')
|
||||
self._call_hook('config-changed')
|
||||
self.assertTrue(_n_api_rel_joined.called)
|
||||
self.assertTrue(_n_plugin_api_rel_joined.called)
|
||||
self.assertTrue(_amqp_rel_joined.called)
|
||||
self.assertTrue(_id_rel_joined.called)
|
||||
self.assertTrue(_id_cluster_joined.called)
|
||||
self.assertTrue(_zmq_joined.called)
|
||||
self.assertTrue(self.CONFIGS.write_all.called)
|
||||
self.assertTrue(self.do_openstack_upgrade.called)
|
||||
self.assertTrue(self.apt_install.called)
|
||||
@ -310,11 +330,119 @@ class NeutronAPIHooksTests(CharmTestCase):
|
||||
self.assertTrue(self.CONFIGS.write.called_with(NEUTRON_CONF))
|
||||
|
||||
def test_neutron_plugin_api_relation_joined_nol2(self):
|
||||
self.IdentityServiceContext.return_value = \
|
||||
DummyContext(return_value={})
|
||||
_relation_data = {
|
||||
'neutron-security-groups': False,
|
||||
'enable-dvr': False,
|
||||
'enable-l3ha': False,
|
||||
'l2-population': False,
|
||||
'overlay-network-type': 'vxlan',
|
||||
'service_protocol': None,
|
||||
'auth_protocol': None,
|
||||
'service_tenant': None,
|
||||
'service_port': None,
|
||||
'region': 'RegionOne',
|
||||
'service_password': None,
|
||||
'auth_port': None,
|
||||
'auth_host': None,
|
||||
'service_username': None,
|
||||
'service_host': None
|
||||
}
|
||||
self.get_dvr.return_value = False
|
||||
self.get_l3ha.return_value = False
|
||||
self.get_l2population.return_value = False
|
||||
self.get_overlay_network_type.return_value = 'vxlan'
|
||||
self._call_hook('neutron-plugin-api-relation-joined')
|
||||
self.relation_set.assert_called_with(
|
||||
relation_id=None,
|
||||
**_relation_data
|
||||
)
|
||||
|
||||
def test_neutron_plugin_api_relation_joined_dvr(self):
|
||||
self.IdentityServiceContext.return_value = \
|
||||
DummyContext(return_value={})
|
||||
_relation_data = {
|
||||
'neutron-security-groups': False,
|
||||
'enable-dvr': True,
|
||||
'enable-l3ha': False,
|
||||
'l2-population': True,
|
||||
'overlay-network-type': 'vxlan',
|
||||
'service_protocol': None,
|
||||
'auth_protocol': None,
|
||||
'service_tenant': None,
|
||||
'service_port': None,
|
||||
'region': 'RegionOne',
|
||||
'service_password': None,
|
||||
'auth_port': None,
|
||||
'auth_host': None,
|
||||
'service_username': None,
|
||||
'service_host': None
|
||||
}
|
||||
self.get_dvr.return_value = True
|
||||
self.get_l3ha.return_value = False
|
||||
self.get_l2population.return_value = True
|
||||
self.get_overlay_network_type.return_value = 'vxlan'
|
||||
self._call_hook('neutron-plugin-api-relation-joined')
|
||||
self.relation_set.assert_called_with(
|
||||
relation_id=None,
|
||||
**_relation_data
|
||||
)
|
||||
|
||||
def test_neutron_plugin_api_relation_joined_l3ha(self):
|
||||
self.IdentityServiceContext.return_value = \
|
||||
DummyContext(return_value={})
|
||||
_relation_data = {
|
||||
'neutron-security-groups': False,
|
||||
'enable-dvr': False,
|
||||
'enable-l3ha': True,
|
||||
'l2-population': False,
|
||||
'overlay-network-type': 'vxlan',
|
||||
'service_protocol': None,
|
||||
'auth_protocol': None,
|
||||
'service_tenant': None,
|
||||
'service_port': None,
|
||||
'region': 'RegionOne',
|
||||
'service_password': None,
|
||||
'auth_port': None,
|
||||
'auth_host': None,
|
||||
'service_username': None,
|
||||
'service_host': None
|
||||
}
|
||||
self.get_dvr.return_value = False
|
||||
self.get_l3ha.return_value = True
|
||||
self.get_l2population.return_value = False
|
||||
self.get_overlay_network_type.return_value = 'vxlan'
|
||||
self._call_hook('neutron-plugin-api-relation-joined')
|
||||
self.relation_set.assert_called_with(
|
||||
relation_id=None,
|
||||
**_relation_data
|
||||
)
|
||||
|
||||
def test_neutron_plugin_api_relation_joined_w_mtu(self):
|
||||
self.IdentityServiceContext.return_value = \
|
||||
DummyContext(return_value={})
|
||||
self.test_config.set('network-device-mtu', 1500)
|
||||
_relation_data = {
|
||||
'neutron-security-groups': False,
|
||||
'l2-population': False,
|
||||
'overlay-network-type': 'vxlan',
|
||||
'network-device-mtu': 1500,
|
||||
'enable-l3ha': True,
|
||||
'enable-dvr': True,
|
||||
'service_protocol': None,
|
||||
'auth_protocol': None,
|
||||
'service_tenant': None,
|
||||
'service_port': None,
|
||||
'region': 'RegionOne',
|
||||
'service_password': None,
|
||||
'auth_port': None,
|
||||
'auth_host': None,
|
||||
'service_username': None,
|
||||
'service_host': None
|
||||
}
|
||||
self.get_dvr.return_value = True
|
||||
self.get_l3ha.return_value = True
|
||||
self.get_l2population.return_value = False
|
||||
self.get_overlay_network_type.return_value = 'vxlan'
|
||||
self._call_hook('neutron-plugin-api-relation-joined')
|
||||
@ -455,8 +583,9 @@ class NeutronAPIHooksTests(CharmTestCase):
|
||||
self.relation_ids.side_effect = self._fake_relids
|
||||
_id_rel_joined = self.patch('identity_joined')
|
||||
hooks.configure_https()
|
||||
self.check_call.assert_called_with(['a2ensite',
|
||||
'openstack_https_frontend'])
|
||||
calls = [call('a2dissite', 'openstack_https_frontend'),
|
||||
call('service', 'apache2', 'reload')]
|
||||
self.check_call.assert_called_has_calls(calls)
|
||||
self.assertTrue(_id_rel_joined.called)
|
||||
|
||||
def test_configure_https_nohttps(self):
|
||||
@ -464,6 +593,7 @@ class NeutronAPIHooksTests(CharmTestCase):
|
||||
self.relation_ids.side_effect = self._fake_relids
|
||||
_id_rel_joined = self.patch('identity_joined')
|
||||
hooks.configure_https()
|
||||
self.check_call.assert_called_with(['a2dissite',
|
||||
'openstack_https_frontend'])
|
||||
calls = [call('a2dissite', 'openstack_https_frontend'),
|
||||
call('service', 'apache2', 'reload')]
|
||||
self.check_call.assert_called_has_calls(calls)
|
||||
self.assertTrue(_id_rel_joined.called)
|
||||
|
Loading…
x
Reference in New Issue
Block a user