Skip to content

Commit

Permalink
B #405: create ovs network without vlan id
Browse files Browse the repository at this point in the history
  • Loading branch information
treywelsh authored and frousselet committed Feb 21, 2023
1 parent 61d8189 commit b8f94e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit b8f94e5

Please sign in to comment.