Skip to content

Networking V2: Omit empty external IP address of the router #1414

@kayrus

Description

@kayrus

The problem description in the https://github.com/terraform-providers/terraform-provider-openstack/issues/449

This request fails:

{
  "router": {
    "admin_state_up": true,
    "external_gateway_info": {
      "external_fixed_ips": [
        {
          "ip_address": "",
          "subnet_id": "55130f47-833c-4210-9768-c174fd9b2671"
        }
      ],
      "network_id": "f55c8e3d-c798-4c6c-9f7e-eeb6600f6aed"
    },
    "name": "router"
  }
}

This one works fine:

{
  "router": {
    "admin_state_up": true,
    "external_gateway_info": {
      "external_fixed_ips": [
        {
          "subnet_id": "55130f47-833c-4210-9768-c174fd9b2671"
        }
      ],
      "network_id": "f55c8e3d-c798-4c6c-9f7e-eeb6600f6aed"
    },
    "name": "router"
  }
}

response:

{
  "router": {
    "status": "ACTIVE",
    "external_gateway_info": {
      "network_id": "f55c8e3d-c798-4c6c-9f7e-eeb6600f6aed",
      "enable_snat": true,
      "external_fixed_ips": [
        {
          "subnet_id": "55130f47-833c-4210-9768-c174fd9b2671",
          "ip_address": "10.16.25.146"
        }
      ]
    },
    "name": "router",
    "admin_state_up": true,
    "tenant_id": "a5e9d48232dc4aa59a716b5ced963584",
    "routes": [],
    "id": "c1afd3a0-dc39-434f-82c2-1911d764a384",
    "description": ""
  }
}

I assume that this ip_address field could be omitted in gophercloud, if it is not set., because it could be allocated automatically.

Some references:

With the diff below I was able to create a router with the desired subnet_id:

b/openstack/networking/v2/extensions/layer3/routers/results.go
@@ -16,7 +16,7 @@ type GatewayInfo struct {
 // ExternalFixedIP is the IP address and subnet ID of the external gateway of a
 // router.
 type ExternalFixedIP struct {
-       IPAddress string `json:"ip_address"`
+       IPAddress string `json:"ip_address,omitempty"`
        SubnetID  string `json:"subnet_id"`
 }
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions