Merge lp:~mbruzek/charms/trusty/nuage-vrsg/network-config into lp:~alai/charms/trusty/nuage-vrsg/network-config

Proposed by Matt Bruzek
Status: Merged
Approved by: Ashley Lai
Approved revision: 51
Merged at revision: 51
Proposed branch: lp:~mbruzek/charms/trusty/nuage-vrsg/network-config
Merge into: lp:~alai/charms/trusty/nuage-vrsg/network-config
Diff against target: 174 lines (+41/-90)
3 files modified
hooks/hooks.py (+40/-1)
hooks/network-config-relation-changed (+0/-86)
metadata.yaml (+1/-3)
To merge this branch: bzr merge lp:~mbruzek/charms/trusty/nuage-vrsg/network-config
Reviewer Review Type Date Requested Status
Ashley Lai Approve
Review via email: mp+295347@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Matt Bruzek (mbruzek) wrote :

Here is the proposed changes for running the network configuration that you asked me about.

Revision history for this message
Ashley Lai (alai) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2016-05-19 18:49:55 +0000
+++ hooks/hooks.py 2016-05-20 17:29:37 +0000
@@ -2,6 +2,7 @@
2# vim: set et ts=4:2# vim: set et ts=4:
33
4import sys4import sys
5import subprocess
56
6from helper_functions import (7from helper_functions import (
7 config_value_changed,8 config_value_changed,
@@ -18,6 +19,7 @@
18 log,19 log,
19 ERROR,20 ERROR,
20 Hooks,21 Hooks,
22 unit_get,
21 UnregisteredHookError,23 UnregisteredHookError,
22 relation_get,24 relation_get,
23 status_set,25 status_set,
@@ -110,7 +112,44 @@
110 # Configure access port112 # Configure access port
111 configure_access_port()113 configure_access_port()
112 status_set('active', 'configured access port')114 status_set('active', 'configured access port')
113 115
116 # Check if any of the network configuration parameters have changed.
117 if (config_value_changed('gateway-port-name') or
118 config_value_changed('vlan-id') or
119 config_value_changed('vsd-vm-ip-address') or
120 config_value_chagned('uplink-subnet') or
121 config_value_changed('uplink-netmask') or
122 config_value_changed('uplink-gateway-ip') or
123 config_value_changed('uplink-ip') or
124 config_value_changed('uplink-intf-mac') or
125 config_value_changed('fip-id')):
126 # The network configuration parameters have changed, run the script.
127 private_address = unit_get('private-address')
128 gateway_port_name = config('gateway-port-name')
129 vlan_id = config('vlan-id')
130 vsd_ip = config('vsd-vm-ip-address')
131 uplink_subnet = config('uplink-subnet')
132 uplink_netmask = config('uplink-netmask')
133 uplink_gateway_ip = config('uplink-gateway-ip')
134 uplink_ip = config('uplink-ip')
135 uplink_intf_mac = config('uplink-intf-mac')
136 fip_id = config('fip-id')
137 # Ensure all variables are not None.
138 if (gateway_port_name and vlan_id and vsd_ip and uplink_netmask and
139 uplink_gateway_ip and uplink_ip and uplink_intf_mac and fpid):
140 # Pass the config values to the script.
141 command = ['configure-network.sh', private_address, gateway_port_name,
142 vlan_id, uplink_subnet, uplink_netmask, uplink_gateway_ip,
143 uplink_ip, uplink_intf_mac, fip_id]
144 subprocess.check_call(command)
145 string = '[GATEWAY]\n'
146 string += 'gateway_ip = {0}\n'.format(gateway_ip)
147
148 with open('/opt/nuage_fip_gateway.ini', 'w') as stream:
149 stream.write(string)
150
151 subprocess.check_call(['mytest'])
152
114153
115@hooks.hook('vrsg-controller-service-relation-changed')154@hooks.hook('vrsg-controller-service-relation-changed')
116def vrsg_controller_changed(relation_id=None, remote_unit=None):155def vrsg_controller_changed(relation_id=None, remote_unit=None):
117156
=== removed file 'hooks/network-config-relation-changed'
--- hooks/network-config-relation-changed 2016-05-20 13:47:47 +0000
+++ hooks/network-config-relation-changed 1970-01-01 00:00:00 +0000
@@ -1,86 +0,0 @@
1#!/bin/bash
2
3set -e
4set -x
5
6gateway_ip1=`unit-get private-address`
7echo "gateway_ip1=$gateway_ip1 "
8gateway_ip=`nslookup $gateway_ip1 | awk '/^Address: / { print $2 ; exit }'`
9echo "gateway_ip=$gateway_ip "
10test=$(nslookup $(unit-get private-address) | awk '/^Address: / { print $2 ; exit }')
11echo "test=$test "
12gateway_port_name=`config-get gateway-port-name`
13vlan_id=`config-get vlan-id`
14vsd_ip=`relation-get vsd-vm-ip-address`
15uplink_subnet=`config-get uplink-subnet`
16uplink_netmask=`config-get uplink-netmask`
17uplink_gateway_ip=`config-get uplink-gateway-ip`
18uplink_ip=`config-get uplink-ip`
19uplink_intf_mac=`config-get uplink-intf-mac`
20fip_id=`config-get fip-id`
21
22if [ -z "$gateway_ip" ]; then
23 echo "gateway_ip is not set"
24 exit 0
25fi
26
27if [ -z "$gateway_port_name" ]; then
28 echo "gateway_port_name is not set"
29 exit 0
30fi
31
32if [ -z "$vlan_id" ]; then
33 echo "vlan_id is not set"
34 exit 0
35fi
36
37if [ -z "$vsd_ip" ]; then
38 echo "vsd_ip is not set"
39 exit 0
40fi
41
42if [ -z "$uplink_subnet" ]; then
43 echo "uplink_subnet is not set"
44 exit 0
45fi
46
47if [ -z "$uplink_netmask" ]; then
48 echo "uplink_netmask is not set"
49 exit 0
50fi
51
52if [ -z "$uplink_gateway_ip" ]; then
53 echo "uplink_gateway_ip is not set"
54 exit 0
55fi
56
57if [ -z "$uplink_ip" ]; then
58 echo "uplink_ip is not set"
59 exit 0
60fi
61
62if [ -z "$uplink_intf_mac" ]; then
63 echo "uplink_intf_mac is not set"
64 exit 0
65fi
66
67if [ -z "$fip_id" ]; then
68 echo "fip_id is not set"
69 exit 0
70fi
71
72cat << EOF > /opt/nuage_fip_gateway.ini
73[GATEWAY]
74gateway_ip = $gateway_ip
75gateway_port_name = $gateway_port_name
76vlan_id = $vlan_id
77vsd_ip = $vsd_ip
78uplink_subnet = $uplink_subnet
79uplink_netmask = $uplink_netmask
80uplink_gateway_ip = $uplink_gateway_ip
81uplink_ip = $uplink_ip
82uplink_intf_mac = $uplink_intf_mac
83fip_id = $fip_id
84EOF
85
86./mytest
870
=== modified file 'metadata.yaml'
--- metadata.yaml 2016-05-19 00:41:01 +0000
+++ metadata.yaml 2016-05-20 17:29:37 +0000
@@ -8,12 +8,10 @@
8 Nuage VRS-G provides a highly flexible, high performance, secure network8 Nuage VRS-G provides a highly flexible, high performance, secure network
9 virtualization solution for data centers.9 virtualization solution for data centers.
10 .10 .
11 This charm is used to configure a gateway 11 This charm is used to configure a gateway
12requires:12requires:
13 vrsg-controller-service:13 vrsg-controller-service:
14 interface: nuage-vrsg-control14 interface: nuage-vrsg-control
15 vsd-rest-api:15 vsd-rest-api:
16 interface: vsd-rest-api16 interface: vsd-rest-api
17 scope: global17 scope: global
18 network-config:
19 interface: nuage-network-config

Subscribers

People subscribed via source and target branches

to all changes: