Hi luc,
good morning .
there is a requirement of
1:creating two distributed port groups
2:and two vmkernel adapters (for vmotion and replication) per esxi in three node cluster.
i thought of doing as below .could you modify orange code so that we can iterate over ips of vmotion and replication .
function create-vmkernelport
{
[cmdletbinding()]
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string]$clustername,
[Parameter(Mandatory=$true)]
[string]$distributedswitch,
[Parameter(Mandatory=$true)]
[string]$vlanvmotion,
[Parameter(Mandatory=$true)]
[string]$vlanreplication,
[Parameter(Mandatory=$true)]
[string]$subnetmask
)
$cluster=Get-Cluster $clustername
$vmhosts=get-vmhost -Location $cluster
$ipvmotion = "172.16.8.21","172.16.8.22","172.16.8.23"
$ipreplication = "172.16.9.21","172.16.9.22","172.16.9.21"
$vmotion=New-VDPortgroup -name "vmotion_112" -VDSwitch $distributedswitch -VlanId 112 -PortBinding Static -NumPorts 8
$replication=New-VDPortgroup -name "replication_113" -VDSwitch $distributedswitch -VlanId 113 -PortBinding Static -NumPorts 8
foreach($vmhost in $vmhosts)
{
New-VMHostNetworkAdapter -VMHost $vmhost -PortGroup $vmotion
-VirtualSwitch $distributedswitch -IP $ipvmotion[$i] -SubnetMask $subnetmask
New-VMHostNetworkAdapter -VMHost $vmhost -PortGroup $replication
-VirtualSwitch $distributedswitch -IP $ipreplication [$i] -SubnetMask $subnetmask
}
}
Try something like this
[cmdletbinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[string]$clustername,
[Parameter(Mandatory = $true)]
[string]$distributedswitch,
[Parameter(Mandatory = $true)]
[string]$vlanvmotion,
[Parameter(Mandatory = $true)]
[string]$vlanreplication,
[Parameter(Mandatory = $true)]
[string]$subnetmask
)
$cluster = Get-Cluster $clustername
$vmhosts = Get-VMHost -Location $cluster
$ipvmotion = "172.16.8.21", "172.16.8.22", "172.16.8.23"
$ipreplication = "172.16.9.21", "172.16.9.22", "172.16.9.21"
if($vmhosts.Count -ne $ipvmotion.Count -or $vmhosts.Count -ne $ipreplication.Count){
Write-Error "Number of IPs does not match number of ESXi nodes"
return
}
$vmotion = New-VDPortgroup -name "vmotion_112" -VDSwitch $distributedswitch -VlanId 112 -PortBinding Static -NumPorts 8
$replication = New-VDPortgroup -name "replication_113" -VDSwitch $distributedswitch -VlanId 113 -PortBinding Static -NumPorts 8
$i = 0
foreach ($vmhost in $vmhosts) {
New-VMHostNetworkAdapter -VMHost $vmhost -PortGroup $vmotion `
-VirtualSwitch $distributedswitch -IP $ipvmotion[$i] -SubnetMask $subnetmask
New-VMHostNetworkAdapter -VMHost $vmhost -PortGroup $replication `
-VirtualSwitch $distributedswitch -IP $ipreplication [$i] -SubnetMask $subnetmask
$i++
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is there a requirement to have a specific IP assigned to a specific ESXi node?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
no it can be random .
Try something like this
[cmdletbinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[string]$clustername,
[Parameter(Mandatory = $true)]
[string]$distributedswitch,
[Parameter(Mandatory = $true)]
[string]$vlanvmotion,
[Parameter(Mandatory = $true)]
[string]$vlanreplication,
[Parameter(Mandatory = $true)]
[string]$subnetmask
)
$cluster = Get-Cluster $clustername
$vmhosts = Get-VMHost -Location $cluster
$ipvmotion = "172.16.8.21", "172.16.8.22", "172.16.8.23"
$ipreplication = "172.16.9.21", "172.16.9.22", "172.16.9.21"
if($vmhosts.Count -ne $ipvmotion.Count -or $vmhosts.Count -ne $ipreplication.Count){
Write-Error "Number of IPs does not match number of ESXi nodes"
return
}
$vmotion = New-VDPortgroup -name "vmotion_112" -VDSwitch $distributedswitch -VlanId 112 -PortBinding Static -NumPorts 8
$replication = New-VDPortgroup -name "replication_113" -VDSwitch $distributedswitch -VlanId 113 -PortBinding Static -NumPorts 8
$i = 0
foreach ($vmhost in $vmhosts) {
New-VMHostNetworkAdapter -VMHost $vmhost -PortGroup $vmotion `
-VirtualSwitch $distributedswitch -IP $ipvmotion[$i] -SubnetMask $subnetmask
New-VMHostNetworkAdapter -VMHost $vmhost -PortGroup $replication `
-VirtualSwitch $distributedswitch -IP $ipreplication [$i] -SubnetMask $subnetmask
$i++
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks Luc.for somereasons new-vdportgroup command is not present in powershell .do i need to import module
i see following
That cmdlet comes from the VMware.VimAutomation.Vds module.
But when the folder under which that module is living is present in $env:PSModulePath, the module should autoload.
You can check where your PowerCLI modules are living with
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
it should autoload
but i run import-module vmware.vimautomation.vds and its available now .
also
You seem to still be on a quite old PowerCLI version (and a MSI based installation I think).
Once again, I would strongly advise to go for a more recent PowerCLI version.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thnaks Luc,
I am checking this again .thoughtof instaling all mangenet utilitiles(including powercli) on separate vm .
Thank you. it was very helpful and kinda reminded me of this: https://www.techwhoop.com/update-straight-talk-phone-signal/. The resemblance is uncanny and it did throw me off guard.
Regards,
Jack.
for some reasons its not creation vmk2 the replication adapter .i know i need to enable replication traffic manually as there is no option in powercli but it should create adapter.
this is how iam running this function.
Remove that blank between $ipreplication and [$i].
The cmdlet thinks you are passing 2 values to the -IP parameter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thnaksLuc.I am going to configure again .
that worked .however how it is taking default gateway as i dont see any parameter in
right now we have enabled management ,vmotion and replication in on same vmk0 .
the whole idea to create this is to create additional port for vmotion and replication .
script worked fine but for someresons default gateway is assigned from vmk0 only.
That is correct, setting the default gateway is doen with the Set-VMHostNetwork cmdlet.
But be aware, there can only be 1 default gateway per network stack.
That means you will have to create a new TCPIPStack for a vmk for which you want to have a different default gateway.
See for example Re: Configure default gateway on vmotion TCP/IP stack
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks I m checking this again.
currently I have three subnet (x,y,z) assigned to mgmt,vmtion,replication respectively.
and each subnet gateway is given by network team and normally the first ip of that subnet.and these three gateway ips will be connected to layer 3 device .
by stack you mean subnet?
so is it not enough to use only set-vmhostnetwork to assign gateway ?
No, I mean the TCP/IP STacks
You have a default gateway per stack.
All the vmk on that stack use the same gateway.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ohh ...thanks .i m going to configure again.thankks for this.
Hi Luc,
good morning ,
i have following three vmkernel as shown below . its from one of the hosts of three node cluster.
i tried following where $esxi is "172.16.7.16" also creating vmotion network stack is also failing.