Commit 17360da8 authored by Heinz N. Gies's avatar Heinz N. Gies

Add images list

parent 8d1123e3
This diff is collapsed.
......@@ -20,8 +20,10 @@ prettytable-rs = "^0.6"
lazy_static = "0.2"
regex = "0.2"
rand = "0.3"
reqwest = "0.7"
chrono = { version = "0.4", features = ["serde", "rustc-serialize"] }
# indicatif = "0.5"
[dependencies.clap]
version = "2"
features = ["yaml"]
\ No newline at end of file
features = ["yaml"]
......@@ -96,4 +96,9 @@ subcommands:
- force:
help: Forces the stop
short: F
takes_value: false
\ No newline at end of file
takes_value: false
- images:
about: image subcommands
subcommands:
- avail:
about: lists available images
......@@ -14,6 +14,9 @@ static CONFIG: &'static str = "/etc/vmadm.toml";
#[derive(Debug, Deserialize, Serialize)]
pub struct Settings {
pub pool: String,
#[serde(default = "default_repo")]
pub repo: String,
#[serde(default = "default_conf_dir")]
pub conf_dir: String,
#[serde(default = "devfs_ruleset")]
......@@ -35,6 +38,10 @@ fn default_conf_dir() -> String {
"/etc/jails".to_string()
}
fn default_repo() -> String {
"https://datasets.project-fifo.net/images".to_string()
}
impl Config {
/// Initializes config
pub fn new() -> Result<Self, Box<Error>> {
......
//! vmadm compatible jail manager
#![deny(trivial_numeric_casts,
......@@ -22,6 +23,9 @@ extern crate toml;
extern crate lazy_static;
extern crate regex;
extern crate rand;
extern crate reqwest;
extern crate chrono;
//extern crate indicatif;
......@@ -51,22 +55,22 @@ use aud::{Failure, Adventure, Saga};
use std::process::Command;
mod zfs;
pub mod jails;
mod images;
mod jails;
use jails::Jail;
pub mod jail_config;
mod jail_config;
mod update;
use jail_config::JailConfig;
pub mod jdb;
mod jdb;
use jdb::{JDB, IdxEntry};
mod config;
use config::Config;
pub mod errors;
mod errors;
use errors::GenericError;
#[cfg(target_os = "freebsd")]
......@@ -180,6 +184,7 @@ fn run() -> i32 {
("get", Some(get_matches)) => get(&config, get_matches),
("info", Some(info_matches)) => info(&config, info_matches),
("console", Some(console_matches)) => console(&config, console_matches),
("images", Some(image_matches)) => images(&config, image_matches),
("", None) => {
help_app.print_help().unwrap();
println!();
......@@ -515,3 +520,17 @@ fn delete(conf: &Config, matches: &clap::ArgMatches) -> Result<i32, Box<Error>>
db.remove(&uuid)?;
res
}
fn images(conf: &Config, matches: &clap::ArgMatches) -> Result<i32, Box<Error>> {
match matches.subcommand() {
("avail", Some(avail_matches)) => images_avail(&conf, avail_matches),
("", None) => {
Ok(0)
}
_ => unreachable!(),
}
}
fn images_avail(conf: &Config, _matches: &clap::ArgMatches) -> Result<i32, Box<Error>> {
images::avail(conf)
}
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