Skip to content

Network interface starts "flapping" after reprovisioning of the VPX #79

Open
@rein-tollevik

Description

@rein-tollevik

If the 'netscalersdx_provision_vpx' resource is used to reprovision the cpu or memory configuration of an existing VPX its channel interfaces will end up in a "flapping" state where it continuously goes down and up again. The undocumented 'device_channel_name' property of the network_interfaces must be set to the same value as the 'port_name' property to avoid the "flapping" state, which is what the GUI does when it changes the configuration.

It is tempting to always set the 'device_channel_name' to the 'port_name' value in the provider, but I haven't tested it on VPXs that don't use channel interfaces. And its name indicates that is should only be used with channels.

# Read the existing VPXs to get the mac addresses of the network interfaces, as they are
# required when changing an existing VPX.
data "http" "ns" {
  url = "https://${var.sdx_hostname}/nitro/v1/config/ns"

  request_headers = {
    "X-NITRO-USER" = var.sdx_username
    "X-NITRO-PASS" = var.sdx_password
  }
}

locals {
  vpx = [for n in jsondecode(data.http.ns.response_body).ns : n if n.name == var.vpx_name] 
  mac = length(local.vpx) == 0 ? {} : { for n in local.vpx.network_interfaces : n.port_name => n.mac_address }
}

resource "netscalersdx_provision_vpx" "vpx" {
  ...
  network_interfaces = [
    {
      port_name           = "LA/1"
      device_channel_name = "LA/1"
      mac_address         = try(local.mac["LA/1"], null) # Value only required when changing an existing VPX
      ...
    },
    {
      port_name           = "LA/2"
      device_channel_name = "LA/2"
      mac_address         = try(local.mac["LA/2"], null)
      ...
    },
  ]
}

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