Added HA coverage
This commit is contained in:
parent
1dfdd5098a
commit
8ecd96dfc4
@ -11,6 +11,7 @@ Step by step instructions on using the charm:
|
||||
juju deploy plumgrid-director
|
||||
|
||||
juju add-relation neutron-api neutron-api-plumgrid
|
||||
juju add-relation neutron-api-plumgrid plumgrid-director
|
||||
|
||||
For plumgrid-director to work make the configuration in the neutron-api and neutron-api-plumgrid charms as specified in the configuration section below.
|
||||
|
||||
|
1
hooks/director-relation-joined
Symbolic link
1
hooks/director-relation-joined
Symbolic link
@ -0,0 +1 @@
|
||||
pg_dir_hooks.py
|
@ -6,6 +6,11 @@ from charmhelpers.core.hookenv import (
|
||||
config,
|
||||
unit_get,
|
||||
)
|
||||
from charmhelpers.core.hookenv import (
|
||||
relation_ids,
|
||||
related_units,
|
||||
relation_get,
|
||||
)
|
||||
from charmhelpers.contrib.openstack import context
|
||||
from charmhelpers.contrib.openstack.utils import get_host_ip
|
||||
from charmhelpers.contrib.network.ip import get_address_in_network
|
||||
@ -13,6 +18,16 @@ from charmhelpers.contrib.network.ip import get_address_in_network
|
||||
import re
|
||||
from socket import gethostname as get_unit_hostname
|
||||
|
||||
def _pg_dir_ips():
|
||||
'''
|
||||
Inspects plumgrid-director peer relation and returns the ips of the peer directors
|
||||
'''
|
||||
pg_dir_ips = []
|
||||
for rid in relation_ids('director'):
|
||||
for unit in related_units(rid):
|
||||
rdata = relation_get(rid=rid, unit=unit)
|
||||
pg_dir_ips.append(rdata['private-address'])
|
||||
return pg_dir_ips
|
||||
|
||||
class PGDirContext(context.NeutronContext):
|
||||
|
||||
@ -48,12 +63,24 @@ class PGDirContext(context.NeutronContext):
|
||||
return {}
|
||||
|
||||
conf = config()
|
||||
pg_ctxt['local_ip'] = \
|
||||
get_address_in_network(network=None,
|
||||
fallback=get_host_ip(unit_get('private-address')))
|
||||
pg_dir_ips =_pg_dir_ips()
|
||||
pg_dir_ips.append(str(get_address_in_network(network=None,
|
||||
fallback=get_host_ip(unit_get('private-address')))))
|
||||
pg_ctxt['director_ips'] = pg_dir_ips
|
||||
pg_dir_ips_string = ''
|
||||
single_ip = True
|
||||
for ip in pg_dir_ips:
|
||||
if single_ip:
|
||||
pg_dir_ips_string = str(ip)
|
||||
single_ip = False
|
||||
else:
|
||||
pg_dir_ips_string = pg_dir_ips_string + ',' + str(ip)
|
||||
pg_ctxt['director_ips_string'] = pg_dir_ips_string
|
||||
pg_ctxt['virtual_ip'] = conf['plumgrid-virtual-ip']
|
||||
pg_ctxt['pg_hostname'] = "pg-director"
|
||||
pg_ctxt['interface'] = "juju-br0"
|
||||
from pg_dir_utils import check_interface_type
|
||||
interface_type = check_interface_type()
|
||||
pg_ctxt['interface'] = interface_type
|
||||
pg_ctxt['label'] = get_unit_hostname()
|
||||
pg_ctxt['fabric_mode'] = 'host'
|
||||
virtual_ip_array = re.split('\.', conf['plumgrid-virtual-ip'])
|
||||
|
@ -50,6 +50,24 @@ def install():
|
||||
add_lcm_key()
|
||||
|
||||
|
||||
@hooks.hook('plumgrid-plugin-relation-joined')
|
||||
def plumgrid_dir():
|
||||
'''
|
||||
This hook is run when relation between neutron-api-plumgrid
|
||||
and plumgrid-director is made.
|
||||
'''
|
||||
ensure_mtu()
|
||||
ensure_files()
|
||||
add_lcm_key()
|
||||
CONFIGS.write_all()
|
||||
restart_pg()
|
||||
|
||||
@hooks.hook('director-relation-joined')
|
||||
def dir_joined():
|
||||
ensure_files()
|
||||
CONFIGS.write_all()
|
||||
restart_pg()
|
||||
|
||||
@hooks.hook('config-changed')
|
||||
def config_changed():
|
||||
'''
|
||||
|
@ -23,6 +23,7 @@ import pg_dir_context
|
||||
import subprocess
|
||||
import time
|
||||
import os
|
||||
import re
|
||||
|
||||
LXC_CONF = '/etc/libvirt/lxc.conf'
|
||||
TEMPLATES = 'templates/'
|
||||
@ -143,6 +144,20 @@ def remove_iovisor():
|
||||
'''
|
||||
_exec_cmd(cmd=['rmmod', 'iovisor'], error_msg='Error Loading IOVisor Kernel Module')
|
||||
|
||||
def check_interface_type():
|
||||
'''
|
||||
Checks the interface. Support added for AWS deployments. There are 2
|
||||
possible interfaces "juju-br0" and "eth0". The default being juju-br0
|
||||
'''
|
||||
log("Checking Interface Type")
|
||||
default_interface = "juju-br0"
|
||||
AWS_interface = "eth0"
|
||||
shell_output = subprocess.check_output(['brctl','show','juju-br0'])
|
||||
output = re.split(' |\n|\t',shell_output)
|
||||
if output[10] == '':
|
||||
return AWS_interface
|
||||
else:
|
||||
return default_interface
|
||||
|
||||
def ensure_mtu():
|
||||
'''
|
||||
@ -150,12 +165,14 @@ def ensure_mtu():
|
||||
'''
|
||||
log("Changing MTU of juju-br0 and all attached interfaces")
|
||||
interface_mtu = config('network-device-mtu')
|
||||
cmd = subprocess.check_output(["brctl", "show", "juju-br0"])
|
||||
words = cmd.split()
|
||||
for word in words:
|
||||
if 'eth' in word:
|
||||
set_nic_mtu(word, interface_mtu)
|
||||
set_nic_mtu('juju-br0', interface_mtu)
|
||||
interface_type = check_interface_type()
|
||||
if interface_type == "juju-br0":
|
||||
cmd = subprocess.check_output(["brctl", "show", interface_type])
|
||||
words = cmd.split()
|
||||
for word in words:
|
||||
if 'eth' in word:
|
||||
set_nic_mtu(word, interface_mtu)
|
||||
set_nic_mtu(interface_type, interface_mtu)
|
||||
|
||||
|
||||
def _exec_cmd(cmd=None, error_msg='Command exited with ERRORs', fatal=False):
|
||||
|
@ -15,3 +15,7 @@ requires:
|
||||
provides:
|
||||
plumgrid:
|
||||
interface: plumgrid
|
||||
peers:
|
||||
director:
|
||||
interface: director
|
||||
|
||||
|
@ -24,7 +24,9 @@ lua_shared_dict apache_servers 16K;
|
||||
lua_shared_dict tc_servers 16K;
|
||||
init_by_lua 'lb = require "lb"
|
||||
init_servers = {
|
||||
["{{ local_ip }}"] = true,
|
||||
{% for ip in director_ips -%}
|
||||
["{{ ip }}"] = true,
|
||||
{% endfor -%}
|
||||
}';
|
||||
|
||||
# Redirect http to https
|
||||
|
@ -1,4 +1,4 @@
|
||||
plumgrid_ip={{ local_ip }}
|
||||
plumgrid_ip={{ director_ips_string }}
|
||||
plumgrid_port=8001
|
||||
mgmt_dev={{ interface }}
|
||||
label={{ label}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user