Skip to content

Commit 07c2f6c

Browse files
author
Chiradeep Vittal
committed
differentiate between dhcp server and elb vm
1 parent e1c5d4e commit 07c2f6c

7 files changed

Lines changed: 249 additions & 95 deletions

File tree

‎patches/systemvm/debian/config/root/loadbalancer.sh‎

Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,42 @@ usage() {
3232

3333
# set -x
3434

35-
# check if gateway domain is up and running
36-
check_gw() {
37-
ping -c 1 -n -q $1 > /dev/null
38-
if [ $? -gt 0 ]
35+
# ensure that the nic has the public ip we are load balancing on
36+
ip_entry() {
37+
local added=$1
38+
local removed=$2
39+
40+
if [ "$added" == "none" ]
3941
then
40-
sleep 1
41-
ping -c 1 -n -q $1 > /dev/null
42+
added=""
4243
fi
43-
return $?;
44+
45+
if [ "$removed" == "none" ]
46+
then
47+
removed=""
48+
fi
49+
50+
local a=$(echo $added | cut -d, -f1- --output-delimiter=" ")
51+
local r=$(echo $removed | cut -d, -f1- --output-delimiter=" ")
52+
53+
for i in $a
54+
do
55+
local pubIp=$(echo $i | cut -d: -f1)
56+
for vif in $VIF_LIST; do
57+
ip addr add dev $vif $pubIp/32
58+
#ignore error since it is because the ip is already there
59+
done
60+
done
61+
62+
for i in $r
63+
do
64+
local pubIp=$(echo $i | cut -d: -f1)
65+
for vif in $VIF_LIST; do
66+
ip addr del $pubIp/32 dev $vif
67+
done
68+
done
69+
70+
return 0
4471
}
4572

4673
# firewall entry to ensure that haproxy can receive on specified port
@@ -117,6 +144,10 @@ get_vif_list() {
117144
vif_list="$vif_list $vif";
118145
fi
119146
done
147+
if [ "$vif_list" == "" ]
148+
then
149+
vif_list="eth0"
150+
fi
120151

121152
echo $vif_list
122153
}
@@ -148,17 +179,19 @@ do
148179
esac
149180
done
150181

151-
VIF_LIST=$(get_vif_list)
152-
153-
# hot reconfigure haproxy
154-
reconfig_lb $cfgfile
182+
if [ "$addedIps" == "" ]
183+
then
184+
addedIps="none"
185+
fi
155186

156-
if [ $? -gt 0 ]
187+
if [ "$removedIps" == "" ]
157188
then
158-
printf "Reconfiguring loadbalancer failed\n"
159-
exit 1
189+
removedIps="none"
160190
fi
161191

192+
VIF_LIST=$(get_vif_list)
193+
194+
162195
if [ "$addedIps" == "" ]
163196
then
164197
addedIps="none"
@@ -169,6 +202,27 @@ then
169202
removedIps="none"
170203
fi
171204

205+
#FIXME: make this explicit via check on vm type or passed in flag
206+
if [ "$VIF_LIST" == "eth0" ]
207+
then
208+
ip_entry $addedIps $removedIps
209+
fi
210+
211+
212+
# hot reconfigure haproxy
213+
reconfig_lb $cfgfile
214+
215+
if [ $? -gt 0 ]
216+
then
217+
printf "Reconfiguring loadbalancer failed\n"
218+
#FIXME: make this explicit via check on vm type or passed in flag
219+
if [ "$VIF_LIST" == "eth0" ]
220+
then
221+
ip_entry $removedIps $addedIps
222+
fi
223+
exit 1
224+
fi
225+
172226
# iptables entry to ensure that haproxy receives traffic
173227
fw_entry $addedIps $removedIps
174228

@@ -180,6 +234,12 @@ then
180234
# Revert iptables rules on DomR, with addedIps and removedIps swapped
181235
fw_entry $removedIps $addedIps
182236

237+
#FIXME: make this explicit via check on vm type or passed in flag
238+
if [ "$VIF_LIST" == "eth0" ]
239+
then
240+
ip_entry $removedIps $addedIps
241+
fi
242+
183243
exit 1
184244
fi
185245

‎server/src/com/cloud/network/lb/ElasticLoadBalancerManager.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@
2323
import com.cloud.exception.InsufficientCapacityException;
2424
import com.cloud.exception.ResourceUnavailableException;
2525
import com.cloud.network.Network;
26+
import com.cloud.network.NetworkVO;
2627
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
2728
import com.cloud.network.rules.FirewallRule;
29+
import com.cloud.network.rules.LoadBalancer;
2830
import com.cloud.user.Account;
2931

3032
public interface ElasticLoadBalancerManager {
3133
public static final int DEFAULT_ELB_VM_RAMSIZE = 512; // 512 MB
3234
public static final int DEFAULT_ELB_VM_CPU_MHZ = 500; // 500 MHz
33-
public long deployLoadBalancerVM(Long networkId, Long accountId);
3435

3536
public boolean applyLoadBalancerRules(Network network,
3637
List<? extends FirewallRule> rules)
37-
throws ResourceUnavailableException;;
38+
throws ResourceUnavailableException;
39+
40+
public void handleCreateLoadBalancerRule(LoadBalancer lb, Account caller);
3841

3942
}

0 commit comments

Comments
 (0)