Skip to content

Commit

Permalink
B #515: fix ignored vlan_id
Browse files Browse the repository at this point in the history
  • Loading branch information
treywelsh committed Jul 3, 2024
1 parent 2c33564 commit 69b85ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.4.2 (Unreleased)

BUG FIXES:

* resources/opennebula_virtual_network: allow to set a `vlan_id` for ovswitch (#515)

# 1.4.1 (Unreleased)

FEATURES:
Expand Down
20 changes: 12 additions & 8 deletions opennebula/resource_opennebula_virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,15 +802,19 @@ func generateVn(d *schema.ResourceData) (string, error) {
tpl.Add(vnk.Name, vnname)
tpl.Add(vnk.VNMad, vnmad)

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 {
tpl.Add(vnk.VlanID, vlanid.(string))
} else {
return "", fmt.Errorf("You must specify a 'vlan_id' or set the flag 'automatic_vlan_id'")
}
vlanSet := false
if d.Get("automatic_vlan_id").(bool) {
tpl.Add("AUTOMATIC_VLAN_ID", "YES")
vlanSet = true
} else if vlanid, ok := d.GetOk("vlan_id"); ok {
tpl.Add(vnk.VlanID, vlanid.(string))
vlanSet = true
}

if mandatoryVLAN(vnmad) && !vlanSet {
return "", fmt.Errorf("you must specify a 'vlan_id' or set the flag 'automatic_vlan_id'")
}

if vnbridge, ok := d.GetOk("bridge"); ok {
tpl.Add(vnk.Bridge, vnbridge.(string))
}
Expand Down

0 comments on commit 69b85ec

Please sign in to comment.