-
Notifications
You must be signed in to change notification settings - Fork 58
fix: make cidr optional for L2 network creation #289
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -74,7 +74,7 @@ func resourceCloudStackNetwork() *schema.Resource { | |
|
|
||
| "cidr": { | ||
| Type: schema.TypeString, | ||
| Required: true, | ||
| Optional: true, | ||
| ForceNew: true, | ||
| }, | ||
|
|
||
|
|
@@ -190,23 +190,25 @@ func resourceCloudStackNetworkCreate(d *schema.ResourceData, meta interface{}) e | |
| return err | ||
| } | ||
|
|
||
| m, err := parseCIDR(d, no.Specifyipranges) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if _, ok := d.GetOk("cidr"); ok { | ||
| m, err := parseCIDR(d, no.Specifyipranges) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
Comment on lines
+193
to
+197
|
||
|
|
||
| // Set the needed IP config | ||
| p.SetGateway(m["gateway"]) | ||
| p.SetNetmask(m["netmask"]) | ||
| // Set the needed IP config | ||
| p.SetGateway(m["gateway"]) | ||
| p.SetNetmask(m["netmask"]) | ||
|
|
||
| // Only set the start IP if we have one | ||
| if startip, ok := m["startip"]; ok { | ||
| p.SetStartip(startip) | ||
| } | ||
| // Only set the start IP if we have one | ||
| if startip, ok := m["startip"]; ok { | ||
| p.SetStartip(startip) | ||
| } | ||
|
|
||
| // Only set the end IP if we have one | ||
| if endip, ok := m["endip"]; ok { | ||
| p.SetEndip(endip) | ||
| // Only set the end IP if we have one | ||
| if endip, ok := m["endip"]; ok { | ||
| p.SetEndip(endip) | ||
| } | ||
| } | ||
|
|
||
| // Set the network domain if we have one | ||
|
|
||
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.
With
cidroptional,GetNetworkOfferingByIDis only needed whencidris present (to readSpecifyiprangesforparseCIDR). To avoid an extra API call on L2/no-cidr networks, consider moving the network-offering lookup inside thecidrconditional block.