From 2ba52039fafac9a0cb804c2ac235bab4e9d75a7e Mon Sep 17 00:00:00 2001 From: Bilal Baqar Date: Thu, 24 Mar 2016 05:33:25 -0700 Subject: [PATCH] First commit-mw --- config.yaml | 6 +++++- hooks/pg_dir_context.py | 1 + hooks/pg_dir_hooks.py | 20 ++++++++++++++++++++ hooks/pg_dir_utils.py | 5 +++++ templates/kilo/00-pg.conf | 1 + templates/kilo/nginx.conf | 2 +- 6 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 templates/kilo/00-pg.conf diff --git a/config.yaml b/config.yaml index c450253..7782791 100644 --- a/config.yaml +++ b/config.yaml @@ -25,7 +25,7 @@ options: type: string description: | Interfaces that will provide fabric connectivity on the director nodes. - Provided in form of json in a string. These interfaces have to be connected + Provided in form of json in a string. These interfaces have to be connected to the os-data-network specified in the config. Default value is MANAGEMENT which will configure the management interface as the fabric interface on each director. @@ -55,3 +55,7 @@ options: default: null type: string 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. diff --git a/hooks/pg_dir_context.py b/hooks/pg_dir_context.py index 3ca7b46..f509684 100644 --- a/hooks/pg_dir_context.py +++ b/hooks/pg_dir_context.py @@ -95,5 +95,6 @@ class PGDirContext(context.NeutronContext): pg_ctxt['fabric_mode'] = 'host' virtual_ip_array = re.split('\.', conf['plumgrid-virtual-ip']) pg_ctxt['virtual_router_id'] = virtual_ip_array[3] + pg_ctxt['opsvm_ip'] = conf['opsvm-ip'] return pg_ctxt diff --git a/hooks/pg_dir_hooks.py b/hooks/pg_dir_hooks.py index 51ec5ca..b59941c 100755 --- a/hooks/pg_dir_hooks.py +++ b/hooks/pg_dir_hooks.py @@ -7,6 +7,7 @@ import sys import time +from charmhelpers.contrib.network.ip import is_ip from charmhelpers.core.hookenv import ( Hooks, @@ -63,6 +64,23 @@ def dir_joined(): 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 = onfig('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}) + #rel_data = { + # 'opsvm-ip': opsvm-ip, + #} + + @hooks.hook('config-changed') def config_changed(): ''' @@ -92,6 +110,8 @@ def config_changed(): apt_install(pkg, options=['--force-yes'], fatal=True) remove_iovisor() load_iovisor() + for rid in relation_ids('plumgrid'): + neutron_plugin_joined(rid) ensure_mtu() add_lcm_key() CONFIGS.write_all() diff --git a/hooks/pg_dir_utils.py b/hooks/pg_dir_utils.py index c580d85..304a08c 100644 --- a/hooks/pg_dir_utils.py +++ b/hooks/pg_dir_utils.py @@ -49,6 +49,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_HS_CONF = '%s/conf/etc/hosts' % 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 TEMP_LICENSE_FILE = '/tmp/license' @@ -73,6 +74,10 @@ BASE_RESOURCE_MAP = OrderedDict([ 'services': ['plumgrid'], 'contexts': [pg_dir_context.PGDirContext()], }), + (OPS_CONF, { + 'services': ['plumgrid'], + 'contexts': [pg_dir_context.PGDirContext()], + }), (PG_IFCS_CONF, { 'services': [], 'contexts': [pg_dir_context.PGDirContext()], diff --git a/templates/kilo/00-pg.conf b/templates/kilo/00-pg.conf new file mode 100644 index 0000000..c5a6016 --- /dev/null +++ b/templates/kilo/00-pg.conf @@ -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 diff --git a/templates/kilo/nginx.conf b/templates/kilo/nginx.conf index 00f58f1..7f5c51b 100644 --- a/templates/kilo/nginx.conf +++ b/templates/kilo/nginx.conf @@ -13,7 +13,7 @@ upstream pgCli { } upstream pgMW { - server 127.0.0.1:4000; + server {{ opsvm_ip }}:4000; } map $http_upgrade $connection_upgrade {