Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove bsu_optimized effect (depecrated) #272

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions outscale/data_source_outscale_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ func dataSourceOutscaleOAPIVMRead(d *schema.ResourceData, meta interface{}) erro

// Populate instance attribute fields with the returned instance
func oapiVMDescriptionAttributes(set AttributeSetter, vm *oscgo.Vm) error {

if err := set("architecture", vm.GetArchitecture()); err != nil {
return err
}

if err := set("block_device_mappings_created", getOscAPIVMBlockDeviceMapping(vm.GetBlockDeviceMappings())); err != nil {
log.Printf("[DEBUG] BLOCKING DEVICE MAPPING ERR %+v", err)
return err
Expand Down Expand Up @@ -133,7 +131,6 @@ func oapiVMDescriptionAttributes(set AttributeSetter, vm *oscgo.Vm) error {
if err := set("nics", getOAPIVMNetworkInterfaceLightSet(vm.GetNics())); err != nil {
return err
}

if err := set("os_family", vm.GetOsFamily()); err != nil {
return err
}
Expand Down Expand Up @@ -195,7 +192,6 @@ func oapiVMDescriptionAttributes(set AttributeSetter, vm *oscgo.Vm) error {
if err := set("tags", getOscAPITagSet(vm.GetTags())); err != nil {
return err
}

return set("vm_type", vm.GetVmType())
}

Expand Down
27 changes: 9 additions & 18 deletions outscale/resource_outscale_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,14 +667,17 @@ func resourceOAPIVMRead(d *schema.ResourceData, meta interface{}) error {
if err != nil {
return err
}

return resourceDataAttrSetter(d, func(set AttributeSetter) error {
bsu := d.Get("bsu_optimized")
if err := resourceDataAttrSetter(d, func(set AttributeSetter) error {
if err := d.Set("admin_password", adminPassword); err != nil {
return err
}
d.SetId(vm.GetVmId())
return oapiVMDescriptionAttributes(set, &vm)
})
}); err != nil {
return err
}
return d.Set("bsu_optimized", bsu)
}

func getOAPIVMAdminPassword(VMID string, conn *oscgo.APIClient) (string, error) {
Expand Down Expand Up @@ -729,11 +732,9 @@ func resourceOAPIVMUpdate(d *schema.ResourceData, meta interface{}) error {
return nil
}

if d.HasChange("vm_type") && !d.IsNewResource() ||
d.HasChange("user_data") && !d.IsNewResource() ||
d.HasChange("bsu_optimized") && !d.IsNewResource() ||
d.HasChange("performance") && !d.IsNewResource() ||
d.HasChange("nested_virtualization") && !d.IsNewResource() {
if !d.IsNewResource() &&
(d.HasChange("vm_type") || d.HasChange("user_data") ||
d.HasChange("performance") || d.HasChange("nested_virtualization")) {
if err := stopVM(id, conn); err != nil {
return err
}
Expand All @@ -757,15 +758,6 @@ func resourceOAPIVMUpdate(d *schema.ResourceData, meta interface{}) error {
}
}

if d.HasChange("bsu_optimized") && !d.IsNewResource() {
opts := oscgo.UpdateVmRequest{VmId: id}
opts.SetBsuOptimized(d.Get("bsu_optimized").(bool))

if err := updateVmAttr(conn, opts); err != nil {
return err
}
}

if d.HasChange("performance") && !d.IsNewResource() {
opts := oscgo.UpdateVmRequest{VmId: id}
opts.SetPerformance(d.Get("performance").(string))
Expand Down Expand Up @@ -964,7 +956,6 @@ func buildCreateVmsRequest(d *schema.ResourceData, meta interface{}) (oscgo.Crea
request := oscgo.CreateVmsRequest{
DeletionProtection: oscgo.PtrBool(d.Get("deletion_protection").(bool)),
BootOnCreation: oscgo.PtrBool(true),
BsuOptimized: oscgo.PtrBool(d.Get("bsu_optimized").(bool)),
MaxVmsCount: oscgo.PtrInt32(1),
MinVmsCount: oscgo.PtrInt32(1),
ImageId: d.Get("image_id").(string),
Expand Down