Home > Blogs > VMware PowerCLI Blog


PowerCLI 5.8 New Feature: Get-OvfConfiguration (Part 1 of 2)

 

As many of you have read in the release notes of vSphere PowerCLI 5.8 r1 we have introduced a new cmdlet ‘Get-OvfConfiguration’ along with a new parameter on the ‘Import-vApp’ cmdlet to allow users to specify and set the OVF properties for an OVF deployment.

image

In Part 1 we will dive in to the Get-OvfConfiguration cmdlet and how to add your configuration to the OvfConfiguration object.

in Part 2 will be on using the –OvfConfiguration parameter with the values from this post, to import vApps into your environment.

So, how does this work?

Let’s take a look at the cmdlet documentation. running ‘get-help get-OvfConfiguration’ will bring this back for us.

Screenshot 2014-09-12 10.04.27

As you can see the syntax of the command requires the path to the OVF and either the vCenter server parameter or that you are already connected to a vCenter server. If your PowerCLI session is already connected, you do not need to add this parameter to the command.

First, we’ll connect to our vCenter server to return the OvfConfiguration properties.

Screenshot 2014-09-12 10.03.23

Now, we can go ahead and run the ‘Get-OvfConfiguration’ cmdlet. We’ll specify the path to the OVF.

$ovfpath = “Path to OVA”

Screenshot 2014-09-12 10.05.13

We can then use our $ovfpath variable in our command: Get-OvfConfiguration –Ovf $ovfpath

Screenshot 2014-09-12 10.05.56

Now that we have the configuration properties of the OVA, lets take a look at them.

$ovfconfig.ToHashTable() | ft –autosize

Screenshot 2014-09-12 10.08.47

We can now see the properties that we can assign values to for deployment. There are several ways we can do this. *Note: The actual position of the property in the OvfConfiguration object may be different from its OVF key.

Assigning Values to vApp Properties

The OvfConfiguration parameter accepts both the OvfConfiguration object as well as a plain Hash Table.

Populating Objects

Populating the object would be done in the following manner:

$ovfconfig.NetworkMapping.Network_1.Value = “Network 1”
$ovfconfig.IpAssignment.IpProtocol.Value = “IPv4”
$ovfconfig.vami.VMware_vCenter_Log_Insight.hostname.value = “SDDC-LogInsight”
$ovfconfig.vami.VMware_vCenter_Log_Insight.ip0.value = “10.144.99.70”
$ovfconfig.vami.VMware_vCenter_Log_Insight.netmask0.value = “255.255.255.0”
$ovfconfig.vami.VMware_vCenter_Log_Insight.gateway.value = “10.144.99.1”
$ovfconfig.vami.VMware_vCenter_Log_Insight.DNS.value = “10.144.99.5”
$ovfconfig.vm.rootpw.value = “VMware1!”

you can see the steps I took to add these values in the screenshots below.

Enter the ovfconfig variable and hit enter. you will see a number of objects.

To set the values for these properties we must find the key that we need to set. We can do this by going deeper into each object.

Screenshot 2014-09-12 10.52.57

In this part we dive in to the vami properties. we can see that there are 5 properties we can set.

  • hostname
  • ip0
  • netmask0
  • gateway
  • DNS

Screenshot 2014-09-12 10.52.57

Following the pattern above we find the path of each key and set the values to each property.

Screenshot 2014-09-12 10.57.18

After setting the vami properties, the last property to set is the root password.

Screenshot 2014-09-12 10.57.45

A few other examples from Alan Renouf include specifying the network mapping for Standard and Distributed port groups

# Populate an OvfConfiguration object
# The populated OvfConfiguration object specifies a network mapping by standard port group.
$ovfConfig = Get-OvfConfiguration “myOvfTemplate.ovf”
$portGroup = Get-VirtualPortGroup -Name “Network 2” -Standard
$ovfConfig.NetworkMapping.Network.Value = $portGroup
Import-VApp $ovfPath -OvfConfiguration $ovfConfig -VMHost $vmHost

# Populate an OvfConfiguration object
# The populated OvfConfiguration object specifies a network mapping by distributed port group.
$ovfConfig = Get-OvfConfiguration “myOvfTemplate.ovf”
$vdPortGroup = Get-VDPortgroup “myDistributedPortGroup”
$ovfConfig.NetworkMapping.Network.Value = $vdPortGroup

Leveraging Hash Tables

We can also directly populate a HashTable to be used with the Import-vApp Cmdlet:

$ovfconfig = @{
“vami.gateway.VMware_vCenter_Log_Insight” = “10.144.99.1”
“vm.rootpw” = “VMware1!”
“vami.DNS.VMware_vCenter_Log_Insight” = “10.144.99.5”
“vami.ip0.VMware_vCenter_Log_Insight”= “10.144.99.70”
“vami.hostname.VMware_vCenter_Log_Insight” = “SDDC-LogInsight”
“vami.netmask0.VMware_vCenter_Log_Insight” = “255.255.255.0”}

which looks like this:

Screenshot 2014-09-12 11.18.51

Either method will deliver the same results; it comes down to personal preference as to which way you do this.

Now that we have populated our OvfConfiguration object we can use it to import vApps.

Stay tuned for Part 2 on using the –OvfConfiguration parameter to import the vApps

This entry was posted in Customization, General, vCenter and tagged , , , on by .
Brian Graf

About Brian Graf

Brian Graf is a well-known VMware evangelist in the IT community. Over the past 5 years, Brian has done Technical Marketing for PowerCLI Automation and ESXi Lifecycle, Product Management of vCenter Distributed Resource Management features (DRS & HA), and is currently working as a Technical Marketing Manager for VMware Cloud on AWS. Brian is a co-author of the PowerCLI Deep Dive 2nd edition book. He has helped develop VMware certification courses and exams and presents around the world at VMware User Conferences, AWS Summits, Interop, as well as other industry Conferences. Brian is also a Microsoft MVP.