0
votes

I have tried the softlayer api to do the same which is not letting the VM to be powered off .

api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest//powerOff? I am adding all the required credentials but it always returns an error sayind resource with id not found.

1

1 Answers

0
votes

The error you got is because the virtual server that you want to powerOff does not exist in your account. I suggest you to verify if that VS exists in your account by the portal control.

Or you can use the following rest api:

Method: GET

https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getVirtualGuests?objectFilter={"virtualGuests":{"id":{"operation":11111}}}

Replace the 11111 data of the filter for your vs id.

Below there is an example how to powerOff a vs by node.js:

        var username = 'set me';
        var apikey = 'set me';
        var virtualGuestId = 1111111;

        var SoftLayer = require('softlayer-node');
        var client = new SoftLayer();
        client
          .auth(username , apikey)
          .path('Virtual_Guest', virtualGuestId, 'powerOff')
          .get()
          .then(function(result) {
          console.log(result);
          }, function(error) {
          console.log(error);
          });

Reference:

https://www.npmjs.com/package/softlayer-node