forked from DGNum/colmena
apply_local: Don't bother evaluating other hosts
This commit is contained in:
parent
e9487ced9e
commit
b44dd1f877
2 changed files with 11 additions and 5 deletions
|
@ -98,11 +98,8 @@ pub async fn run(_global_args: &ArgMatches<'_>, local_args: &ArgMatches<'_>) {
|
|||
};
|
||||
let goal = Goal::from_str(local_args.value_of("goal").unwrap()).unwrap();
|
||||
|
||||
log::info!("Enumerating nodes...");
|
||||
let all_nodes = hive.deployment_info().await.unwrap();
|
||||
|
||||
let target: Target = {
|
||||
if let Some(info) = all_nodes.get(&hostname) {
|
||||
if let Some(info) = hive.deployment_info_for(&hostname).await.unwrap() {
|
||||
if !info.allows_local_deployment() {
|
||||
log::error!("Local deployment is not enabled for host {}.", hostname);
|
||||
log::error!("Hint: Set deployment.allowLocalDeployment to true.");
|
||||
|
|
|
@ -46,7 +46,7 @@ impl Hive {
|
|||
&self.hive
|
||||
}
|
||||
|
||||
/// Retrieve deployment info for all nodes
|
||||
/// Retrieve deployment info for all nodes.
|
||||
pub async fn deployment_info(&self) -> NixResult<HashMap<String, NodeConfig>> {
|
||||
// FIXME: Really ugly :(
|
||||
let s: String = self.nix_instantiate("hive.deploymentConfigJson").eval()
|
||||
|
@ -62,6 +62,15 @@ impl Hive {
|
|||
Ok(configs)
|
||||
}
|
||||
|
||||
/// Retrieve deployment info for a single node.
|
||||
pub async fn deployment_info_for(&self, node: &str) -> NixResult<Option<NodeConfig>> {
|
||||
let expr = format!("toJSON (hive.nodes.\"{}\".config.deployment or null)", node);
|
||||
let s: String = self.nix_instantiate(&expr).eval()
|
||||
.capture_json().await?;
|
||||
|
||||
Ok(serde_json::from_str(&s).unwrap())
|
||||
}
|
||||
|
||||
/// Evaluates selected nodes.
|
||||
///
|
||||
/// Evaluation may take up a lot of memory, so we make it possible
|
||||
|
|
Loading…
Reference in a new issue