Print this page
7711 SMF: Finish implementing support for degraded state

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/svc/svcadm/svcadm.c
          +++ new/usr/src/cmd/svc/svcadm/svcadm.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26   26  /*
  27   27   * Copyright 2015, Joyent, Inc. All rights reserved.
       28 + * Copyright 2017 RackTop Systems.
  28   29   */
  29   30  
  30   31  /*
  31   32   * svcadm - request adminstrative actions for service instances
  32   33   */
  33   34  
  34   35  #include <locale.h>
  35   36  #include <libintl.h>
  36   37  #include <libscf.h>
  37   38  #include <libscf_priv.h>
↓ open down ↓ 1886 lines elided ↑ open up ↑
1924 1925  
1925 1926          if (svcsearch && strcmp(state, svcstate) != 0)
1926 1927                  return (0);
1927 1928  
1928 1929          if (strcmp(state, SCF_STATE_STRING_ONLINE) != 0) {
1929 1930                  uu_warn(gettext("Instance \"%s\" is not online.\n"), wip->fmri);
1930 1931                  exit_status = 1;
1931 1932                  return (0);
1932 1933          }
1933 1934  
     1935 +        if ((flags & MARK_TEMPORARY) == 0) {
     1936 +                uu_warn(gettext("Instance \"%s\" cannot be degraded "
     1937 +                    "permantently.\n"), wip->fmri);
     1938 +                exit_status = 1;
     1939 +                return (0);
     1940 +        }
     1941 +
1934 1942          set_inst_action(wip->fmri, wip->inst, (flags & MARK_IMMEDIATE) ?
1935 1943              SCF_PROPERTY_DEGRADE_IMMEDIATE : SCF_PROPERTY_DEGRADED);
1936 1944  
1937 1945          return (0);
1938 1946  }
1939 1947  
1940 1948  static int
1941 1949  force_maintenance(void *data, scf_walkinfo_t *wip)
1942 1950  {
1943 1951          int flags = (int)data;
↓ open down ↓ 556 lines elided ↑ open up ↑
2500 2508                          else {
2501 2509                                  assert(0);
2502 2510                                  abort();
2503 2511                          }
2504 2512                  }
2505 2513  
2506 2514                  if (argc - optind < 2)
2507 2515                          usage();
2508 2516  
2509 2517                  if (strcmp(argv[optind], "degraded") == 0) {
2510      -                        if (flags & MARK_TEMPORARY)
2511      -                                uu_xdie(UU_EXIT_USAGE, gettext("-t may not be "
2512      -                                    "used with degraded.\n"));
2513 2518                          callback = force_degraded;
2514      -
2515 2519                  } else if (strcmp(argv[optind], "maintenance") == 0) {
2516 2520                          callback = force_maintenance;
2517 2521                  } else {
2518 2522                          usage();
2519 2523                  }
2520 2524  
2521 2525                  optind++;
2522 2526                  argc -= optind;
2523 2527                  argv += optind;
2524 2528  
2525 2529                  if (argc == 0 && !svcsearch)
2526 2530                          usage();
2527 2531  
2528 2532                  if (argc > 0 && svcsearch)
2529 2533                          usage();
2530 2534  
2531 2535                  if ((err = scf_walk_fmri(h, argc, argv, WALK_FLAGS, callback,
2532      -                    NULL, &exit_status, pr_warn)) != 0) {
     2536 +                    (void *)flags, &exit_status, pr_warn)) != 0) {
2533 2537                          pr_warn(gettext("failed to iterate over "
2534 2538                              "instances: %s\n"),
2535 2539                              scf_strerror(err));
2536 2540                          exit_status = UU_EXIT_FATAL;
2537 2541                  }
2538 2542  
2539 2543          } else if (strcmp(argv[optind], "clear") == 0) {
2540 2544                  ++optind;
2541 2545                  argc -= optind;
2542 2546                  argv += optind;
↓ open down ↓ 142 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX