0
votes

i tried to upgrade block(performance) storage volume and IOPs via API.

test code returns the error message :

"Error: com.softlayer.api.ApiException$Internal: Invalid price Block Storage (189443) provided on the order container.(code: SoftLayer_Exception_Order_Item_Invalid, status: 500)"

I am using placeOrder and verifyOrder method for order.

where can i find sample code to upgrade storage volume?

public void test03() throws Exception {
    System.out.println("\nStorage Upgrade Test Start !!\n");

    ApiClient client = new RestApiClient().withCredentials(username, apiKey);

    com.softlayer.api.service.container.product.order.network.storage.asaservice.Upgrade storage = new com.softlayer.api.service.container.product.order.network.storage.asaservice.Upgrade();

    Storage.Service service = Storage.service(client, 38366457L);
    service.withMask().accountId();
    service.withMask().id();
    service.withMask().bytesUsed();
    service.withMask().osTypeId();
    service.withMask().iops();
    service.withMask().username();
    service.withMask().allowedIpAddresses();
    service.withMask().replicationStatus();
    service.withMask().parentVolume();
    service.withMask().parentVolume().volumeStatus();
    service.withMask().serviceResourceBackendIpAddress();
    service.withMask().serviceResource().datacenter();
    service.withMask().allowedHardware().allowedHost().credential().username().password();
    service.withMask().allowedSubnets();
    service.withMask().allowedVirtualGuests().allowedHost().credential().username().password();
    service.withMask().allowedIpAddresses().allowedHost().credential().username().password();
    service.withMask().snapshotCapacityGb();
    service.withMask().snapshotSizeBytes();
    service.withMask().snapshotSpaceAvailable();
    service.withMask().parentVolume().snapshotSizeBytes();
    service.withMask().parentVolume().snapshotSpaceAvailable();
    service.withMask().properties().type();
    service.withMask().billingItem();
    service.withMask().billingItem().children().activeFlag();
    service.withMask().billingItem().children().item();
    service.withMask().properties().volume();
    service.withMask().capacityGb();
    service.withMask().nasType();

    Storage storage1 = service.getObject();

    Order order = null;

    try {
        // 1. Storage volume
        storage.setVolumeSize(80L);
        storage.setIops(400L);

        storage1.setUpgradableFlag(true);
        storage.setVolume(storage1);

        order = storage;

        // Set SoftLayer Package Id
        order.setPackageId(759L);

        order.setUseHourlyPricing(true);

        // Set Data Center Location
        order.setLocation("1854895");

        List<Price> S_prices = new ArrayList<Price>();

        //International Services
        Price price1 = new Price();
        price1.setId(189433L);

        // 2. Block/File Storage
        Price price2 = new Price();
        price2.setId(189443L); //Block Storage

        //Storage Space
        Price price3 = new Price();
        price3.setId(189753L);

        //IOPS
        Price price4 = new Price();
        price4.setId(189813L);

        S_prices.add(price1);
        S_prices.add(price2);
        S_prices.add(price3);
        S_prices.add(price4);

        // Set Item Prices
        order.getPrices().addAll(S_prices);

        Order baseContainer = new Order();
        baseContainer.getOrderContainers().add(order);

        // verify
        Order verifiedOrder = com.softlayer.api.service.product.Order.service(client).verifyOrder(baseContainer);

        // placeorder
        com.softlayer.api.service.container.product.order.Receipt receipt = com.softlayer.api.service.product.Order.service(client).placeOrder(baseContainer, false);
    } catch (Exception e) {
        System.out.println("Error: " + e);
    } finally {
        System.out.println("\nTest End !!\n");
    }
}
2

2 Answers

0
votes

try deleting this price:

 // 2. Block/File Storage
        Price price2 = new Price();
        price2.setId(189443L); //Block Storage

As you are upgrading a "storage_as_a_service" you only need that price (189433) and the prices for the volume size and IOPS

This is the RESTFul request that I used:

POST https://$USERNAME:[email protected]/rest/v3/SoftLayer_Product_Order/placeOrder

{

    "parameters": [{

        "complexType": "SoftLayer_Container_Product_Order_Network_Storage_AsAService_Upgrade",

        "packageId": 759,

        "volume": {
            "id": 38740447
        },

        "volumeSize": 2000,

        "iops": 1000,

        "useHourlyPricing": true,

        "prices": [{
            "id": 190233
        }, {
            "id": 190293
        }, {
            "id": 189433
        }],

        "quantity": 1

    }]

}

So I recommend you:

1.- Try upgrading your block storage using the control portal, it may an issue with your account or your block storage.

2.- Try the upgrading using the RESTFul request, maybe the java client is sending wrong the request.

3.- Try Looging your Java code and see if the RESTFul request that your Java code is sending is similar to the RESTFUL request that I posted for that you need to this:

Logging Logging the requests and response to stdout can be enabled by invoking withLoggingEnabled on the RestApiClient. In order to log elsewhere, simply make your own implementation of RestApiClient with logRequest and logResponse overridden.

e.g.

ApiClient client = new RestApiClient().withCredentials(username, apiKey).withLoggingEnabled();

Regards

0
votes

I solved a problem.

my code had two issue.

first, in case of upgrading a storage(Block/File), the Type isn't need

// 2. Block/File Storage
Price price2 = new Price();
price2.setId(189443L); //Block Storage

two, Wrapping Order of the upgrade's container isn't need

because to upgrade storage, the ComplexType must be "SoftLayer_Container_Product_Order_Network_Storage_AsAService_Upgrade"

but Order's ComplexType is "SoftLayer_Container_Product_Order"

Order baseContainer = new Order(); <-- ComplextType : SoftLayer_Container_Product_Order
baseContainer.getOrderContainers().add(order);

so i deleted them and I modifed the verifyOrder and placeOrder parameters to order variable.

Order verifiedOrder = com.softlayer.api.service.product.Order.service(client).verifyOrder(order);

    // placeorder
com.softlayer.api.service.container.product.order.Receipt receipt = com.softlayer.api.service.product.Order.service(client).placeOrder(order, false);

this is a final code

public void test03() throws Exception {
System.out.println("\nStorage Upgrade Test Start !!\n");

ApiClient client = new RestApiClient().withCredentials(username, apiKey);

com.softlayer.api.service.container.product.order.network.storage.asaservice.Upgrade storage = new com.softlayer.api.service.container.product.order.network.storage.asaservice.Upgrade();

Storage.Service service = Storage.service(client, 38366457L);
service.withMask().id();

Storage storage1 = service.getObject();

Order order = null;

try {
    // 1. Storage volume
    storage.setVolumeSize(80L);
    storage.setIops(400L);

    storage1.setUpgradableFlag(true);
    storage.setVolume(storage1);

    order = storage;

    // Set SoftLayer Package Id
    order.setPackageId(759L);

    order.setUseHourlyPricing(true);

    // Set Data Center Location
    order.setLocation("1854895");

    List<Price> S_prices = new ArrayList<Price>();

    //International Services
    Price price1 = new Price();
    price1.setId(189433L);

    //Storage Space
    Price price3 = new Price();
    price3.setId(189753L);

    //IOPS
    Price price4 = new Price();
    price4.setId(189813L);

    S_prices.add(price1);
    S_prices.add(price3);
    S_prices.add(price4);

    // Set Item Prices
    order.getPrices().addAll(S_prices);

    // verify
    Order verifiedOrder = com.softlayer.api.service.product.Order.service(client).verifyOrder(order);

    // placeorder
    com.softlayer.api.service.container.product.order.Receipt receipt = com.softlayer.api.service.product.Order.service(client).placeOrder(order, false);
} catch (Exception e) {
    System.out.println("Error: " + e);
} finally {
    System.out.println("\nTest End !!\n");
}

}