Home C# Create VMDK / Virtual HDD using C# & SDK / API.
Create VMDK / Virtual HDD using C# & SDK / API. PDF Print E-mail
Written by Siva   
Thursday, 18 November 2010 20:32

Here is a sample of creating VMDK / Virtual HDD file using C#.

 

using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Net;
using System.Text;
using System.Web.Services;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Globalization;

using System.Collections;
using VimApi;

 

//then use diskSpec command in namespace /class..

                // Create a new disk - file based - for the vm
                //VirtualDeviceConfigSpec diskSpec = null;
                //diskSpec = createVirtualDisk(datastoreName, diskCtlrKey, datastoreRef, diskSizeMB);
                String volumeName = "[" + datastoreName + "]";
                VirtualDeviceConfigSpec diskSpec = new VirtualDeviceConfigSpec();

                diskSpec.fileOperation = VirtualDeviceConfigSpecFileOperation.create;
                diskSpec.fileOperationSpecified = true;
                diskSpec.operation = VirtualDeviceConfigSpecOperation.add;
                diskSpec.operationSpecified = true;

                VirtualDisk disk = new VirtualDisk();
                VirtualDiskFlatVer2BackingInfo diskfileBacking = new VirtualDiskFlatVer2BackingInfo();

                diskfileBacking.fileName = "MyVmVMDK.vmdk";
                diskfileBacking.diskMode = "persistent";

                disk.key = 0;
                disk.controllerKey = diskCtlrKey;
                disk.unitNumber = 0;
                disk.backing = diskfileBacking;
                disk.capacityInKB = 20000;
                disk.controllerKeySpecified = true;
                disk.unitNumberSpecified = true;

                diskSpec.device = disk;

Last Updated on Friday, 19 November 2010 07:12
 
 

Advertisement

Featured Links:
HREmail.com
Looking for job? Try HREmail.com
Want to have CMS based Websites?
Try siliconwebcreators.com to CMS based websites.
VM Solutions Inc
For best VM solutions..
Digital Procedure Inc.
Looking for Oracle /SAP /Weblogic Consulting services? visit digitalprocedure.com