Commit 40cb1893 authored by Heinz N. Gies's avatar Heinz N. Gies

Add config to show hypervisor config

parent d57cd990
......@@ -93,7 +93,7 @@ cat <<EOF > $ID.json
"v": 2,
"uuid": "${ID}",
"name": "FreeBSD",
"version": "10.2",
"version": "${VSN}",
"type": "jail-dataset",
"os": "freebsd",
"files": [
......
......@@ -13,6 +13,7 @@ args:
conflicts_with:
list
subcommands:
- list:
about: lists jails
args:
......@@ -79,6 +80,8 @@ subcommands:
help: UUID if the jail to get
index: 1
required: true
- config:
about: gets hypervisor configuration
- info:
about: gets a info for a hardware virtualized vm
args:
......
......@@ -187,6 +187,8 @@ fn run() -> i32 {
("info", Some(info_matches)) => info(&config, info_matches),
("console", Some(console_matches)) => console(&config, console_matches),
("images", Some(image_matches)) => images(&config, image_matches),
("config", Some(config_matches)) => hv_config(&config, config_matches),
("", None) => {
help_app.print_help().unwrap();
println!();
......@@ -266,7 +268,7 @@ fn info(conf: &Config, matches: &clap::ArgMatches) -> Result<i32, Box<Error>> {
let db = JDB::open(conf)?;
let uuid_string = value_t!(matches, "uuid", String).unwrap();
let uuid = Uuid::parse_str(uuid_string.as_str()).unwrap();
debug!("Starting jail {}", uuid.hyphenated());
debug!("Getting jail info {}", uuid.hyphenated());
match db.get(&uuid) {
Err(e) => Err(e),
Ok(_jail) => {
......@@ -276,6 +278,21 @@ fn info(conf: &Config, matches: &clap::ArgMatches) -> Result<i32, Box<Error>> {
}
}
#[derive(Serialize)]
struct Info {
networks: Vec<String>
}
fn hv_config(conf: &Config, _matches: &clap::ArgMatches) -> Result<i32, Box<Error>> {
let info = Info{
networks: conf.settings.networks.keys().map(|v| v.clone()).collect::<Vec<String>>()
};
debug!("Getting hypervisor info.");
let j = serde_json::to_string_pretty(&info)?;
println!("{}\n", j);
Ok(0)
}
fn console(conf: &Config, matches: &clap::ArgMatches) -> Result<i32, Box<Error>> {
let db = JDB::open(conf)?;
let uuid_string = value_t!(matches, "uuid", String).unwrap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment