summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric MacDonald <eric.macdonald@windriver.com>2019-01-30 15:16:24 -0500
committerEric MacDonald <eric.macdonald@windriver.com>2019-02-04 14:15:40 +0000
commit7e8be891434c75889768efdf32ff0c7573f2fbb5 (patch)
tree54e258dd2e05e84a655f2d4272b1d92042deb237
parentff8ef3ea8a98e14007ee323abdb16c70b527f6de (diff)
Make Mtce default to Simplex system type if label is missing
This update refactors daemon_system_type function so that it returns a SIMPLEX system type if it is unable to properly find and parse the system_mode/system_type from platform.conf This is needed for Ansible Bootstrap Deployment where mtcAgent and mtcClient need to run and function like it would in a simplex system prior to the system type being added to the platform.conf file. Change-Id: Ib0130f3559ee3aa8d8d8203ea59d4896a571944f Story: 2004695 Task: 28714 Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
Notes
Notes (review): Code-Review+2: John Kung <john.kung@windriver.com> Code-Review+2: Don Penney <don.penney@windriver.com> Workflow+1: Don Penney <don.penney@windriver.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 04 Feb 2019 15:27:29 +0000 Reviewed-on: https://review.openstack.org/634043 Project: openstack/stx-metal Branch: refs/heads/master
-rw-r--r--mtce-common/centos/build_srpm.data2
-rwxr-xr-xmtce-common/src/daemon/daemon_files.cpp145
2 files changed, 62 insertions, 85 deletions
diff --git a/mtce-common/centos/build_srpm.data b/mtce-common/centos/build_srpm.data
index 01e786b..9e6662d 100644
--- a/mtce-common/centos/build_srpm.data
+++ b/mtce-common/centos/build_srpm.data
@@ -1,3 +1,3 @@
1SRC_DIR="src" 1SRC_DIR="src"
2TIS_PATCH_VER=142 2TIS_PATCH_VER=143
3BUILD_IS_SLOW=5 3BUILD_IS_SLOW=5
diff --git a/mtce-common/src/daemon/daemon_files.cpp b/mtce-common/src/daemon/daemon_files.cpp
index 0d6dbb3..82878b9 100755
--- a/mtce-common/src/daemon/daemon_files.cpp
+++ b/mtce-common/src/daemon/daemon_files.cpp
@@ -339,103 +339,91 @@ string daemon_mgmnt_iface ( void )
339 * 339 *
340 * Name : daemon_system_type 340 * Name : daemon_system_type
341 * 341 *
342 * Description: Read the platform.conf file looking for system type system_mode label. 342 * Purpose : Learn the system type
343 * If found then load and return that content.
344 * if not found then return an empty string.
345 * 343 *
346 * Assumptions: Caller is expected to interpret the data. 344 * Description: Read the platform.conf file looking for system type.
347 * 345 * If type is not Standard then refine the system type to
348 * At time of writing the valid CPE Modes were 346 * one of the AIO variations.
349 *
350 * - simplex - All In One Controller/Compute (one unit )
351 * - duplex - Fully redundant Combined Controller/Compute (two units)
352 * 347 *
353 *****************************************************************************/ 348 *****************************************************************************/
354 349
355#define SYSTEM_TYPE_PREFIX ((const char *)("System Type :")) 350#define SYSTEM_TYPE_PREFIX ((const char *)("System Type :"))
356system_type_enum daemon_system_type ( void ) 351system_type_enum daemon_system_type ( void )
357{ 352{
358 bool system_type_found = false ; 353 char buffer [BUFFER];
359 bool system_mode_found = false ; 354 system_type_enum system_type = SYSTEM_TYPE__CPE_MODE__SIMPLEX ;
360 bool cpe_system = false ;
361
362 system_type_enum system_type = SYSTEM_TYPE__NORMAL ;
363
364 FILE * cfg_file_stream = fopen ( PLATFORM_CONF_FILE, "r" ); 355 FILE * cfg_file_stream = fopen ( PLATFORM_CONF_FILE, "r" );
365 if ( cfg_file_stream != NULL ) 356 if ( cfg_file_stream != NULL )
366 { 357 {
367 char buffer [BUFFER];
368 int line = 0 ;
369 MEMSET_ZERO(buffer); 358 MEMSET_ZERO(buffer);
370 while ( fgets (buffer, BUFFER, cfg_file_stream) != NULL ) 359 while ( fgets (buffer, BUFFER, cfg_file_stream) != NULL )
371 { 360 {
372 char mode_str[BUFFER];
373 MEMSET_ZERO(mode_str);
374 if ( strstr ( buffer, "system_type") != NULL ) 361 if ( strstr ( buffer, "system_type") != NULL )
375 { 362 {
376 int rc = sscanf ( &buffer[0], "system_type=%1023s", &mode_str[0] ); 363 char type_str[BUFFER];
377 if ( rc == 1 ) 364 MEMSET_ZERO(type_str);
365 if ( sscanf ( &buffer[0], "system_type=%1023s", &type_str[0] ) == 1 )
378 { 366 {
379 string mode = mode_str ; 367 string type_string = type_str ;
380 368 if ( !type_string.empty() && ( type_string == "Standard"))
381 if ( !mode.empty() )
382 { 369 {
383 if (( mode == "CPE" ) || ( mode == "All-in-one")) 370 system_type = SYSTEM_TYPE__NORMAL ;
384 {
385 cpe_system = true ;
386 }
387 system_type_found = true ;
388 } 371 }
372 break ;
389 } 373 }
390 } 374 }
391 else if ( strstr ( buffer, "system_mode") != NULL ) 375 MEMSET_ZERO(buffer);
376 }
377 }
378
379 if ( cfg_file_stream )
380 {
381 /* Close the file */
382 fclose(cfg_file_stream);
383 cfg_file_stream = NULL ;
384 }
385
386 /* If system_type is updated to NORMAL then we are done.
387 * Otherwise lets see what kind of AIO system mode we are running in. */
388 if ( system_type != SYSTEM_TYPE__NORMAL )
389 {
390 cfg_file_stream = fopen ( PLATFORM_CONF_FILE, "r" );
391 if ( cfg_file_stream != NULL )
392 {
393 MEMSET_ZERO(buffer);
394 while ( fgets (buffer, BUFFER, cfg_file_stream) != NULL )
392 { 395 {
393 int rc = sscanf ( &buffer[0], "system_mode=%1023s", &mode_str[0] ); 396 if ( strstr ( buffer, "system_mode") != NULL )
394 if ( rc == 1 )
395 { 397 {
396 string mode = mode_str ; 398 char mode_str[BUFFER];
397 399 MEMSET_ZERO(mode_str);
398 if ( !mode.empty() ) 400 if ( sscanf ( &buffer[0], "system_mode=%1023s", &mode_str[0] ) == 1 )
399 { 401 {
400 if ( mode.compare("duplex") == 0 ) 402 string mode = mode_str ;
401 { 403 if ( !mode.empty() )
402 system_mode_found = true ;
403 system_type = SYSTEM_TYPE__CPE_MODE__DUPLEX ;
404 }
405 else if ( mode.compare("duplex-direct") == 0 )
406 { 404 {
407 system_mode_found = true ; 405 if ( mode.compare("duplex") == 0 )
408 system_type = SYSTEM_TYPE__CPE_MODE__DUPLEX_DIRECT ; 406 system_type = SYSTEM_TYPE__CPE_MODE__DUPLEX ;
409 } 407 else if ( mode.compare("duplex-direct") == 0 )
410 else if ( mode.compare("simplex") == 0 ) 408 system_type = SYSTEM_TYPE__CPE_MODE__DUPLEX_DIRECT ;
411 { 409 else if ( mode.compare("simplex") == 0 )
412 system_mode_found = true ; 410 system_type = SYSTEM_TYPE__CPE_MODE__SIMPLEX ;
413 system_type = SYSTEM_TYPE__CPE_MODE__SIMPLEX ; 411 else
412 {
413 elog ("%s All-In-One system type ; mode unknown\n", SYSTEM_TYPE_PREFIX );
414 wlog ("... %s\n", buffer );
415 }
414 } 416 }
415 else 417 else
416 { 418 {
417 elog ("%s CPE Undetermined\n", SYSTEM_TYPE_PREFIX ); 419 elog ("%s All-In-One system type ; mode empty\n", SYSTEM_TYPE_PREFIX );
418 wlog ("... %s\n", buffer ); 420 wlog ("... %s\n", buffer );
419 } 421 }
420 } 422 }
421 else 423 break ;
422 {
423 elog ("%s CPE Undetermined\n", SYSTEM_TYPE_PREFIX );
424 wlog ("... %s\n", buffer );
425 }
426 }
427 else
428 {
429 elog ("%s CPE Undetermined\n", SYSTEM_TYPE_PREFIX );
430 wlog ("... %s\n", buffer );
431 } 424 }
432 break ; 425 MEMSET_ZERO(buffer);
433 } 426 }
434 if (( system_type_found == true ) && ( system_mode_found == true ))
435 break ;
436
437 line++ ;
438 MEMSET_ZERO(buffer);
439 } 427 }
440 } 428 }
441 429
@@ -445,39 +433,28 @@ system_type_enum daemon_system_type ( void )
445 fclose(cfg_file_stream); 433 fclose(cfg_file_stream);
446 } 434 }
447 435
448 if (( system_type_found == true ) && ( system_mode_found == true )) 436 switch ( system_type )
449 { 437 {
450 if ( !cpe_system ) 438 case SYSTEM_TYPE__NORMAL:
451 { 439 {
452 system_type = SYSTEM_TYPE__NORMAL ; 440 ilog("%s Standard System\n", SYSTEM_TYPE_PREFIX);
441 break ;
453 } 442 }
454 }
455 else
456 {
457 system_type = SYSTEM_TYPE__NORMAL ;
458 }
459
460 switch ( system_type )
461 {
462 case SYSTEM_TYPE__CPE_MODE__DUPLEX_DIRECT: 443 case SYSTEM_TYPE__CPE_MODE__DUPLEX_DIRECT:
463 { 444 {
464 ilog ("%s Duplex Direct Connect CPE\n", SYSTEM_TYPE_PREFIX ); 445 ilog ("%s All-in-one Duplex Direct Connect\n", SYSTEM_TYPE_PREFIX );
465 break ; 446 break ;
466 } 447 }
467 case SYSTEM_TYPE__CPE_MODE__DUPLEX: 448 case SYSTEM_TYPE__CPE_MODE__DUPLEX:
468 { 449 {
469 ilog ("%s Duplex CPE\n", SYSTEM_TYPE_PREFIX ); 450 ilog ("%s All-in-one Duplex\n", SYSTEM_TYPE_PREFIX );
470 break ; 451 break ;
471 } 452 }
472 case SYSTEM_TYPE__CPE_MODE__SIMPLEX: 453 case SYSTEM_TYPE__CPE_MODE__SIMPLEX:
473 {
474 ilog ("%s Simplex CPE\n", SYSTEM_TYPE_PREFIX );
475 break ;
476 }
477 case SYSTEM_TYPE__NORMAL:
478 default: 454 default:
479 { 455 {
480 ilog("%s Large System\n", SYSTEM_TYPE_PREFIX); 456 ilog ("%s All-in-one Simplex \n", SYSTEM_TYPE_PREFIX );
457 system_type = SYSTEM_TYPE__CPE_MODE__SIMPLEX ;
481 break ; 458 break ;
482 } 459 }
483 } 460 }