message: hermes: Only provide networks listed on the command line
diff: @@ -3,8 +3,9 @@ use serde_yaml;
  use storage::{self, Storage};
  use storage::config::StorageConfig;
  use exe_common::config::{net};
  -use std::{io, result, path::{PathBuf, Path}, env::{VarError, self, home_dir}, fs};
  +use std::{io, result, path::{PathBuf, Path}, env::{VarError, self, home_dir}};
  use std::{num::{ParseIntError}, collections::{BTreeMap}, sync::{Arc}};
  +use std::collections::HashSet;
  #[derive(Debug)]
  pub enum Error {
  @@ -37,7 +38,8 @@ type Result<T> = result::Result<T, Error>;
  #[derive(Debug, Clone, Serialize, Deserialize)]
  pub struct Config {
  pub root_dir: PathBuf,
  - pub port: u16
  + pub port: u16,
  + pub network_names: HashSet<String>
  }
  impl Default for Config {
  @@ -51,29 +53,27 @@ impl Config {
  pub fn new(root_dir: PathBuf, port: u16) -> Self {
  Config {
  root_dir: root_dir,
  - port: port
  + port: port,
  + network_names: HashSet::new()
  }
  }
  pub fn get_networks_dir(&self) -> PathBuf { self.root_dir.clone() }
  pub fn get_networks(&self) -> Result<Networks> {
  - let dir = self.get_networks_dir();
  let mut networks = Networks::new();
  - for entry in fs::read_dir(dir.clone()).expect("read the networks-dir") {
  - let entry = entry?;
  - if ! entry.file_type()?.is_dir() { continue; }
  - let name = entry.file_name();
  - if let Some(name) = name.to_str() {
  + for name in &self.network_names {
  + let netcfg_dir = self.get_networks_dir().join(name);
  +
  let network = Network {
  - path: entry.path().to_path_buf(),
  + path: netcfg_dir,
  config: self.get_network_config(name)?,
  storage: Arc::new(self.get_storage(name)?)
  };
  +
  networks.insert(name.to_owned(), network);
  }
  - }
  Ok(networks)
  }
  @@ -89,10 +89,13 @@ impl Config {
  }
  }
  - pub fn add_network(&self, name: &str, netcfg: &net::Config) -> Result<()> {
  + pub fn add_network(&mut self, name: &str, netcfg: &net::Config) -> Result<()> {
  let netcfg_dir = self.get_networks_dir().join(name);
  - if netcfg_dir.exists() { return Ok(()) }
  + if netcfg_dir.exists() {
  + self.network_names.insert(name.to_string());
  + return Ok(())
  + }
  let storage_config = self.get_storage_config(name);
  let _ = Storage::init(&storage_config)?;
  @@ -101,6 +104,7 @@ impl Config {
  netcfg.to_file(network_file);
  info!("Added network {}", name);
  + self.network_names.insert(name.to_string());
  Ok(())
  }
  @@ -119,6 +123,7 @@ pub struct Network {
  pub config: net::Config,
  pub storage: Arc<storage::Storage>,
  }
  +
  pub type Networks = BTreeMap<String, Network>;
  /// the environment variable to define where the Hermes files are stores
  