简体   繁体   中英

power off virtual guest using softlayer api using Javascript

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM