VMPowerOnOff


 * Launchpad Entry: https://blueprints.launchpad.net/nova/+spec/power-on-off-vm
 * Created: 23 Aug 2012
 * Contributors: Chetan Kumar

Summary
Add the ability in Nova to:
 * 1) power off a VM without destroying the instance
 * 2) power on a powered-off VM on an availability_zone of choice

Release Note
Added following features:


 * 1) Power off a VM without destroying the instance
 * 2) Power on a VM powered off earlier with the same settings some time later on an availability_zone of choice
 * 3) Added a new power_state POWER_OFF for the purpose

Rationale
It is not possible to power off a VM and power on later with the same network settings.

User stories
User wants to use an existing VM later with the current settings.

Design

 * 1) The VmPowerOnOffController will have extensions to:
 * 2) power off a VM
 * 3) power on the VM on a give availability_zone

Code Changes
Add VmPowerOnOffController to support the following API:

1. Power off VM:

URI: v2//servers//action Request Body: JSON {               "vm-poweroff": {} }

Normal Response Code: 202 Error Response Code(s): Bad Request (400), Not Found(404) Response: JSON {                }

Response: XML  

2. Power on VM:

URI: v2//servers//action Request body: JSON {           "vm-poweron": { "availability_zone":  }       }

Request body: XML  

Normal Response Code: 202 Error Response Code(s): Bad Request (400), Not Found(404) Response: JSON {                }

Response: XML 



Possible exceptions required to be handled:
 * 1) VM is not in POWER_OFF state.
 * 2) VM does not exist.
 * 3) Insufficient permissions: The API should return a 'Bad Request (400)' response with an appropriate error message.

Migration
No database or core API changes.

Test/Demo Plan
Tests being added