Browse Source

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>
Eric MacDonald 2 months ago
parent
commit
7e8be89143
2 changed files with 62 additions and 85 deletions
  1. 1
    1
      mtce-common/centos/build_srpm.data
  2. 61
    84
      mtce-common/src/daemon/daemon_files.cpp

+ 1
- 1
mtce-common/centos/build_srpm.data View File

@@ -1,3 +1,3 @@
1 1
 SRC_DIR="src"
2
-TIS_PATCH_VER=142
2
+TIS_PATCH_VER=143
3 3
 BUILD_IS_SLOW=5

+ 61
- 84
mtce-common/src/daemon/daemon_files.cpp View File

@@ -339,103 +339,91 @@ string daemon_mgmnt_iface ( void )
339 339
  *
340 340
  * Name       : daemon_system_type
341 341
  *
342
- * Description: Read the platform.conf file looking for system type system_mode label.
343
- *              If found then load and return that content.
344
- *              if not found then return an empty string.
342
+ * Purpose    : Learn the system type
345 343
  *
346
- * Assumptions: Caller is expected to interpret the data.
347
- *
348
- * At time of writing the valid CPE Modes were
349
- *
350
- *  - simplex - All In One Controller/Compute               (one unit )
351
- *  - duplex  - Fully redundant Combined Controller/Compute (two units)
344
+ * Description: Read the platform.conf file looking for system type.
345
+ *              If type is not Standard then refine the system type to
346
+ *              one of the AIO variations.
352 347
  *
353 348
  *****************************************************************************/
354 349
 
355 350
 #define SYSTEM_TYPE_PREFIX ((const char *)("System Type :"))
356 351
 system_type_enum daemon_system_type ( void )
357 352
 {
358
-    bool system_type_found = false ;
359
-    bool system_mode_found = false ;
360
-    bool cpe_system        = false ;
361
-
362
-    system_type_enum system_type = SYSTEM_TYPE__NORMAL ;
363
-
353
+    char buffer  [BUFFER];
354
+    system_type_enum system_type = SYSTEM_TYPE__CPE_MODE__SIMPLEX ;
364 355
     FILE * cfg_file_stream = fopen ( PLATFORM_CONF_FILE, "r" );
365 356
     if ( cfg_file_stream != NULL )
366 357
     {
367
-        char   buffer  [BUFFER];
368
-        int    line  = 0       ;
369 358
         MEMSET_ZERO(buffer);
370 359
         while ( fgets (buffer, BUFFER, cfg_file_stream) != NULL )
371 360
         {
372
-            char   mode_str[BUFFER];
373
-            MEMSET_ZERO(mode_str);
374 361
             if ( strstr ( buffer, "system_type") != NULL )
375 362
             {
376
-                int rc = sscanf ( &buffer[0], "system_type=%1023s",  &mode_str[0] );
377
-                if ( rc == 1 )
363
+                char   type_str[BUFFER];
364
+                MEMSET_ZERO(type_str);
365
+                if ( sscanf ( &buffer[0], "system_type=%1023s",  &type_str[0] ) == 1 )
378 366
                 {
379
-                    string mode = mode_str ;
380
-
381
-                    if ( !mode.empty() )
367
+                    string type_string = type_str ;
368
+                    if ( !type_string.empty() && ( type_string == "Standard"))
382 369
                     {
383
-                        if (( mode == "CPE" ) || ( mode == "All-in-one"))
384
-                        {
385
-                            cpe_system = true ;
386
-                        }
387
-                        system_type_found = true ;
370
+                        system_type = SYSTEM_TYPE__NORMAL ;
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] );
394
-                if ( rc == 1 )
396
+                if ( strstr ( buffer, "system_mode") != NULL )
395 397
                 {
396
-                    string mode = mode_str ;
397
-
398
-                    if ( !mode.empty() )
398
+                    char mode_str[BUFFER];
399
+                    MEMSET_ZERO(mode_str);
400
+                    if ( sscanf ( &buffer[0], "system_mode=%1023s",  &mode_str[0] ) == 1 )
399 401
                     {
400
-                        if ( mode.compare("duplex") == 0 )
401
-                        {
402
-                            system_mode_found = true ;
403
-                            system_type = SYSTEM_TYPE__CPE_MODE__DUPLEX ;
404
-                        }
405
-                        else if ( mode.compare("duplex-direct") == 0 )
402
+                        string mode = mode_str ;
403
+                        if ( !mode.empty() )
406 404
                         {
407
-                            system_mode_found = true ;
408
-                            system_type = SYSTEM_TYPE__CPE_MODE__DUPLEX_DIRECT ;
409
-                        }
410
-                        else if ( mode.compare("simplex") == 0 )
411
-                        {
412
-                            system_mode_found = true ;
413
-                            system_type = SYSTEM_TYPE__CPE_MODE__SIMPLEX ;
405
+                            if ( mode.compare("duplex") == 0 )
406
+                                system_type = SYSTEM_TYPE__CPE_MODE__DUPLEX ;
407
+                            else if ( mode.compare("duplex-direct") == 0 )
408
+                                system_type = SYSTEM_TYPE__CPE_MODE__DUPLEX_DIRECT ;
409
+                            else if ( mode.compare("simplex") == 0 )
410
+                                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 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 420
                             wlog ("... %s\n", buffer );
419 421
                         }
420 422
                     }
421
-                    else
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 );
423
+                    break ;
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 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 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 446
             break ;
466 447
         }
467 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 451
             break ;
471 452
         }
472 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 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 458
             break ;
482 459
         }
483 460
     }

Loading…
Cancel
Save