Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

private Hypervisor.HypervisorType hypervisorType;
private String instanceName;
private String instancePath;

// VMware Remote Instances parameters (required for exporting OVA through ovftool)
// TODO: cloud.agent.transport.Request#getCommands() cannot handle gsoc decode for polymorphic classes
Expand All @@ -44,9 +45,10 @@
this.instanceName = instanceName;
}

public RemoteInstanceTO(String instanceName, String vcenterHost, String vcenterUsername, String vcenterPassword, String datacenterName) {
public RemoteInstanceTO(String instanceName, String instancePath, String vcenterHost, String vcenterUsername, String vcenterPassword, String datacenterName) {

Check warning on line 48 in api/src/main/java/com/cloud/agent/api/to/RemoteInstanceTO.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/com/cloud/agent/api/to/RemoteInstanceTO.java#L48

Added line #L48 was not covered by tests
this.hypervisorType = Hypervisor.HypervisorType.VMware;
this.instanceName = instanceName;
this.instancePath = instancePath;

Check warning on line 51 in api/src/main/java/com/cloud/agent/api/to/RemoteInstanceTO.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/com/cloud/agent/api/to/RemoteInstanceTO.java#L51

Added line #L51 was not covered by tests
this.vcenterHost = vcenterHost;
this.vcenterUsername = vcenterUsername;
this.vcenterPassword = vcenterPassword;
Expand All @@ -61,6 +63,10 @@
return this.instanceName;
}

public String getInstancePath() {
return this.instancePath;
}

Check warning on line 68 in api/src/main/java/com/cloud/agent/api/to/RemoteInstanceTO.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/com/cloud/agent/api/to/RemoteInstanceTO.java#L66-L68

Added lines #L66 - L68 were not covered by tests

public String getVcenterUsername() {
return vcenterUsername;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

private String internalCSName;

private String path;

private PowerState powerState;

private PowerState cloneSourcePowerState;
Expand Down Expand Up @@ -75,6 +77,14 @@
this.internalCSName = internalCSName;
}

public String getPath() {
return path;
}

Check warning on line 82 in api/src/main/java/org/apache/cloudstack/vm/UnmanagedInstanceTO.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/vm/UnmanagedInstanceTO.java#L80-L82

Added lines #L80 - L82 were not covered by tests

public void setPath(String path) {
this.path = path;
}

Check warning on line 86 in api/src/main/java/org/apache/cloudstack/vm/UnmanagedInstanceTO.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/vm/UnmanagedInstanceTO.java#L84-L86

Added lines #L84 - L86 were not covered by tests

public PowerState getPowerState() {
return powerState;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
RemoteInstanceTO sourceInstance = cmd.getSourceInstance();
Hypervisor.HypervisorType sourceHypervisorType = sourceInstance.getHypervisorType();
String sourceInstanceName = sourceInstance.getInstanceName();
String sourceInstancePath = sourceInstance.getInstancePath();
Hypervisor.HypervisorType destinationHypervisorType = cmd.getDestinationHypervisorType();
DataStoreTO conversionTemporaryLocation = cmd.getConversionTemporaryLocation();
long timeout = (long) cmd.getWait() * 1000;
Expand Down Expand Up @@ -177,9 +178,15 @@
String password = vmwareInstance.getVcenterPassword();
String datacenter = vmwareInstance.getDatacenterName();
String vm = vmwareInstance.getInstanceName();
String path = vmwareInstance.getInstancePath();

Check warning on line 181 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java#L181

Added line #L181 was not covered by tests

String encodedUsername = encodeUsername(username);
String encodedPassword = encodeUsername(password);
if (StringUtils.isNotBlank(path)) {
s_logger.info("VM path: " + path);
return String.format("vi://%s:%s@%s/%s/%s/%s",

Check warning on line 187 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java#L186-L187

Added lines #L186 - L187 were not covered by tests
encodedUsername, encodedPassword, vcenter, datacenter, path, vm);
}
return String.format("vi://%s:%s@%s/%s/vm/%s",
encodedUsername, encodedPassword, vcenter, datacenter, vm);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@
LOGGER.debug(String.format("Delegating the conversion of instance %s from VMware to KVM to the host %s (%s) after OVF export through ovftool",
sourceVM, convertHost.getId(), convertHost.getName()));

RemoteInstanceTO remoteInstanceTO = new RemoteInstanceTO(sourceVMwareInstance.getName(), vcenterHost, vcenterUsername, vcenterPassword, datacenterName);
RemoteInstanceTO remoteInstanceTO = new RemoteInstanceTO(sourceVMwareInstance.getName(), sourceVMwareInstance.getPath(), vcenterHost, vcenterUsername, vcenterPassword, datacenterName);

Check warning on line 1950 in server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java#L1950

Added line #L1950 was not covered by tests
List<String> destinationStoragePools = selectInstanceConversionStoragePools(convertStoragePools, sourceVMwareInstance.getDisks(), serviceOffering, dataDiskOfferingMap);
ConvertInstanceCommand cmd = new ConvertInstanceCommand(remoteInstanceTO,
Hypervisor.HypervisorType.KVM, temporaryConvertLocation, null, false, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,27 @@
return fileLayout;
}

public String getPath() throws Exception {
List<String> subPaths = new ArrayList<>();
ManagedObjectReference mor = _context.getVimClient().getDynamicProperty(_mor, "parent");

Check warning on line 896 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java#L894-L896

Added lines #L894 - L896 were not covered by tests
while (mor != null && mor.getType().equalsIgnoreCase("Folder")) {
String subPath = _context.getVimClient().getDynamicProperty(mor, "name");

Check warning on line 898 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java#L898

Added line #L898 was not covered by tests
if (StringUtils.isBlank(subPath)) {
return null;

Check warning on line 900 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java#L900

Added line #L900 was not covered by tests
}
subPaths.add(subPath);
mor = _context.getVimClient().getDynamicProperty(mor, "parent");
}

Check warning on line 904 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java#L902-L904

Added lines #L902 - L904 were not covered by tests

if (!subPaths.isEmpty()) {
Collections.reverse(subPaths);
String path = StringUtils.join(subPaths, "/");
return path;

Check warning on line 909 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java#L907-L909

Added lines #L907 - L909 were not covered by tests
}

return null;
}

Check warning on line 913 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java#L912-L913

Added lines #L912 - L913 were not covered by tests

@Override
public ManagedObjectReference getParentMor() throws Exception {
return _context.getVimClient().getDynamicProperty(_mor, "parent");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@
instance = new UnmanagedInstanceTO();
instance.setName(vmMo.getVmName());
instance.setInternalCSName(vmMo.getInternalCSName());
instance.setPath((vmMo.getPath()));

Check warning on line 804 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareHelper.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareHelper.java#L804

Added line #L804 was not covered by tests
instance.setCpuCoresPerSocket(vmMo.getCoresPerSocket());
instance.setOperatingSystemId(vmMo.getVmGuestInfo().getGuestId());
VirtualMachineConfigSummary configSummary = vmMo.getConfigSummary();
Expand Down
Loading