vmm: Implement the VM HTTP endpoint handlers

Implement the vm.create, vm.boot, vm.shutdown and vm.reboot HTTP endpoint
handlers.

Fixes: #244

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz
2019-09-27 01:37:06 +02:00
parent 8a5e47f989
commit c505cfae2b
4 changed files with 136 additions and 4 deletions

View File

@@ -4,9 +4,9 @@
//
extern crate threadpool;
extern crate vmm_sys_util;
use crate::api::ApiRequest;
use crate::api::http_endpoint::{VmActionHandler, VmCreate};
use crate::api::{ApiRequest, VmAction};
use crate::{Error, Result};
use micro_http::{HttpConnection, Request, Response, StatusCode, Version};
use std::collections::HashMap;
@@ -50,10 +50,15 @@ macro_rules! endpoint {
lazy_static! {
/// HTTP_ROUTES contain all the cloud-hypervisor HTTP routes.
pub static ref HTTP_ROUTES: HttpRoutes = {
let r = HttpRoutes {
let mut r = HttpRoutes {
routes: HashMap::new(),
};
r.routes.insert(endpoint!("/vm.create"), Box::new(VmCreate {}));
r.routes.insert(endpoint!("/vm.boot"), Box::new(VmActionHandler::new(VmAction::Boot)));
r.routes.insert(endpoint!("/vm.shutdown"), Box::new(VmActionHandler::new(VmAction::Shutdown)));
r.routes.insert(endpoint!("/vm.reboot"), Box::new(VmActionHandler::new(VmAction::Reboot)));
r
};
}