Skip to content

Commit

Permalink
Issue #95: remove partial call from update
Browse files Browse the repository at this point in the history
  • Loading branch information
treywelsh committed Feb 5, 2021
1 parent 327145e commit 999384e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 42 deletions.
8 changes: 0 additions & 8 deletions opennebula/resource_opennebula_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down
17 changes: 0 additions & 17 deletions opennebula/resource_opennebula_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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))
Expand All @@ -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)
}

Expand All @@ -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))
Expand All @@ -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)
}

Expand Down
17 changes: 0 additions & 17 deletions opennebula/resource_opennebula_service_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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))
Expand All @@ -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)
}

Expand All @@ -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))
Expand All @@ -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)
}

Expand Down

0 comments on commit 999384e

Please sign in to comment.