-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow to add ips to vrouter nics #565
Changes from all commits
efefbd6
16684e0
71630fa
e8ed893
482fea9
0f79e87
fbcf514
eca6a1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,12 @@ func resourceOpennebulaVirtualRouterNIC() *schema.Resource { | |
Default: false, | ||
ForceNew: true, | ||
}, | ||
"ip": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
ForceNew: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
@@ -137,6 +143,10 @@ func resourceOpennebulaVirtualRouterNICCreate(ctx context.Context, d *schema.Res | |
} | ||
} | ||
|
||
if v, ok := d.GetOk("ip"); ok { | ||
nicTpl.Add("IP", v.(string)) | ||
} | ||
|
||
// wait before checking NIC | ||
nicID, err := vrNICAttach(ctx, d.Timeout(schema.TimeoutCreate), controller, vRouterID, nicTpl) | ||
if err != nil { | ||
|
@@ -209,6 +219,13 @@ func resourceOpennebulaVirtualRouterNICRead(ctx context.Context, d *schema.Resou | |
|
||
floatingIP, _ := nic.GetStr("FLOATING_IP") | ||
floatingOnly, _ := nic.GetStr("FLOATING_ONLY") | ||
ip, _ := nic.Get("IP") | ||
|
||
// For VRouter NICs, floating IPs are set using the "IP" field, but it is represented in the ON API | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tiny typo: ONE There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi! I believe this implementation suggestion is incorrect. If you look at implementation of a virtual machine https://registry.terraform.io/providers/OpenNebula/opennebula/latest/docs/resources/virtual_machine#nic there is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand the need for consistency, but do we really want two fields, an |
||
// as the "VROUTER_IP" field. | ||
if strings.ToUpper(floatingIP) == "YES" { | ||
ip, _ = nic.Get("VROUTER_IP") | ||
} | ||
|
||
d.Set("network_id", networkID) | ||
d.Set("virtual_router_id", vr.ID) | ||
|
@@ -219,6 +236,7 @@ func resourceOpennebulaVirtualRouterNICRead(ctx context.Context, d *schema.Resou | |
d.Set("security_groups", sg) | ||
d.Set("floating_ip", strings.ToUpper(floatingIP) == "YES") | ||
d.Set("floating_only", strings.ToUpper(floatingOnly) == "YES") | ||
d.Set("ip", ip) | ||
|
||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless I miss something it seems that this whole code part in helpers_vr.go is useless ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These few lines enable the IP to be set on the NIC resource for vrouter. On VRouter NICs that use floating IP, ON represents the IP in the
VROUTER_IP
field.This loop is ran when updating NICs. Without this, when running
terraform apply
to update the NIC would yield an empty IP (and therefore trigger a recreation when not necessary)