mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2025-04-21 19:56:25 +02:00
Compare commits
No commits in common. "646aae8ef59a37a632692d535a9f0f89201eb5fa" and "d5fe7cbe5c8d4aee3b33a212e6aa9b385f6322b6" have entirely different histories.
646aae8ef5
...
d5fe7cbe5c
@ -243,16 +243,12 @@ pub fn load(
|
|||||||
.compat(),
|
.compat(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut actor_connections_data_vec: Vec<(String, String)> = vec![];
|
let mut actor_map: HashMap<String, _> = config
|
||||||
for actor_connection in config.actor_connections.clone().into_iter() {
|
.actor_connections
|
||||||
actor_connections_data_vec.push((actor_connection.machine, actor_connection.actor));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut actor_map: HashMap<String, _> = actor_connections_data_vec
|
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(k, v)| {
|
.filter_map(|(k, v)| {
|
||||||
if let Some(resource) = resources.get_by_id(k) {
|
if let Some(resource) = resources.get_by_id(v) {
|
||||||
Some((v.clone(), resource.get_signal()))
|
Some((k.clone(), resource.get_signal()))
|
||||||
} else {
|
} else {
|
||||||
tracing::error!(actor=%k, machine=%v, "Machine configured for actor not found!");
|
tracing::error!(actor=%k, machine=%v, "Machine configured for actor not found!");
|
||||||
None
|
None
|
||||||
|
@ -90,11 +90,11 @@ pub struct Config {
|
|||||||
|
|
||||||
/// Actors to load and their configuration options
|
/// Actors to load and their configuration options
|
||||||
pub actors: HashMap<String, ModuleConfig>,
|
pub actors: HashMap<String, ModuleConfig>,
|
||||||
pub actor_connections: Vec<ActorConnectionConfig>,
|
pub actor_connections: HashMap<String, String>,
|
||||||
|
|
||||||
/// Initiators to load and their configuration options
|
/// Initiators to load and their configuration options
|
||||||
pub initiators: HashMap<String, ModuleConfig>,
|
pub initiators: HashMap<String, ModuleConfig>,
|
||||||
pub init_connections: Vec<InitiatorConnectionConfig>,
|
pub init_connections: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
@ -109,24 +109,6 @@ pub struct ModuleConfig {
|
|||||||
pub params: HashMap<String, String>,
|
pub params: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct ParamsConfig {
|
|
||||||
pub module: String,
|
|
||||||
pub params: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct ActorConnectionConfig {
|
|
||||||
pub machine: String,
|
|
||||||
pub actor: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct InitiatorConnectionConfig {
|
|
||||||
pub machine: String,
|
|
||||||
pub initiator: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn deser_option<'de, D, T>(d: D) -> std::result::Result<Option<T>, D::Error>
|
pub(crate) fn deser_option<'de, D, T>(d: D) -> std::result::Result<Option<T>, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
@ -142,21 +124,6 @@ impl Default for Config {
|
|||||||
let mut roles: HashMap<String, Role> = HashMap::new();
|
let mut roles: HashMap<String, Role> = HashMap::new();
|
||||||
let mut machines: HashMap<String, MachineDescription> = HashMap::new();
|
let mut machines: HashMap<String, MachineDescription> = HashMap::new();
|
||||||
|
|
||||||
let mut initiator_123_params: HashMap<String, String> = HashMap::new();
|
|
||||||
initiator_123_params.insert("args".to_string(), "".to_string());
|
|
||||||
initiator_123_params.insert("cmd".to_string(), "echo".to_string());
|
|
||||||
|
|
||||||
let mut actor_connections_vec: Vec<ActorConnectionConfig> = vec![ActorConnectionConfig {
|
|
||||||
machine: "resource_a".to_string(),
|
|
||||||
actor: "actor_123".to_string(),
|
|
||||||
}];
|
|
||||||
|
|
||||||
let mut initiator_connections_vec: Vec<InitiatorConnectionConfig> =
|
|
||||||
vec![InitiatorConnectionConfig {
|
|
||||||
machine: "resource_a".to_string(),
|
|
||||||
initiator: "initiator_123".to_string(),
|
|
||||||
}];
|
|
||||||
|
|
||||||
roles.insert(
|
roles.insert(
|
||||||
"admin".to_string(),
|
"admin".to_string(),
|
||||||
Role {
|
Role {
|
||||||
@ -256,7 +223,7 @@ impl Default for Config {
|
|||||||
"initiator_123".to_string(),
|
"initiator_123".to_string(),
|
||||||
ModuleConfig {
|
ModuleConfig {
|
||||||
module: "Process".to_string(),
|
module: "Process".to_string(),
|
||||||
params: initiator_123_params,
|
params: HashMap::new(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -281,9 +248,9 @@ impl Default for Config {
|
|||||||
roles,
|
roles,
|
||||||
machines,
|
machines,
|
||||||
actors,
|
actors,
|
||||||
actor_connections: actor_connections_vec,
|
actor_connections: vec!(("actor".to_string(), "actor_123".to_string()), ("machine".to_string(),"resource_a".to_string())).into_iter().collect(),
|
||||||
initiators,
|
initiators,
|
||||||
init_connections: initiator_connections_vec,
|
init_connections: vec!(("initiator".to_string(), "initiator_123".to_string()), ("machine".to_string(),"resource_b".to_string())).into_iter().collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,16 +103,12 @@ pub fn load(
|
|||||||
let span = tracing::info_span!("loading initiators");
|
let span = tracing::info_span!("loading initiators");
|
||||||
let _guard = span.enter();
|
let _guard = span.enter();
|
||||||
|
|
||||||
let mut init_connections_data_vec: Vec<(String, String)> = vec![];
|
let mut initiator_map: HashMap<String, Resource> = config
|
||||||
for init_connection in config.init_connections.clone().into_iter() {
|
.init_connections
|
||||||
init_connections_data_vec.push((init_connection.machine, init_connection.initiator));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut initiator_map: HashMap<String, Resource> = init_connections_data_vec
|
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(k, v)| {
|
.filter_map(|(k, v)| {
|
||||||
if let Some(resource) = resources.get_by_id(k) {
|
if let Some(resource) = resources.get_by_id(v) {
|
||||||
Some((v.clone(), resource.clone()))
|
Some((k.clone(), resource.clone()))
|
||||||
} else {
|
} else {
|
||||||
tracing::error!(initiator=%k, machine=%v,
|
tracing::error!(initiator=%k, machine=%v,
|
||||||
"Machine configured for initiator not found!");
|
"Machine configured for initiator not found!");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user