def get_vapp_port_forwarding_rules(vAppId)
      params = {
        'method' => :get,
        'command' => "/vApp/vapp-#{vAppId}/networkConfigSection"
      }

      response, headers = send_request(params)

      # FIXME: this will return nil if the vApp uses multiple vApp Networks
      # with Edge devices in natRouted/portForwarding mode.
      config = response.css('NetworkConfigSection/NetworkConfig/Configuration')
      fenceMode = config.css('/FenceMode').text
      natType = config.css('/Features/NatService/NatType').text

      raise InvalidStateError, "Invalid request because FenceMode must be set to natRouted." unless fenceMode == "natRouted"
      raise InvalidStateError, "Invalid request because NatType must be set to portForwarding." unless natType == "portForwarding"

      nat_rules = {}
      config.css('/Features/NatService/NatRule').each do |rule|
        # portforwarding rules information
        ruleId = rule.css('Id').text
        vmRule = rule.css('VmRule')

        nat_rules[rule.css('Id').text] = {
          :ExternalIpAddress  => vmRule.css('ExternalIpAddress').text,
          :ExternalPort       => vmRule.css('ExternalPort').text,
          :VAppScopedVmId     => vmRule.css('VAppScopedVmId').text,
          :VmNicId            => vmRule.css('VmNicId').text,
          :InternalPort       => vmRule.css('InternalPort').text,
          :Protocol           => vmRule.css('Protocol').text
        }
      end
      nat_rules
    end
def get_vapp_port_forwarding_rules(vAppId)
      params = {
        'method' => :get,
        'command' => "/vApp/vapp-
      }

      response, headers = send_request(params)

      
      
      config = response.css('NetworkConfigSection/NetworkConfig/Configuration')
      fenceMode = config.css('/FenceMode').text
      natType = config.css('/Features/NatService/NatType').text

      raise InvalidStateError, "Invalid request because FenceMode must be set to natRouted." unless fenceMode == "natRouted"
      raise InvalidStateError, "Invalid request because NatType must be set to portForwarding." unless natType == "portForwarding"

      nat_rules = {}
      config.css('/Features/NatService/NatRule').each do |rule|
        
        ruleId = rule.css('Id').text
        vmRule = rule.css('VmRule')

        nat_rules[rule.css('Id').text] = {
          :ExternalIpAddress  => vmRule.css('ExternalIpAddress').text,
          :ExternalPort       => vmRule.css('ExternalPort').text,
          :VAppScopedVmId     => vmRule.css('VAppScopedVmId').text,
          :VmNicId            => vmRule.css('VmNicId').text,
          :InternalPort       => vmRule.css('InternalPort').text,
          :Protocol           => vmRule.css('Protocol').text
        }
      end
      nat_rules
    end
def get_vapp_port_forwarding_rules ( vAppId ) params = { 'method' => :get , 'command' => "/vApp/vapp-#{vAppId}/networkConfigSection" } response , headers = send_request ( params ) # FIXME: this will return nil if the vApp uses multiple vApp Networks # with Edge devices in natRouted/portForwarding mode. config = response . css ( 'NetworkConfigSection/NetworkConfig/Configuration' ) fenceMode = config . css ( '/FenceMode' ) . text natType = config . css ( '/Features/NatService/NatType' ) . text raise InvalidStateError , "Invalid request because FenceMode must be set to natRouted." unless fenceMode == "natRouted" raise InvalidStateError , "Invalid request because NatType must be set to portForwarding." unless natType == "portForwarding" nat_rules = { } config . css ( '/Features/NatService/NatRule' ) . each do | rule | # portforwarding rules information ruleId = rule . css ( 'Id' ) . text vmRule = rule . css ( 'VmRule' ) nat_rules [ rule . css ( 'Id' ) . text ] = { :ExternalIpAddress => vmRule . css ( 'ExternalIpAddress' ) . text , :ExternalPort => vmRule . css ( 'ExternalPort' ) . text , :VAppScopedVmId => vmRule . css ( 'VAppScopedVmId' ) . text , :VmNicId => vmRule . css ( 'VmNicId' ) . text , :InternalPort => vmRule . css ( 'InternalPort' ) . text , :Protocol => vmRule . css ( 'Protocol' ) . text } end nat_rules end
Get vApp port forwarding rules

 - vappid: id of the vApp
Get vApp port forwarding rules