Added HA coverage
This commit is contained in:
parent
161417c062
commit
88abf130b7
@ -17,17 +17,12 @@ def _pg_dir_settings():
|
||||
'''
|
||||
Inspects relation with PLUMgrid director.
|
||||
'''
|
||||
pg_settings = {
|
||||
'pg_dir_ip': '192.168.100.201',
|
||||
}
|
||||
director_ips=[]
|
||||
for rid in relation_ids('plumgrid'):
|
||||
for unit in related_units(rid):
|
||||
rdata = relation_get(rid=rid, unit=unit)
|
||||
pg_settings = {
|
||||
'pg_dir_ip': rdata['private-address'],
|
||||
}
|
||||
return pg_settings
|
||||
|
||||
director_ips.append(str(rdata['private-address']))
|
||||
return director_ips
|
||||
|
||||
class PGGwContext(context.NeutronContext):
|
||||
|
||||
@ -63,12 +58,21 @@ class PGGwContext(context.NeutronContext):
|
||||
return {}
|
||||
|
||||
conf = config()
|
||||
pg_dir_ips = ''
|
||||
pg_dir_settings = _pg_dir_settings()
|
||||
pg_ctxt['local_ip'] = pg_dir_settings['pg_dir_ip']
|
||||
|
||||
single_ip = True
|
||||
for ip in pg_dir_settings:
|
||||
if single_ip:
|
||||
pg_dir_ips=str(ip)
|
||||
single_ip = False
|
||||
else:
|
||||
pg_dir_ips= pg_dir_ips + ',' + str(ip)
|
||||
pg_ctxt['local_ip'] = pg_dir_ips
|
||||
unit_hostname = get_unit_hostname()
|
||||
pg_ctxt['pg_hostname'] = unit_hostname
|
||||
pg_ctxt['interface'] = "juju-br0"
|
||||
from pg_gw_utils import check_interface_type
|
||||
interface_type = check_interface_type()
|
||||
pg_ctxt['interface'] = interface_type
|
||||
pg_ctxt['label'] = unit_hostname
|
||||
pg_ctxt['fabric_mode'] = 'host'
|
||||
|
||||
|
@ -24,6 +24,7 @@ import pg_gw_context
|
||||
import subprocess
|
||||
import time
|
||||
import os
|
||||
import re
|
||||
|
||||
LXC_CONF = "/etc/libvirt/lxc.conf"
|
||||
TEMPLATES = 'templates/'
|
||||
@ -134,6 +135,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():
|
||||
'''
|
||||
@ -141,12 +156,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):
|
||||
|
Loading…
Reference in New Issue
Block a user