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 @@ public class RemoteInstanceTO implements Serializable {

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 @@ public RemoteInstanceTO(String instanceName) {
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) {
this.hypervisorType = Hypervisor.HypervisorType.VMware;
this.instanceName = instanceName;
this.instancePath = instancePath;
this.vcenterHost = vcenterHost;
this.vcenterUsername = vcenterUsername;
this.vcenterPassword = vcenterPassword;
Expand All @@ -61,6 +63,10 @@ public String getInstanceName() {
return this.instanceName;
}

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

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

private String internalCSName;

private String path;

private PowerState powerState;

private PowerState cloneSourcePowerState;
Expand Down Expand Up @@ -75,6 +77,14 @@ public void setInternalCSName(String internalCSName) {
this.internalCSName = internalCSName;
}

public String getPath() {
return path;
}

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

public PowerState getPowerState() {
return powerState;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,15 @@ private String getExportOVAUrlFromRemoteInstance(RemoteInstanceTO vmwareInstance
String password = vmwareInstance.getVcenterPassword();
String datacenter = vmwareInstance.getDatacenterName();
String vm = vmwareInstance.getInstanceName();
String path = vmwareInstance.getInstancePath();

String encodedUsername = encodeUsername(username);
String encodedPassword = encodeUsername(password);
if (StringUtils.isNotBlank(path)) {
logger.info("VM path: {}", path);
return String.format("vi://%s:%s@%s/%s/%s/%s",
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 @@ -1982,7 +1982,7 @@ private UnmanagedInstanceTO convertVmwareInstanceToKVMAfterExportingOVFToConvert
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);
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 @@ -996,6 +996,27 @@ public VirtualMachineFileLayoutEx getFileLayout() throws Exception {
return fileLayout;
}

public String getPath() throws Exception {
List<String> subPaths = new ArrayList<>();
ManagedObjectReference mor = _context.getVimClient().getDynamicProperty(_mor, "parent");
while (mor != null && mor.getType().equalsIgnoreCase("Folder")) {
String subPath = _context.getVimClient().getDynamicProperty(mor, "name");
if (StringUtils.isBlank(subPath)) {
return null;
}
subPaths.add(subPath);
mor = _context.getVimClient().getDynamicProperty(mor, "parent");
}

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

return null;
}

@Override
public ManagedObjectReference getParentMor() throws Exception {
return (ManagedObjectReference)_context.getVimClient().getDynamicProperty(_mor, "parent");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ public static UnmanagedInstanceTO getUnmanagedInstance(VmwareHypervisorHost hype
instance = new UnmanagedInstanceTO();
instance.setName(vmMo.getVmName());
instance.setInternalCSName(vmMo.getInternalCSName());
instance.setPath((vmMo.getPath()));
instance.setCpuCoresPerSocket(vmMo.getCoresPerSocket());
instance.setOperatingSystemId(vmMo.getVmGuestInfo().getGuestId());
VirtualMachineConfigSummary configSummary = vmMo.getConfigSummary();
Expand Down
Loading