VMware Cloud Community
dwchan
Enthusiast
Enthusiast

Deploying ova with PowerCLI and no vCenter

I am trying to automate an OVA deployment of a virtual machine (virtual router) that is based on VMware Photon.  It has 3 network interfaces where during a normal deployment, using the ESXi Host Client web, the user would input the standard parameter (name, datastore, disk thin or thick) and the custom eth0 interface IP (address/subnet/gw) info.  Eth1 and eth2 already has a set of default values.  I been googling and racking my brain and can't seem to find a way to do this without vCenter.  Some of my obseravtion

1. using ova format with Import-vApp does not work with the typical "Invalid URI: The hostname could not be parsed." error

2. I convert the ova to ovf (ovf, mf, and vmdk) and trying to use the Import-vApp option -Ovfconfigation, that also doesn't work as I have no context to the proper variables fo build the hashtable array $ovfconfig. 

3.I tried to best guess it, but ended up get a content library error?

$ovfConfig = Get-OvfConfiguration $OVF
$ovfConfig.ToHashTable()
$ovfConfig = @{
   "vami.ip0.VM_1"="192.168.10.4";
   "vami.netmask0.VM_1"="255.255.255.0";
   "vami.gateway.VM_1"="192.168.10.2"
}
 

Get-OvfConfiguration : Cannot bind argument to parameter 'ContentLibraryItem' because it is null.
At line:1 char:35
+ $ovfConfig = Get-OvfConfiguration $OVF
+ ~~~~
+ CategoryInfo : InvalidData: (:) [Get-OvfConfiguration], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,VMware.VimAutomation.ViCore.Cmdlets.Commands.OVF.GetOvfConfiguration

Method invocation failed because [System.Collections.Hashtable] does not contain a method named 'ToHashTable'.
At line:2 char:1
+ $ovfConfig.ToHashTable()
+ ~~~~~~~~~~~~~~~~~~~~~~~~
At line:2 char:1
+ $ovfConfig.ToHashTable()
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

4. Last but not least, I try to Import-vApp the convert ovf as it (knowing that at least eth0 will need post configuration), the virtual router VM import across with zero network configuration (eth0, eth1, eth2)

I am totally out of ideas, so any suggestions would be strongly appreciated

 

Labels (1)
Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership

What do you have in the $OVF variable?

The ContentLibrary error is normal, the Get-OvfConfiguration cmdlet has 2 parametersets.
When using the OVF parameter (the Ovf parameterset) an OVA or OVF location is expected.
The FromLibrayItem parameterset has a ContentLibraryItem parameter.
Since you didn't specify either, the cmdlet takes the default parameterset, hence the ContentLibrary error.
Use the OVF parameter.

Also not sure what the meaning of the call to the ToHashTable method is about.

Setting the new values for the Ovf import is not done the way you did it, that just creates a new hash table.
It does not fill in values to the hashtable returned by the cmdlet.



Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
dwchan
Enthusiast
Enthusiast

It seem I can't attach ovf or text file on here.  So would do my best to get my idea across.  I also attached a pdf as to what a typical manual installation would look like.  When I extracted the original OVA, i get three archive files - ovf, mf, and vmdk.  From what gather, here are the three values in the entire ovf that are waiting to be configure by the users

      <Property ovf:key="External_IP" ovf:type="string" ovf:userConfigurable="true">
        <Label>External IP</Label>
        <Description>Leave Blank for DHCP</Description>
      </Property>
      <Property ovf:key="External_Subnet" ovf:type="string" ovf:userConfigurable="true">
        <Label>External Subnet</Label>
        <Description>Leave Blank for DHCP</Description>
      </Property>
      <Property ovf:key="External_Gateway" ovf:type="string" ovf:userConfigurable="true">
        <Label>External_Gateway</Label>
 
If there is a way for me to used the a PowerCLI cmdlet to insert those values into during an automated ova import process, that would be idea
Reply
0 Kudos
dwchan
Enthusiast
Enthusiast

your ask - What do you have in the $OVF variable?

Here are some additional info.  At the top of the script, I defined the following

$HoloRouterOVAName = 'HoloRouter-2.0.ova' ------------The actual OVA filename
$HoloRouterOVAPath = 'C:\Users\cdominic\Downloads\holodeck-standard-main\Holo-Router'
$HoloRouterOVA = $HoloRouterOVAPath  + '\' + $HoloRouterOVAName    ----- Fullpath to the actual OVA

HoloRouterVMName = "Holo-C-Router"
$HoloRouterEULA = "1"
$HoloRouterDS = "Repository"
$HoloRouterExtNetwork = "VM Network"   ----- name of the portgroup that eth0 on the OVA VM would be attach to 
$HoloRouterSite1Network = $HoloDeckSite1PortGroup   ----- name of the portgroup that eth1 on the OVA VM would be attach to 
$HoloRouterSite2Network = $HoloDeckSite2PortGroup   ----- name of the portgroup that eth2 on the OVA VM would be attach to 
$HoloRouterDiskProvision = "thin"
$HoloRouterExternalIP = "192.168.10.4"  --one of the values the ESXi Host Client GUI as during the standard manual import process
$HoloRouterExternalSubnet = "255.255.255.0"--one of the values the ESXi Host Client GUI as during the standard manual import process
$HoloRouterExternalGW = "192.168.10.2"--one of the values the ESXi Host Client GUI as during the standard manual import process
 
If I try to use Import-vApp with its native OVA format
        Import-vApp -Name $HoloRouterVMName -Datastore $HRdataStore -VMHost $vmhost -Source $HoloRouterOVA -DiskStorageFormat $HoloRouterDiskProvision -Force
It would error with the "Import-vApp : 1/13/2024 4:09:39 PM Import-VApp Invalid URI: The hostname could not be parsed. "

So I tried this next - extract the ovf as it from the ova
$HoloRouterOVF = $HoloRouterOVAPath  + '\' + 'HoloRouter-2.0.ovf'
Start-Process -FilePath "C:\Program Files\VMware\VMware OVF Tool\ovftool.exe "$HoloRouterOVA" "$HoloRouterOVF"" -NoNewWindow -Wait
 
follow by
 
Import-vApp -Name $HoloRouterVMName -Datastore $HRdataStore -VMHost $vmhost -Source $HoloRouterOVF -DiskStorageFormat $HoloRouterDiskProvision -Force
 
This works where I can get the VM created, with the expected name, datatsore location, power up, etc.  I than asside the the proper portgroup values for all the three NICS
       $HoloRouterNIC1 = Get-VM -Name $HoloRouterVMName | Get-NetworkAdapter -Name "Network adapter 1"
        $HoloRouterNIC2 = Get-VM -Name $HoloRouterVMName | Get-NetworkAdapter -Name "Network adapter 2"
        $HoloRouterNIC3 = Get-VM -Name $HoloRouterVMName | Get-NetworkAdapter -Name "Network adapter 3"
        Set-NetworkAdapter -NetworkAdapter $HoloRouterNIC1 -Portgroup $HoloRouterExtNetwork -Confirm:$false
        Set-NetworkAdapter -NetworkAdapter $HoloRouterNIC2 -Portgroup $HoloRouterSite1Network -Confirm:$false
        Set-NetworkAdapter -NetworkAdapter $HoloRouterNIC3 -Portgroup $HoloRouterSite2Network -Confirm:$false
 
However, none of the network information inside the OVF spec are set on the VM (i.e. eth1 and eth2.  And given I didn't go through the GUI during the initial import process, didn't expect it will have any IP info on eth0.
 
So what I was thinking, if I can use the following command with the ovf
Import-VApp -Name $HoloRouterVMName -OvfConfiguration $ovfConfig -Datastore $dataStore -VMHost $VMHost -Source $HoloRouterOVF -DiskStorageFormat Thin
Where I will feed the Import-VApp with an ovfconfiguration info, but this doesn't seem to work either as
1. do not know what the hash format support to look like.
2. So I figure I try something or guess with the following to build my $ovfconfig value
 
$ovfConfig = Get-OvfConfiguration $HoloRouterOVF
$ovfConfig.ToHashTable()
$ovfConfig = @{
   "vami.ip0.VM_1"="192.168.10.4";
   "vami.netmask0.VM_1"="255.255.255.0";
   "vami.gateway.VM_1"="192.168.10.2"
}
and getting this error
 

Get-OvfConfiguration : Cannot bind argument to parameter 'ContentLibraryItem' because it is null.
At line:1 char:35
+ $ovfConfig = Get-OvfConfiguration $OVF
+ ~~~~
+ CategoryInfo : InvalidData: (:) [Get-OvfConfiguration], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,VMware.VimAutomation.ViCore.Cmdlets.Commands.OVF.GetOvfConfiguration

Method invocation failed because [System.Collections.Hashtable] does not contain a method named 'ToHashTable'.
At line:2 char:1
+ $ovfConfig.ToHashTable()
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

PS C:\Users\cdominic>
PS C:\Users\cdominic> $ovfConfig = Get-OvfConfiguration $HoloRouterOVF
$ovfConfig.ToHashTable()
$ovfConfig = @{
"vami.ip0.VM_1"="192.168.10.4";
"vami.netmask0.VM_1"="255.255.255.0";
"vami.gateway.VM_1"="192.168.10.2"
}

Get-OvfConfiguration : 1/13/2024 4:19:33 PM Get-OvfConfiguration This cmdlet requires a vCenter Server connection.
At line:1 char:14
+ $ovfConfig = Get-OvfConfiguration $HoloRouterOVF
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Get-OvfConfiguration], ViServerConnectionException
+ FullyQualifiedErrorId : ViCore_SharedParameterHelper_ThrowVCenterServerConnectionIsRequiredError,VMware.VimAutomation.ViCore.Cmdlets.Commands.O
VF.GetOvfConfiguration

Method invocation failed because [System.Collections.Hashtable] does not contain a method named 'ToHashTable'.
At line:2 char:1
+ $ovfConfig.ToHashTable()
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

 
Reply
0 Kudos
LucD
Leadership
Leadership

Did you actually read my reply?
Without the Ovf parameter you will keep getting that ContentLibraryItem error


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
dwchan
Enthusiast
Enthusiast

I notice my syntax error with my get-ovfconfiguration and tried again without success

PS C:\Users\cdominic> $ovfConfig = Get-OvfConfiguration -ovf $HoloRouterOVF

Get-OvfConfiguration : 1/13/2024 4:23:10 PM Get-OvfConfiguration This cmdlet requires a vCenter Server connection.
At line:1 char:14
+ $ovfConfig = Get-OvfConfiguration -ovf $HoloRouterOVF
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Get-OvfConfiguration], ViServerConnectionException
+ FullyQualifiedErrorId : ViCore_SharedParameterHelper_ThrowVCenterServerConnectionIsRequiredError,VMware.VimAutomation.ViCore.Cmdlets.Commands.O
VF.GetOvfConfiguration

Reply
0 Kudos
dwchan
Enthusiast
Enthusiast

 
Reply
0 Kudos
LucD
Leadership
Leadership

The cmdlet currently does not work without a vCenter connection.
See also Support for Standalone ESXi Host for OVF cmdlets: | VMware PowerCLI (aha.io)

You will have to use the ovftool


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
dwchan
Enthusiast
Enthusiast

After numerous tries, I got the ova deploy to with the right name, datastore, and NIC mapping using ovftool

ovftool.exe --noDestinationSSLVerify --acceptAllEulas --disableVerification --name=HoloRouter --net:ExternalNet="VM Network" --net:Site_1_Net="VLC-A-PG" --net:Site_2_Net="VLC-A2-PG" --datastore="Repository" --diskMode=thin C:\Users\cdominic\Downloads\holodeck-standard-main\Holo-Router\HoloRouter-2.0.ova vi://root:VMware123!@esx01.tataoui.com

However, I still can't figure out the syntax / switches (sorry but the documentation is poor at best) to assign static IP to the network adapter.  ;( Any input or suggestion anyone can provide would be strongly appreicated 

The following are the configuration mapping I was able to get out from ovftool

 

Download Size:  378.57 MB

Deployment Sizes:
  Flat disks:   16.00 GB
  Sparse disks: 1.01 GB

Networks:
  Name:        ExternalNet
  Description: The ExternalNet network

  Name:        Site_1_Net
  Description: The Site_1_Net network

  Name:        Site_2_Net
  Description: The Site_2_Net network

Virtual Machines:
  Name:               HoloRouter-2.0
  Operating System:   vmwarephoton64guest
  Virtual Hardware:
    Families:         vmx-19
    Number of CPUs:   1
    Cores per socket: 1
    Memory:           2.00 GB

    Disks:
      Index:          0
      Instance ID:    11
      Capacity:       16.00 GB
      Disk Types:     SCSI-VirtualSCSI

    NICs:
      Adapter Type:   VmxNet3
      Connection:     ExternalNet

      Adapter Type:   VmxNet3
      Connection:     Site_1_Net

      Adapter Type:   VmxNet3
      Connection:     Site_2_Net

Properties:
  Key:         External_IP
  Label:       External IP
  Type:        string
  Description: Leave Blank for DHCP

  Key:         External_Subnet
  Label:       External Subnet
  Type:        string
  Description: Leave Blank for DHCP

  Key:         External_Gateway
  Label:       External_Gateway
  Type:        string
  Description: Leave Blank for DHCP

  Key:         Site_1_VLAN
  Label:       Site 1 VLAN
  Type:        string(..4)
  Description: VLAN ID for Site 1 management network
  Value:       10

  Key:         Site_1_IP
  Label:       Site 1 IP
  Type:        string
  Description: IP address on Site 1 management network (ex: 10.0.0.1)
  Value:       10.0.0.1

  Key:         Site_1_Subnet
  Label:       Site 1 Subnet
  Type:        string
  Value:       255.255.255.0

  Key:         Site_2_VLAN
  Label:       Site_2_VLAN
  Type:        string(..4)
  Description: VLAN ID for Site 2 management network
  Value:       20

  Key:         Site_2_IP
  Label:       Site 2 IP
  Type:        string
  Description: IP address on Site 1 management network (ex: 10.0.20.1)
  Value:       10.0.20.1

  Key:         Site_2_Subnet
  Label:       Site 2 Subnet
  Type:        string
  Value:       255.255.255.0

  Key:         Internal_FWD_IP
  Label:       Internal FWD IP
  Type:        string
  Description: IP Address of jump box
  Value:       10.0.0.201

  Key:         Internal_FWD_PORT
  Label:       Internal FWD PORT
  Type:        string
  Description: Port of jump box, e.g. 3389 for RDP, 5900 for VNC
  Value:       3389

IP Allocation Policy:
  Schemes:     ovfenv dhcp
  Protocols:   IPv4

References:
  File:  HoloRouter-2.0-disk1.vmdk

 

Reply
0 Kudos