api2/subscription.rs: add subscription api class

This commit is contained in:
Dietmar Maurer 2019-01-22 12:50:19 +01:00
parent 576e3bf252
commit 7e13b2d67f
3 changed files with 42 additions and 0 deletions

View File

@ -30,4 +30,5 @@ openssl = "0.10"
siphasher = "0.3"
endian_trait = "0.6"
walkdir = "2"
md5 = "0.6"

28
src/api2/subscription.rs Normal file
View File

@ -0,0 +1,28 @@
use failure::*;
use crate::tools;
use crate::api::schema::*;
use crate::api::router::*;
use serde_json::{json, Value};
fn get_subscription(_param: Value, _info: &ApiMethod) -> Result<Value, Error> {
let url = "https://www.proxmox.com/en/proxmox-backup-server/pricing";
Ok(json!({
"status": "NotFound",
"message": "There is no subscription key",
"serverid": tools::get_hardware_address()?,
"url": url,
}))
}
pub fn router() -> Router {
let route = Router::new()
.get(ApiMethod::new(
get_subscription,
ObjectSchema::new("Read subscription info.")));
route
}

View File

@ -355,3 +355,16 @@ pub fn scandir<P, F>(
}
Ok(())
}
pub fn get_hardware_address() -> Result<String, Error> {
static FILENAME: &str = "/etc/ssh/assh_host_rsa_key.pub";
let mut file = File::open(FILENAME)?;
let mut contents = Vec::new();
file.read_to_end(&mut contents)?;
let digest = md5::compute(contents);
Ok(format!("{:0x}", digest))
}