Skip to content

Commit 567f2b0

Browse files
Merge branch '4.22' into 4.22-fix-template-type-upload-template
2 parents e01730a + 59b6c32 commit 567f2b0

File tree

59 files changed

+874
-213
lines changed

Some content is hidden

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

59 files changed

+874
-213
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ UserVm upgradeVirtualMachine(ScaleVMCmd cmd) throws ResourceUnavailableException
524524
* @param userId user ID
525525
* @param serviceOffering service offering for the imported VM
526526
* @param sshPublicKey ssh key for the imported VM
527+
* @param guestOsId guest OS ID for the imported VM (if not passed, then the guest OS of the template will be used)
527528
* @param hostName the name for the imported VM
528529
* @param hypervisorType hypervisor type for the imported VM
529530
* @param customParameters details for the imported VM
@@ -533,7 +534,7 @@ UserVm upgradeVirtualMachine(ScaleVMCmd cmd) throws ResourceUnavailableException
533534
* @throws InsufficientCapacityException in case of errors
534535
*/
535536
UserVm importVM(final DataCenter zone, final Host host, final VirtualMachineTemplate template, final String instanceNameInternal, final String displayName, final Account owner, final String userData, final Account caller, final Boolean isDisplayVm, final String keyboard,
536-
final long accountId, final long userId, final ServiceOffering serviceOffering, final String sshPublicKey,
537+
final long accountId, final long userId, final ServiceOffering serviceOffering, final String sshPublicKey, final Long guestOsId,
537538
final String hostName, final HypervisorType hypervisorType, final Map<String, String> customParameters,
538539
final VirtualMachine.PowerState powerState, final LinkedHashMap<String, List<NicProfile>> networkNicMap) throws InsufficientCapacityException;
539540

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ public static StateMachine2<State, VirtualMachine.Event, VirtualMachine> getStat
124124
s_fsm.addTransition(new Transition<State, Event>(State.Stopping, VirtualMachine.Event.StopRequested, State.Stopping, null));
125125
s_fsm.addTransition(new Transition<State, Event>(State.Stopping, VirtualMachine.Event.AgentReportShutdowned, State.Stopped, Arrays.asList(new Impact[]{Impact.USAGE})));
126126
s_fsm.addTransition(new Transition<State, Event>(State.Expunging, VirtualMachine.Event.OperationFailed, State.Expunging,null));
127+
// Note: In addition to the Stopped -> Error transition for failed VM creation,
128+
// a VM can also transition from Expunging to Error on OperationFailedToError.
129+
s_fsm.addTransition(new Transition<State, Event>(State.Expunging, VirtualMachine.Event.OperationFailedToError, State.Error, null));
127130
s_fsm.addTransition(new Transition<State, Event>(State.Expunging, VirtualMachine.Event.ExpungeOperation, State.Expunging,null));
128131
s_fsm.addTransition(new Transition<State, Event>(State.Error, VirtualMachine.Event.DestroyRequested, State.Expunging, null));
129132
s_fsm.addTransition(new Transition<State, Event>(State.Error, VirtualMachine.Event.ExpungeOperation, State.Expunging, null));

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.cloudstack.api.Parameter;
3131
import org.apache.cloudstack.api.ResponseObject;
3232
import org.apache.cloudstack.api.ServerApiException;
33+
import org.apache.cloudstack.api.response.GuestOSResponse;
3334
import org.apache.cloudstack.api.response.HostResponse;
3435
import org.apache.cloudstack.api.response.NetworkResponse;
3536
import org.apache.cloudstack.api.response.StoragePoolResponse;
@@ -171,6 +172,13 @@ public class ImportVmCmd extends ImportUnmanagedInstanceCmd {
171172
description = "(only for importing VMs from VMware to KVM) optional - if true, forces virt-v2v conversions to write directly on the provided storage pool (avoid using temporary conversion pool).")
172173
private Boolean forceConvertToPool;
173174

175+
@Parameter(name = ApiConstants.OS_ID,
176+
type = CommandType.UUID,
177+
entityType = GuestOSResponse.class,
178+
since = "4.22.1",
179+
description = "(only for importing VMs from VMware to KVM) optional - the ID of the guest OS for the imported VM.")
180+
private Long guestOsId;
181+
174182
/////////////////////////////////////////////////////
175183
/////////////////// Accessors ///////////////////////
176184
/////////////////////////////////////////////////////
@@ -268,6 +276,10 @@ public boolean getForceConvertToPool() {
268276
return BooleanUtils.toBooleanDefaultIfNull(forceConvertToPool, false);
269277
}
270278

279+
public Long getGuestOsId() {
280+
return guestOsId;
281+
}
282+
271283
@Override
272284
public String getEventDescription() {
273285
String vmName = getName();

api/src/main/java/org/apache/cloudstack/api/command/user/guest/ListGuestOsCmd.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public class ListGuestOsCmd extends BaseListCmd {
4545
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuestOSResponse.class, description = "List by OS type ID")
4646
private Long id;
4747

48+
@Parameter(name = ApiConstants.IDS, type = CommandType.LIST, collectionType = CommandType.UUID,
49+
entityType = GuestOSResponse.class, since = "4.22.1",
50+
description = "Comma separated list of OS types")
51+
private List<Long> ids;
52+
4853
@Parameter(name = ApiConstants.OS_CATEGORY_ID, type = CommandType.UUID, entityType = GuestOSCategoryResponse.class, description = "List by OS Category ID")
4954
private Long osCategoryId;
5055

@@ -63,6 +68,10 @@ public Long getId() {
6368
return id;
6469
}
6570

71+
public List<Long> getIds() {
72+
return ids;
73+
}
74+
6675
public Long getOsCategoryId() {
6776
return osCategoryId;
6877
}

api/src/main/java/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd {
4646
@Parameter(name = ApiConstants.GATEWAY_ID,
4747
type = CommandType.UUID,
4848
entityType = PrivateGatewayResponse.class,
49-
required = true,
5049
description = "The gateway ID we are creating static route for. Mutually exclusive with the nexthop parameter")
5150
private Long gatewayId;
5251

api/src/main/java/org/apache/cloudstack/api/response/UnmanagedInstanceResponse.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ public class UnmanagedInstanceResponse extends BaseResponse {
5151
@Param(description = "The name of the host to which Instance belongs")
5252
private String hostName;
5353

54+
@SerializedName(ApiConstants.HYPERVISOR)
55+
@Param(description = "The hypervisor to which Instance belongs")
56+
private String hypervisor;
57+
58+
@SerializedName(ApiConstants.HYPERVISOR_VERSION)
59+
@Param(description = "The hypervisor version of the host to which Instance belongs")
60+
private String hypervisorVersion;
61+
5462
@SerializedName(ApiConstants.POWER_STATE)
5563
@Param(description = "The power state of the Instance")
5664
private String powerState;
@@ -140,6 +148,22 @@ public void setHostName(String hostName) {
140148
this.hostName = hostName;
141149
}
142150

151+
public String getHypervisor() {
152+
return hypervisor;
153+
}
154+
155+
public void setHypervisor(String hypervisor) {
156+
this.hypervisor = hypervisor;
157+
}
158+
159+
public String getHypervisorVersion() {
160+
return hypervisorVersion;
161+
}
162+
163+
public void setHypervisorVersion(String hypervisorVersion) {
164+
this.hypervisorVersion = hypervisorVersion;
165+
}
166+
143167
public String getPowerState() {
144168
return powerState;
145169
}

api/src/main/java/org/apache/cloudstack/storage/volume/VolumeImportUnmanageService.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,29 @@
2525
import org.apache.cloudstack.api.response.ListResponse;
2626
import org.apache.cloudstack.api.response.VolumeForImportResponse;
2727
import org.apache.cloudstack.api.response.VolumeResponse;
28+
import org.apache.cloudstack.framework.config.ConfigKey;
29+
import org.apache.cloudstack.framework.config.Configurable;
2830

2931
import java.util.Arrays;
3032
import java.util.List;
3133

32-
public interface VolumeImportUnmanageService extends PluggableService {
34+
public interface VolumeImportUnmanageService extends PluggableService, Configurable {
3335

3436
List<Hypervisor.HypervisorType> SUPPORTED_HYPERVISORS =
3537
Arrays.asList(Hypervisor.HypervisorType.KVM, Hypervisor.HypervisorType.VMware);
3638

3739
List<Storage.StoragePoolType> SUPPORTED_STORAGE_POOL_TYPES_FOR_KVM = Arrays.asList(Storage.StoragePoolType.NetworkFilesystem,
3840
Storage.StoragePoolType.Filesystem, Storage.StoragePoolType.RBD);
3941

42+
ConfigKey<Boolean> AllowImportVolumeWithBackingFile = new ConfigKey<>(Boolean.class,
43+
"allow.import.volume.with.backing.file",
44+
"Advanced",
45+
"false",
46+
"If enabled, allows QCOW2 volumes with backing files to be imported or unmanaged",
47+
true,
48+
ConfigKey.Scope.Global,
49+
null);
50+
4051
ListResponse<VolumeForImportResponse> listVolumesForImport(ListVolumesForImportCmd cmd);
4152

4253
VolumeResponse importVolume(ImportVolumeCmd cmd);

api/src/main/java/org/apache/cloudstack/vm/UnmanagedInstanceTO.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public enum PowerState {
5555

5656
private String hostName;
5757

58+
private String hypervisorType;
59+
private String hostHypervisorVersion;
60+
5861
private List<Disk> disks;
5962

6063
private List<Nic> nics;
@@ -168,6 +171,22 @@ public void setHostName(String hostName) {
168171
this.hostName = hostName;
169172
}
170173

174+
public String getHypervisorType() {
175+
return hypervisorType;
176+
}
177+
178+
public void setHypervisorType(String hypervisorType) {
179+
this.hypervisorType = hypervisorType;
180+
}
181+
182+
public String getHostHypervisorVersion() {
183+
return hostHypervisorVersion;
184+
}
185+
186+
public void setHostHypervisorVersion(String hostHypervisorVersion) {
187+
this.hostHypervisorVersion = hostHypervisorVersion;
188+
}
189+
171190
public List<Disk> getDisks() {
172191
return disks;
173192
}

api/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
public interface UnmanagedVMsManager extends VmImportService, UnmanageVMService, PluggableService, Configurable {
2828

29+
String VM_IMPORT_DEFAULT_TEMPLATE_NAME = "system-default-vm-import-dummy-template.iso";
30+
String KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME = "kvm-default-vm-import-dummy-template";
2931
ConfigKey<Boolean> UnmanageVMPreserveNic = new ConfigKey<>("Advanced", Boolean.class, "unmanage.vm.preserve.nics", "false",
3032
"If set to true, do not remove VM nics (and its MAC addresses) when unmanaging a VM, leaving them allocated but not reserved. " +
3133
"If set to false, nics are removed and MAC addresses can be reassigned", true, ConfigKey.Scope.Zone);

core/src/main/java/com/cloud/storage/template/HttpTemplateDownloader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import com.cloud.utils.Pair;
5353
import com.cloud.utils.UriUtils;
5454
import com.cloud.utils.exception.CloudRuntimeException;
55+
import com.cloud.utils.net.HttpClientCloudStackUserAgent;
5556
import com.cloud.utils.net.Proxy;
5657

5758
/**
@@ -125,6 +126,7 @@ private GetMethod createRequest(String downloadUrl) {
125126
GetMethod request = new GetMethod(downloadUrl);
126127
request.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, myretryhandler);
127128
request.setFollowRedirects(followRedirects);
129+
request.getParams().setParameter(HttpMethodParams.USER_AGENT, HttpClientCloudStackUserAgent.CLOUDSTACK_USER_AGENT);
128130
return request;
129131
}
130132

0 commit comments

Comments
 (0)