Merge lp:~thomnico/charms/precise/clearwater-bono/openstack-support into lp:~matt-williams-x/charms/precise/clearwater-bono/trunk

Proposed by Nicolas Thomas
Status: Needs review
Proposed branch: lp:~thomnico/charms/precise/clearwater-bono/openstack-support
Merge into: lp:~matt-williams-x/charms/precise/clearwater-bono/trunk
Diff against target: 66 lines (+31/-12)
2 files modified
hooks/programmable-multiple-relation-changed (+2/-2)
lib/unit-get (+29/-10)
To merge this branch: bzr merge lp:~thomnico/charms/precise/clearwater-bono/openstack-support
Reviewer Review Type Date Requested Status
Matt Williams Pending
Review via email: mp+233719@code.launchpad.net

Description of the change

Adding OpenStack support

linked to : https://code.launchpad.net/~thomnico/charms/precise/dns/openstack-support

Should not impact EC2

To post a comment you must log in.
12. By Nicolas Thomas

 OpenStack support

Unmerged revisions

12. By Nicolas Thomas

 OpenStack support

11. By Nicolas Thomas

 OpenStack support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/programmable-multiple-relation-changed'
2--- hooks/programmable-multiple-relation-changed 2014-06-06 14:38:15 +0000
3+++ hooks/programmable-multiple-relation-changed 2014-09-12 15:09:17 +0000
4@@ -17,9 +17,9 @@
5 if [ "$(relation-get public-address)" != "" ]
6 then
7 echo nameserver $(relation-get public-address) > /etc/dnsmasq.resolv.conf
8- grep -v ^RESOLV_CONF= /etc/default/dnsmasq > /tmp/dnsmasq.$$
9+ grep -v ^RESOLV_CONF= /etc/default/dnsmasq > /tmp/dnsmasq.$$ || juju-log "WARNING RESOLV_CONF not found"
10 mv /tmp/dnsmasq.$$ /etc/default/dnsmasq
11- echo RESOLV_CONF=/etc/dnsmasq.resolv.conf > /etc/default/dnsmasq
12+ echo RESOLV_CONF=/etc/dnsmasq.resolv.conf >> /etc/default/dnsmasq
13 service dnsmasq restart
14 fi
15
16
17=== modified file 'lib/unit-get'
18--- lib/unit-get 2014-06-07 07:10:01 +0000
19+++ lib/unit-get 2014-09-12 15:09:17 +0000
20@@ -1,17 +1,36 @@
21 #!/bin/bash
22-set -e
23-
24+set -ex
25+onEC2=false
26 key=$1
27 val=$(unit-get $1)
28
29-if [ "$key" = "public-address" ] &&
30- [ -n "$(dig +short $val | head -1)" ]
31-then
32- val=$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
33-elif [ "$key" = "private-address" ]
34-then
35- val_ip=$(dig +short $val | head -1)
36- [ -z "$val_ip" ] || val=$val_ip
37+if [ -f $CHARM_DIR/lib/provider.txt ]
38+then
39+ PROVIDER=`cat $CHARM_DIR/lib/provider.txt `
40+else
41+ #checking dirty ec2 hack will work
42+ wget -q http://169.254.169.254/latest/meta-data/public-ipv4 && onEC2=true
43+ if ( "$onEC2" == true )
44+ then
45+ echo "EC2" > $CHARM_DIR/lib/provider.txt
46+ else
47+ echo "NOTEC2" > $CHARM_DIR/lib/provider.txt
48+ fi
49+fi
50+
51+if [ "$PROVIDER" == "EC2" ]
52+then
53+ if [ "$key" = "public-address" ] && [ -n "$(dig +short $val | head -1)" ]
54+ then
55+ val=$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
56+ elif [ "$key" = "private-address" ]
57+ then
58+ val_ip=$(dig +short $val | head -1)
59+ [ -z "$val_ip" ] || val=$val_ip
60+ ##if val_ip is empty getting the system IP
61+ [ -z "$val_ip" ] && val=`ip route | grep src | cut -d " " -f 12`
62+ fi
63 fi
64
65 echo $val
66+

Subscribers

People subscribed via source and target branches

to all changes: