feat: add app-node inspect
This commit is contained in:
		
							parent
							
								
									bf8a4f3a8b
								
							
						
					
					
						commit
						4bd6b48877
					
				| @ -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") | ||||
|  | ||||
| @ -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::<String>("ip").unwrap().clone(); | ||||
|             cli_print(sgx::inspect_node(ip).map_err(Into::into)); | ||||
|         } | ||||
|         Some(("report", _)) => { | ||||
|             // let node_pubkey: String = path_subcommand.get_one::<String>("pubkey").unwrap().clone();
 | ||||
|             // let contract_uuid: String = path_subcommand.get_one::<String>("contract").unwrap().clone();
 | ||||
|  | ||||
| @ -24,6 +24,18 @@ pub enum Error { | ||||
| 
 | ||||
| type Result<T> = std::result::Result<T, Error>; | ||||
| 
 | ||||
| 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<NewAppRes> { | ||||
|     let resource = app_deploy_config.clone().resource; | ||||
|     let mut req: NewAppReq = app_deploy_config.clone().into(); | ||||
|  | ||||
| @ -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<AppNodeListResp, grpc_brain::Error> { | ||||
|     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<AppNodeListResp> { | ||||
| pub fn print_nodes() -> Result<Vec<AppNodeListResp>, 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)) | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user