The ability to export a VM to OVF format using the vCenter OVFTool can be easily integrated into a vCommander Change Request with a script. The steps below will guide you through configuring that script and change request workflow.


Requirements



Create the vCenter Credential File


For the script to access the vCenter it must have credentials to pass to the ovftool application. 

  1. Open Powershell ISE as an Administrator on the vCommander host.
  2. Execute the following to load the Embotics vCommander REST API:

    $moduleName = "VCommanderRestClient"
    If (-not (Get-Module -name $moduleName)) {Import-Module -Name $moduleName } 
    else {Remove-Module $moduleName
            Import-Module -Name $moduleName }
    $moduleName = "VCommander"
    If (-not (Get-Module -name $moduleName)) {Import-Module -Name $moduleName} 
    else {Remove-Module $moduleName
            Import-Module -Name $moduleName}


  3. Next, create a new Credential using:

    New-EncryptCredential -destFilePath "c:\scripts\vCenterCredentials.xml"


  4. Enter the user name and password for the vCenter system that users will be downloading OVF images from and click OK.



Configure the Request Form


  1. Log into your vCommander Administrative portal. Select Configuration -> Service Request Configuration from the top menu and select the Form Designer tab.
  2. Click the Add button under the Form Library on the left hand side. Set the Name of the new Form to "Export VM to OVF". Set the Completion Workflow to None. Click OK.
  3. Remove all fields except the Header field. Then, click the Text field link from the right hand side to add a Text box field. Enter this text in the Text field Text area:

    Click OK to begin the OVF export.
    
    Please Note:
    The export process may take a long period of time depending on the size of the selected VM.

    Click OK to save the Text field.

  4. Click Save to save the form.


Configure the Script


  1. Extract the "Export_To_OVF.ps1" script and "RSAProceed.txt" file to your vCommander scripts folder. This is usually "C:\Scripts\".
  2. Open the Export_To_OVF.ps1 file and edit the "Customer Configured Variables" section. Set the URL of your vCommander install, the path to your vCommander Credentials file and the path to the RSAProceed.txt file. 
  3. Next, set the $OVFExportLocation variable. This is the path to the location on disk where you want to save the OVF files.

    Important: the vCommander User Account must have READ/WRITE access to the location where you wish to save the OVF files of the script will fail.

  4. In your vCommander Administrative portal. Select Configuration -> Service Request Configuration from the top menu and select the Completion Workflow tab.
  5. Click the Add button. Set the Name to "Export VM to OVF" and the Apply this workflow option to "after a Change Request is fulfilled". Click Next.
  6. On the Steps page, click Add and select an Execute Script step type. Set the name to "Execute OVF Export Script" and set the Command line value to:
    powershell.exe  -ExecutionPolicy Bypass  &{C:\scripts\Export_To_OVF.ps1 -requestID "#{request.id}" -targetManagedServer "#{target.managedSystem.address}" -targetVMDNS "#{target.dnsName}" }


  7. Because the OVF export process can be lengthy it is recommended to increase the Timeout value to 1200 or something similarly long to allow the export to process. Click Next.
  8. On the Assigned Forms page check the Export VM to OVF option and  click Next.
  9. On the Summary page click Finish.


Now, you can perform a Change Request on a vCenter VM and select the Export VM to OVF option which will download the selected VM as an OVF file.