Skip to content

Commit b38f136

Browse files
committed
Merge branch '4.19'
2 parents 2a63483 + 33659fd commit b38f136

9 files changed

Lines changed: 62 additions & 25 deletions

File tree

engine/components-api/src/main/java/com/cloud/configuration/ConfigurationManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121
import java.util.Set;
2222

23+
import com.cloud.dc.VlanVO;
2324
import org.apache.cloudstack.framework.config.ConfigKey;
2425
import org.apache.cloudstack.framework.config.impl.ConfigurationSubGroupVO;
2526

@@ -189,7 +190,7 @@ DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2,
189190
* @param caller
190191
* @return success/failure
191192
*/
192-
boolean deleteVlanAndPublicIpRange(long userId, long vlanDbId, Account caller);
193+
VlanVO deleteVlanAndPublicIpRange(long userId, long vlanDbId, Account caller);
193194

194195
void checkZoneAccess(Account caller, DataCenter zone);
195196

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@
259259
import com.googlecode.ipv6.IPv6Address;
260260
import org.jetbrains.annotations.NotNull;
261261

262+
import static com.cloud.configuration.ConfigurationManager.MESSAGE_DELETE_VLAN_IP_RANGE_EVENT;
263+
262264
/**
263265
* NetworkManagerImpl implements NetworkManager.
264266
*/
@@ -3324,17 +3326,17 @@ public boolean destroyNetwork(final long networkId, final ReservationContext con
33243326

33253327
final NetworkVO networkFinal = network;
33263328
try {
3327-
Transaction.execute(new TransactionCallbackNoReturn() {
3329+
final List<VlanVO> deletedVlanRangeToPublish = Transaction.execute(new TransactionCallback<List<VlanVO>>() {
33283330
@Override
3329-
public void doInTransactionWithoutResult(final TransactionStatus status) {
3331+
public List<VlanVO> doInTransaction(TransactionStatus status) {
33303332
final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, networkFinal.getGuruName());
33313333

33323334
if (!guru.trash(networkFinal, _networkOfferingDao.findById(networkFinal.getNetworkOfferingId()))) {
33333335
throw new CloudRuntimeException("Failed to trash network.");
33343336
}
3335-
3336-
if (!deleteVlansInNetwork(networkFinal, context.getCaller().getId(), callerAccount)) {
3337-
logger.warn("Failed to delete network {}; was unable to cleanup corresponding ip ranges", networkFinal);
3337+
Pair<Boolean, List<VlanVO>> deletedVlans = deleteVlansInNetwork(networkFinal, context.getCaller().getId(), callerAccount);
3338+
if (!deletedVlans.first()) {
3339+
logger.warn("Failed to delete network " + networkFinal + "; was unable to cleanup corresponding ip ranges");
33383340
throw new CloudRuntimeException("Failed to delete network " + networkFinal + "; was unable to cleanup corresponding ip ranges");
33393341
} else {
33403342
// commit transaction only when ips and vlans for the network are released successfully
@@ -3367,8 +3369,10 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
33673369
_resourceLimitMgr.decrementResourceCount(networkFinal.getAccountId(), ResourceType.network, networkFinal.getDisplayNetwork());
33683370
}
33693371
}
3372+
return deletedVlans.second();
33703373
}
33713374
});
3375+
publishDeletedVlanRanges(deletedVlanRangeToPublish);
33723376
if (_networksDao.findById(network.getId()) == null) {
33733377
// remove its related ACL permission
33743378
final Pair<Class<?>, Long> networkMsg = new Pair<Class<?>, Long>(Network.class, networkFinal.getId());
@@ -3386,22 +3390,34 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
33863390
return success;
33873391
}
33883392

3393+
private void publishDeletedVlanRanges(List<VlanVO> deletedVlanRangeToPublish) {
3394+
if (CollectionUtils.isNotEmpty(deletedVlanRangeToPublish)) {
3395+
for (VlanVO vlan : deletedVlanRangeToPublish) {
3396+
_messageBus.publish(_name, MESSAGE_DELETE_VLAN_IP_RANGE_EVENT, PublishScope.LOCAL, vlan);
3397+
}
3398+
}
3399+
}
3400+
33893401
@Override
33903402
public boolean resourceCountNeedsUpdate(final NetworkOffering ntwkOff, final ACLType aclType) {
33913403
//Update resource count only for Isolated account specific non-system networks
33923404
final boolean updateResourceCount = ntwkOff.getGuestType() == GuestType.Isolated && !ntwkOff.isSystemOnly() && aclType == ACLType.Account;
33933405
return updateResourceCount;
33943406
}
33953407

3396-
protected boolean deleteVlansInNetwork(final NetworkVO network, final long userId, final Account callerAccount) {
3408+
protected Pair<Boolean, List<VlanVO>> deleteVlansInNetwork(final NetworkVO network, final long userId, final Account callerAccount) {
33973409
final long networkId = network.getId();
33983410
//cleanup Public vlans
33993411
final List<VlanVO> publicVlans = _vlanDao.listVlansByNetworkId(networkId);
3412+
List<VlanVO> deletedPublicVlanRange = new ArrayList<>();
34003413
boolean result = true;
34013414
for (final VlanVO vlan : publicVlans) {
3402-
if (!_configMgr.deleteVlanAndPublicIpRange(userId, vlan.getId(), callerAccount)) {
3403-
logger.warn("Failed to delete vlan {});", vlan.getId());
3415+
VlanVO vlanRange = _configMgr.deleteVlanAndPublicIpRange(userId, vlan.getId(), callerAccount);
3416+
if (vlanRange == null) {
3417+
logger.warn("Failed to delete vlan " + vlan.getId() + ");");
34043418
result = false;
3419+
} else {
3420+
deletedPublicVlanRange.add(vlanRange);
34053421
}
34063422
}
34073423

@@ -3421,7 +3437,7 @@ protected boolean deleteVlansInNetwork(final NetworkVO network, final long userI
34213437
_dcDao.releaseVnet(BroadcastDomainType.getValue(network.getBroadcastUri()), network.getDataCenterId(),
34223438
network.getPhysicalNetworkId(), network.getAccountId(), network.getReservationId());
34233439
}
3424-
return result;
3440+
return new Pair<>(result, deletedPublicVlanRange);
34253441
}
34263442

34273443
public class NetworkGarbageCollector extends ManagedContextRunnable {

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5362,7 +5362,7 @@ private void checkGatewayOverlap(String startIp, String endIp, String gateway) {
53625362

53635363
@Override
53645364
@DB
5365-
public boolean deleteVlanAndPublicIpRange(final long userId, final long vlanDbId, final Account caller) {
5365+
public VlanVO deleteVlanAndPublicIpRange(final long userId, final long vlanDbId, final Account caller) {
53665366
VlanVO vlanRange = _vlanDao.findById(vlanDbId);
53675367
if (vlanRange == null) {
53685368
throw new InvalidParameterValueException("Please specify a valid IP range id.");
@@ -5468,9 +5468,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
54685468
}
54695469
});
54705470

5471-
messageBus.publish(_name, MESSAGE_DELETE_VLAN_IP_RANGE_EVENT, PublishScope.LOCAL, vlanRange);
5472-
5473-
return true;
5471+
return vlanRange;
54745472
}
54755473

54765474
@Override
@@ -5976,7 +5974,16 @@ public boolean deleteVlanIpRange(final DeleteVlanIpRangeCmd cmd) {
59765974
throw new InvalidParameterValueException("Please specify a valid IP range id.");
59775975
}
59785976

5979-
return deleteVlanAndPublicIpRange(CallContext.current().getCallingUserId(), vlanDbId, CallContext.current().getCallingAccount());
5977+
return deleteAndPublishVlanAndPublicIpRange(CallContext.current().getCallingUserId(), vlanDbId, CallContext.current().getCallingAccount());
5978+
}
5979+
5980+
private boolean deleteAndPublishVlanAndPublicIpRange(final long userId, final long vlanDbId, final Account caller) {
5981+
VlanVO deletedVlan = deleteVlanAndPublicIpRange(userId, vlanDbId, caller);
5982+
if (deletedVlan != null) {
5983+
messageBus.publish(_name, MESSAGE_DELETE_VLAN_IP_RANGE_EVENT, PublishScope.LOCAL, deletedVlan);
5984+
return true;
5985+
}
5986+
return false;
59805987
}
59815988

59825989
@Override

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8044,7 +8044,7 @@ public Pair<UserVmVO, Volume> doInTransaction(final TransactionStatus status) th
80448044

80458045
// Detach, destroy and create the usage event for the old root volume.
80468046
_volsDao.detachVolume(root.getId());
8047-
_volumeService.destroyVolume(root.getId(), caller, Volume.State.Allocated.equals(root.getState()) || expunge, false);
8047+
destroyVolumeInContext(vm, Volume.State.Allocated.equals(root.getState()) || expunge, root);
80488048

80498049
if (currentTemplate.getId() != template.getId() && VirtualMachine.Type.User.equals(vm.type) && !VirtualMachineManager.ResourceCountRunningVMsonly.value()) {
80508050
ServiceOfferingVO serviceOffering = serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId());

server/src/test/java/com/cloud/vpc/MockConfigurationManagerImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.cloud.dc.HostPodVO;
2727
import com.cloud.dc.Pod;
2828
import com.cloud.dc.Vlan;
29+
import com.cloud.dc.VlanVO;
2930
import com.cloud.domain.Domain;
3031
import com.cloud.exception.ConcurrentOperationException;
3132
import com.cloud.exception.InsufficientCapacityException;
@@ -515,9 +516,9 @@ public HostPodVO createPod(long userId, String podName, DataCenter zone, String
515516
* @see com.cloud.configuration.ConfigurationManager#deleteVlanAndPublicIpRange(long, long, com.cloud.user.Account)
516517
*/
517518
@Override
518-
public boolean deleteVlanAndPublicIpRange(long userId, long vlanDbId, Account caller) {
519+
public VlanVO deleteVlanAndPublicIpRange(long userId, long vlanDbId, Account caller) {
519520
// TODO Auto-generated method stub
520-
return false;
521+
return null;
521522
}
522523

523524
/* (non-Javadoc)

test/integration/smoke/test_events_resource.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,23 @@ def test_01_events_resource(self):
116116
self.services["domain"],
117117
parentdomainid=self.domain.id
118118
)
119+
self.cleanup.append(domain1)
119120
self.services["domainid"] = domain1.id
120121

121122
account = Account.create(
122123
self.apiclient,
123124
self.services["account"],
124125
domainid=domain1.id
125126
)
127+
self.cleanup.append(account)
126128

127129
account_network = Network.create(
128130
self.apiclient,
129131
self.services["network"],
130132
account.name,
131133
account.domainid
132134
)
135+
self.cleanup.append(account_network)
133136
virtual_machine = VirtualMachine.create(
134137
self.apiclient,
135138
self.services,
@@ -138,6 +141,7 @@ def test_01_events_resource(self):
138141
networkids=account_network.id,
139142
serviceofferingid=self.service_offering.id
140143
)
144+
self.cleanup.append(virtual_machine)
141145
volume = Volume.create(
142146
self.apiclient,
143147
self.services,
@@ -146,6 +150,7 @@ def test_01_events_resource(self):
146150
domainid=account.domainid,
147151
diskofferingid=self.disk_offering.id
148152
)
153+
self.cleanup.append(volume)
149154
virtual_machine.attach_volume(
150155
self.apiclient,
151156
volume
@@ -157,15 +162,20 @@ def test_01_events_resource(self):
157162
time.sleep(self.services["sleep"])
158163
virtual_machine.detach_volume(self.apiclient, volume)
159164
volume.delete(self.apiclient)
165+
self.cleanup.remove(volume)
160166
ts = str(time.time())
161167
virtual_machine.update(self.apiclient, displayname=ts)
162168
virtual_machine.delete(self.apiclient)
169+
self.cleanup.remove(virtual_machine)
163170
account_network.update(self.apiclient, name=account_network.name + ts)
164171
account_network.delete(self.apiclient)
172+
self.cleanup.remove(account_network)
165173
account.update(self.apiclient, newname=account.name + ts)
166174
account.disable(self.apiclient)
167175
account.delete(self.apiclient)
176+
self.cleanup.remove(account)
168177
domain1.delete(self.apiclient)
178+
self.cleanup.remove(domain1)
169179

170180
cmd = listEvents.listEventsCmd()
171181
cmd.startdate = start_time
@@ -185,8 +195,9 @@ def test_01_events_resource(self):
185195
for event in events:
186196
if event.type.startswith("VM.") or (event.type.startswith("NETWORK.") and not event.type.startswith("NETWORK.ELEMENT")) or event.type.startswith("VOLUME.") or event.type.startswith("ACCOUNT.") or event.type.startswith("DOMAIN.") or event.type.startswith("TEMPLATE."):
187197
if event.resourceid is None or event.resourcetype is None:
188-
self.debug("Failed event:: %s" % json.dumps(event, indent=2))
189-
self.fail("resourceid or resourcetype for the event not found!")
198+
event_json = json.dumps(event.__dict__, indent=2)
199+
self.debug("Failed event:: %s" % event_json)
200+
self.fail("resourceid or resourcetype not found for the event: %s" % event_json)
190201
else:
191202
self.debug("Event %s at %s:: Resource Type: %s, Resource ID: %s" % (event.type, event.created, event.resourcetype, event.resourceid))
192203

ui/src/config/section/compute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ export default {
626626
name: 'autoscalevmgroup',
627627
title: 'label.autoscale.vm.groups',
628628
icon: 'fullscreen-outlined',
629-
docHelp: 'adminguide/autoscale_without_netscaler.html',
629+
docHelp: 'adminguide/autoscale_with_virtual_router.html',
630630
resourceType: 'AutoScaleVmGroup',
631631
permission: ['listAutoScaleVmGroups'],
632632
columns: (store) => {

ui/src/views/compute/EditVM.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ export default {
177177
isdynamicallyscalable: this.resource.isdynamicallyscalable,
178178
group: this.resource.group,
179179
securitygroupids: this.resource.securitygroup.map(x => x.id),
180-
userdata: ''
180+
userdata: '',
181+
haenable: this.resource.haenable
181182
})
182183
this.rules = reactive({})
183184
},

ui/src/views/dashboard/UsageDashboard.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
<a-progress
203203
status="active"
204204
:percent="parseFloat(getPercentUsed(entity[usageType + 'total'], entity[usageType + 'limit']))"
205-
:format="p => resource[item + 'limit'] !== '-1' && resource[item + 'limit'] !== 'Unlimited' ? p.toFixed(0) + '%' : ''"
205+
:format="p => entity[usageType + 'limit'] !== '-1' && entity[usageType + 'limit'] !== 'Unlimited' ? p.toFixed(0) + '%' : ''"
206206
stroke-color="#52c41a"
207207
size="small"
208208
/>
@@ -238,7 +238,7 @@
238238
<a-progress
239239
status="active"
240240
:percent="parseFloat(getPercentUsed(entity[usageType + 'total'], entity[usageType + 'limit']))"
241-
:format="p => resource[item + 'limit'] !== '-1' && resource[item + 'limit'] !== 'Unlimited' ? p.toFixed(0) + '%' : ''"
241+
:format="p => entity[usageType + 'limit'] !== '-1' && entity[usageType + 'limit'] !== 'Unlimited' ? p.toFixed(0) + '%' : ''"
242242
stroke-color="#52c41a"
243243
size="small"
244244
/>
@@ -274,7 +274,7 @@
274274
<a-progress
275275
status="active"
276276
:percent="parseFloat(getPercentUsed(entity[usageType + 'total'], entity[usageType + 'limit']))"
277-
:format="p => resource[item + 'limit'] !== '-1' && resource[item + 'limit'] !== 'Unlimited' ? p.toFixed(0) + '%' : ''"
277+
:format="p => entity[usageType + 'limit'] !== '-1' && entity[usageType + 'limit'] !== 'Unlimited' ? p.toFixed(0) + '%' : ''"
278278
stroke-color="#52c41a"
279279
size="small"
280280
/>

0 commit comments

Comments
 (0)