From a7ae36c3d3b6471744afc49fd003ed1cbe97c6a9 Mon Sep 17 00:00:00 2001 From: Pierre Lafievre Date: Tue, 22 Dec 2020 15:22:44 +0100 Subject: [PATCH] Issue #95: remove partial call from update --- .../resource_opennebula_security_group.go | 8 -------- opennebula/resource_opennebula_service.go | 17 ----------------- .../resource_opennebula_service_template.go | 17 ----------------- 3 files changed, 42 deletions(-) diff --git a/opennebula/resource_opennebula_security_group.go b/opennebula/resource_opennebula_security_group.go index daa2cf269..29370aac8 100644 --- a/opennebula/resource_opennebula_security_group.go +++ b/opennebula/resource_opennebula_security_group.go @@ -354,9 +354,6 @@ func resourceOpennebulaSecurityGroupCreate(d *schema.ResourceData, meta interfac func resourceOpennebulaSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) error { - // Enable partial state mode - d.Partial(true) - //Get Security Group sgc, err := getSecurityGroupController(d, meta) if err != nil { @@ -420,7 +417,6 @@ func resourceOpennebulaSecurityGroupUpdate(d *schema.ResourceData, meta interfac return err } } - d.SetPartial("permissions") log.Printf("[INFO] Successfully updated Permissions Security Group %s\n", securitygroup.Name) } @@ -432,10 +428,6 @@ func resourceOpennebulaSecurityGroupUpdate(d *schema.ResourceData, meta interfac log.Printf("[INFO] Successfully updated group for Security Group %s\n", securitygroup.Name) } - // We succeeded, disable partial mode. This causes Terraform to save - // save all fields again. - d.Partial(false) - return resourceOpennebulaSecurityGroupRead(d, meta) } diff --git a/opennebula/resource_opennebula_service.go b/opennebula/resource_opennebula_service.go index 56d540e13..18eeef19b 100644 --- a/opennebula/resource_opennebula_service.go +++ b/opennebula/resource_opennebula_service.go @@ -298,9 +298,6 @@ func resourceOpennebulaServiceExists(d *schema.ResourceData, meta interface{}) ( func resourceOpennebulaServiceUpdate(d *schema.ResourceData, meta interface{}) error { controller := meta.(*goca.Controller) - // Enable partial state mode - d.Partial(true) - //Get Service controller sc, err := getServiceController(d, meta) if err != nil { @@ -319,7 +316,6 @@ func resourceOpennebulaServiceUpdate(d *schema.ResourceData, meta interface{}) e } service, err := sc.Info() - d.SetPartial("name") log.Printf("[INFO] Successfully updated name (%s) for Service ID %x\n", service.Name, service.ID) } @@ -330,7 +326,6 @@ func resourceOpennebulaServiceUpdate(d *schema.ResourceData, meta interface{}) e return err } } - d.SetPartial("permissions") log.Printf("[INFO] Successfully updated Permissions for Service %s\n", service.Name) } @@ -345,8 +340,6 @@ func resourceOpennebulaServiceUpdate(d *schema.ResourceData, meta interface{}) e } d.Set("gname", group.Name) - d.SetPartial("gname") - d.SetPartial("gid") log.Printf("[INFO] Successfully updated group for Service %s\n", service.Name) } else if d.HasChange("gname") { gid, err := controller.Groups().ByName(d.Get("gname").(string)) @@ -359,8 +352,6 @@ func resourceOpennebulaServiceUpdate(d *schema.ResourceData, meta interface{}) e } d.Set("gid", gid) - d.SetPartial("gid") - d.SetPartial("gname") log.Printf("[INFO] Successfully updated group for Service %s\n", service.Name) } @@ -375,8 +366,6 @@ func resourceOpennebulaServiceUpdate(d *schema.ResourceData, meta interface{}) e } d.Set("uname", user.Name) - d.SetPartial("uname") - d.SetPartial("uid") log.Printf("[INFO] Successfully updated owner for Service %s\n", service.Name) } else if d.HasChange("uname") { uid, err := controller.Users().ByName(d.Get("uname").(string)) @@ -389,15 +378,9 @@ func resourceOpennebulaServiceUpdate(d *schema.ResourceData, meta interface{}) e } d.Set("uid", uid) - d.SetPartial("uid") - d.SetPartial("uname") log.Printf("[INFO] Successfully updated owner for Service %s\n", service.Name) } - // We succeeded, disable partial mode. This causes Terraform to save - // save all fields again. - d.Partial(false) - return resourceOpennebulaServiceRead(d, meta) } diff --git a/opennebula/resource_opennebula_service_template.go b/opennebula/resource_opennebula_service_template.go index 63ec249b8..2d6733fc8 100644 --- a/opennebula/resource_opennebula_service_template.go +++ b/opennebula/resource_opennebula_service_template.go @@ -209,9 +209,6 @@ func resourceOpennebulaServiceTemplateExists(d *schema.ResourceData, meta interf func resourceOpennebulaServiceTemplateUpdate(d *schema.ResourceData, meta interface{}) error { controller := meta.(*goca.Controller) - // Enable partial state mode - d.Partial(true) - //Get Service controller stc, err := getServiceTemplateController(d, meta) if err != nil { @@ -230,7 +227,6 @@ func resourceOpennebulaServiceTemplateUpdate(d *schema.ResourceData, meta interf } stemplate, err := stc.Info() - d.SetPartial("name") log.Printf("[INFO] Successfully updated name (%s) for service template ID %x\n", stemplate.Name, stemplate.ID) } @@ -241,7 +237,6 @@ func resourceOpennebulaServiceTemplateUpdate(d *schema.ResourceData, meta interf return err } } - d.SetPartial("permissions") log.Printf("[INFO] Successfully updated Permissions for service template %s\n", stemplate.Name) } @@ -256,8 +251,6 @@ func resourceOpennebulaServiceTemplateUpdate(d *schema.ResourceData, meta interf } d.Set("gname", group.Name) - d.SetPartial("gname") - d.SetPartial("gid") log.Printf("[INFO] Successfully updated group for service template %s\n", stemplate.Name) } else if d.HasChange("gname") { gid, err := controller.Groups().ByName(d.Get("gname").(string)) @@ -270,8 +263,6 @@ func resourceOpennebulaServiceTemplateUpdate(d *schema.ResourceData, meta interf } d.Set("gid", gid) - d.SetPartial("gid") - d.SetPartial("gname") log.Printf("[INFO] Successfully updated group for service template %s\n", stemplate.Name) } @@ -286,8 +277,6 @@ func resourceOpennebulaServiceTemplateUpdate(d *schema.ResourceData, meta interf } d.Set("uname", user.Name) - d.SetPartial("uname") - d.SetPartial("uid") log.Printf("[INFO] Successfully updated owner for service template %s\n", stemplate.Name) } else if d.HasChange("uname") { uid, err := controller.Users().ByName(d.Get("uname").(string)) @@ -300,15 +289,9 @@ func resourceOpennebulaServiceTemplateUpdate(d *schema.ResourceData, meta interf } d.Set("uid", uid) - d.SetPartial("uid") - d.SetPartial("uname") log.Printf("[INFO] Successfully updated owner for service template %s\n", stemplate.Name) } - // We succeeded, disable partial mode. This causes Terraform to save - // save all fields again. - d.Partial(false) - return resourceOpennebulaServiceTemplateRead(d, meta) }