diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java index 3d3b6d476b7..8ffd6ea93f2 100644 --- a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java +++ b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java @@ -105,6 +105,11 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis if (nicVO.getVmType() != VirtualMachine.Type.User) { to.setPxeDisable(true); } + List secIps = null; + if (nicVO.getSecondaryIp()) { + secIps = _nicSecIpDao.getSecondaryIpAddressesForNic(nicVO.getId()); + } + to.setNicSecIps(secIps); } else { s_logger.warn("Unabled to load NicVO for NicProfile " + profile.getId()); } @@ -112,11 +117,6 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis //check whether the this nic has secondary ip addresses set //set nic secondary ip address in NicTO which are used for security group // configuration. Use full when vm stop/start - List secIps = null; - if (nicVO.getSecondaryIp()) { - secIps = _nicSecIpDao.getSecondaryIpAddressesForNic(nicVO.getId()); - } - to.setNicSecIps(secIps); return to; } diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java index 9d1fc6680d6..130d05176db 100755 --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@ -1385,7 +1385,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { aclType, subdomainAccess, vpcId, ip6Gateway, ip6Cidr, displayNetwork, isolatedPvlan); } - if (_accountMgr.isRootAdmin(caller.getId()) && createVlan) { + if (_accountMgr.isRootAdmin(caller.getId()) && createVlan && network != null) { // Create vlan ip range _configMgr.createVlanAndPublicIpRange(pNtwk.getDataCenterId(), network.getId(), physicalNetworkId, false, null, startIP, endIP, gateway, netmask, vlanId, null, startIPv6, endIPv6, ip6Gateway, ip6Cidr); @@ -3996,23 +3996,21 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { + " in zone " + _entityMgr.findById(DataCenter.class, pNtwk.getDataCenterId()).getName()); } } - - //add entry to private_ip_address table - PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkIdAndVpcId(privateNetwork.getId(), startIp, vpcId); - if (privateIp != null) { - throw new InvalidParameterValueException("Private ip address " + startIp + " already used for private gateway" + " in zone " - + _entityMgr.findById(DataCenter.class, pNtwk.getDataCenterId()).getName()); + if (vpcId != null) { + //add entry to private_ip_address table + PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkIdAndVpcId(privateNetwork.getId(), startIp, vpcId); + if (privateIp != null) { + throw new InvalidParameterValueException("Private ip address " + startIp + " already used for private gateway" + " in zone " + + _entityMgr.findById(DataCenter.class, pNtwk.getDataCenterId()).getName()); + } + Long mac = dc.getMacAddress(); + Long nextMac = mac + 1; + dc.setMacAddress(nextMac); + privateIp = new PrivateIpVO(startIp, privateNetwork.getId(), nextMac, vpcId, sourceNat); + _privateIpDao.persist(privateIp); + _dcDao.update(dc.getId(), dc); } - Long mac = dc.getMacAddress(); - Long nextMac = mac + 1; - dc.setMacAddress(nextMac); - - privateIp = new PrivateIpVO(startIp, privateNetwork.getId(), nextMac, vpcId, sourceNat); - _privateIpDao.persist(privateIp); - - _dcDao.update(dc.getId(), dc); - s_logger.debug("Private network " + privateNetwork + " is created"); return privateNetwork; diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index d58c0a468a5..a45edea44bc 100644 --- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java @@ -2194,10 +2194,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis try { // Cleanup inactive VPCs List inactiveVpcs = _vpcDao.listInactiveVpcs(); - s_logger.info("Found " + inactiveVpcs.size() + " removed VPCs to cleanup"); - for (VpcVO vpc : inactiveVpcs) { - s_logger.debug("Cleaning up " + vpc); - destroyVpc(vpc, _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM), User.UID_SYSTEM); + if (inactiveVpcs != null) { + s_logger.info("Found " + inactiveVpcs.size() + " removed VPCs to cleanup"); + for (VpcVO vpc : inactiveVpcs) { + s_logger.debug("Cleaning up " + vpc); + destroyVpc(vpc, _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM), User.UID_SYSTEM); + } } } catch (Exception e) { s_logger.error("Exception ", e);