Exporting VM (VMware)

This is a really simple export routine for VMware using a custom button.

In an implementation I would maybe wrap this with

  1. A dialog to offer different export locations and naming of the export to include date/time stamp and maybe a checkbox to enable disable the overwrite of existing exports.
  2. Add in the approval system, basically some workloads should require authorisation by a manager to allow the export, we could do this by tag, and capture this in the method.
  3. Some error checking and folder creation stuff in the simple method.

Pre-req – We need OVFTOOL from VMware, we want to stay supported and this is the right route to take. You can download the ovftool from here http://www.vmware.com/support/developer/ovf/ Simply download, transfer, install, no reboot required.

So how will it look?

Screen Shot 2013-05-22 at 21.30.34

You will execute a custom button from the VM’s view.The button will be configured as follows;

Screen Shot 2013-05-22 at 21.37.18

The method sitting behind the button will be as follows; (don’t forget to set the export_location variable, and you also need to create the location manually in this example, also create a sub folder called “VMware” as this is where the exported OVFs will be placed – Example – /vmExport/VMware/)

Download method here https://github.com/jonnyfiveiq/CloudFORMSNOW/tree/master/Integrations/Operations/vmExport

<br /><br />#<br /># EVM Automate Method<br />#<br />$evm.log("info", "EVM Automate Method Started")<br />#<br /># Method Code Goes here<br />#<br />export_location = "/vmExport/"<br />vm = $evm.root['vm']<br />ems = vm.ext_management_system<br />$evm.log("info","VM Name = #{vm.name}")<br />$evm.log("info","vCenter Name = #{ems.name}")<br /><br />dir = export_location + vm.vendor<br />ovftool = "/usr/bin/ovftool "<br />arguments = "vi://#{ems.authentication_userid}:#{ems.authentication_password}@#{ems.ipaddress}/#{vm.v_owning_datacenter}?ds=[#{vm.storage_name}]/#{vm.location} #{dir}/#{vm.name}"<br />command = ovftool + arguments<br />$evm.log("info","Launching Command - #{command}")<br />begin<br />rc = system(command)<br />rescue<br />$evm.log("info","OVFTOOL Return - #{rc}")<br />end<br /><br />#<br />#<br />#<br />$evm.log("info", "EVM Automate Method Ended")<br />exit MIQ_OK<br /><br />

 

When executed you should see in the automate log the following, the process is fire and forget as it could take some time to complete.

Screen Shot 2013-05-22 at 21.35.27

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s