Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Can not obtain imported networks #785

Open
AlexanderB1290 opened this issue Nov 9, 2021 · 2 comments
Open

Can not obtain imported networks #785

AlexanderB1290 opened this issue Nov 9, 2021 · 2 comments

Comments

@AlexanderB1290
Copy link

AlexanderB1290 commented Nov 9, 2021

Trough the UI, you can add an OrgVDC network to specific vApp. The network you can select is either an existing one in the VDC or imported one from the NSX-T. Both of them are visible and quarriable using the REST API when performing a request againsts:

https://{hostname}/cloudapi/1.0.0/orgVdcNetworks?filter=(ownerRef.id==urn:vcloud:vdc:{vdc.id};_context==includeAccessible)

But the library returns an empty array for both methods for querying networks for OrgVDC: lits_orgvdc_network_resources(), list_orgvdc_network_records()

image

Here is the returned payload when I perform the REST request using the Swagger API of VCD:

{
  "resultTotal": 1,
  "pageCount": 1,
  "page": 1,
  "pageSize": 16,
  "associations": null,
  "values": [
    {
      "id": "urn:vcloud:network:208a6080-d6ef-4120-a932-657b843feef7",
      "name": "Public-Network",
      "description": "",
      "subnets": {
        "values": [
          {
            "gateway": "10.27.115.253",
            "prefixLength": 22,
            "dnsSuffix": null,
            "dnsServer1": "",
            "dnsServer2": "",
            "ipRanges": {
              "values": null
            },
            "enabled": true,
            "totalIpCount": 0,
            "usedIpCount": 0
          }
        ]
      },
      "backingNetworkId": "67f8afcc-ed04-40fe-87ba-18c8ead0dae8",
      "backingNetworkType": "IMPORTED_T_LOGICAL_SWITCH",
      "parentNetworkId": null,
      "networkType": "OPAQUE",
      "orgVdc": null,
      "ownerRef": {
        "name": "DC-Group-HaaS",
        "id": "urn:vcloud:vdcGroup:dd2f9c27-5470-4477-9013-6967d037956b"
      },
      "orgRef": {
        "name": "pscoe",
        "id": "urn:vcloud:org:b9d337df-8020-4ecd-b681-16f74d0c8a9a"
      },
      "connection": null,
      "isDefaultNetwork": null,
      "shared": true,
      "enableDualSubnetNetwork": false,
      "status": "REALIZED",
      "lastTaskFailureMessage": null,
      "guestVlanTaggingAllowed": false,
      "retainNicResources": false,
      "crossVdcNetworkId": null,
      "crossVdcNetworkLocationId": null,
      "totalIpCount": 0,
      "usedIpCount": 0,
      "routeAdvertised": false,
      "securityGroups": null
    }
  ]
}

If I try to perform the operation using client.get_resources(), it throws an error that a field ownerRef.id and _context are not available. I have gone even further and made the same request using client._do_request_prim(), which resolves into a INTERNAL_SERVER_ERROR (shown in the uploaded screenshot).

@phongvu0403
Copy link

@AlexanderB1290 I think your vCloud Director has enabled Data Center Group. At that time, "ownerRef" has "urn:vcloud:vdcGroup:xxx" id . It is not available. When vCD hasn't enable Data Center Group, everything will be fined. I'm facing with your issue. Do you any idea how to pass this issue?

@AlexanderB1290
Copy link
Author

AlexanderB1290 commented Mar 10, 2022

@phongvu0403 After some troubles and debugging, I found out that there are 2 different objects relating to the two types of networks - imported from NSX-T and those that are VLANs from vSphere or NSX-V. The REST API is seeing them both, but there is no presentation object for the NSX-T ones. What I did as a workaround was to separate the code into couple of fragments and do the needed operations using different approaches, so I can complete the functionality.

  1. Using PowerCLI to make a copy of template vApp, cause the Terraform provider don't have such functionality
  2. Bind the correct network adapters to the machines from the selected vApp using Terraform. This way I am addressing an issue where when you provision a vApp from different VDC provider, the networks are copied. Those networks only work in the old provider.
  3. Using pyvcloud and python perform operations for changing the owner and adding some metadata messages for tracking.

All of this wrapped in a docker container and executed as a single FaaS. Not the best solution, but it works with NSX-T networks. I would really be happy if I don't need to resolve using 3 different modules (and languages) to complete the whole task.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants