您可以通过virtual.go:EditObject()编辑vsi bandwith分配吗?

I am using a modified version of this script: https://softlayer.github.io/go/edit_virtual_guest.go/

The script is the same except my objectTemplate looks like:

var objectTemplate datatypes.Virtual_Guest
objectTemplate.BandwidthAllocation = sl.Float(250)

The output after running is "Virtual Guest Server was successfully edited" but my vsi does not show updated bandwidth in the ui.

Is it possible to edit bandwidth using the EditObject call? Is it possible to edit the bandwidth using a different api call?

The “bandwidthAllocation” attribute that you are using does not work to edit the bandwidth of a virtual server, I suggest you to use SoftLayer_Product_Order::placeOrder to upgrade your bandwidth because the control portal use this method and service to do that.

There is not possible to edit bandwidth using the EditObject call.

This is a go example that you can use to upgrade your bandwidth:

/*
Upgrade bandwidth of a virtual server.

Build a SoftLayer_Container_Product_Order_Virtual_Guest object for a new virtual server order and
pass it to the SoftLayer_Product_Order API service to order it.
See below for more details.

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order
https://softlayer.github.io/reference/datatypes/SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade/

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/


package main

import (
    "fmt"
    "github.com/softlayer/softlayer-go/datatypes"
    "github.com/softlayer/softlayer-go/services"
    "github.com/softlayer/softlayer-go/session"
    "github.com/softlayer/softlayer-go/sl"
    "encoding/json"
)

func main() {
    // SoftLayer API username and key
    username := "set me"
    apikey   := "set me"

    // Declare the id for the virtual server you wish to order.
    vmId := 11111

    // Build a skeleton SoftLayer_Virtual_Guest object.
    virtualGuests := []datatypes.Virtual_Guest {
        {   // id of SoftLayer_Virtual_Guest object
            Id: sl.Int(vmId),
        },
    }

    // Build a skeleton SoftLayer_Product_Item_Price objects. To get the list of valid
    // prices for the package use the SoftLayer_Product_Package:getItems method
    prices := []datatypes.Product_Item_Price {
        { Id: sl.Int(50231) },     // 1000 GB Bandwidth
    }

    properties := []datatypes.Container_Product_Order_Property{
        {
            Name: sl.String("NOTE_GENERAL"),
            Value: sl.String("upgrade bandwidth"),
        },
        {
            Name: sl.String("MAINTENANCE_WINDOW"),
            Value: sl.String("2018-07-26T19:20:14.743Z"),
        },
        {
            Name: sl.String("orderOrigin"),
            Value: sl.String("control"),
        },
    }

    // Build a Container_Product_Order object containing the order you wish to place.
    orderTemplate := datatypes.Container_Product_Order{
        ComplexType   : sl.String("SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade"),
        VirtualGuests : virtualGuests,
        Prices        : prices,
        Properties: properties,
    }

    hardwareContainer := datatypes.Container_Product_Order_Hardware_Server{
        Container_Product_Order: orderTemplate,
    }

    virtualGuestContainer := datatypes.Container_Product_Order_Virtual_Guest{
        Container_Product_Order_Hardware_Server: hardwareContainer,
    }

    orderContainer := &datatypes.Container_Product_Order_Virtual_Guest_Upgrade{
        Container_Product_Order_Virtual_Guest: virtualGuestContainer,
    }


    // Create a session
    sess := session.New(username, apikey)

    // Get SoftLayer_Product_Order service
    service := services.GetProductOrderService(sess)

    // Use verifyOrder() method to check for errors. Replace this with placeOrder() when
    // you are ready to order.
    receipt, err := service.VerifyOrder(orderContainer)
    if err != nil {
        fmt.Printf("
 Unable to place order:
 - %s
", err)
        return
    }

    // Following helps to print the result in json format.
    jsonFormat, jsonErr := json.MarshalIndent(receipt, "", "    ")
    if jsonErr != nil {
        fmt.Println(jsonErr)
        return
    }

    fmt.Println(string(jsonFormat))
}

To get the item prices and their respective locations available you can use the following example:

/*
GetItemPrices

Retrieve a collection of SoftLayer_Product_Item_Prices that are valid for this package.

Important manual pages:
https://softlayer.github.io/reference/services/SoftLayer_Product_Package/getItemPrices/

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/

package main

import (
    "fmt"
    "github.com/softlayer/softlayer-go/services"
    "github.com/softlayer/softlayer-go/session"
    "encoding/json"
    "terraform-provider-softlayer/softlayer"
)


func main() {
    softlayer.Provider()

    // SoftLayer API username and key
    username := "set me"
    apikey   := "set me"

    packageId := 46
    mask := "id;locationGroupId;item[id,keyName,description];pricingLocationGroup[locations[id, name, longName]]"

    // Create a session
    sess := session.New(username, apikey)

    service := services.GetProductPackageService(sess)

    receipt, err := service.Id(packageId).Mask(mask).GetItemPrices()
    if err != nil {
        fmt.Printf("
 Unable to retrieve the item prices:
 - %s
", err)
        return
    }

    // Following helps to get the result in json format.
    // Following helps to print the result in json format.
    jsonFormat, jsonErr := json.MarshalIndent(receipt, "", "    ")
    if jsonErr != nil {
        fmt.Println(jsonErr)
        return
    }

    fmt.Println(string(jsonFormat))
}