VMware {code} Community
tos2k
Expert
Expert

How to select specific disks

Hi!

How can I select specific disks from a physical machine, how to disable not needed disks - as I can do in the UI?

The documentation on the converter API is a shame... basically just a bunch of 100s of classes... very poor.

Tos2k

0 Kudos
6 Replies
peevs
VMware Employee
VMware Employee

To specify concrete disk you will have to add set the

ConverterStorageParams.targetDiskParams property.

This is an array in which you have to put only the info about the disk you want to copy. If this property is not set all disk a copied.

Path to ConverterStorageParams...

ConverterServerConversionConversionJobSpec.ConverterConversionParams.ConverterCloningParams.ConverterStorageParams...

In the targetDiskParams (which is array of ConverterStorageParamsTargetDiskParams) you will have to specify sourceDiskId of the each disk you wan't to be copied. To get this IDs you can use QueryManager... to query info about the source first.

Here it is example code.. which query Physical machine to get list of services... you will have to modify it to get the list of the disk infos and also if your source is not Phisical machine.

private ConverterServiceInfo[] getLiveVmServicesList(ConverterComputerSpecLiveComputerLocation liveComputerLocation)
         throws Exception {
      if (liveComputerLocation == null) {
         throw new Exception("liveComputer location is null !");
      }
      if (!liveComputerLocation.getOsType().equalsIgnoreCase("windowsOs")) {
         throw new Exception("Unsupporter OS type - \"getLiveVmServiceList\" is supported only for Windows sources !");
      }
      ConverterComputerSpec computerSpec = new ConverterComputerSpec();
      computerSpec.setLocation(liveComputerLocation);
      ConverterComputerInfo computerInfo = converterQuery(computerSpec);
      ConverterServiceInfo[] computerServices = computerInfo.getOsInfo().getServices();
      return computerServices;
   }

private ConverterComputerInfo converterQuery(ConverterComputerSpec computerSpec) throws Exception {
      ManagedObjectReference queryManagerMor = _converterServer.getQueryManager();
      ConverterComputerInfo computerInfo =
            _converterServer.getConverterServicePort().converterQuery(queryManagerMor, computerSpec); //converterServer class if from the SDK examples...
      return computerInfo;
   }

tos2k
Expert
Expert

Looks like you are using Java. All that stuff looks cute, but is that from some Framework/API wrapping ConverterAPI, or just som helper code you wrote on your own?

Tos2k

0 Kudos
tos2k
Expert
Expert

Refined .NET C# code to pick disk idents:

        public ConverterComputerOsInfoLogicalVolumeInfo[] GetLiveVmDisksList()

        {

            if (liveComputerLocation == null)

            {

                throw new Exception("liveComputer location is null !");

            }

            if (!liveComputerLocation.osType.ToLower().Equals("windowsos"))

            {

                throw new Exception("Unsupporter OS type - \"getLiveVmServiceList\" is supported only for Windows sources !");

            }

            ConverterComputerSpec computerSpec = new ConverterComputerSpec();

            computerSpec.location = liveComputerLocation;

            ConverterComputerInfo computerInfo = _converterService.ConverterQuery(_converterServerContent.queryManager, computerSpec);

            return computerInfo.osInfo.logicalVolumeInfo;

        }

Maybe more suitable now 😉

Tos2k

0 Kudos
RBarfoot
Contributor
Contributor

I've been trying to query a list of disk IDs so I can set them all to thin provisioned disks during the conversion (physical to virtual in my case). I've tried your example, but in the SDK I downloaded, I don't see getQueryManager or getConverterServicePort in any of the sample classes.

Was this example for an older/different version, perhaps?

Is there another way to set all disks, regardless of the number of disks, to thin provisioning while preparing a physical to virtual conversion?

Thank you.

0 Kudos
iangelov
VMware Employee
VMware Employee

Look at java example ConverterConnectoion.java file.

Query manager is accessible by _converterServerContent.getQueryManager().

In the same place you can find service port used.

0 Kudos
RBarfoot
Contributor
Contributor

Awesome, thank you iangelov. I now have my list of IDs. I really appreciate the help.

I'd give you one of those 'helpful' stars, but I'm new to these forums and I don't know how.

Thank you anyway. Give yourself a gold star for the day Smiley Happy.

0 Kudos