PowerCLI

 View Only
Expand all | Collapse all

Remove unused DVuplinks for DVswitch

zhornsby

zhornsbyOct 26, 2018 08:05 PM

  • 1.  Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 02:51 PM

    i recently had a few network changes within my lab environment and i have to decrease my amount of uplink ports on my dvswitch from 7 to 4. i removed the physical nics from the dvswitch but now im left with 3 unused dvUplinks. when i try to reduce the amount of uplinks from the edit settings window on the dvswitch i get a "resource 1707 is in use on host x.x.x.x"

    does anyone know how else i can remove the unused dvuplinks from my dvswitch.

    6.0 vcsa, dvswitch 5.5 (didnt notice until now, will upgrade to 6.0)



  • 2.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 03:04 PM

    Do you by any chance still have an ESXi host connected to one of the Uplinks?



  • 3.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 03:12 PM

    i do not. i have three host in the cluster, dvuplinks 1,2,3,4 have vmnic's 3,4,5,6 (vmnic 1,2 are assigned to a standard switch) assigned to them respectively. dvuplinks 5,6,7 have no vmnics assigned to them on either one of the hosts



  • 4.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 04:17 PM

    Try like this.

    Note that there is no checking if  any of the dropped Uplinks has a connection.

    $vdsName = 'MyVds'

    $vdsUplinkNumber = 2

    $vds = Get-VDSwitch -Name $vdsName

    $spec = New-Object VMware.Vim.VMwareDVSConfigSpec

    $spec.ConfigVersion = $vds.ExtensionData.Config.ConfigVersion

    $uplink = New-Object VMware.Vim.DVSNameArrayUplinkPortPolicy

    $uplink.UplinkPortName = @()

    1..$vdsUplinkNumber | %{

        $uplink.UplinkPortName += $vds.ExtensionData.Config.UplinkPortPolicy.UplinkPortName[$_ - 1]

    }

    $spec.UplinkPortPolicy = $uplink

    $vds.ExtensionData.ReconfigureDvs($spec)



  • 5.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 04:57 PM

    $vdsName = 'Lab_DV_SW'

    $vdsUplinkNumber = 2

    $vds = Get-VDSwitch -Name $vdsName

    $spec = New-Object VMware.Vim.VMwareDVSConfigSpec

    $spec.ConfigVersion = $vds.ExtensionData.Config.ConfigVersion

    $uplink = New-Object VMware.Vim.DVSNameArrayUplinkPortPolicy

    $uplink.UplinkPortName = @()

    1..$vdsUplinkNumber | %{

    $uplink.UplinkPortName += $vds.ExtensionData.Config.UplinkPortPolicy.UplinkPortName[$_ - 1]

    }

    $spec.UplinkPortPolicy = $uplink

    $vds.ExtensionData.ReconfigureDvs($spec)

    Made my changes, submitted, error returned "Exception calling "ReconfigureDvs" with "1" argument(s): "The resource '1707' is in use. The Uplink name dvUplink3 is in use by the connected uplink port 1707 on host x.x.0.18, which is connected to the physical network adapter vmnic5"

    this error is true as dvuplink3 is connected to vmnic 5, however im not trying to remove dvuplink3. im trying to remove dvuplink 5, 6, 7



  • 6.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 05:41 PM

    I'm confused, Uplinks are normally numbered sequentially.
    Do you have empty Uplinks in the sequence?

    Perhaps show a screenshot of the topology to help me understand.



  • 7.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 06:13 PM

    They are in order, however i have vmnic 1,2 assigned to a standard switch for kernel traffic



  • 8.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 06:17 PM

    But wait a minute, you seem to have specified

    $vdsUplinkNumber = 2

    That should say

    $vdsUplinkNumber = 4

    That way you will bring down the number of Uplinks from 7 to 4.



  • 9.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 06:24 PM

    whoops i pasted it wrong back into the thread. this was the result



  • 10.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 06:30 PM

    Ok, can you tell me what these show?

    $vds.ExtensionData.Config.UplinkPortPolicy

    $spec.UplinkPortPolicy



  • 11.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 08:05 PM



  • 12.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 26, 2018 08:37 PM

    I'm flabbergasted. That all looks normal and how I expected it to be :smileycry:

    Ok, I think at this point we should have a look at the vpxd log.
    See if you can find the entries from around the time you executed the call to the method.

    On the other hand, since you also seem to get this error when you do the same via the Web Client, I'm wondering if there isn't anything else causing this error.
    The vpxd log could give us some more info on that as well.



  • 13.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 05:53 PM

    i dont see anything in the vpxd logs. are you referring to vpxd.log correct? not the vpxd-profiler logs



  • 14.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 06:17 PM

    Correct, not the vpxd profiler logs.

    Could you run the following and check if the mentioned port is in there?

    $vds = Get-VDSwitch -Name <your-vds>

    $vds.ExtensionData.Config.Host |

    ForEach-Object -Process {

        $esx = Get-View -Id $_.Config.Host

        Write-Host "ESXi $($esx.Name)  Ports $($_.UplinkPortKey -join '|')"

    }



  • 15.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 06:38 PM

    doesnt seem to like your first command



  • 16.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 06:45 PM

    Just the name of the switch, without the <>



  • 17.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 06:51 PM

    gotchya, sorry about that.

    it doesnt seem to report anything

    is there a way to identify which dvuplink specifically you want to remove?



  • 18.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 07:14 PM

    I didn't want to remove anything with that script, just wanted to know to which VDS ports the uplinks were connected for each ESXi node.

    The script wasn't finished in your run (that is what the >> mean).

    Type } followed by <enter>, and then another <enter>



  • 19.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 07:18 PM

    whoops sorry about that, im new to powercli. still trying to learn it



  • 20.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 07:31 PM

    Can you check on the VDS in the port list with the Web CLient, what is connected to port 1707?

    In other words, is there anything in the Connectee column for port 1707?



  • 21.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 08:30 PM

    there is, however that is not the dvuplink i would like to remove...

    i want to remove dvuplink 5,6,7



  • 22.  RE: Remove unused DVuplinks for DVswitch
    Best Answer

    Posted Oct 29, 2018 08:34 PM

    Ok, now I have a clear picture of the issue.

    Your Uplinks are not in order, it says Uplink1, Uplink2, Uplink4, Uplink3.

    And the Uplinks are connected to the last 4 ports that are reserved for Uplinks.

    This is probably due to changing/removing Uplinks in the past.
    I will now have to find a way to link the Uplinks to the correct ports, and do the removal in the correct order.



  • 23.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 08:36 PM

    if you think thats the case, i can modify the vmnics and their uplinks. thats not difficult to do in the dvswitch. if you think thats what needs to be done



  • 24.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 09:11 PM

    You can try, but I'm not sure that is going to change the order.
    In fact the method I use to lower the number of Uplinks, depends on the last n Uplinks to be unused.

    In you case the Uplinks seem to be mapped to the last 4 ports, instead of the first 4 ports.



  • 25.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 10:36 PM

    that was the magic sauce. i removed all but dvuplink1. once all other vmnic's were removed i was able to shrink the total numbers of dvuplinks. then i was able to rearrange my vmnics and

    dvuplinks to match

    Thank you so much!!



  • 26.  RE: Remove unused DVuplinks for DVswitch

    Posted Oct 29, 2018 06:39 PM

    did you mean $vdsname?