protected void assignVPCPublicIpAddress(Connection conn, String vmName, String routerIp, IpAddressTO ip) throws Exception {
try {
VM router = getVM(conn, vmName);
VIF correctVif = getVifByMac(conn, router, ip.getVifMacAddress());
if (correctVif == null) {
if (ip.isAdd()) {
throw new InternalErrorException("Failed to find DomR VIF to associate IP with.");
} else {
s_logger.debug("VIF to deassociate IP with does not exist, return success");
return;
}
}
String args = "vpc_ipassoc.sh " + routerIp;
if (ip.isAdd()) {
args += " -A ";
} else {
args += " -D ";
}
args += " -l ";
args += ip.getPublicIp();
args += " -c ";
args += "eth" + correctVif.getDevice(conn);
args += " -g ";
args += ip.getVlanGateway();
args += " -m ";