summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Maiocchi <dmaiocchi@suse.com>2017-11-23 19:24:24 +0100
committerAlvaro <alvaro.saurin@gmail.com>2017-11-27 09:57:46 +0100
commit538f29d84684083cabfacde7f901ebc4f7c6e37a (patch)
tree9cea5047bfc985284bf3a4eae01174f11b504128
parentb7894a88a97a5882084d6ccfa5c1496f51dc5ae2 (diff)
downloadterraform-provider-libvirt-538f29d84684083cabfacde7f901ebc4f7c6e37a.tar
terraform-provider-libvirt-538f29d84684083cabfacde7f901ebc4f7c6e37a.tar.gz
Init first backport
-rw-r--r--libvirt/resource_libvirt_network.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/libvirt/resource_libvirt_network.go b/libvirt/resource_libvirt_network.go
index 7bf93c75..78be64a9 100644
--- a/libvirt/resource_libvirt_network.go
+++ b/libvirt/resource_libvirt_network.go
@@ -74,6 +74,11 @@ func resourceLibvirtNetwork() *schema.Resource {
Type: schema.TypeString,
},
},
+ "autostart": {
+ Type: schema.TypeBool,
+ Optional: true,
+ Required: false,
+ },
"running": {
Type: schema.TypeBool,
Optional: true,
@@ -158,6 +163,14 @@ func resourceLibvirtNetworkUpdate(d *schema.ResourceData, meta interface{}) erro
d.Partial(false)
+ if d.HasChange("autostart") {
+ err = network.SetAutostart(d.Get("autostart").(bool))
+ if err != nil {
+ return fmt.Errorf("Error setting autostart for network: %s", err)
+ }
+ d.SetPartial("autostart")
+ }
+
return nil
}
@@ -331,6 +344,13 @@ func resourceLibvirtNetworkCreate(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Error waiting for network to reach ACTIVE state: %s", err)
}
+ if autostart, ok := d.GetOk("autostart"); ok {
+ err = network.SetAutostart(autostart.(bool))
+ if err != nil {
+ return fmt.Errorf("Error setting autostart for network: %s", err)
+ }
+ }
+
return resourceLibvirtNetworkRead(d, meta)
}
@@ -365,6 +385,11 @@ func resourceLibvirtNetworkRead(d *schema.ResourceData, meta interface{}) error
}
d.Set("running", active)
+ autostart, err := network.GetAutostart()
+ if err != nil {
+ return fmt.Errorf("Error reading network autostart setting: %s", err)
+ }
+ d.Set("autostart", autostart)
addresses := []string{}
for _, address := range networkDef.IPs {
// we get the host interface IP (ie, 10.10.8.1) but we want the network CIDR (ie, 10.10.8.0/24)