2 Replies Latest reply on Sep 10, 2020 11:30 PM by KBricksBuilder

    How to view the portgroupID property?

    KBricksBuilder Novice

      I need it to be able to create and Edge via the NSX API, for which I need a portgroupId which i havent been able to find anywhere.
      Ive seen the other post here on forum, but the guide appears to be for a web interface different than mine, since im not finding the URL revealing the portgroupID as explained in that solution. Also I would very much prefer to be able to get a list of portgroupIDs via the API if possible.

      Ive tried:

      • Using the port group NAMES
      • Listing portgroupID /Networks in the web interface but no ID property is revealed here
      • Listing portgroupID/Networks via the API but I haven’t been able to identify a query that does this from the API documentation

       

      The API query im currently using which is missing the portgroupID:

      curl -k -X POST -H "Content-Type: application/xml" -u user:password -d '<edge><datacenterMoid>datacenter-2</datacenterMoid><name>APICreated-LBSS-Edge</name><tenant>Default</tenant><vseLogLevel>info</vseLogLevel><appliances><applianceSize>compact</applianceSize><appliance><resourcePoolId>123</resourcePoolId><datastoreId>123</datastoreId></appliance></appliances><vnics><vnic><index>0</index><name>APICreated-LBSS-Edge-Interface</name><type>uplink</type><portgroupId>AZT-vlan12</portgroupId><addressGroups><addressGroup><primaryAddress>213</primaryAddress><secondaryAddresses><ipAddress>123</ipAddress></secondaryAddresses><subnetPrefixLength>28</subnetPrefixLength></addressGroup></addressGroups><mtu>1500</mtu><enableProxyArp>false</enableProxyArp><enableSendRedirects>false</enableSendRedirects><isConnected>true</isConnected><inShapingPolicy><averageBandwidth>20000000</averageBandwidth><peakBandwidth>20000000</peakBandwidth><burstSize>0</burstSize><enabled>true</enabled><inherited>false</inherited></inShapingPolicy><outShapingPolicy><averageBandwidth>20000000</averageBandwidth><peakBandwidth>20000000</peakBandwidth><burstSize>0</burstSize><enabled>true</enabled><inherited>false</inherited></outShapingPolicy></vnic></vnics><cliSettings><userName>admin</userName><password>123</password><remoteAccess>false</remoteAccess></cliSettings></edge>' 'https://123/api/4.0/edges'

      Kind regards

        • 1. Re: How to view the portgroupID property?
          Bayu Wibowo Master
          User ModeratorsCommunity Warriors

          Hi Kasper,

           

          Are you referring to NSX-v or NSX-T and which request/URI path are you trying to request?

          I'm assuming it's NSX-v and you're trying to do POST /api/4.0/edges to create a new Edge Gateway

          The portgroupId field needs to be populated by a portgroup MoRefID e.g. <portgroupId>dvportgroup-114</portgroupId>

          That ID is not so much NSX objects, but it's a vCenter object

           

          There are multiple ways to find the portgroupId but not so much via NSX API as it is a vCenter object

          Looking up Managed Object Reference (MoRef) in vCenter Server (1017126)

          How to (quickly) match a moRef ID to a name in VMware vSphere – Danilo Chiavari

          https://docs.vmware.com/en/VMware-NSX-Data-Center-for-vSphere/6.4/nsx_64_api.pdf

          Bayu Wibowo | VCIX6-DCV/NV
          Author of VMware NSX Cookbook http://bit.ly/NSXCookbook
          https://github.com/bayupw/PowerNSX-Scripts
          https://nz.linkedin.com/in/bayupw | twitter @bayupw
          • 2. Re: How to view the portgroupID property?
            KBricksBuilder Novice

            I followed this guide and the property value here is "Network-738" which im unsure of is correct as im still getting the following error when trying to deploy an Edge via the API using this value:Error

             

            API CURL:
            curl -k -X POST -H "Content-Type: application/xml" -u user:password -d '<edge><datacenterMoid>datacenter-2</datacenterMoid><name>APICreated-LBSS-Edge</name><tenant>Default</tenant><vseLogLevel>info</vseLogLevel><appliances><applianceSize>compact</applianceSize><appliance><resourcePoolId>Physhost</resourcePoolId><datastoreId>VRTX-Test-VD0</datastoreId></appliance></appliances><vnics><vnic><index>0</index><name>APICreated-LBSS-Edge-Interface</name><type>uplink</type><portgroupId>network-738</portgroupId><addressGroups><addressGroup><primaryAddress>123.123.123.123</primaryAddress><secondaryAddresses><ipAddress>123.123.123.123</ipAddress></secondaryAddresses><subnetPrefixLength>28</subnetPrefixLength></addressGroup></addressGroups><mtu>1500</mtu><enableProxyArp>false</enableProxyArp><enableSendRedirects>false</enableSendRedirects><isConnected>true</isConnected><inShapingPolicy><averageBandwidth>20000000</averageBandwidth><peakBandwidth>20000000</peakBandwidth><burstSize>0</burstSize><enabled>true</enabled><inherited>false</inherited></inShapingPolicy><outShapingPolicy><averageBandwidth>20000000</averageBandwidth><peakBandwidth>20000000</peakBandwidth><burstSize>0</burstSize><enabled>true</enabled><inherited>false</inherited></outShapingPolicy></vnic></vnics><cliSettings><userName>admin</userName><password>somepassword</password><remoteAccess>false</remoteAccess></cliSettings></edge>' 'https://123.123.123.123/api/4.0/edges'

             

            Error:

            "{"errorCode":10086,"details":"Traffic shaping policy can be set only for a Vnic connected to a VMware distributed virtual portgroup configured with static port binding. Invalid portgroup network-738."       
                

            Since im still getting this after adding what seems to be the right portgroupID, im thinking the error is elsewhere, and im gonna be looking into the Traffic shaping policy next.
            If you know this error or has any tips for the debugging, please do share.

             

            Otherwise, have a nice day and thanks for your input so far