.. versionadded:: 2015.8.5 Return a list of all static services root Enable/disable/mask unit files in the specified root directory CLI Example: .. code-block:: bash salt '*' service.get_static
(root=None)
| 560 | |
| 561 | |
| 562 | def get_static(root=None): |
| 563 | """ |
| 564 | .. versionadded:: 2015.8.5 |
| 565 | |
| 566 | Return a list of all static services |
| 567 | |
| 568 | root |
| 569 | Enable/disable/mask unit files in the specified root directory |
| 570 | |
| 571 | CLI Example: |
| 572 | |
| 573 | .. code-block:: bash |
| 574 | |
| 575 | salt '*' service.get_static |
| 576 | """ |
| 577 | ret = set() |
| 578 | # Get static systemd units. Can't use --state=static here because it's |
| 579 | # not present until systemd 216. |
| 580 | out = __salt__["cmd.run"]( |
| 581 | _systemctl_cmd("--full --no-legend --no-pager list-unit-files", root=root), |
| 582 | python_shell=False, |
| 583 | ignore_retcode=True, |
| 584 | ) |
| 585 | for line in salt.utils.itertools.split(out, "\n"): |
| 586 | try: |
| 587 | fullname, unit_state = line.strip().split()[:2] |
| 588 | except ValueError: |
| 589 | continue |
| 590 | else: |
| 591 | if unit_state != "static": |
| 592 | continue |
| 593 | try: |
| 594 | unit_name, unit_type = fullname.rsplit(".", 1) |
| 595 | except ValueError: |
| 596 | continue |
| 597 | if unit_type in VALID_UNIT_TYPES: |
| 598 | ret.add(unit_name if unit_type == "service" else fullname) |
| 599 | |
| 600 | # sysvinit services cannot be static |
| 601 | return sorted(ret) |
| 602 | |
| 603 | |
| 604 | def get_all(root=None): |
nothing calls this directly
no test coverage detected