5656import org .apache .cloudstack .utils .security .KeyStoreUtils ;
5757import org .apache .commons .collections .CollectionUtils ;
5858import org .apache .commons .io .FileUtils ;
59+ import org .apache .commons .lang3 .ObjectUtils ;
5960import org .apache .commons .lang3 .StringUtils ;
6061import org .apache .logging .log4j .LogManager ;
6162import org .apache .logging .log4j .Logger ;
@@ -135,6 +136,8 @@ public int value() {
135136 ServerResource serverResource ;
136137 Link link ;
137138 Long id ;
139+ String _uuid ;
140+ String _name ;
138141
139142 ScheduledExecutorService selfTaskExecutor ;
140143 ScheduledExecutorService certExecutor ;
@@ -219,9 +222,12 @@ public Agent(final IAgentShell shell, final int localAgentId, final ServerResour
219222 serverResource = resource ;
220223 link = null ;
221224 resource .setAgentControl (this );
222- final String value = this .shell .getPersistentProperty (getResourceName (), "id" );
225+ final String value = shell .getPersistentProperty (getResourceName (), "id" );
226+ _uuid = shell .getPersistentProperty (getResourceName (), "uuid" );
227+ _name = shell .getPersistentProperty (getResourceName (), "name" );
223228 id = value != null ? Long .parseLong (value ) : null ;
224- logger .info ("id is {}" , (id != null ? id : "" ));
229+ logger .info ("Initialising agent [id: {}, uuid: {}, name: {}]" , ObjectUtils .defaultIfNull (id , "" ), _uuid , _name );
230+
225231 final Map <String , Object > params = new HashMap <>();
226232 // merge with properties from command line to let resource access command line parameters
227233 for (final Map .Entry <String , Object > cmdLineProp : this .shell .getCmdLineProperties ().entrySet ()) {
@@ -238,15 +244,17 @@ public Agent(final IAgentShell shell, final int localAgentId, final ServerResour
238244 logger .info ("{} with host = {}, local id = {}" , this , host , localAgentId );
239245 }
240246
247+
241248 @ Override
242249 public String toString () {
243- return String .format ("Agent [id = %s, type = %s, zone = %s, pod = %s, workers = %d, host = %s, port = %d]" ,
244- (id != null ? String .valueOf (id ) : "new" ),
250+ return String .format ("Agent [id = %s, uuid = %s, name = %s, type = %s, zone = %s, pod = %s, workers = %d, port = %d]" ,
251+ ObjectUtils .defaultIfNull (id , "new" ),
252+ _uuid ,
253+ _name ,
245254 getResourceName (),
246255 this .shell .getZone (),
247256 this .shell .getPod (),
248257 this .shell .getWorkers (),
249- this .shell .getNextHost (),
250258 this .shell .getPort ());
251259 }
252260
@@ -406,6 +414,24 @@ public void setId(final Long id) {
406414 shell .setPersistentProperty (getResourceName (), "id" , Long .toString (id ));
407415 }
408416
417+ public String getUuid () {
418+ return _uuid ;
419+ }
420+
421+ public void setUuid (String uuid ) {
422+ this ._uuid = uuid ;
423+ shell .setPersistentProperty (getResourceName (), "uuid" , uuid );
424+ }
425+
426+ public String getName () {
427+ return _name ;
428+ }
429+
430+ public void setName (String name ) {
431+ this ._name = name ;
432+ shell .setPersistentProperty (getResourceName (), "name" , name );
433+ }
434+
409435 private void scheduleCertificateRenewalTask () {
410436 String name = "CertificateRenewalTask" ;
411437 if (certExecutor != null && !certExecutor .isShutdown ()) {
@@ -655,17 +681,21 @@ public void processStartupAnswer(final Answer answer, final Response response, f
655681 return ;
656682 }
657683
658- logger .info ("Process agent startup answer, agent id = {}" , startup .getHostId ());
684+ logger .info ("Process agent startup answer, agent [id: {}, uuid: {}, name: {}] connected to the server" ,
685+ startup .getHostId (), startup .getHostUuid (), startup .getHostName ());
659686
660687 setId (startup .getHostId ());
688+ setUuid (startup .getHostUuid ());
689+ setName (startup .getHostName ());
661690 pingInterval = startup .getPingInterval () * 1000L ; // change to ms.
662691
663692 updateLastPingResponseTime ();
664693 scheduleWatch (link , response , pingInterval , pingInterval );
665694
666695 outRequestHandler .setKeepAliveTime (2 * pingInterval , TimeUnit .MILLISECONDS );
667696
668- logger .info ("Startup Response Received: agent id = {}" , getId ());
697+ logger .info ("Startup Response Received: agent [id: {}, uuid: {}, name: {}]" ,
698+ startup .getHostId (), startup .getHostUuid (), startup .getHostName ());
669699 }
670700
671701 protected void processRequest (final Request request , final Link link ) {
@@ -921,15 +951,17 @@ public void processReadyCommand(final Command cmd) {
921951 NumbersUtil .enableHumanReadableSizes = humanReadable ;
922952 }
923953
924- logger .info ("Processing agent ready command, agent id = {}" , ready .getHostId ());
954+ logger .info ("Processing agent ready command, agent id = {}, uuid = {}, name = {} " , ready .getHostId (), ready . getHostUuid (), ready . getHostName ());
925955 if (ready .getHostId () != null ) {
926956 setId (ready .getHostId ());
957+ setUuid (ready .getHostUuid ());
958+ setName (ready .getHostName ());
927959 }
928960
929961 verifyAgentArch (ready .getArch ());
930962 processManagementServerList (ready .getMsHostList (), ready .getLbAlgorithm (), ready .getLbCheckInterval ());
931963
932- logger .info ("Ready command is processed for agent id = {} " , getId ());
964+ logger .info ("Ready command is processed for agent [id: {}, uuid: {}, name: {}] " , getId (), getUuid (), getName ());
933965 }
934966
935967 private void verifyAgentArch (String arch ) {
0 commit comments