Cleaned code
This commit is contained in:
commit
d9713c8c21
@ -55,3 +55,7 @@ options:
|
|||||||
default: null
|
default: null
|
||||||
type: string
|
type: string
|
||||||
description: Provide the PLUMgrid ONS License key.
|
description: Provide the PLUMgrid ONS License key.
|
||||||
|
opsvm-ip:
|
||||||
|
default: 127.0.0.1
|
||||||
|
type: string
|
||||||
|
description: IP address of the PLUMgrid Operations VM Management interface.
|
||||||
|
@ -103,5 +103,6 @@ class PGDirContext(context.NeutronContext):
|
|||||||
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'])
|
||||||
pg_ctxt['virtual_router_id'] = virtual_ip_array[3]
|
pg_ctxt['virtual_router_id'] = virtual_ip_array[3]
|
||||||
|
pg_ctxt['opsvm_ip'] = conf['opsvm-ip']
|
||||||
|
|
||||||
return pg_ctxt
|
return pg_ctxt
|
||||||
|
@ -8,12 +8,15 @@
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from charmhelpers.core.host import service_running
|
from charmhelpers.core.host import service_running
|
||||||
|
from charmhelpers.contrib.network.ip import is_ip
|
||||||
|
|
||||||
from charmhelpers.core.hookenv import (
|
from charmhelpers.core.hookenv import (
|
||||||
Hooks,
|
Hooks,
|
||||||
UnregisteredHookError,
|
UnregisteredHookError,
|
||||||
log,
|
log,
|
||||||
config,
|
config,
|
||||||
|
relation_set,
|
||||||
|
relation_ids
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
@ -64,6 +67,20 @@ def dir_joined():
|
|||||||
restart_pg()
|
restart_pg()
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.hook('plumgrid-relation-joined')
|
||||||
|
def plumgrid_joined(relation_id=None):
|
||||||
|
'''
|
||||||
|
This hook is run when relation with edge or gateway is created.
|
||||||
|
'''
|
||||||
|
opsvm_ip = config('opsvm-ip')
|
||||||
|
if opsvm_ip == '127.0.0.1':
|
||||||
|
return 1
|
||||||
|
elif not is_ip(opsvm_ip):
|
||||||
|
raise ValueError('Incorrect IP specified')
|
||||||
|
else:
|
||||||
|
relation_set(relation_id=relation_id, opsvm_ip=opsvm_ip)
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('config-changed')
|
@hooks.hook('config-changed')
|
||||||
def config_changed():
|
def config_changed():
|
||||||
'''
|
'''
|
||||||
@ -96,6 +113,10 @@ def config_changed():
|
|||||||
apt_install(pkg, options=['--force-yes'], fatal=True)
|
apt_install(pkg, options=['--force-yes'], fatal=True)
|
||||||
remove_iovisor()
|
remove_iovisor()
|
||||||
load_iovisor()
|
load_iovisor()
|
||||||
|
if charm_config.changed('opsvm-ip'):
|
||||||
|
for rid in relation_ids('plumgrid'):
|
||||||
|
plumgrid_joined(rid)
|
||||||
|
stop_pg()
|
||||||
ensure_mtu()
|
ensure_mtu()
|
||||||
CONFIGS.write_all()
|
CONFIGS.write_all()
|
||||||
if not service_running('plumgrid'):
|
if not service_running('plumgrid'):
|
||||||
@ -121,8 +142,9 @@ def upgrade_charm():
|
|||||||
'''
|
'''
|
||||||
This hook is run when the charm is upgraded
|
This hook is run when the charm is upgraded
|
||||||
'''
|
'''
|
||||||
load_iptables()
|
ensure_mtu()
|
||||||
CONFIGS.write_all()
|
CONFIGS.write_all()
|
||||||
|
restart_pg()
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('stop')
|
@hooks.hook('stop')
|
||||||
|
@ -50,6 +50,7 @@ PG_DEF_CONF = '%s/conf/pg/nginx.conf' % PG_LXC_DATA_PATH
|
|||||||
PG_HN_CONF = '%s/conf/etc/hostname' % PG_LXC_DATA_PATH
|
PG_HN_CONF = '%s/conf/etc/hostname' % PG_LXC_DATA_PATH
|
||||||
PG_HS_CONF = '%s/conf/etc/hosts' % PG_LXC_DATA_PATH
|
PG_HS_CONF = '%s/conf/etc/hosts' % PG_LXC_DATA_PATH
|
||||||
PG_IFCS_CONF = '%s/conf/pg/ifcs.conf' % PG_LXC_DATA_PATH
|
PG_IFCS_CONF = '%s/conf/pg/ifcs.conf' % PG_LXC_DATA_PATH
|
||||||
|
OPS_CONF = '%s/conf/etc/00-pg.conf' % PG_LXC_DATA_PATH
|
||||||
AUTH_KEY_PATH = '%s/root/.ssh/authorized_keys' % PG_LXC_DATA_PATH
|
AUTH_KEY_PATH = '%s/root/.ssh/authorized_keys' % PG_LXC_DATA_PATH
|
||||||
TEMP_LICENSE_FILE = '/tmp/license'
|
TEMP_LICENSE_FILE = '/tmp/license'
|
||||||
|
|
||||||
@ -74,6 +75,10 @@ BASE_RESOURCE_MAP = OrderedDict([
|
|||||||
'services': ['plumgrid'],
|
'services': ['plumgrid'],
|
||||||
'contexts': [pg_dir_context.PGDirContext()],
|
'contexts': [pg_dir_context.PGDirContext()],
|
||||||
}),
|
}),
|
||||||
|
(OPS_CONF, {
|
||||||
|
'services': ['plumgrid'],
|
||||||
|
'contexts': [pg_dir_context.PGDirContext()],
|
||||||
|
}),
|
||||||
(PG_IFCS_CONF, {
|
(PG_IFCS_CONF, {
|
||||||
'services': [],
|
'services': [],
|
||||||
'contexts': [pg_dir_context.PGDirContext()],
|
'contexts': [pg_dir_context.PGDirContext()],
|
||||||
|
1
hooks/plumgrid-relation-joined
Symbolic link
1
hooks/plumgrid-relation-joined
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
pg_dir_hooks.py
|
1
templates/kilo/00-pg.conf
Normal file
1
templates/kilo/00-pg.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
$template ls_json,"{{'{'}}{{'%'}}timestamp:::date-rfc3339,jsonf:@timestamp%,%source:::jsonf:@source_host%,%msg:::json%}":syslogtag,isequal,"pg:" @{{ opsvm_ip }}:6000;ls_json
|
@ -13,7 +13,7 @@ upstream pgCli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
upstream pgMW {
|
upstream pgMW {
|
||||||
server 127.0.0.1:4000;
|
server {{ opsvm_ip }}:4000;
|
||||||
}
|
}
|
||||||
|
|
||||||
map $http_upgrade $connection_upgrade {
|
map $http_upgrade $connection_upgrade {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user