Skip to content

Commit 0c9ddcb

Browse files
authored
Merge pull request #1993 from Accelerite/sharednw
CLOUDSTACK-8931: Fail to deploy VM instance when use.system.public.ips=false
2 parents 6f168c8 + e1384c3 commit 0c9ddcb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

server/src/com/cloud/network/IpAddressManagerImpl.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ public IPAddressVO doInTransaction(TransactionStatus status) throws Insufficient
678678
boolean fetchFromDedicatedRange = false;
679679
List<Long> dedicatedVlanDbIds = new ArrayList<Long>();
680680
List<Long> nonDedicatedVlanDbIds = new ArrayList<Long>();
681+
DataCenter zone = _entityMgr.findById(DataCenter.class, dcId);
681682

682683
SearchCriteria<IPAddressVO> sc = null;
683684
if (podId != null) {
@@ -691,10 +692,14 @@ public IPAddressVO doInTransaction(TransactionStatus status) throws Insufficient
691692

692693
// If owner has dedicated Public IP ranges, fetch IP from the dedicated range
693694
// Otherwise fetch IP from the system pool
694-
List<AccountVlanMapVO> maps = _accountVlanMapDao.listAccountVlanMapsByAccount(owner.getId());
695-
for (AccountVlanMapVO map : maps) {
696-
if (vlanDbIds == null || vlanDbIds.contains(map.getVlanDbId()))
697-
dedicatedVlanDbIds.add(map.getVlanDbId());
695+
Network network = _networksDao.findById(guestNetworkId);
696+
//Checking if network is null in the case of system VM's. At the time of allocation of IP address to systemVm, no network is present.
697+
if(network == null || !(network.getGuestType() == GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced)) {
698+
List<AccountVlanMapVO> maps = _accountVlanMapDao.listAccountVlanMapsByAccount(owner.getId());
699+
for (AccountVlanMapVO map : maps) {
700+
if (vlanDbIds == null || vlanDbIds.contains(map.getVlanDbId()))
701+
dedicatedVlanDbIds.add(map.getVlanDbId());
702+
}
698703
}
699704
List<DomainVlanMapVO> domainMaps = _domainVlanMapDao.listDomainVlanMapsByDomain(owner.getDomainId());
700705
for (DomainVlanMapVO map : domainMaps) {
@@ -727,8 +732,6 @@ public IPAddressVO doInTransaction(TransactionStatus status) throws Insufficient
727732

728733
sc.setParameters("dc", dcId);
729734

730-
DataCenter zone = _entityMgr.findById(DataCenter.class, dcId);
731-
732735
// for direct network take ip addresses only from the vlans belonging to the network
733736
if (vlanUse == VlanType.DirectAttached) {
734737
sc.setJoinParameters("vlan", "networkId", guestNetworkId);

0 commit comments

Comments
 (0)