Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 119 Next »

How to edit VM cost codes, lock and protect VMs, relocate a VM, troubleshoot VM launch, manage VMs with workflow feature, and perform power operations with the API on the hybrid cloud platform.

Edit extra charges with cost codes for a VM

To assign extra charges with cost codes to a VM:

Privileges: View virtual machine extra charges, Manage virtual machine extra charges

  1. Edit the VM

  2. Go to Extra charges

  3. Click the + add button

  4. Select an Extra charge with a cost code

    1. For an extra charge a cost code with Usage user licenses unit, enter the number of Users for the VM

  5. After you finish editing the VM, click Save

You cannot change extra charges with cost codes that are inherited from the hardware profile or template

VM Extra charges


Protect a VM

An administrator can block actions on a VM in the platform by other users who do not have the Protect virtual machine privilege.

This section describes how to protect a VM from changes within the platform. To protect a VM with disaster recovery, see Protect a VM with disaster recovery

You can lock or protect a deployed VM when it is powered on, paused, or powered off.

Privileges: Protect virtual machine

To protect a VM

  1. Select the VM and click the padlock protect VM button on the VM control panel near the Deploy VM button

  2. In the Protect virtual machine dialog, enter the reason for protecting the VM.

 Protect a VM from the padlock button on the VM control panel

The platform will display a padlock symbol in the top left corner of the VM icon and change the status of the VM to MAINTENANCE. The administrator can customize this status in the UI labels. 

The name of the administrator who blocked the VM and the reason display in VM details → General.

To release a protected VM, click the open padlock unprotect VM button


Reset VM password

In vCloud Director, to reset the initial password of the root or Administrator user for a VM do these steps.

  1. Select a deployed VM

  2. On the control panel, click the key display initial guest password button

    Reset the VM password
  3. On the popup that opens, click Reset password

The platform will automatically shut down the VM and run the process to reset the password, then it will restart the VM.
The platform will send the new password by email or SMS as usual.


Restrict virtual appliances and VMs

To restrict a VM by moving it to a restricted VApp:

  1. Click the VM move button on the VM control panel

     Move a VM button on the VM control panel
  2. To move a VM to a restricted virtual appliance, the user can do one of the following depending on their privileges:

    • Select the option to Move the VM to a restricted VApp

    • Select a restricted VApp from the list

      Select a restricted VApp
    • Create a new restricted VApp.


Relocate a deployed VM to another host

The relocate VM feature enables you to move a deployed VM to another hypervisor on the same rack with the same manager. This feature is available for VMware ESXi and uses the vMotion feature. This feature requires the "Relocate a VM into a compatible host" privilege. The Relocate VM button is on the VM control panel near the Protect VM padlock button.

Privileges: Relocate a VM into a compatible host

To relocate a VM:

  1. Go to Virtual datacenters → open a virtual appliance → go to Virtual machines → select a VM

  2. On the VM control panel on the lower right-hand side of the screen, click the Relocate VM button  

  3. The platform will display a dialog with a list of hypervisor hosts where you can relocate the VM

  4. Click the Show details link to display the host metrics and the Relocate button

  5. Select the host with the same manager where you wish to relocate the VM, go to the host section and click Relocate. The platform will display the VM status as Relocating

  6. After relocation, the new hypervisor location will display in the control panel, for example, with a new Remote access address. If you click the Relocate button again, you should see a different host list, including the original host.

Screenshot: Select the VM and click relocate

Relocate a VM to move it to a compatible host in the same datacenter using vMotion

Screenshot: Host selection list

Select a host to relocate a VM using vMotion

Screenshot: Host metrics and Relocate button

Check host metrics when selecting a hypervisor to relocate the VM

Screenshot: You can check the relocation by clicking the Relocate button again, which will show the original host as a new candidate

Check relocation by clicking the relocate button again to display the original host


What happens when the user clicks deploy?

The VM scheduler deploys the VM.

A simplified description of the deploy process is shown in the following diagram.

 What happens when you click deploy

Deploy errors

When an error occurs during a VM deploy, the platform displays one or more of the following:

  • A yellow warning or red error notification message

  • An error state on the VM icon

  • A VM warning symbol in the lower part of the VM icon. 

 Deploy errors on VM icon

The user and the administrator may be notified of the error. 

The user can click on the error icon to display the events and the user can click on an event in the list to display its tracer message.

 Display details of VM events

The platform displays the full details of an error in the Events view and on the Events panel in the Home view.

Here is an example of an event for a failed reconfigure. 

Source: Abiquo / admin /
Date/time: 2014-4-29 13:41:41
Action: VIRTUAL_MACHINE_DEPLOY
Performed by: admin
User: admin
Trace: There are 1 candidate machines but all are oversubscribed by the current workload rules (RAM and CPU oversubscription or no suitable datastore with enough free space). Please check the workload rules or the physical machine resources. Virtual machine requires 1 CPU -- 128 RAM Candidate machines : BCN_KVM_02 ip - 10.60.13.20 .
Severity: ERROR

The platform displays the VM warning symbol for the VM task state. The VM tasks are a collection of jobs. For example, a Deploy task includes jobs to allocate, configure, and power on the VM. If a job fails, then the task will also fail and the platform will display the warning symbol on the VM. 

To acknowledge and delete a warning symbol, click on the symbol to remove it. 

If your user role is an administrator role with the privilege to Manage users, then you can also delete warnings for the users of the enterprises that you manage.


Virtual machine states table

State

Description

Not Allocated

VM icon of a VM in the not allocated state

A not allocated VM does not exist on the cloud node; it is just a template of the VM to be deployed and it only exists in Abiquo.
Abiquo has not allocated a physical machine or resources in the cloud to the VM. The VM is not consuming any resources. 
For example, if you add a VM template to a virtual appliance, the VM you just created is not deployed and its state is not allocated. If you undeploy a virtual appliance, then all the VMs in the virtual appliance will be undeployed, and these VMs will be in the not allocated state.

Allocated

An allocated VM does not exist on the cloud node but Abiquo has assigned a physical machine or provider to it. When you deploy a VM, the first step in the deploy process is the resource scheduling or allocation. After resource allocation, the VM is in the allocated state. This state is usually a short step in the deploy process.

Configured

A configured VM exists on the cloud node. Abiquo has allocated resources such as networks and disk to it on the physical machine or in the provider. After the VM is configured in the hypervisor or provider, the VM is in the configured state. This state is usually a short step in the deploy process.

On

VM icon of a VM in a powered ON or running state


The final step in the deploy process is to power on the VM. A VM in the on state exists in the cloud node and is running. 

Paused

VM icon of a VM in a paused state

A paused VM exists on the cloud node and the VM is suspended.

Off

VM icon of a VM in a powered OFF state

A VM in the off state exists in the cloud node but it is not running. Resources are still allocated in the cloud node, so the VM may be consuming resources for accounting purposes.

Locked

VM icon of a VM in a locked state

An operation is being performed on the VM. The status bar shows LOCKED but the VM icon has the progress notification.

Unknown

VM icon of a VM in an unknown state

Abiquo does not have information about the current state of a VM in the unknown state but the VM exists on the cloud node.  VMs may be put in the unknown state if there is an issue with a connection to the hypervisor or provider.

To delete a VM in the unknown state, you need the Delete unknown virtual machine privilege and also access to the enterprise or the Administer all enterprises privilege. Abiquo does not display VMs in the unknown state and their resources on the dashboard, and it does not count them in allocation limits for CPU, RAM, and storage.

Maintenance

VM icon of a VM in a maintenance state

The administrator can lock or protect a VM for maintenance when it is in any of the deployed states of on, paused, or off. See Protect a VM

Additional VM state in Microsoft Azure

State

Description

Off - Deallocated

VM icon of a VM in an OFF - deallocated state in Azure

A VM in the off (deallocated) state exists in Azure but it is deallocated. This means:

  1. It is powered off

  2. It is not consuming any CPU or RAM costs in Azure

  3. It does not have any IP addresses assigned to it in Azure

The deallocated state is not an Abiquo VM state,
but Abiquo recognizes this state in an Azure VM after a hard power off.

A VM in the deallocated state will have the deallocated attribute set to true.

For details of the Abiquo architecture for state management, see Abiquo technical overview .

Virtual appliance states

The virtual appliance states are calculated from the VM states as described below. The state name in the table has the color code for the Virtual appliance in each state.

State

Description

EMPTY

There are no VMs in the virtual appliance

DEPLOYED

All of the VMs are not in the Undeployed state. 
All the VMs exist in the hypervisor or provider and none are in the Unknown or Locked state.
Resources are allocated in the cloud node.

NOT DEPLOYED

All the VMs are in the Undeployed state.
None of the VMs exist in the hypervisor or provider, and none are in the Unknown or Locked state.
The virtual appliance can be seen as a template.
Resources are not allocated in the cloud node.

PARTIALLY DEPLOYED

This state occurs when a virtual appliance that is in the Deployed state is modified.
Such as when you add a new VM.
This state indicates that the configuration of the virtual appliance in the cloud node is different to the configuration of the virtual appliance in the Abiquo Server (database).
To update the cloud node with the changes, click Deploy all VMs.

LOCKED

One or more of the VMs is in the Locked state and none is in the Unknown state.
Note: Virtual appliances awaiting workflow review will be locked with VM state Waiting to be reviewed

UNKNOWN

Some or all of the VMs are in the Unknown state.
The virtual appliance state is unknown when the VM states cannot be recovered from the hypervisor or provider.
To continue working with this virtual appliance, the system administrator must take action.


Some of these states are shown in the virtual appliances lists in following screenshot.

 Virtual appliance states

Deployed state and powered off VMs
The fact that all the VMs in a virtual appliance are powered off does not imply that the virtual appliance is undeployed.
A deployed virtual appliance is always consuming resources because the VMs exist in the cloud nodes. An undeployed virtual appliance is not consuming resources.
In Microsoft Azure a deployed VM in the "Off - deallocated" state is not consuming cloud resources


Manage workflow tasks

When workflow is enabled, the user's requests to deploy, reconfigure and undeploy VMs will be held with the status waiting to be reviewed. 

This can include actions on scaling groups, unless the administrator selects the option to disable workflow in the scaling group. 

To view the list of workflow tasks

  1. Go to Virtual datacenters → Workflow tasks.

To filter workflow tasks, enter text in the filter box at the top of the tasks list.

 Display workflow tasks

To continue a queued workflow task, click the Accept link beside the task.

To cancel a queued workflow task, click the Reject link beside the task


Retrieve a VM using the API

This section describes how to retrieve a virtual machine with the REST API.

  1. Before you begin, create a VM with the Abiquo UI and power it off. Open the browser console. This example uses Chrome, so we clicked F12.

  2. Select the Network view

  3. Click the red arrow record button and the clear button next to it

  4. In the platform on the VM control panel, click the Start button

     Steps 1-4 for retrieving a VM via API
  5. Scroll up to the first request, which should be a PUT request to the virtual machine state URL. Click on the request

    1. If you can't see the Method column, right click on a column heading and select Method from the list

       Click on a request in the browser console
  6. Select the link to the VM up to the end of the VM ID number (before "/state")

  7. Use a cURL request similar to the one the example below or a REST API tool such as Postman to perform a GET request to this link. For this basic testing, you can use the -k option to avoid security warnings.

curl -X GET https://mjsabiquo.bcn.abiquo.com/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47 \
     -H 'Accept:application/vnd.abiquo.virtualmachine+json;version=6.1' \
     -u admin:xabiquo -k --verbose

 Click here to show or hide the response example

Success status code: 200

Response payload:

{
  "id": 47,
  "uuid": "e189ea34-46ac-4f15-a4e1-1c860e30fab2",
  "description": "A virtual machine",
  "coresPerSocket": 1,
  "idState": 4,
  "idType": 0,
  "type": "MANAGED",
  "highDisponibility": 0,
  "monitored": false,
  "protected": false,
  "variables": {},
  "backuppolicies": [],
  "lastSynchronize": 1589912530000,
  "generateGuestInitialPassword": false,
  "natrules": [],
  "vdrpEnabled": false,
  "vdrpPort": 0,
  "password": "50WyfITK",
  "deallocated": false,
  "name": "ABQ_e189ea34-46ac-4f15-a4e1-1c860e30fab2",
  "label": "yVM - 2020/05/01 16:34:54 CEST",
  "ram": 48,
  "cpu": 1,
  "state": "ON",
  "creationTimestamp": 1588343694000,
  "links": [
    {
      "title": "KVM",
      "rel": "machine",
      "type": "application/vnd.abiquo.machine+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/1/racks/2/machines/3"
    },
    {
      "title": "BCDC",
      "rel": "location",
      "type": "application/vnd.abiquo.datacenter+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/locations/1"
    },
    {
      "title": "Abiquo",
      "rel": "enterprise",
      "type": "application/vnd.abiquo.enterprise+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1"
    },
    {
      "title": "ABQ_e189ea34-46ac-4f15-a4e1-1c860e30fab2",
      "rel": "edit",
      "type": "application/vnd.abiquo.virtualmachine+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47"
    },
    {
      "rel": "asynctasks",
      "type": "application/vnd.abiquo.asynctasks+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/asynctasks"
    },
    {
      "title": "send mail",
      "rel": "sendmail",
      "type": "application/vnd.abiquo.mail+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/1/racks/2/machines/3/virtualmachines/47/action/sendmail"
    },
    {
      "title": "Cloud Administrator",
      "rel": "user",
      "type": "application/vnd.abiquo.user+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1/users/1"
    },
    {
      "title": "bcdc_vdc_kvm",
      "rel": "virtualdatacenter",
      "type": "application/vnd.abiquo.virtualdatacenter+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2"
    },
    {
      "title": "vapp_kvm",
      "rel": "virtualappliance",
      "type": "application/vnd.abiquo.virtualappliance+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1"
    },
    {
      "title": "metadata",
      "rel": "metadata",
      "type": "application/vnd.abiquo.metadata+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/metadata"
    },
    {
      "title": "vlan network configurations",
      "rel": "configurations",
      "type": "application/vnd.abiquo.virtualmachinenetworkconfigurations+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/network/configurations"
    },
    {
      "title": "192.168.0.0/24",
      "rel": "network_configuration",
      "type": "application/vnd.abiquo.virtualmachinenetworkconfiguration+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/network/configurations/2"
    },
    {
      "title": "nics",
      "rel": "nics",
      "type": "application/vnd.abiquo.nics+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/network/nics"
    },
    {
      "title": "disks",
      "rel": "harddisks",
      "type": "application/vnd.abiquo.harddisks+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/storage/disks"
    },
    {
      "title": "ON",
      "rel": "state",
      "type": "application/vnd.abiquo.virtualmachinestate+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/state"
    },
    {
      "title": "virtual machine undeploy",
      "rel": "undeploy",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/action/undeploy"
    },
    {
      "title": "virtual machine deploy",
      "rel": "deploy",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/action/deploy"
    },
    {
      "title": "virtual machine reset",
      "rel": "reset",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/action/reset"
    },
    {
      "title": "virtual machine snapshot",
      "rel": "instance",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/action/instance"
    },
    {
      "title": "remote access",
      "rel": "rdpaccess",
      "type": "application/vnd.abiquo.virtualmachineconsole+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/config/rdpaccess"
    },
    {
      "title": "tasks",
      "rel": "tasks",
      "type": "application/vnd.abiquo.tasks+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/tasks"
    },
    {
      "title": "firewalls",
      "rel": "firewalls",
      "type": "application/vnd.abiquo.links+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/firewalls"
    },
    {
      "title": "load balancers",
      "rel": "loadbalancers",
      "type": "application/vnd.abiquo.loadbalancers+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/loadbalancers"
    },
    {
      "title": "request on demand backup",
      "rel": "requestbackup",
      "type": "application/vnd.abiquo.ondemandbackup+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/backup/action/request"
    },
    {
      "title": "request a restore of a backup",
      "rel": "requestrestore",
      "type": "application/vnd.abiquo.restore+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/backup/action/restore"
    },
    {
      "title": "move VM to a virtual appliance",
      "rel": "vappmove",
      "type": "application/vnd.abiquo.links+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/action/vappmove"
    },
    {
      "title": "move VM to another virtual datacenter",
      "rel": "move",
      "type": "application/vnd.abiquo.movevm+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/action/move"
    },
    {
      "title": "volumes",
      "rel": "volumes",
      "type": "application/vnd.abiquo.volumes+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/storage/volumes"
    },
    {
      "title": "HP_CPU1-RAM48-CPS1-CostCodenone-ABQf15c3a97",
      "rel": "hardwareprofile",
      "type": "application/vnd.abiquo.hardwareprofile+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/locations/1/hardwareprofiles/106"
    },
    {
      "diskControllerType": "IDE",
      "diskLabel": "Hard disk 1",
      "length": "64",
      "title": "c4ec520d-95a0-4ce4-a0bf-01053751b742",
      "rel": "disk0",
      "type": "application/vnd.abiquo.harddisk+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/disks/8"
    },
    {
      "title": "Default Tier",
      "rel": "datastoretier0",
      "type": "application/vnd.abiquo.datastoretier+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/locations/1/datastoretiers/1"
    },
    {
      "title": "192.168.0.4",
      "rel": "nic0",
      "type": "application/vnd.abiquo.privateip+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/privatenetworks/2/ips/9"
    },
    {
      "title": "192.168.0.8",
      "rel": "nic1",
      "type": "application/vnd.abiquo.privateip+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/privatenetworks/2/ips/27"
    },
    {
      "title": "protect",
      "rel": "protect",
      "type": "text/plain",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/action/protect"
    },
    {
      "title": "unprotect",
      "rel": "unprotect",
      "type": "text/plain",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/action/unprotect"
    },
    {
      "title": "metricsmetadata",
      "rel": "metricsmetadata",
      "type": "application/vnd.abiquo.metricsmetadata+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/metrics"
    },
    {
      "title": "enablemonitoring",
      "rel": "enablemonitoring",
      "type": "",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/enablemonitoring"
    },
    {
      "title": "collectd",
      "rel": "collectd",
      "type": "application/json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/metrics/collectd"
    },
    {
      "title": "alarmssearch",
      "rel": "alarmssearch",
      "type": "application/vnd.abiquo.alarms+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/alarms"
    },
    {
      "title": "clone",
      "rel": "clone",
      "type": "application/vnd.abiquo.virtualmachinecloneoptions+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/1/virtualmachines/47/action/clone"
    },
    {
      "title": "KVM",
      "rel": "hypervisortype",
      "type": "application/vnd.abiquo.hypervisortype+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/config/hypervisortypes/KVM"
    },
    {
      "title": "yVM",
      "rel": "virtualmachinetemplate",
      "type": "application/vnd.abiquo.virtualmachinetemplate+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/58"
    },
    {
      "title": "Others",
      "rel": "category",
      "type": "application/vnd.abiquo.category+json",
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/config/categories/1"
    }
  ],
  "usageStatistics": []
}  

Manage VM power states using the API

To manage the Vm using the API, first you need to retrieve the VM and find the links for different actions.

Remember to see VirtualMachinesResource for full details of VM operations using the Abiquo API.

To perform a power action (except for reset) on a VM using the API:

  1. Perform a GET request to obtain the VM object and find the VM state link

  2. Create a virtualmachinestate object

  3. Send a PUT request to the VM state link

The VM state link is a link in the VM object with the "rel" attribute set to state. The "title" attribute contains the current state. You can send a PUT request of a virtualmachine state object to the link (in the "href" attribute) to change the power state of the VM.

    {
      "title": "ON",
      "rel": "state",
      "type": "application/vnd.abiquo.virtualmachinestate+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/state"
    }, 

Here are some examples of virtualmachinestate objects and notes about changing VM states

  • Hard power off

    {"state": "OFF"}

    When you perform a power off via API, the response will include a link where you can monitor the progress of this operation. For an example of a hard power off, see https://wiki.abiquo.com/api/latest/VirtualMachinesResource.html#change-the-state-of-a-virtual-machine

  • Graceful shutdown

    {"state": "OFF", "gracefulShutdown": true}

    To perform a graceful shutdown, your VM will need to have guest extensions installed on it. After an operation completes, you can view the status of the task by going to the link in the accepted request link of the response. In this case, the graceful shutdown was successful.

    curl -X PUT 'https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/state' \
      -k --verbose \
      -H 'Accept: application/vnd.abiquo.acceptedrequest+json; version=5.0' \
      -H 'Content-Type: application/vnd.abiquo.virtualmachinestate+json; version=5.0' \
      -d '{"state": "OFF", "gracefulShutdown": true}' \
      -u user:password | jq .

    {
      "taskId": "d62be542-f34c-4fed-b9f8-6443f2db4cc1",
      "userId": "10",
      "type": "SHUTDOWN",
      "ownerId": "19454",
      "state": "FINISHED_SUCCESSFULLY",
      "creationTimestamp": 1596040226,
      "timestamp": 1596040226,
      "jobs": {
        "links": [],
        "collection": [
          {
            "id": "d62be542-f34c-4fed-b9f8-6443f2db4cc1.2cd94a0c-179d-4506-a71d-fabaf29a4d43",
            "parentTaskId": "d62be542-f34c-4fed-b9f8-6443f2db4cc1",
            "type": "SHUTDOWN",
            "description": "Shutdown task's shutdown on virtual machine with id 19454",
            "state": "DONE",
            "rollbackState": "UNKNOWN",
            "creationTimestamp": 1596040226,
            "timestamp": 1596040226,
            "links": []
          }
        ]
      },
      "links": [
        {
          "rel": "self",
          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/tasks/d62be542-f34c-4fed-b9f8-6443f2db4cc1"
        },
        {
          "rel": "parent",
          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/tasks"
        },
        {
          "rel": "result",
          "type": "application/vnd.abiquo.virtualmachine+json",
          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454"
        },
        {
          "title": "user",
          "rel": "user",
          "type": "application/vnd.abiquo.user+json",
          "href": "https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/336/users/10"
        },
        {
          "title": "ABQ_2fb11009-8157-4d61-915d-40fa45f440ac",
          "rel": "virtualmachine",
          "type": "application/vnd.abiquo.virtualmachine+json",
          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454"
        }
      ]
    } 

  • Power on

    {"state": "ON"}

  • Pause

    {"state": "PAUSED"}

  • Azure power off and deallocate

    Azure has two power off states - powered off and deallocated.

    • To power off a VM in Azure via the Abiquo API, use the graceful shutdown

    • To deallocate a VM in Azure via the Abiquo API, use the hard power off

      • The deallocated VM will have a "deallocated" attribute that is set to "true".

To reset a VM using the API, use a POST request to the reset action link. If you are using a test environment, you may wish to add the --insecure option.

cURL:

curl -X POST 'https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/reset' \ 
-k --verbose \
-H 'Accept: application/vnd.abiquo.acceptedrequest+json; version=5.0' \
-u user:password | jq . 

Success status code: 202

Request payload:

--none--

Response payload:

{
  "message": "You can keep track of the progress in the link",
  "links": [
    {
      "title": "status",
      "rel": "status",
      "type": "application/vnd.abiquo.task+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/tasks/edec6cf1-8874-451d-a4c0-57f4c24da371"
    }
  ]
} 


Related pages

  • No labels