Skip to content

Commit 8dc5fdd

Browse files
server: fix cannot get systemvm ips in dedicated ranges (#7144)
This fixes #6698
1 parent f5a1f41 commit 8dc5fdd

File tree

6 files changed

+146
-139
lines changed

6 files changed

+146
-139
lines changed

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ public VlanIpRangeResponse createVlanIpRangeResponse(Class<? extends VlanIpRange
901901
Long networkId = vlan.getNetworkId();
902902
if (networkId != null) {
903903
Network network = _ntwkModel.getNetwork(networkId);
904-
if (network != null) {
904+
if (network != null && TrafficType.Guest.equals(network.getTrafficType())) {
905905
Long accountId = network.getAccountId();
906906
populateAccount(vlanResponse, accountId);
907907
populateDomain(vlanResponse, ApiDBUtils.findAccountById(accountId).getDomainId());

server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5397,10 +5397,11 @@ public Vlan dedicatePublicIpRange(final DedicatePublicIpRangeCmd cmd) throws Res
53975397

53985398
// Check if any of the Public IP addresses is allocated to another
53995399
// account
5400-
boolean forSystemVms = false;
54015400
final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
54025401
for (final IPAddressVO ip : ips) {
5403-
forSystemVms = ip.isForSystemVms();
5402+
if (ip.isForSystemVms()) {
5403+
throw new InvalidParameterValueException(ip.getAddress() + " Public IP address in range is dedicated to system vms ");
5404+
}
54045405
final Long allocatedToAccountId = ip.getAllocatedToAccountId();
54055406
if (allocatedToAccountId != null) {
54065407
if (vlanOwner != null && allocatedToAccountId != vlanOwner.getId()) {
@@ -5425,7 +5426,7 @@ public Vlan dedicatePublicIpRange(final DedicatePublicIpRangeCmd cmd) throws Res
54255426
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_ASSIGN, vlanOwner.getId(), ip.getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(),
54265427
vlan.getVlanType().toString(), ip.getSystem(), usageHidden, ip.getClass().getName(), ip.getUuid());
54275428
}
5428-
} else if (domain != null && !forSystemVms) {
5429+
} else if (domain != null) {
54295430
// Create an DomainVlanMapVO entry
54305431
DomainVlanMapVO domainVlanMapVO = new DomainVlanMapVO(domain.getId(), vlan.getId());
54315432
_domainVlanMapDao.persist(domainVlanMapVO);
@@ -7250,7 +7251,6 @@ public Account getVlanAccount(final long vlanId) {
72507251
@Override
72517252
public Domain getVlanDomain(long vlanId) {
72527253
Vlan vlan = _vlanDao.findById(vlanId);
7253-
Long domainId = null;
72547254

72557255
// if vlan is Virtual Domain specific, get vlan information from the
72567256
// accountVlanMap; otherwise get account information

0 commit comments

Comments
 (0)