bug 6909: get the logic of removing ips from the second vif right

status 6909: resolved fixed
This commit is contained in:
Chiradeep Vittal 2010-11-02 17:48:45 -07:00
parent a907c1d09f
commit fe9a8c5aeb
2 changed files with 30 additions and 9 deletions

View File

@ -106,11 +106,32 @@ remove_an_ip () {
local pubIp=$2
local ipNoMask=$(echo $2 | awk -F'/' '{print $1}')
local mask=$(echo $2 | awk -F'/' '{print $2}')
[ "$mask" == "" ] && mask="32"
ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$dRIp "\
ip addr del dev $correctVif "$ipNoMask/$mask"
"
if [ $? -gt 0 -a $? -ne 2 ]
local existingIpMask=$(ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$dRIp "
ip addr show dev $correctVif | grep inet | awk '{print \$2}' | grep -w $ipNoMask
")
[ "$existingIpMask" == "" ] && return 0
local existingMask=$(echo $existingIpMask | awk -F'/' '{print $2}')
if [ "$existingMask" == "32" ]
then
ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$dRIp "
ip addr del dev $correctVif $existingIpMask
"
result=$?
fi
if [ "$existingMask" != "32" ]
then
ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$dRIp "
replaceIpMask=\`ip addr show dev $correctVif | grep inet | grep -v $existingIpMask | awk '{print \$2}' | sort -t/ -k2 -n|tail -1\`
ip addr del dev $correctVif $existingIpMask;
if [ -n \"\$replaceIpMask\" ]; then
ip addr del dev $correctVif \$replaceIpMask;
replaceIp=\`echo \$replaceIpMask | awk -F/ '{print \$1}'\`;
ip addr add dev $correctVif \$replaceIp/$existingMask;
fi
"
result=$?
fi
if [ $result -gt 0 -a $result -ne 2 ]
then
return 1
fi

View File

@ -1290,7 +1290,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
final Command [] cmds = new Command[ipAddrList.size()];
int i=0;
boolean sourceNat = false;
Map<VlanVO, ArrayList<IPAddressVO>> vlanIpMap = new HashMap<VlanVO, ArrayList<IPAddressVO>>();
Map<Long, ArrayList<IPAddressVO>> vlanIpMap = new HashMap<Long, ArrayList<IPAddressVO>>();
for (final String ipAddress: ipAddrList) {
IPAddressVO ip = _ipAddressDao.findById(ipAddress);
@ -1300,9 +1300,9 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
ipList = new ArrayList<IPAddressVO>();
}
ipList.add(ip);
vlanIpMap.put(vlan, ipList);
vlanIpMap.put(vlan.getId(), ipList);
}
for (Map.Entry<VlanVO, ArrayList<IPAddressVO>> vlanAndIp: vlanIpMap.entrySet()) {
for (Map.Entry<Long, ArrayList<IPAddressVO>> vlanAndIp: vlanIpMap.entrySet()) {
boolean firstIP = true;
ArrayList<IPAddressVO> ipList = vlanAndIp.getValue();
Collections.sort(ipList, new Comparator<IPAddressVO>() {
@ -1313,7 +1313,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
for (final IPAddressVO ip: ipList) {
sourceNat = ip.getSourceNat();
VlanVO vlan = vlanAndIp.getKey();
VlanVO vlan = _vlanDao.findById(vlanAndIp.getKey());
String vlanId = vlan.getVlanId();
String vlanGateway = vlan.getVlanGateway();
String vlanNetmask = vlan.getVlanNetmask();