Skip to content
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

B-405: create ovswitch network without vlan id #407

Merged
merged 1 commit into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
BUG FIXES:

* resources/opennebula_virtual_machine: add transient state `LCM_INIT` (#410)
* resources/opennebula_virtual_network: for `ovswitch` type the attributes `vlan_id` and `automatic_vlan_id` are optional (#405)

NOTES:

Expand Down
7 changes: 3 additions & 4 deletions opennebula/resource_opennebula_virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,8 @@ func changeVNetGroup(d *schema.ResourceData, meta interface{}) error {
return nil
}

func validVlanType(intype string) int {
vlanType := []string{"802.1Q", "vxlan", "ovswitch"}
return inArray(intype, vlanType)
func mandatoryVLAN(intype string) bool {
return inArray(intype, []string{"802.1Q", "vxlan"}) >= 0
}

func resourceOpennebulaVirtualNetworkCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
Expand Down Expand Up @@ -804,7 +803,7 @@ func generateVn(d *schema.ResourceData) (string, error) {
tpl.Add(vnk.Name, vnname)
tpl.Add(vnk.VNMad, vnmad)

if validVlanType(vnmad) >= 0 {
if mandatoryVLAN(vnmad) {
if d.Get("automatic_vlan_id") == true {
tpl.Add("AUTOMATIC_VLAN_ID", "YES")
} else if vlanid, ok := d.GetOk("vlan_id"); ok {
Expand Down