mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user