vmware / go-vcloud-director

Golang SDK for VMware Cloud Director
Other
80 stars 79 forks source link

Adding SecondaryIpAddress and SecondaryIpAddressAllocationMode to NetworkConnection of a VM #604

Open riconem opened 1 year ago

riconem commented 1 year ago

Is your feature request related to a problem? Please describe.

Currently it's not possible to create a network connection with dualstack ip adress pools. There are no options for that. You can create a vm with an ip adress pool but you can't choose if it's ipv4 or ipv6 like in the GUI. It's some kind of random behaviour.

Describe the solution you'd like

In the XML Representation of NetworkConnection there are SecondaryIpAddress and SecondaryIpAddressAllocationMode elements defined. This could be added to the current types for api version 34.0.

Describe alternatives you've considered

I have also tried to add this here, but I am struggeling a bit. I have added the secondary elements in NetworkConnection type (https://github.com/vmware/go-vcloud-director/commit/31bf4542a02862455cae4abba71b7a9759b93e6c)

I applied my config with an customized terraform vcd provider here.

When I deploy a vm with secondary elements I get the following error.

2023/08/03 16:27:36 --------------------------------------------------------------------------------
2023/08/03 16:27:36 Request caller: govcd.(*VApp).AddRawVM-->govcd.(*VApp).AddRawVM-->govcd.executeRequestWithApiVersion-->govcd.(*Client).executeTaskRequest-->govcd.executeRequestCustomErr-->govcd.executeRequestCustomErr-->govcd.(*Client).newRequest
2023/08/03 16:27:36 POST https://xxxxxxx/api/vApp/vapp-3cfc9d4e-23bb-407f-be87-7c67af7d8dc8/action/recomposeVApp
2023/08/03 16:27:36 --------------------------------------------------------------------------------
2023/08/03 16:27:36 Req header:
2023/08/03 16:27:36     Accept: [application/*+xml;version=36.0]
2023/08/03 16:27:36     X-Vmware-Vcloud-Token-Type: [Bearer]
2023/08/03 16:27:36     Authorization: [********]
2023/08/03 16:27:36     User-Agent: [terraform-provider-vcd/v3.10.0-3-g74f0dd27 (linux/amd64; isProvider:false)]
2023/08/03 16:27:36     X-Vmware-Vcloud-Access-Token: [********]
2023/08/03 16:27:36 Request data: [1833]
<?xml version="1.0" encoding="UTF-8"?>
  <RecomposeVAppParams xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.vmware.com/vcloud/v1.5" name="xxxxxxx" deploy="false" powerOn="false">
      <SourcedItem>
          <Source href="https://xxxxxxx/api/vAppTemplate/vm-e2bc5a74-1ae9-4991-850f-95eaabcf2cee" name="xxxxxxx"></Source>
          <VmGeneralParams></VmGeneralParams>
          <InstantiationParams>
              <NetworkConnectionSection>
                  <ovf:Info></ovf:Info>
                  <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
                  <NetworkConnection network="xxxxxxx">
                      <NetworkConnectionIndex>0</NetworkConnectionIndex>
                      <IsConnected>true</IsConnected>
                      <IpAddressAllocationMode>POOL</IpAddressAllocationMode>
                      <NetworkAdapterType>VMXNET3</NetworkAdapterType>
                      <SecondaryIpAddressAllocationMode>POOL</SecondaryIpAddressAllocationMode>
                  </NetworkConnection>
                  <NetworkConnection network="xxxxxxx">
                      <NetworkConnectionIndex>1</NetworkConnectionIndex>
                      <IsConnected>true</IsConnected>
                      <IpAddressAllocationMode>POOL</IpAddressAllocationMode>
                      <NetworkAdapterType>VMXNET3</NetworkAdapterType>
                      <SecondaryIpAddressAllocationMode>POOL</SecondaryIpAddressAllocationMode>
                  </NetworkConnection>
              </NetworkConnectionSection>
          </InstantiationParams>
      </SourcedItem>
      <AllEULAsAccepted>true</AllEULAsAccepted>
  </RecomposeVAppParams>
2023/08/03 16:27:36 ################################################################################
2023/08/03 16:27:36 Response caller govcd.(*VApp).AddRawVM-->govcd.(*VApp).AddRawVM-->govcd.executeRequestWithApiVersion-->govcd.(*Client).executeTaskRequest-->govcd.executeRequestCustomErr-->govcd.checkRespWithErrType-->govcd.ParseErr-->govcd.decodeBody
2023/08/03 16:27:36 Response status 400 Bad Request
2023/08/03 16:27:36 ################################################################################
2023/08/03 16:27:36 Response header:
2023/08/03 16:27:36     X-Vmware-Vcloud-Request-Execution-Time: [14]
2023/08/03 16:27:36     Cache-Control: [no-store, must-revalidate]
2023/08/03 16:27:36     Content-Length: [897]
2023/08/03 16:27:36     Date: [Thu, 03 Aug 2023 14:27:37 GMT]
2023/08/03 16:27:36     X-Vmware-Vcloud-Request-Id: [12f462a7-c258-4548-b8c6-e00b284539e6]
2023/08/03 16:27:36     Content-Type: [application/vnd.vmware.vcloud.error+xml;version=36.0]
2023/08/03 16:27:36 Response text: [897]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:ovfenv="http://schemas.dmtf.org/ovf/environment/1" xmlns:ns9="http://www.vmware.com/vcloud/versions" message="[ 12f462a7-c258-4548-b8c6-e00b284539e6 ] HTTP 400 Bad Request&#10; - cvc-complex-type.2.4.d: Invalid content was found starting with element 'SecondaryIpAddressAllocationMode'. No child element is expected at this point." majorErrorCode="400" minorErrorCode="BAD_REQUEST"/>

Additional context

No response