diff --git a/src/bin/detee-cli.rs b/src/bin/detee-cli.rs index 867b953..107f728 100644 --- a/src/bin/detee-cli.rs +++ b/src/bin/detee-cli.rs @@ -269,7 +269,6 @@ fn clap_cmd() -> Command { .subcommand(Command::new("app-node") .about("info about Intel SGX servers registerd to DeTEE") .subcommand(Command::new("search").about("search nodes based on filters")) - /* .subcommand(Command::new("inspect").about("get detailed information about a node") .arg( Arg::new("ip") @@ -278,6 +277,7 @@ fn clap_cmd() -> Command { .required(true) ) ) + /* .subcommand(Command::new("report").about("report a node for poor performance") .arg( Arg::new("pubkey") diff --git a/src/sgx/cli_handler.rs b/src/sgx/cli_handler.rs index d01366a..dd1a77c 100644 --- a/src/sgx/cli_handler.rs +++ b/src/sgx/cli_handler.rs @@ -3,6 +3,7 @@ use super::utils::deploy_new_app_and_update_config; use super::{get_app_node, AppContract, AppDeployResponse}; use crate::name_generator::random_app_name; +use crate::sgx; use crate::sgx::config::{validate_yaml, DeteeCliExt}; use crate::sgx::grpc_brain::delete_app; use crate::sgx::grpc_dtpm::{attest_and_send_config, get_config_from_enclave}; @@ -28,8 +29,11 @@ pub fn handle_app(app_matche: &ArgMatches) { pub fn handle_app_nodes(matches: &ArgMatches) { match matches.subcommand() { - Some(("search", _)) => cli_print(crate::sgx::print_nodes().map_err(Into::into)), - Some(("inspect", _)) => todo!(), + Some(("search", _)) => cli_print(sgx::print_nodes().map_err(Into::into)), + Some(("inspect", subcom_args)) => { + let ip: String = subcom_args.get_one::("ip").unwrap().clone(); + cli_print(sgx::inspect_node(ip).map_err(Into::into)); + } Some(("report", _)) => { // let node_pubkey: String = path_subcommand.get_one::("pubkey").unwrap().clone(); // let contract_uuid: String = path_subcommand.get_one::("contract").unwrap().clone(); diff --git a/src/sgx/grpc_brain.rs b/src/sgx/grpc_brain.rs index 750940b..3d458c3 100644 --- a/src/sgx/grpc_brain.rs +++ b/src/sgx/grpc_brain.rs @@ -24,6 +24,18 @@ pub enum Error { type Result = std::result::Result; +impl crate::HumanOutput for AppNodeListResp { + fn human_cli_print(&self) { + println!("The pubkey of this node is {} and the IP is {}", self.node_pubkey, self.ip); + println!("It belongs to the operator {}", self.operator); + println!( + "This node is located in the city {}, within the region of {}, in {}", + self.city, self.region, self.country + ); + println!("The price multiplier for the node is {}.", self.price); + } +} + pub async fn new_app(app_deploy_config: AppDeployConfig) -> Result { let resource = app_deploy_config.clone().resource; let mut req: NewAppReq = app_deploy_config.clone().into(); diff --git a/src/sgx/mod.rs b/src/sgx/mod.rs index 63be85a..19a0f20 100644 --- a/src/sgx/mod.rs +++ b/src/sgx/mod.rs @@ -165,6 +165,11 @@ pub async fn get_app_node( get_one_app_node(app_node_filter).await } +pub fn inspect_node(ip: String) -> Result { + let req = AppNodeFilters { ip, ..Default::default() }; + block_on(get_one_app_node(req)) +} + #[derive(Tabled, Debug, Serialize, Deserialize)] pub struct TabledAppNode { #[tabled(rename = "Operator")] @@ -204,5 +209,5 @@ impl super::HumanOutput for Vec { pub fn print_nodes() -> Result, grpc_brain::Error> { log::debug!("This will support flags in the future, but we have only one node atm."); let req = AppNodeFilters { ..Default::default() }; - Ok(block_on(grpc_brain::get_app_node_list(req))?) + block_on(grpc_brain::get_app_node_list(req)) }