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 deploy plumgrid-director
|
||||||
|
|
||||||
juju add-relation neutron-api neutron-api-plumgrid
|
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.
|
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,
|
config,
|
||||||
unit_get,
|
unit_get,
|
||||||
)
|
)
|
||||||
|
from charmhelpers.core.hookenv import (
|
||||||
|
relation_ids,
|
||||||
|
related_units,
|
||||||
|
relation_get,
|
||||||
|
)
|
||||||
from charmhelpers.contrib.openstack import context
|
from charmhelpers.contrib.openstack import context
|
||||||
from charmhelpers.contrib.openstack.utils import get_host_ip
|
from charmhelpers.contrib.openstack.utils import get_host_ip
|
||||||
from charmhelpers.contrib.network.ip import get_address_in_network
|
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
|
import re
|
||||||
from socket import gethostname as get_unit_hostname
|
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):
|
class PGDirContext(context.NeutronContext):
|
||||||
|
|
||||||
@ -48,12 +63,24 @@ class PGDirContext(context.NeutronContext):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
conf = config()
|
conf = config()
|
||||||
pg_ctxt['local_ip'] = \
|
pg_dir_ips =_pg_dir_ips()
|
||||||
get_address_in_network(network=None,
|
pg_dir_ips.append(str(get_address_in_network(network=None,
|
||||||
fallback=get_host_ip(unit_get('private-address')))
|
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['virtual_ip'] = conf['plumgrid-virtual-ip']
|
||||||
pg_ctxt['pg_hostname'] = "pg-director"
|
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['label'] = get_unit_hostname()
|
||||||
pg_ctxt['fabric_mode'] = 'host'
|
pg_ctxt['fabric_mode'] = 'host'
|
||||||
virtual_ip_array = re.split('\.', conf['plumgrid-virtual-ip'])
|
virtual_ip_array = re.split('\.', conf['plumgrid-virtual-ip'])
|
||||||
|
@ -50,6 +50,24 @@ def install():
|
|||||||
add_lcm_key()
|
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')
|
@hooks.hook('config-changed')
|
||||||
def config_changed():
|
def config_changed():
|
||||||
'''
|
'''
|
||||||
|
@ -23,6 +23,7 @@ import pg_dir_context
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
LXC_CONF = '/etc/libvirt/lxc.conf'
|
LXC_CONF = '/etc/libvirt/lxc.conf'
|
||||||
TEMPLATES = 'templates/'
|
TEMPLATES = 'templates/'
|
||||||
@ -143,6 +144,20 @@ def remove_iovisor():
|
|||||||
'''
|
'''
|
||||||
_exec_cmd(cmd=['rmmod', 'iovisor'], error_msg='Error Loading IOVisor Kernel Module')
|
_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():
|
def ensure_mtu():
|
||||||
'''
|
'''
|
||||||
@ -150,12 +165,14 @@ def ensure_mtu():
|
|||||||
'''
|
'''
|
||||||
log("Changing MTU of juju-br0 and all attached interfaces")
|
log("Changing MTU of juju-br0 and all attached interfaces")
|
||||||
interface_mtu = config('network-device-mtu')
|
interface_mtu = config('network-device-mtu')
|
||||||
cmd = subprocess.check_output(["brctl", "show", "juju-br0"])
|
interface_type = check_interface_type()
|
||||||
|
if interface_type == "juju-br0":
|
||||||
|
cmd = subprocess.check_output(["brctl", "show", interface_type])
|
||||||
words = cmd.split()
|
words = cmd.split()
|
||||||
for word in words:
|
for word in words:
|
||||||
if 'eth' in word:
|
if 'eth' in word:
|
||||||
set_nic_mtu(word, interface_mtu)
|
set_nic_mtu(word, interface_mtu)
|
||||||
set_nic_mtu('juju-br0', interface_mtu)
|
set_nic_mtu(interface_type, interface_mtu)
|
||||||
|
|
||||||
|
|
||||||
def _exec_cmd(cmd=None, error_msg='Command exited with ERRORs', fatal=False):
|
def _exec_cmd(cmd=None, error_msg='Command exited with ERRORs', fatal=False):
|
||||||
|
@ -15,3 +15,7 @@ requires:
|
|||||||
provides:
|
provides:
|
||||||
plumgrid:
|
plumgrid:
|
||||||
interface: plumgrid
|
interface: plumgrid
|
||||||
|
peers:
|
||||||
|
director:
|
||||||
|
interface: director
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@ lua_shared_dict apache_servers 16K;
|
|||||||
lua_shared_dict tc_servers 16K;
|
lua_shared_dict tc_servers 16K;
|
||||||
init_by_lua 'lb = require "lb"
|
init_by_lua 'lb = require "lb"
|
||||||
init_servers = {
|
init_servers = {
|
||||||
["{{ local_ip }}"] = true,
|
{% for ip in director_ips -%}
|
||||||
|
["{{ ip }}"] = true,
|
||||||
|
{% endfor -%}
|
||||||
}';
|
}';
|
||||||
|
|
||||||
# Redirect http to https
|
# Redirect http to https
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
plumgrid_ip={{ local_ip }}
|
plumgrid_ip={{ director_ips_string }}
|
||||||
plumgrid_port=8001
|
plumgrid_port=8001
|
||||||
mgmt_dev={{ interface }}
|
mgmt_dev={{ interface }}
|
||||||
label={{ label}}
|
label={{ label}}
|
||||||
|
Loading…
Reference in New Issue
Block a user