aboutsummaryrefslogtreecommitdiff
path: root/libvirt
diff options
context:
space:
mode:
authorDean Smith <dean@zelotus.com>2017-02-17 20:47:44 +0000
committerDean Smith <dean@zelotus.com>2017-02-17 20:56:33 +0000
commite60609f3fe5766885a2edb36b2e52e1dd58ffa6d (patch)
treef830dd90f1dbb21b1edbdb07728756e2f1e8231a /libvirt
parentb43db5136f5d80267a8172289af3133e4ab241ab (diff)
downloadterraform-provider-libvirt-e60609f3fe5766885a2edb36b2e52e1dd58ffa6d.tar
terraform-provider-libvirt-e60609f3fe5766885a2edb36b2e52e1dd58ffa6d.tar.gz
Fix for bridged networks.
Need to make domain attribute optional, as not used for bridge Disabling forwarding for bridged networks Ensure that parsing existing network doesn't fail due to lack of domain attribute
Diffstat (limited to 'libvirt')
-rw-r--r--libvirt/resource_libvirt_network.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/libvirt/resource_libvirt_network.go b/libvirt/resource_libvirt_network.go
index d27acfc8..6d4e54b8 100644
--- a/libvirt/resource_libvirt_network.go
+++ b/libvirt/resource_libvirt_network.go
@@ -48,7 +48,7 @@ func resourceLibvirtNetwork() *schema.Resource {
},
"domain": &schema.Schema{
Type: schema.TypeString,
- Required: true,
+ Optional: true,
ForceNew: true,
},
"mode": &schema.Schema{ // can be "none", "nat" (default), "route", "bridge"
@@ -209,6 +209,8 @@ func resourceLibvirtNetworkCreate(d *schema.ResourceData, meta interface{}) erro
if bridgeName == "" {
return fmt.Errorf("'bridge' must be provided when using the bridged network mode")
}
+ // Bridges cannot forward
+ networkDef.Forward = nil
} else {
return fmt.Errorf("unsupported network mode '%s'", networkDef.Forward.Mode)
}
@@ -284,9 +286,13 @@ func resourceLibvirtNetworkRead(d *schema.ResourceData, meta interface{}) error
}
d.Set("name", networkDef.Name)
- d.Set("domain", networkDef.Domain.Name)
d.Set("bridge", networkDef.Bridge.Name)
+ // Domain as won't be present for bridged networks
+ if (networkDef.Domain != nil) {
+ d.Set("domain", networkDef.Domain.Name)
+ }
+
active, err := network.IsActive()
if err != nil {
return err