VMware {code} Community
nikbkd28
Contributor
Contributor

Install ISO on a Virtual Machine

Hi,

I can create a virtual machine through VMCreate API.

Now I want to install an iso image remotely through API. Could you please mention which API class should I go for?

I have not found any API in the VI-SDK (4.0), so I was thinking of FTP/SCP-ing the ISO image on the ESX Servers and then boot the virtual machine (created above) with the iso. Is there any such mechanisms that are supported through API?

Thank you in advance.

0 Kudos
9 Replies
lamw
Community Manager
Community Manager

So vSphere API does not provide any API calls for installing a guestOS, that is left up to you whether you do it manually or through some automated deployment infrastructure ...(e.g. how do you deploy physical systems, that should answer the question on how you install an OS on VMs)

You can mount an ISO if it exists on a datastore to a given VM, you'll want to use ReconfigureVM_Task, if you don't have the ISO, you can either upload it to datastore using the APIs or using something like Datastore Browser in vSphere Client. Provisioning the actual OS is outside of the scope of vSphere API.

If you have an existing OS that is supported that's already installed, you can clone this image and customize the VM using the vSphere API, but if you're installing from scratch, there are no VMware APIs to help with this.

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
nikbkd28
Contributor
Contributor

Thanks William!

0 Kudos
rajatscybage
Contributor
Contributor

Thanks William!!

Is there a way I can autorun that ISO which is mounted??

Thanks a lot in advance

Rajat

0 Kudos
stumpr
Virtuoso
Virtuoso

You can manipulate the boot order through the API, it was added in vSphere 4 I believe (not 100% sure).  If not, you just need your boot order to include the CDROM appropriately.

You can also leverage PXE through the VMware BIOS as well (again, just set the appropriate boot order and environment).

Reuben Stump | http://www.virtuin.com | @ReubenStump
0 Kudos
rajatscybage
Contributor
Contributor

It would be great if you share code snippet with me... I want to use vsphere sdk API only

0 Kudos
lamw
Community Manager
Community Manager

Reuben is correct, you can easily modify the boot order (this was introduced in vSphere 5.0 API). Here's a blog article with the details as well as a sample script http://www.virtuallyghetto.com/2011/07/2-hidden-virtual-machine-gems-in.html

0 Kudos
rajatscybage
Contributor
Contributor

Thanks Lamw for information

I am new to this Vmware vsphere sdk coding part. It would be great if you provide me sample code in vsphere 4.1 sdk API for the same.

I would be very thankful to you.

Thanks,

Regards,

Rajat

0 Kudos
lamw
Community Manager
Community Manager

Hi,

As mentioned in my last reply, modifying the boot order for a VM is a feature that was introduced in vSphere 5.0, you will need to be using vSphere 5.0 or greather to use this feature.

0 Kudos
rajatscybage
Contributor
Contributor

can you please provide me code for same..

0 Kudos