VMware Cloud Community
jvm2016
Hot Shot
Hot Shot
Jump to solution

creating vmkernel port group_powercli

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

 

           

           

           

        

        

     }  

     }   

0 Kudos
25 Replies
LucD
Leadership
Leadership
Jump to solution

You have to use the resulting object from Get-VMHostNetwork on the Network parameter, not a string.


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

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

if i do like below

pastedImage_0.png

it will change vmkernel gateway for the entire tcp/ip stack .

since i m not able to create individual tcp/ipstack for vmtion and replication it might cause problem.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Why can't you create a new TCPIP stack?

Is that a policy you have to follow?


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

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

well i followed the code from one your similar post (as suggested by you).

it thows error to check vmkernellogs.

also from vmware docs we can create only one default stack which is already there .it says we need to add static routes if we want traffic segregation for vmotion and replication.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you want to go with routes, you can use the New-VMHostRoute cmdlet.


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

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

i think i can start a new thred for this .Smiley Happy

0 Kudos