provider/vsphere: read gateway and ipv6_gateway
read gateway and ipv6_gateway information for vsphere_virtual_machine resources.
This commit is contained in:
parent
250ee8d089
commit
5984f84c12
|
@ -795,6 +795,31 @@ func resourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{})
|
||||||
networkInterfaces = append(networkInterfaces, networkInterface)
|
networkInterfaces = append(networkInterfaces, networkInterface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if mvm.Guest.IpStack != nil {
|
||||||
|
for _, v := range mvm.Guest.IpStack {
|
||||||
|
if v.IpRouteConfig != nil && v.IpRouteConfig.IpRoute != nil {
|
||||||
|
for _, route := range v.IpRouteConfig.IpRoute {
|
||||||
|
if route.Gateway.Device != "" {
|
||||||
|
gatewaySetting := ""
|
||||||
|
if route.Network == "::" {
|
||||||
|
gatewaySetting = "ipv6_gateway"
|
||||||
|
} else if route.Network == "0.0.0.0" {
|
||||||
|
gatewaySetting = "ipv4_gateway"
|
||||||
|
}
|
||||||
|
if gatewaySetting != "" {
|
||||||
|
deviceID, err := strconv.Atoi(route.Gateway.Device)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[WARN] error at processing %s of device id %#v: %#v", gatewaySetting, route.Gateway.Device, err)
|
||||||
|
} else {
|
||||||
|
log.Printf("[DEBUG] %s of device id %d: %s", gatewaySetting, deviceID, route.Gateway.IpAddress)
|
||||||
|
networkInterfaces[deviceID][gatewaySetting] = route.Gateway.IpAddress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
log.Printf("[DEBUG] networkInterfaces: %#v", networkInterfaces)
|
log.Printf("[DEBUG] networkInterfaces: %#v", networkInterfaces)
|
||||||
err = d.Set("network_interface", networkInterfaces)
|
err = d.Set("network_interface", networkInterfaces)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -50,6 +50,7 @@ func TestAccVSphereVirtualMachine_basic(t *testing.T) {
|
||||||
gateway,
|
gateway,
|
||||||
label,
|
label,
|
||||||
ip_address,
|
ip_address,
|
||||||
|
gateway,
|
||||||
datastoreOpt,
|
datastoreOpt,
|
||||||
template,
|
template,
|
||||||
),
|
),
|
||||||
|
@ -111,6 +112,7 @@ func TestAccVSphereVirtualMachine_diskInitType(t *testing.T) {
|
||||||
gateway,
|
gateway,
|
||||||
label,
|
label,
|
||||||
ip_address,
|
ip_address,
|
||||||
|
gateway,
|
||||||
datastoreOpt,
|
datastoreOpt,
|
||||||
template,
|
template,
|
||||||
),
|
),
|
||||||
|
@ -490,6 +492,7 @@ func TestAccVSphereVirtualMachine_createWithExistingVmdk(t *testing.T) {
|
||||||
gateway,
|
gateway,
|
||||||
label,
|
label,
|
||||||
ip_address,
|
ip_address,
|
||||||
|
gateway,
|
||||||
datastoreOpt,
|
datastoreOpt,
|
||||||
vmdk_path,
|
vmdk_path,
|
||||||
),
|
),
|
||||||
|
@ -935,6 +938,7 @@ resource "vsphere_virtual_machine" "foo" {
|
||||||
label = "%s"
|
label = "%s"
|
||||||
ipv4_address = "%s"
|
ipv4_address = "%s"
|
||||||
ipv4_prefix_length = 24
|
ipv4_prefix_length = 24
|
||||||
|
ipv4_gateway = "%s"
|
||||||
}
|
}
|
||||||
disk {
|
disk {
|
||||||
%s
|
%s
|
||||||
|
@ -958,6 +962,7 @@ resource "vsphere_virtual_machine" "thin" {
|
||||||
label = "%s"
|
label = "%s"
|
||||||
ipv4_address = "%s"
|
ipv4_address = "%s"
|
||||||
ipv4_prefix_length = 24
|
ipv4_prefix_length = 24
|
||||||
|
ipv4_gateway = "%s"
|
||||||
}
|
}
|
||||||
disk {
|
disk {
|
||||||
%s
|
%s
|
||||||
|
@ -1078,6 +1083,7 @@ resource "vsphere_virtual_machine" "with_existing_vmdk" {
|
||||||
label = "%s"
|
label = "%s"
|
||||||
ipv4_address = "%s"
|
ipv4_address = "%s"
|
||||||
ipv4_prefix_length = 24
|
ipv4_prefix_length = 24
|
||||||
|
ipv4_gateway = "%s"
|
||||||
}
|
}
|
||||||
disk {
|
disk {
|
||||||
%s
|
%s
|
||||||
|
|
Loading…
Reference in New Issue