VMware Cloud Community
Nizue
Contributor
Contributor
Jump to solution

Show NSX Edge form factor from vCloud Director

Hello!

Please tell me if there is a way to collect NSX Edge form factor from vCloud Director using PowerCLI.

0 Kudos
1 Solution

Accepted Solutions
Nizue
Contributor
Contributor
Jump to solution

It's possible to do it better:

## Connect to vCloud Director before running this scripts
$Edges = Get-EdgeGateway ## Collect list of all NSX Edges

## Custom Object view
$myView = @()
Foreach ($Edge in $Edges) {
    $Report = [PSCustomObject] @{
            Name = $Edge.Name
			FormFactor = ($Edge).ExtensionData.Configuration.GatewayBackingConfig
			Organization = $Edge.OrgVDC.Org
			OrgDesc = $Edge.OrgVDC.Org.Description
            OrgVDC = $Edge.OrgVdc
       }
    $MyView += $Report
}

## https://devblogs.microsoft.com/powershell/why-cant-i-pipe-format-table-to-export-csv-and-get-something-useful/
$MyView | export-csv edgesD.csv ## Export all the things to CSV

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

Have you checked the PowerNSX module?


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

0 Kudos
Nizue
Contributor
Contributor
Jump to solution

I have tried it. Am I right that it's not possible to run PowerNSX on vCloud Director level?

Anyway, it's possible to combine vCenter and vCloud output.

 

Using PowerNSX it's possible to  find form-factor in xml with PowerNSX, it's called applianceSize

*<applianceSize>*</applianceSize>* in

Get-NsxEdge | fl Name,OuterXml

 

 

But how to extract this value using PowerShell?

It's somehow can not be parsed in PowerShell with [xml]

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Are you saying that a cast with [XML] of the OuterXml property does not work?
What does the following show?

Get-NsxEdge | Format-Custom


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

0 Kudos
Nizue
Contributor
Contributor
Jump to solution

 

I have replaces customer name since it is required in our company.

$appliancesize = Get-NsxEdge "vse-CUSTOMER-vc7-edge (fc328f3f-c501-412d-a2c7-e961a4528e12)" | Format-Custom
PS C:\tmp> $appliancesize

class XmlElement
{
  id = edge-4
  version = 20
  status = deployed
  datacenterMoid = datacenter-2
  datacenterName = N1-DC
  tenant = 10c953c0-11bc-4d3c-b0eb-e446588c792b
  name = vse-CUSTOMER-vc7-edge (fc328f3f-c501-412d-a2c7-e961a4528e12)
  fqdn = vse-fc328f3f-c501-412d-a2c7-e961a4528e12
  enableAesni = true
  enableFips = false
  vseLogLevel = info
  vnics =
    class XmlElement
    {
      vnic =
        [
          class XmlElement
          {
            label = vNic_0
            name = vnic0
            addressGroups =
              class XmlElement
              {
                addressGroup =
                  class XmlElement
                  {
                    primaryAddress = 95.181.205.7
                    subnetMask = 255.255.255.0
                    subnetPrefixLength = 24
                  }
              }
            mtu = 1500
            type = uplink
            isConnected = true
            index = 0
            portgroupId = dvportgroup-73
            portgroupName = vc7-internet-650
            enableProxyArp = false
            enableSendRedirects = true
          }
          class XmlElement
          {
            label = vNic_1
            name = vnic1
            addressGroups =
              class XmlElement
              {
                addressGroup =
                  class XmlElement
                  {
                    primaryAddress = 172.16.110.254
                    subnetMask = 255.255.255.0
                    subnetPrefixLength = 24
                  }
              }
            mtu = 1500
            type = internal
            isConnected = true
            index = 1
            portgroupId = dvportgroup-130
            portgroupName = dvs.VCDVSLTcompany-VC7-routed-77e8f124-2674-4a99-94d1-ec5f0a69e4a5
            enableProxyArp = false
            enableSendRedirects = true
          }
          class XmlElement
          {
            label = vNic_2
            name = vnic2
            addressGroups =
            mtu = 1500
            type = internal
            isConnected = false
            index = 2
            enableProxyArp = false
            enableSendRedirects = true
          }
          class XmlElement
          {
            label = vNic_3
            name = vnic3
            addressGroups =
            mtu = 1500
            type = internal
            isConnected = false
            index = 3
            enableProxyArp = false
            enableSendRedirects = true
          }
          ...
        ]

    }
  appliances =
    class XmlElement
    {
      applianceSize = compact
      appliance =
        class XmlElement
        {
          highAvailabilityIndex = 0
          vcUuid = 501dd886-11f4-dabd-b61e-74e00d7ace1b
          vmId = vm-278756
          resourcePoolId = resgroup-72
          resourcePoolName = System vDC (9728535b-5762-4d22-aabc-2577b45f5ba0)
          datastoreId = datastore-165069
          datastoreName = IBM_SSD1_NORD3_ID61
          hostId = host-1852
          hostName = n1c3s6.dtln.ru
          vmFolderId = group-v81
          vmFolderName = V
          vmHostname = vse-fc328f3f-c501-412d-a2c7-e961a4528e12-0
          vmName = vse-CUSTOMER-vc7-edge (fc328f3f-c501-412d-a2c7-e961a4528e12)-0
          deployed = true
          cpuReservation =
            class XmlElement
            {
              limit = -1
              reservation = 64
            }
          memoryReservation =
            class XmlElement
            {
              limit = -1
              reservation = 256
            }
          edgeId = edge-4
          configuredResourcePool =
            class XmlElement
            {
              id = resgroup-72
              name = System vDC (9728535b-5762-4d22-aabc-2577b45f5ba0)
              isValid = true
            }
          configuredDataStore =
            class XmlElement
            {
              id = datastore-74
              isValid = false
            }
          configuredHost =
            class XmlElement
            {
              id = host-32
              name = n1c3s5.dtln.ru
              isValid = true
            }
          configuredVmFolder =
            class XmlElement
            {
              id = group-v81
              name = V
              isValid = true
            }
        }
      deployAppliances = true
    }
  cliSettings =
    class XmlElement
    {
      remoteAccess = false
      userName = admin
      sshLoginBannerText =
      ***************************************************************************
      NOTICE TO USERS


      This computer system is the private property of its owner, whether
      individual, corporate or government.  It is for authorized use only.
      Users (authorized or unauthorized) have no explicit or implicit
      expectation of privacy.

      Any or all uses of this system and all files on this system may be
      intercepted, monitored, recorded, copied, audited, inspected, and
      disclosed to your employer, to authorized site, government, and law
      enforcement personnel, as well as authorized officials of government
      agencies, both domestic and foreign.

      By using this system, the user consents to such interception, monitoring,
      recording, copying, auditing, inspection, and disclosure at the
      discretion of such personnel or officials.  Unauthorized or improper use
      of this system may result in civil and criminal penalties and
      administrative or disciplinary action, as appropriate. By continuing to
      use this system you indicate your awareness of and consent to these terms
      and conditions of use. LOG OFF IMMEDIATELY if you do not agree to the
      conditions stated in this warning.

      ****************************************************************************
      passwordExpiry = 99999
    }
  features =
    class XmlElement
    {
      nat =
        class XmlElement
        {
          version = 14
          enabled = true
          natRules =
          nat64Rules =
        }
      l2Vpn =
        class XmlElement
        {
          version = 9
          enabled = false
          logging =
            class XmlElement
            {
              enable = true
              logLevel = notice
            }
        }
      featureConfig =
        [




        ]

      dns =
        class XmlElement
        {
          version = 10
          enabled = false
          cacheSize = 16
          listeners =
            class XmlElement
            {
              vnic = any
            }
          dnsViews =
            class XmlElement
            {
              dnsView =
                class XmlElement
                {
                  viewId = view-0
                  name = vsm-default-view
                  enabled = true
                  viewMatch =
                    class XmlElement
                    {
                      ipAddress = any
                      vnic = any
                    }
                  recursion = false
                }
            }
          logging =
            class XmlElement
            {
              enable = false
              logLevel = info
            }
        }
      syslog =
        class XmlElement
        {
          version = 3
          enabled = false
        }
      sslvpnConfig =
        class XmlElement
        {
          version = 9
          enabled = false
          logging =
            class XmlElement
            {
              enable = true
              logLevel = notice
            }
          advancedConfig =
            class XmlElement
            {
              enableCompression = false
              forceVirtualKeyboard = false
              randomizeVirtualkeys = false
              preventMultipleLogon = false
              clientNotification =
              enablePublicUrlAccess = false
              timeout =
                class XmlElement
                {
                  forcedTimeout = 0
                  sessionIdleTimeout = 10
                }
            }
          clientConfiguration =
            class XmlElement
            {
              autoReconnect = true
              upgradeNotification = false
            }
          layoutConfiguration =
            class XmlElement
            {
              portalTitle = VMware
              companyName = VMware
              logoExtention = jpg
              logoUri = /api/4.0/edges/edge-4/sslvpn/config/layout/images/portallogo
              logoBackgroundColor = 56A2D4
              titleColor = 996600
              topFrameColor = 000000
              menuBarColor = 999999
              rowAlternativeColor = FFFFFF
              bodyColor = FFFFFF
              rowColor = F5F5F5
            }
          authenticationConfiguration =
            class XmlElement
            {
              passwordAuthentication =
                class XmlElement
                {
                  authenticationTimeout = 1
                  primaryAuthServers =
                  secondaryAuthServer =
                }
            }
        }
      highAvailability =
        class XmlElement
        {
          version = 10
          enabled = false
          declareDeadTime = 15
          logging =
            class XmlElement
            {
              enable = false
              logLevel = info
            }
          security =
            class XmlElement
            {
              enabled = false
            }
        }
      routing =
        class XmlElement
        {
          version = 15
          enabled = true
          routingGlobalConfig =
            class XmlElement
            {
              ecmp = false
              logging =
                class XmlElement
                {
                  enable = false
                  logLevel = info
                }
            }
          staticRouting =
            class XmlElement
            {
              defaultRoute =
                class XmlElement
                {
                  vnic = 0
                  gatewayAddress = 95.181.205.1
                  adminDistance = 1
                }
              staticRoutes =
            }
          ospf =
            class XmlElement
            {
              enabled = false
              ospfAreas =
                class XmlElement
                {
                  ospfArea =
                    [
                      ospfArea
                      ospfArea
                    ]

                }
              ospfInterfaces =
              redistribution =
                class XmlElement
                {
                  enabled = false
                  rules =
                }
              gracefulRestart = true
              defaultOriginate = false
            }
        }
      gslb =
        class XmlElement
        {
          version = 3
          enabled = false
          logging =
            class XmlElement
            {
              enable = false
              logLevel = info
            }
        }
      firewall =
        class XmlElement
        {
          version = 6
          enabled = true
          globalConfig =
            class XmlElement
            {
              tcpPickOngoingConnections = false
              enableFtpLooseMode = false
              tcpAllowOutOfWindowPackets = false
              tcpSendResetForClosedVsePorts = true
              dropInvalidTraffic = true
              logInvalidTraffic = false
              tcpTimeoutOpen = 30
              tcpTimeoutEstablished = 21600
              tcpTimeoutClose = 30
              udpTimeout = 60
              icmpTimeout = 10
              icmp6Timeout = 10
              ipGenericTimeout = 120
              enableSynFloodProtection = false
              logIcmpErrors = false
              dropIcmpReplays = false
              enableSnmpAlg = true
              enableFtpAlg = true
              enableTftpAlg = true
            }
          defaultPolicy =
            class XmlElement
            {
              action = accept
              loggingEnabled = false
            }
          firewallRules =
            class XmlElement
            {
              firewallRule =
                [
                  class XmlElement
                  {
                    id = 131074
                    ruleTag = 131074
                    name = firewall
                    ruleType = internal_high
                    enabled = true
                    loggingEnabled = false
                    description = firewall
                    action = accept
                    source = source
                  }
                  class XmlElement
                  {
                    id = 131073
                    ruleTag = 131073
                    name = default rule for ingress traffic
                    ruleType = default_policy
                    enabled = true
                    loggingEnabled = false
                    description = default rule for ingress traffic
                    action = accept
                  }
                ]

            }
        }
      loadBalancer =
        class XmlElement
        {
          version = 3
          enabled = false
          enableServiceInsertion = false
          accelerationEnabled = false
          monitor =
            [
              class XmlElement
              {
                monitorId = monitor-1
                type = tcp
                interval = 5
                timeout = 15
                maxRetries = 3
                name = default_tcp_monitor
              }
              class XmlElement
              {
                monitorId = monitor-2
                type = http
                interval = 5
                timeout = 15
                maxRetries = 3
                method = GET
                url = /
                name = default_http_monitor
              }
              class XmlElement
              {
                monitorId = monitor-3
                type = https
                interval = 5
                timeout = 15
                maxRetries = 3
                method = GET
                url = /
                name = default_https_monitor
              }
            ]

          logging =
            class XmlElement
            {
              enable = false
              logLevel = info
            }
        }
      ipsec =
        class XmlElement
        {
          version = 3
          enabled = false
          logging =
            class XmlElement
            {
              enable = true
              logLevel = warning
            }
          sites =
          global =
            class XmlElement
            {
              psk = ******
              caCertificates =
              crlCertificates =
            }
        }
      bridges =
        class XmlElement
        {
          version = 9
          enabled = false
        }
      dhcp =
        class XmlElement
        {
          version = 9
          enabled = false
          staticBindings =
          ipPools =
          logging =
            class XmlElement
            {
              enable = false
              logLevel = info
            }
        }
    }
  autoConfiguration =
    class XmlElement
    {
      enabled = true
      rulePriority = high
    }
  type = gatewayServices
  isUniversal = false
  hypervisorAssist = false
  queryDaemon =
    class XmlElement
    {
      enabled = false
      port = 5666
    }
  tunnels =
  edgeSummary =
    class XmlElement
    {
      objectId = edge-4
      objectTypeName = Edge
      vsmUuid = 42353918-DC8E-5F34-05DC-B4C7FD137C8D
      nodeId = 1e4e7bec-1a59-4f51-a40b-b15c9b7f8b6a
      revision = 20
      type =
        class XmlElement
        {
          typeName = Edge
        }
      name = vse-CUSTOMER-vc7-edge (fc328f3f-c501-412d-a2c7-e961a4528e12)
      clientHandle =
      extendedAttributes =
      isUniversal = false
      universalRevision = 0
      isTemporal = false
      isUpgradeAvailable = true
      id = edge-4
      state = deployed
      edgeType = gatewayServices
      datacenterMoid = datacenter-2
      datacenterName = N1-DC
      tenantId = 10c953c0-11bc-4d3c-b0eb-e446588c792b
      apiVersion = 4.0
      edgeStatus = GREEN
      numberOfConnectedVnics = 2
      appliancesSummary =
        class XmlElement
        {
          vmVersion = 6.4.6
          vmBuildInfo = 6.4.6-14780962
          applianceSize = compact
          fqdn = vse-fc328f3f-c501-412d-a2c7-e961a4528e12
          numberOfDeployedVms = 1
          activeVseHaIndex = 0
          vmMoidOfActiveVse = vm-278756
          vmNameOfActiveVse = vse-CUSTOMER-vc7-edge (fc328f3f-c501-412d-a2c7-e961a4528e12)-0
          hostMoidOfActiveVse = host-1852
          hostNameOfActiveVse = n1c3s6.dtln.ru
          resourcePoolMoidOfActiveVse = resgroup-72
          resourcePoolNameOfActiveVse = System vDC (9728535b-5762-4d22-aabc-2577b45f5ba0)
          dataStoreMoidOfActiveVse = datastore-165069
          dataStoreNameOfActiveVse = IBM_SSD1_NORD3_ID61
          statusFromVseUpdatedOn = 1618330021131
          communicationChannel = msgbus
          enableFips = false
        }
      hypervisorAssist = false
      allowedActions =
        class XmlElement
        {
          string =
            [
              Change Log Level
              Add Edge Appliance
              Delete Edge Appliance
              Edit Edge Appliance
              ...
            ]

        }
    }
}

 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That looks like a regular XML structure.
Which element in there is the one you need?


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

0 Kudos
Nizue
Contributor
Contributor
Jump to solution

I need to get

applianceSize = compact

as variable.

The variable must contain what is after '='

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Does this not return the values?

(Get-NsxEdge).appliances.ApplianceSize

 


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

0 Kudos
Nizue
Contributor
Contributor
Jump to solution

For 1 edge it's working. I'll try to collect info for full cloud, it will take a few days.

0 Kudos
Nizue
Contributor
Contributor
Jump to solution

It's possible to do it better:

## Connect to vCloud Director before running this scripts
$Edges = Get-EdgeGateway ## Collect list of all NSX Edges

## Custom Object view
$myView = @()
Foreach ($Edge in $Edges) {
    $Report = [PSCustomObject] @{
            Name = $Edge.Name
			FormFactor = ($Edge).ExtensionData.Configuration.GatewayBackingConfig
			Organization = $Edge.OrgVDC.Org
			OrgDesc = $Edge.OrgVDC.Org.Description
            OrgVDC = $Edge.OrgVdc
       }
    $MyView += $Report
}

## https://devblogs.microsoft.com/powershell/why-cant-i-pipe-format-table-to-export-csv-and-get-something-useful/
$MyView | export-csv edgesD.csv ## Export all the things to CSV
0 Kudos