Skip to content

Commit c94a75c

Browse files
author
Kishan Kavala
committed
CLOUDSTACK-752: Removed 1 private gateway for VPC limitation.
Verified that more than 8 private gateways can be created.
1 parent e85b1cb commit c94a75c

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

‎plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3974,7 +3974,9 @@ protected VIF getVifByMac(Connection conn, VM router, String mac) throws XmlRpcE
39743974
}
39753975

39763976
protected String getLowestAvailableVIFDeviceNum(Connection conn, VM vm) {
3977+
String vmName = "";
39773978
try {
3979+
vmName = vm.getNameLabel(conn);
39783980
List<Integer> usedDeviceNums = new ArrayList<Integer>();
39793981
Set<VIF> vifs = vm.getVIFs(conn);
39803982
Iterator<VIF> vifIter = vifs.iterator();
@@ -3983,14 +3985,15 @@ protected String getLowestAvailableVIFDeviceNum(Connection conn, VM vm) {
39833985
try{
39843986
usedDeviceNums.add(Integer.valueOf(vif.getDevice(conn)));
39853987
} catch (NumberFormatException e) {
3986-
s_logger.debug("Obtained an invalid value for an allocated VIF device number for VM: " + vm.getNameLabel(conn));
3987-
return null;
3988+
String msg = "Obtained an invalid value for an allocated VIF device number for VM: " + vmName;
3989+
s_logger.debug(msg, e);
3990+
throw new CloudRuntimeException(msg);
39883991
}
39893992
}
39903993

39913994
for(Integer i=0; i< _maxNics; i++){
39923995
if(!usedDeviceNums.contains(i)){
3993-
s_logger.debug("Lowest available Vif device number: "+i+" for VM: " + vm.getNameLabel(conn));
3996+
s_logger.debug("Lowest available Vif device number: "+i+" for VM: " + vmName);
39943997
return i.toString();
39953998
}
39963999
}
@@ -4002,7 +4005,7 @@ protected String getLowestAvailableVIFDeviceNum(Connection conn, VM vm) {
40024005
s_logger.warn(msg, e);
40034006
}
40044007

4005-
return null;
4008+
throw new CloudRuntimeException("Could not find available VIF slot in VM with name: " + vmName);
40064009
}
40074010

40084011
protected VDI mount(Connection conn, StoragePoolType pooltype, String volumeFolder, String volumePath) {

‎server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,11 @@ public boolean plugNic(Network network, NicTO nic, VirtualMachineTO vm,
341341
_agentMgr.send(dest.getHost().getId(), cmds);
342342
PlugNicAnswer plugNicAnswer = cmds.getAnswer(PlugNicAnswer.class);
343343
if (!(plugNicAnswer != null && plugNicAnswer.getResult())) {
344-
s_logger.warn("Unable to plug nic for vm " + vm.getHostName());
344+
s_logger.warn("Unable to plug nic for vm " + vm.getName());
345345
result = false;
346346
}
347347
} catch (OperationTimedoutException e) {
348-
throw new AgentUnavailableException("Unable to plug nic for router " + vm.getHostName() + " in network " + network,
348+
throw new AgentUnavailableException("Unable to plug nic for router " + vm.getName() + " in network " + network,
349349
dest.getHost().getId(), e);
350350
}
351351
} else {

‎server/src/com/cloud/network/vpc/VpcManagerImpl.java‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,13 +1233,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
12331233
ex.addProxyObject("vpc", vpcId, "VPC");
12341234
throw ex;
12351235
}
1236-
1237-
//allow only one private gateway per vpc
1238-
VpcGatewayVO gatewayVO = _vpcGatewayDao.getPrivateGatewayForVpc(vpcId);
1239-
if (gatewayVO != null) {
1240-
throw new InvalidParameterValueException("Private ip address already exists for vpc " + vpc);
1241-
}
1242-
1236+
12431237
//Validate physical network
12441238
if (physicalNetworkId == null) {
12451239
List<? extends PhysicalNetwork> pNtwks = _ntwkModel.getPhysicalNtwksSupportingTrafficType(vpc.getZoneId(), TrafficType.Guest);
@@ -1258,7 +1252,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
12581252
vlan, ipAddress, null, gateway, netmask, gatewayOwnerId, vpcId);
12591253

12601254
//2) create gateway entry
1261-
gatewayVO = new VpcGatewayVO(ipAddress, VpcGateway.Type.Private, vpcId, privateNtwk.getDataCenterId(),
1255+
VpcGatewayVO gatewayVO = new VpcGatewayVO(ipAddress, VpcGateway.Type.Private, vpcId, privateNtwk.getDataCenterId(),
12621256
privateNtwk.getId(), vlan, gateway, netmask, vpc.getAccountId(), vpc.getDomainId());
12631257
_vpcGatewayDao.persist(gatewayVO);
12641258

0 commit comments

Comments
 (0)