bug 3120: reverting changes as still soliciting feedback on design

This commit is contained in:
abhishek 2010-09-15 11:52:31 -07:00
parent a05dc480a7
commit 652620363d
8 changed files with 15 additions and 20 deletions

View File

@ -39,7 +39,7 @@ public class IPAssocCommand extends RoutingCommand {
protected IPAssocCommand() {
}
public IPAssocCommand(String routerName, String privateIpAddress, String ipAddress, boolean add, boolean firstIP, boolean sourceNat, String vlanId, String vlanGateway, String vlanNetmask, String vifMacAddress, boolean oneToOneNat) {
public IPAssocCommand(String routerName, String privateIpAddress, String ipAddress, boolean add, boolean firstIP, boolean sourceNat, String vlanId, String vlanGateway, String vlanNetmask, String vifMacAddress) {
this.setRouterName(routerName);
this.routerIp = privateIpAddress;
this.publicIp = ipAddress;
@ -50,7 +50,6 @@ public class IPAssocCommand extends RoutingCommand {
this.vlanGateway = vlanGateway;
this.vlanNetmask = vlanNetmask;
this.vifMacAddress = vifMacAddress;
this.oneToOneNat = oneToOneNat;
}
public String getRouterIp() {

View File

@ -1288,7 +1288,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
}
protected void assignPublicIpAddress(final String vmName, final String privateIpAddress, final String publicIpAddress, final boolean add, final boolean firstIP,
final boolean sourceNat, final String vlanId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress, final boolean oneToOneNat) throws InternalErrorException {
final boolean sourceNat, final String vlanId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress) throws InternalErrorException {
try {
Connection conn = getConnection();
@ -1405,7 +1405,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
protected Answer execute(final IPAssocCommand cmd) {
try {
assignPublicIpAddress(cmd.getRouterName(), cmd.getRouterIp(), cmd.getPublicIp(), cmd.isAdd(), cmd.isFirstIP(), cmd.isSourceNat(), cmd.getVlanId(),
cmd.getVlanGateway(), cmd.getVlanNetmask(), cmd.getVifMacAddress(), cmd.isOneToOneNat());
cmd.getVlanGateway(), cmd.getVlanNetmask(), cmd.getVifMacAddress());
} catch (InternalErrorException e) {
return new Answer(cmd, false, e.getMessage());
}

View File

@ -409,13 +409,12 @@ public interface ManagementServer {
* @param accountId
* @param domainId
* @param zoneId
* @param oneToOneNat whether we want one to one mapping for this public ip to a private ip
* @return allocated IP address in the zone specified
* @throws InsufficientAddressCapacityException if no more addresses are available
* @throws InvalidParameterValueException if no router for that user exists in the zone specified
* @throws InternalErrorException if the new address could not be sent down to the router
*/
String associateIpAddress(long userId, long accountId, long domainId, long zoneId, boolean oneToOneNat) throws ResourceAllocationException, InsufficientAddressCapacityException, InvalidParameterValueException, InternalErrorException;
String associateIpAddress(long userId, long accountId, long domainId, long zoneId) throws ResourceAllocationException, InsufficientAddressCapacityException, InvalidParameterValueException, InternalErrorException;
long associateIpAddressAsync(long userId, long accountId, long domainId, long zoneId);

View File

@ -70,9 +70,7 @@ public class AssociateIPAddrCmd extends BaseCmd {
Account account = (Account)params.get(BaseCmd.Properties.ACCOUNT_OBJ.getName());
Long userId = (Long)params.get(BaseCmd.Properties.USER_ID.getName());
String accountName = (String)params.get(BaseCmd.Properties.ACCOUNT.getName());
Long domainId = (Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
boolean oneToOneNat = false;
oneToOneNat = (Boolean)params.get(BaseCmd.Properties.ONE_TO_ONE_NAT.getName());
Long domainId = (Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
String newIpAddr = null;
String errorDesc = null;
Long accountId = null;
@ -109,7 +107,7 @@ public class AssociateIPAddrCmd extends BaseCmd {
}
try {
newIpAddr = getManagementServer().associateIpAddress(userId.longValue(), accountId.longValue(), domainId.longValue(), zoneId.longValue(), oneToOneNat);
newIpAddr = getManagementServer().associateIpAddress(userId.longValue(), accountId.longValue(), domainId.longValue(), zoneId.longValue());
} catch (ResourceAllocationException rae) {
if (rae.getResourceType().equals("vm")) throw new ServerApiException (BaseCmd.VM_ALLOCATION_ERROR, rae.getMessage());
else if (rae.getResourceType().equals("ip")) throw new ServerApiException (BaseCmd.IP_ALLOCATION_ERROR, rae.getMessage());

View File

@ -62,7 +62,7 @@ public class AssociateIpAddressExecutor extends BaseAsyncJobExecutor {
} else {
try {
String ipAddress = managementServer.associateIpAddress(param.getUserId(), param.getAccountId(),
param.getDomainId(), param.getZoneId(), false);
param.getDomainId(), param.getZoneId());
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_SUCCEEDED, 0,
composeResultObject(managementServer, param, ipAddress));
} catch (ResourceAllocationException e) {

View File

@ -170,10 +170,9 @@ public interface NetworkManager extends Manager {
* @param router router object to send the association to
* @param ipAddrList list of public IP addresses
* @param add true if associate, false if disassociate
* @param whether one to one nat mapping or not
* @return
*/
boolean associateIP(DomainRouterVO router, List<String> ipAddrList, boolean add, boolean oneToOneNat) throws ResourceAllocationException;
boolean associateIP(DomainRouterVO router, List<String> ipAddrList, boolean add) throws ResourceAllocationException;
boolean updateFirewallRule(FirewallRuleVO fwRule, String oldPrivateIP, String oldPrivatePort);
boolean executeAssignToLoadBalancer(AssignToLoadBalancerExecutor executor, LoadBalancerParam param);

View File

@ -1109,7 +1109,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
ipAddrList.add(ipVO.getAddress());
}
if (!ipAddrList.isEmpty()) {
final boolean success = associateIP(router, ipAddrList, true, false);
final boolean success = associateIP(router, ipAddrList, true);
if (!success) {
return false;
}
@ -1344,7 +1344,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
}
@Override
public boolean associateIP(final DomainRouterVO router, final List<String> ipAddrList, final boolean add, final boolean oneToOneNat) {
public boolean associateIP(final DomainRouterVO router, final List<String> ipAddrList, final boolean add) {
final Command [] cmds = new Command[ipAddrList.size()];
int i=0;
boolean sourceNat = false;
@ -1365,7 +1365,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
vifMacAddress = macAddresses[1];
}
cmds[i++] = new IPAssocCommand(router.getInstanceName(), router.getPrivateIpAddress(), ipAddress, add, firstIP, sourceNat, vlanId, vlanGateway, vlanNetmask, vifMacAddress, oneToOneNat);
cmds[i++] = new IPAssocCommand(router.getInstanceName(), router.getPrivateIpAddress(), ipAddress, add, firstIP, sourceNat, vlanId, vlanGateway, vlanNetmask, vifMacAddress);
sourceNat = false;
}
@ -1708,7 +1708,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
s_logger.debug("Disassociate ip " + router.getName());
}
if (associateIP(router, ipAddrs, false, false)) {
if (associateIP(router, ipAddrs, false)) {
_ipAddressDao.unassignIpAddress(ipAddress);
} else {
if (s_logger.isDebugEnabled()) {

View File

@ -1478,7 +1478,7 @@ public class ManagementServerImpl implements ManagementServer {
boolean success = true;
String params = "\nsourceNat=" + false + "\ndcId=" + zoneId;
ArrayList<String> dummyipAddrList = new ArrayList<String>();
success = _networkMgr.associateIP(router,ipAddrsList, true, false);
success = _networkMgr.associateIP(router,ipAddrsList, true);
String errorMsg = "Unable to assign public IP address pool";
if (!success) {
s_logger.debug(errorMsg);
@ -1509,7 +1509,7 @@ public class ManagementServerImpl implements ManagementServer {
@Override
@DB
public String associateIpAddress(long userId, long accountId, long domainId, long zoneId, boolean oneToOneNat) throws ResourceAllocationException, InsufficientAddressCapacityException,
public String associateIpAddress(long userId, long accountId, long domainId, long zoneId) throws ResourceAllocationException, InsufficientAddressCapacityException,
InvalidParameterValueException, InternalErrorException {
Transaction txn = Transaction.currentTxn();
AccountVO account = null;
@ -1561,7 +1561,7 @@ public class ManagementServerImpl implements ManagementServer {
ipAddrs.add(ipAddress);
if (router.getState() == State.Running) {
success = _networkMgr.associateIP(router, ipAddrs, true, oneToOneNat);
success = _networkMgr.associateIP(router, ipAddrs, true);
if (!success) {
errorMsg = "Unable to assign public IP address.";
}