Skip to content

Commit 7d8eb37

Browse files
nvazquezrafaelweingartner
authored andcommitted
[4.11] Fix set initial reservation on public IP ranges (#2980)
* Fix initial reservation on public IP ranges * Do not allow dedicating a system VM IP range
1 parent af0c1e4 commit 7d8eb37

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,10 +3569,10 @@ public VlanVO doInTransaction(final TransactionStatus status) {
35693569
}
35703570
// increment resource count for dedicated public ip's
35713571
_resourceLimitMgr.incrementResourceCount(vlanOwner.getId(), ResourceType.public_ip, new Long(ips.size()));
3572-
} else if (domain != null) {
3572+
} else if (domain != null && !forSystemVms) {
35733573
// This VLAN is domain-wide, so create a DomainVlanMapVO entry
3574-
//final DomainVlanMapVO domainVlanMapVO = new DomainVlanMapVO(domain.getId(), vlan.getId());
3575-
//_domainVlanMapDao.persist(domainVlanMapVO);
3574+
final DomainVlanMapVO domainVlanMapVO = new DomainVlanMapVO(domain.getId(), vlan.getId());
3575+
_domainVlanMapDao.persist(domainVlanMapVO);
35763576
} else if (podId != null) {
35773577
// This VLAN is pod-wide, so create a PodVlanMapVO entry
35783578
final PodVlanMapVO podVlanMapVO = new PodVlanMapVO(podId, vlan.getId());
@@ -3754,8 +3754,10 @@ public Vlan dedicatePublicIpRange(final DedicatePublicIpRangeCmd cmd) throws Res
37543754

37553755
// Check if any of the Public IP addresses is allocated to another
37563756
// account
3757+
boolean forSystemVms = false;
37573758
final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
37583759
for (final IPAddressVO ip : ips) {
3760+
forSystemVms = ip.isForSystemVms();
37593761
final Long allocatedToAccountId = ip.getAllocatedToAccountId();
37603762
if (allocatedToAccountId != null) {
37613763
final Account accountAllocatedTo = _accountMgr.getActiveAccountById(allocatedToAccountId);
@@ -3779,7 +3781,7 @@ public Vlan dedicatePublicIpRange(final DedicatePublicIpRangeCmd cmd) throws Res
37793781
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_ASSIGN, vlanOwner.getId(), ip.getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(),
37803782
vlan.getVlanType().toString(), ip.getSystem(), ip.getClass().getName(), ip.getUuid());
37813783
}
3782-
} else if (domain != null) {
3784+
} else if (domain != null && !forSystemVms) {
37833785
// Create an DomainVlanMapVO entry
37843786
DomainVlanMapVO domainVlanMapVO = new DomainVlanMapVO(domain.getId(), vlan.getId());
37853787
_domainVlanMapDao.persist(domainVlanMapVO);

ui/scripts/system.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,16 @@
126126
var $systemvmsCb = $systemvms.find('input[type=checkbox]');
127127
var $account = args.$form.find('.form-item[rel=account]');
128128
var $accountTxt = args.$form.find('input[name=account]');
129+
var $domainid = args.$form.find('select[name=domainid]');
129130
$systemvmsCb.change(function() {
130131
if ($systemvmsCb.is(':checked')) {
131132
$accountTxt.val('');
132133
$accountTxt.attr('disabled', true);
134+
$domainid.attr('disabled', true);
133135
}
134136
else {
135137
$accountTxt.attr('disabled', false);
138+
$domainid.attr('disabled', false);
136139
}
137140
});
138141
}
@@ -524,7 +527,8 @@
524527
},
525528
actionPreFilter: function (args) {
526529
var actionsToShow =[ 'destroy'];
527-
if (args.context.multiRule[0].domain == 'ROOT' && args.context.multiRule[0].account != null && args.context.multiRule[0].account.account == 'system')
530+
if (args.context.multiRule[0].domain == 'ROOT' && args.context.multiRule[0].account != null &&
531+
args.context.multiRule[0].account.account == 'system' && !args.context.multiRule[0].forsystemvms)
528532
actionsToShow.push('addAccount'); else
529533
actionsToShow.push('releaseFromAccount');
530534
return actionsToShow;

0 commit comments

Comments
 (0)