VMware Cloud Community
VipalGujrathi
Contributor
Contributor

Need to correct Script - OVA Deployment

Team,

Need help to find out whats wrong in script. My requirement is to deploy two OVA on ESX cluster (Around 500 cluster) with 2 host in each cluster. I was testing it in lab and found it deploy one OVA without any issue but for other it throws below error

"invalid network "x,x,x,104"  in property ip"

IP mentioned in error is exactly same which is supposed to be assigned.

######################################################################################

Connect-VIServer vc.lan.local -User username -Password password

  $dc = Get-Content $HOME\Desktop\OVFTOOL\datacenter.txt

$array = @()

$array += $dc

foreach ($vc in $global:DefaultVIServers | sort name){

foreach ($folder in Get-Folder -Server $vc -Type Datacenter |where {$_.Name -like "*Store*"}){

foreach ($clus in Get-Cluster -Location $folder){

if ($clus -notin $dc){ continue }

$filername = "$HOME\Desktop\OVFTOOL\Vipal\EMC_RecoverPoint_vRPA-RP4VMs_rel5.2.P3_a.412_md5_af60dfbb4aad77124becc86342bd4814.ova"

#################################################################3

$vswitch = 'vSwitch5'

$pg = 'RP4VM_VMKernel'

$port = 'vRPA_Data'

$subnet = '255.255.255.0'

$subnetprefix = '17X.X.X'

$ipperserver = 1

$firstip = 40

#################################################

## collect IP information #########

$IPS = @()

$ucsip = Get-Cluster $clus | Get-VMHost | select -First 1 | Get-VMHostNetwork | select DnsAddress

$split = $ucsip.dnsaddress

$IPbyte = $split[0].Split(".")

$newucsip = ($IPByte[0]+"."+$IPByte[1]+"."+$IPByte[2])

$startip = "103"

$endip = "104"

$gateway = "254"

$netmask = "255.255.255.0"

$ucsipaddress = "$newucsip.$($startip+$_)"

$ucsipaddress1 = "$newucsip.$($endip+$_)"

$ucsgateway = "$newucsip.$($gateway+$_)"

$IPS += $ucsipaddress

$IPS += $ucsipaddress1

$internet = 0

#########################################

###########Collect VM name##################

#$VMNAME = @()

#$vm = "Prod$($clus)_vRPA1"

#$vm1 = "Prod$($clus)_vRPA2"

#$VMNAME += $vm

#$VMNAME += $vm1

$i = 1

#################################

########## Select PortGroup #############

$portgoup = get-cluster $clus | Get-VMHost|select -First 1 | Get-VirtualPortGroup |where {$_.name -like "*vmn*"}

####################################

$ovfconfig = Get-OvfConfiguration -Ovf $filername

###################################

  

foreach ($esxhost in (Get-cluster $clus | Get-VMHost | sort Name )){

$virtual = "Prod$($clus)_vRPA" + $i

$datastore = get-cluster $clus | Get-Datastore | where {$_.name -like "$($clus)0" + $i }

$i ++

$protocol = $IPS[$internet]

$internet ++

#$ucsdatastore = $Data[$datastoreloop]

#$datastoreloop ++

$ovfconfig.Common.ip.Value = $protocol

$ovfconfig.Common.netmask.Value = $netmask

$ovfconfig.Common.gateway.Value = $ucsgateway

$ovfconfig.DeploymentOption.Value = 'Med+'

$ovfconfig.IpAssignment.IpProtocol.Value = 'IPv4'

$ovfconfig.NetworkMapping.RecoverPoint_Management_Network.Value = $portgoup

$esxhost | Import-vapp -source $filername -OvfConfiguration  $ovfconfig -Datastore $datastore -Name $virtual -DiskStorageFormat Thin -Force

##### Create Portgroup for vRPA ##############################

Get-VirtualSwitch -VMHost $esxhost -Name $vswitch | New-VirtualPortGroup -Name $port

Get-VirtualSwitch -VMHost $esxhost -Name $vswitch | New-VirtualPortGroup -Name $pg

###############################################################

  1. 0..$($ipperserver-1) | %{

$ipaddress = "$subnetprefix.$($firstip + $_)"

$firstip += $ipperserver

New-VMHostNetworkAdapter -VMHost $esxhost -VirtualSwitch $vswitch -IP $ipaddress -SubnetMask $subnet -PortGroup $pg

}

}

}

}

}

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

Can you show us the complete error message?


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

Reply
0 Kudos
VipalGujrathi
Contributor
Contributor

Hi Lucd,

attached error.

Reply
0 Kudos
LucD
Leadership
Leadership

Does the Import-VApp itself also give an error?


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

Reply
0 Kudos
VipalGujrathi
Contributor
Contributor

Hi Lucd,

i figured out issue.

i added $portgroup inside child foreach loop and it started working.

Reply
0 Kudos