Skip to content

Commit

Permalink
Add support for IPv6 address information (#247)
Browse files Browse the repository at this point in the history
Expose computed_ip6_global and computed_ip6_link next to computed_ip

Signed-off-by: Daniel Molkentin <daniel@molkentin.de>
  • Loading branch information
danimo authored and frousselet committed May 23, 2022
1 parent 376ab4d commit 105bc94
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions opennebula/resource_opennebula_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ func nicComputedVMFields() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"computed_ip6_global": {
Type: schema.TypeString,
Computed: true,
},
"computed_ip6_link": {
Type: schema.TypeString,
Computed: true,
},
"computed_mac": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -648,6 +656,8 @@ func flattenNICComputed(nic shared.NIC) map[string]interface{} {
ip, _ := nic.Get(shared.IP)
mac, _ := nic.Get(shared.MAC)
physicalDevice, _ := nic.GetStr("PHYDEV")
ip6_global, _ := nic.GetStr("IP6_GLOBAL")
ip6_link, _ := nic.GetStr("IP6_LINK")
network, _ := nic.Get(shared.Network)

model, _ := nic.Get(shared.Model)
Expand All @@ -664,6 +674,8 @@ func flattenNICComputed(nic shared.NIC) map[string]interface{} {
"nic_id": nicID,
"network": network,
"computed_ip": ip,
"computed_ip6_global": ip6_global,
"computed_ip6_link": ip6_link,
"computed_mac": mac,
"computed_physical_device": physicalDevice,
"computed_model": model,
Expand All @@ -679,6 +691,12 @@ func flattenVMNICComputed(NICConfig map[string]interface{}, NIC shared.NIC) map[
if len(NICConfig["ip"].(string)) > 0 {
NICMap["ip"] = NICMap["computed_ip"]
}
if len(NICConfig["ip6_global"].(string)) > 0 {
NICMap["ip6_global"] = NICMap["computed_ip6_global"]
}
if len(NICConfig["ip6_link"].(string)) > 0 {
NICMap["ip6_link"] = NICMap["computed_ip6_link"]
}
if len(NICConfig["mac"].(string)) > 0 {
NICMap["mac"] = NICMap["computed_mac"]
}
Expand Down
8 changes: 8 additions & 0 deletions opennebula/shared_schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ func nicFields() map[string]*schema.Schema {
Type: schema.TypeString,
Optional: true,
},
"ip6_global": {
Type: schema.TypeString,
Optional: true,
},
"ip6_link": {
Type: schema.TypeString,
Optional: true,
},
"mac": {
Type: schema.TypeString,
Optional: true,
Expand Down

0 comments on commit 105bc94

Please sign in to comment.