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

Subscribers

People subscribed via source and target branches

to all changes: