Skip to content

Commit cb9b313

Browse files
committed
Merge branch '4.19'
2 parents 1cf1786 + 8d02e5f commit cb9b313

File tree

66 files changed

+1119
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1119
-329
lines changed

api/src/main/java/com/cloud/event/EventTypes.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import org.apache.cloudstack.api.response.ZoneResponse;
3030
import org.apache.cloudstack.config.Configuration;
3131
import org.apache.cloudstack.ha.HAConfig;
32+
import org.apache.cloudstack.quota.QuotaTariff;
3233
import org.apache.cloudstack.storage.object.Bucket;
3334
import org.apache.cloudstack.storage.object.ObjectStore;
34-
import org.apache.cloudstack.quota.QuotaTariff;
3535
import org.apache.cloudstack.usage.Usage;
3636
import org.apache.cloudstack.vm.schedule.VMSchedule;
3737

@@ -1229,4 +1229,8 @@ public static Class getEntityClassForEvent(String eventName) {
12291229
public static boolean isVpcEvent(String eventType) {
12301230
return EventTypes.EVENT_VPC_CREATE.equals(eventType) || EventTypes.EVENT_VPC_DELETE.equals(eventType);
12311231
}
1232+
1233+
public static void addEntityEventDetail(String event, Class<?> clazz) {
1234+
entityEventDetails.put(event, clazz);
1235+
}
12321236
}

api/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterHelper.java api/src/main/java/com/cloud/kubernetes/cluster/KubernetesServiceHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.cloud.uservm.UserVm;
2222
import com.cloud.utils.component.Adapter;
2323

24-
public interface KubernetesClusterHelper extends Adapter {
24+
public interface KubernetesServiceHelper extends Adapter {
2525

2626
ControlledEntity findByUuid(String uuid);
2727
ControlledEntity findByVmId(long vmId);

api/src/main/java/com/cloud/network/NetworkService.java

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121

2222
import com.cloud.dc.DataCenter;
23+
import org.apache.cloudstack.acl.ControlledEntity;
2324
import org.apache.cloudstack.api.command.admin.address.ReleasePodIpCmdByAdmin;
2425
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
2526
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
@@ -102,6 +103,10 @@ IpAddress allocatePortableIP(Account ipOwner, int regionId, Long zoneId, Long ne
102103

103104
Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException;
104105

106+
Network createGuestNetwork(long networkOfferingId, String name, String displayText, Account owner,
107+
PhysicalNetwork physicalNetwork, long zoneId, ControlledEntity.ACLType aclType) throws
108+
InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException;
109+
105110
Pair<List<? extends Network>, Integer> searchForNetworks(ListNetworksCmd cmd);
106111

107112
boolean deleteNetwork(long networkId, boolean forced);

api/src/main/java/com/cloud/vm/UserVmService.java

+4-23
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.cloud.exception.ConcurrentOperationException;
4646
import com.cloud.exception.InsufficientCapacityException;
4747
import com.cloud.exception.ManagementServerException;
48+
import com.cloud.exception.OperationTimedoutException;
4849
import com.cloud.exception.ResourceAllocationException;
4950
import com.cloud.exception.ResourceUnavailableException;
5051
import com.cloud.exception.StorageUnavailableException;
@@ -66,10 +67,7 @@ public interface UserVmService {
6667
/**
6768
* Destroys one virtual machine
6869
*
69-
* @param userId
70-
* the id of the user performing the action
71-
* @param vmId
72-
* the id of the virtual machine.
70+
* @param cmd the API Command Object containg the parameters to use for this service action
7371
* @throws ConcurrentOperationException
7472
* @throws ResourceUnavailableException
7573
*/
@@ -112,6 +110,8 @@ UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, E
112110

113111
UserVm rebootVirtualMachine(RebootVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ResourceAllocationException;
114112

113+
void startVirtualMachine(UserVm vm) throws OperationTimedoutException, ResourceUnavailableException, InsufficientCapacityException;
114+
115115
UserVm updateVirtualMachine(UpdateVMCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException;
116116

117117
/**
@@ -148,14 +148,6 @@ UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, E
148148
* Creates a Basic Zone User VM in the database and returns the VM to the
149149
* caller.
150150
*
151-
*
152-
*
153-
* @param sshKeyPair
154-
* - name of the ssh key pair used to login to the virtual
155-
* machine
156-
* @param cpuSpeed
157-
* @param memory
158-
* @param cpuNumber
159151
* @param zone
160152
* - availability zone for the virtual machine
161153
* @param serviceOffering
@@ -231,9 +223,6 @@ UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering s
231223
* Creates a User VM in Advanced Zone (Security Group feature is enabled) in
232224
* the database and returns the VM to the caller.
233225
*
234-
*
235-
*
236-
* @param type
237226
* @param zone
238227
* - availability zone for the virtual machine
239228
* @param serviceOffering
@@ -309,14 +298,6 @@ UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOfferin
309298
* Creates a User VM in Advanced Zone (Security Group feature is disabled)
310299
* in the database and returns the VM to the caller.
311300
*
312-
*
313-
*
314-
* @param sshKeyPair
315-
* - name of the ssh key pair used to login to the virtual
316-
* machine
317-
* @param cpuSpeed
318-
* @param memory
319-
* @param cpuNumber
320301
* @param zone
321302
* - availability zone for the virtual machine
322303
* @param serviceOffering

api/src/main/java/org/apache/cloudstack/api/ApiCommandResourceType.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
package org.apache.cloudstack.api;
1818

1919
import java.util.ArrayList;
20+
import java.util.HashMap;
2021
import java.util.List;
22+
import java.util.Map;
2123

2224
import org.apache.cloudstack.region.PortableIp;
2325
import org.apache.commons.collections.CollectionUtils;
@@ -81,15 +83,22 @@ public enum ApiCommandResourceType {
8183
ManagementServer(org.apache.cloudstack.management.ManagementServerHost.class),
8284
ObjectStore(org.apache.cloudstack.storage.object.ObjectStore.class),
8385
Bucket(org.apache.cloudstack.storage.object.Bucket.class),
84-
QuotaTariff(org.apache.cloudstack.quota.QuotaTariff.class);
86+
QuotaTariff(org.apache.cloudstack.quota.QuotaTariff.class),
87+
KubernetesCluster(null),
88+
KubernetesSupportedVersion(null);
8589

8690
private final Class<?> clazz;
8791

92+
static final Map<ApiCommandResourceType, Class<?>> additionalClassMappings = new HashMap<>();
93+
8894
private ApiCommandResourceType(Class<?> clazz) {
8995
this.clazz = clazz;
9096
}
9197

9298
public Class<?> getAssociatedClass() {
99+
if (this.clazz == null && additionalClassMappings.containsKey(this)) {
100+
return additionalClassMappings.get(this);
101+
}
93102
return this.clazz;
94103
}
95104

@@ -119,4 +128,8 @@ public static ApiCommandResourceType fromString(String value) {
119128
}
120129
return null;
121130
}
131+
132+
public static void setClassMapping(ApiCommandResourceType type, Class<?> clazz) {
133+
additionalClassMappings.put(type, clazz);
134+
}
122135
}

api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ public class CreateServiceOfferingCmd extends BaseCmd {
5454
@Parameter(name = ApiConstants.CPU_NUMBER, type = CommandType.INTEGER, required = false, description = "the CPU number of the service offering")
5555
private Integer cpuNumber;
5656

57-
@Parameter(name = ApiConstants.CPU_SPEED, type = CommandType.INTEGER, required = false, description = "the CPU speed of the service offering in MHz.")
57+
@Parameter(name = ApiConstants.CPU_SPEED, type = CommandType.INTEGER, required = false, description = "For VMware and Xen based hypervisors this is the CPU speed of the service offering in MHz.\n" +
58+
"For the KVM hypervisor," +
59+
" the values of the parameters cpuSpeed and cpuNumber will be used to calculate the `shares` value. This value is used by the KVM hypervisor to calculate how much time" +
60+
" the VM will have access to the host's CPU. The `shares` value does not have a unit, and its purpose is being a weight value for the host to compare between its guest" +
61+
" VMs. For more information, see https://libvirt.org/formatdomain.html#cpu-tuning.")
5862
private Integer cpuSpeed;
5963

6064
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, description = "The display text of the service offering, defaults to 'name'.")

api/src/main/java/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public class ListVMsCmd extends BaseListRetrieveOnlyResourceCountCmd implements
9797
collectionType = CommandType.STRING,
9898
description = "comma separated list of vm details requested, "
9999
+ "value can be a list of [all, group, nics, stats, secgrp, tmpl, servoff, diskoff, backoff, iso, volume, min, affgrp]."
100-
+ " If no parameter is passed in, the details will be defaulted to all. When return.vm.stats.on.vm.list is true, the default" +
101-
"details change to [group, nics, secgrp, tmpl, servoff, diskoff, backoff, iso, volume, min, affgrp], thus the stats will not be returned. ")
100+
+ " When no parameters are passed, all the details are returned if list.vm.default.details.stats is true (default),"
101+
+ " otherwise when list.vm.default.details.stats is false the API response will exclude the stats details.")
102102
private List<String> viewDetails;
103103

104104
@Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.UUID, entityType = TemplateResponse.class, description = "list vms by template")

api/src/main/java/org/apache/cloudstack/query/QueryService.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ public interface QueryService {
125125
static final ConfigKey<Boolean> SharePublicTemplatesWithOtherDomains = new ConfigKey<>("Advanced", Boolean.class, "share.public.templates.with.other.domains", "true",
126126
"If false, templates of this domain will not show up in the list templates of other domains.", true, ConfigKey.Scope.Domain);
127127

128-
ConfigKey<Boolean> ReturnVmStatsOnVmList = new ConfigKey<>("Advanced", Boolean.class, "return.vm.stats.on.vm.list", "true",
129-
"If false, changes the listVirtualMachines default details to [group, nics, secgrp, tmpl, servoff, diskoff, backoff, iso, volume, min, affgrp], so that the VMs' stats" +
130-
" are not returned by default when listing VMs; only when the 'stats' or 'all' detail is informed.", true, ConfigKey.Scope.Global);
128+
ConfigKey<Boolean> ReturnVmStatsOnVmList = new ConfigKey<>("Advanced", Boolean.class, "list.vm.default.details.stats", "true",
129+
"Determines whether VM stats should be returned when details are not explicitly specified in listVirtualMachines API request. When false, details default to [group, nics, secgrp, tmpl, servoff, diskoff, backoff, iso, volume, min, affgrp]. When true, all details are returned including 'stats'.", true, ConfigKey.Scope.Global);
131130

132131
ListResponse<UserResponse> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException;
133132

core/src/main/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@
339339
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
340340
</bean>
341341

342-
<bean id="kubernetesClusterHelperRegistry"
342+
<bean id="kubernetesServiceHelperRegistry"
343343
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
344344
</bean>
345345

core/src/main/resources/META-INF/cloudstack/kubernetes/spring-core-lifecycle-kubernetes-context-inheritable.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
>
2626

2727
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
28-
<property name="registry" ref="kubernetesClusterHelperRegistry" />
29-
<property name="typeClass" value="com.cloud.kubernetes.cluster.KubernetesClusterHelper" />
28+
<property name="registry" ref="kubernetesServiceHelperRegistry" />
29+
<property name="typeClass" value="com.cloud.kubernetes.cluster.KubernetesServiceHelper" />
3030
</bean>
3131

3232
</beans>

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1185,8 +1185,9 @@ public VolumeVO doInTransaction(TransactionStatus status) {
11851185
logger.error("Unable to destroy existing volume [{}] due to [{}].", volumeToString, e.getMessage());
11861186
}
11871187
// In case of VMware VM will continue to use the old root disk until expunged, so force expunge old root disk
1188-
if (vm.getHypervisorType() == HypervisorType.VMware) {
1189-
logger.info("Trying to expunge volume [{}] from primary data storage.", volumeToString);
1188+
// For system VM we do not need volume entry in Destroy state
1189+
if (vm.getHypervisorType() == HypervisorType.VMware || vm.getType().isUsedBySystem()) {
1190+
logger.info(String.format("Trying to expunge volume [%s] from primary data storage.", volumeToString));
11901191
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volFactory.getVolume(existingVolume.getId()));
11911192
try {
11921193
future.get();

engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
--;
1919
-- Schema upgrade cleanup from 4.19.0.0 to 4.19.1.0
2020
--;
21+
22+
-- List VMs response optimisation, don't sum during API handling
23+
UPDATE cloud.configuration set value='false' where name='vm.stats.increment.metrics';
24+
DELETE from cloud.configuration where name='vm.stats.increment.metrics.in.memory';

engine/schema/src/main/resources/META-INF/db/views/cloud.user_vm_view.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ FROM
196196
LEFT JOIN `networks` ON ((`nics`.`network_id` = `networks`.`id`)))
197197
LEFT JOIN `vpc` ON (((`networks`.`vpc_id` = `vpc`.`id`)
198198
AND ISNULL(`vpc`.`removed`))))
199-
LEFT JOIN `user_ip_address` ON ((`user_ip_address`.`vm_id` = `vm_instance`.`id`)))
199+
LEFT JOIN `user_ip_address` FORCE INDEX(`fk_user_ip_address__vm_id`) ON ((`user_ip_address`.`vm_id` = `vm_instance`.`id`)))
200200
LEFT JOIN `user_vm_details` `ssh_details` ON (((`ssh_details`.`vm_id` = `vm_instance`.`id`)
201201
AND (`ssh_details`.`name` = 'SSH.KeyPairNames'))))
202202
LEFT JOIN `resource_tags` ON (((`resource_tags`.`resource_id` = `vm_instance`.`id`)

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapperTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ public void testGetUnmanagedInstanceDisks() {
214214

215215
LibvirtDomainXMLParser parser = Mockito.mock(LibvirtDomainXMLParser.class);
216216
Mockito.when(parser.getDisks()).thenReturn(List.of(diskDef));
217+
Mockito.doReturn(new Pair<String, String>(null, null)).when(convertInstanceCommandWrapper).getNfsStoragePoolHostAndPath(destinationPool);
217218

218219
List<UnmanagedInstanceTO.Disk> unmanagedInstanceDisks = convertInstanceCommandWrapper.getUnmanagedInstanceDisks(disks, parser);
219220
Assert.assertEquals(1, unmanagedInstanceDisks.size());

0 commit comments

Comments
 (0)