@@ -778,43 +778,35 @@ async fn add_agent(
778778 }
779779 ) ;
780780
781- // Determine agent connection details (needed for pull model)
782- let ( agent_ip, agent_port) = if !is_push_model {
783- // Pull model: need agent IP/port for direct communication
784- let agent_ip = params
785- . ip
786- . map ( |s| s. to_string ( ) )
787- . or_else ( || {
788- agent_data
789- . get ( "ip" )
790- . and_then ( |v| v. as_str ( ) . map ( |s| s. to_string ( ) ) )
791- } )
792- . ok_or_else ( || {
793- CommandError :: invalid_parameter (
794- "ip" ,
795- "Agent IP address is required for pull model (use --push-model to skip)" . to_string ( ) ,
796- )
797- } ) ?;
798-
799- let agent_port = params
800- . port
801- . or_else ( || {
802- agent_data
803- . get ( "port" )
804- . and_then ( |v| v. as_u64 ( ) . map ( |n| n as u16 ) )
805- } )
806- . ok_or_else ( || {
807- CommandError :: invalid_parameter (
808- "port" ,
809- "Agent port is required for pull model (use --push-model to skip)" . to_string ( ) ,
810- )
811- } ) ?;
781+ // Determine agent connection details
782+ let agent_ip = params
783+ . ip
784+ . map ( |s| s. to_string ( ) )
785+ . or_else ( || {
786+ agent_data
787+ . get ( "ip" )
788+ . and_then ( |v| v. as_str ( ) . map ( |s| s. to_string ( ) ) )
789+ } )
790+ . ok_or_else ( || {
791+ CommandError :: invalid_parameter (
792+ "ip" ,
793+ "Agent IP address is required" . to_string ( ) ,
794+ )
795+ } ) ?;
812796
813- ( agent_ip, agent_port)
814- } else {
815- // Push model: agent will connect to verifier, so use placeholder values
816- ( "localhost" . to_string ( ) , 9002 )
817- } ;
797+ let agent_port = params
798+ . port
799+ . or_else ( || {
800+ agent_data
801+ . get ( "port" )
802+ . and_then ( |v| v. as_u64 ( ) . map ( |n| n as u16 ) )
803+ } )
804+ . ok_or_else ( || {
805+ CommandError :: invalid_parameter (
806+ "port" ,
807+ "Agent port is required" . to_string ( ) ,
808+ )
809+ } ) ?;
818810
819811 // Step 3: Perform attestation for pull model
820812 let attestation_result = if !is_push_model {
@@ -863,6 +855,8 @@ async fn add_agent(
863855 & agent_data,
864856 params. runtime_policy ,
865857 params. mb_policy ,
858+ & agent_ip,
859+ agent_port,
866860 ) ?
867861 } else {
868862 // API 2.x: Full enrollment with direct agent communication
@@ -2292,11 +2286,15 @@ fn build_push_model_request(
22922286 agent_data : & Value ,
22932287 runtime_policy : Option < & str > ,
22942288 mb_policy : Option < & str > ,
2289+ cloudagent_ip : & str ,
2290+ cloudagent_port : u16 ,
22952291) -> Result < Value , CommandError > {
22962292 debug ! ( "Building push model enrollment request for agent {agent_id}" ) ;
22972293
22982294 let mut request = json ! ( {
22992295 "agent_id" : agent_id,
2296+ "cloudagent_ip" : cloudagent_ip,
2297+ "cloudagent_port" : cloudagent_port,
23002298 "tpm_policy" : tpm_policy,
23012299 "accept_attestations" : true ,
23022300 "ak_tpm" : agent_data. get( "aik_tpm" ) ,
0 commit comments