Exemple #1
0
    parser.add_argument("-a", "--addon", help="check the status of an addon.", default="all")
    parser.add_argument(
        "--yaml", action='store_true', help="DEPRECATED, use '--format yaml' instead"
    )

    # read arguments from the command line
    args = parser.parse_args()

    wait_ready = args.wait_ready
    timeout = args.timeout
    yaml_short = args.yaml

    if wait_ready:
        isReady = wait_for_ready(wait_ready, timeout)
    else:
        isReady = is_cluster_ready()

    available_addons = get_available_addons(get_current_arch())

    if args.addon != "all":
        available_addons = get_addon_by_name(available_addons, args.addon)

    enabled, disabled = get_status(available_addons, isReady)

    if args.addon != "all":
        print_addon_status(enabled)
    else:
        if args.format == "yaml":
            print_yaml(isReady, enabled, disabled)
        elif args.format == "short":
            print_short(isReady, enabled, disabled)
if __name__ == '__main__':
    while True:
        # Check for changes every 10 seconds
        sleep(10)
        try:

            if microk8s_group_exists():
                set_dqlite_file_permissions()

            # We will not attempt to stop services if:
            # 1. The cluster is not ready
            # 2. We are not on an HA cluster
            # 3. The control plane kicker is disabled
            # 4. dqlite has less than 4 nodes
            if (
                not is_cluster_ready()
                or not is_ha_enabled()
                or not is_service_expected_to_start('control-plane-kicker')
            ):
                start_control_plane_services()
                continue

            info = get_dqlite_info()
            if len(info) <= 3:
                start_control_plane_services()
                continue

            local_ips = []
            for interface in netifaces.interfaces():
                if netifaces.AF_INET not in netifaces.ifaddresses(interface):
                    continue
if __name__ == '__main__':
    while True:
        # Check for changes every 10 seconds
        sleep(10)
        try:

            if microk8s_group_exists() and is_ha_enabled():
                set_dqlite_file_permissions()

            # We will not attempt to stop services if:
            # 1. The cluster is not ready
            # 2. We are not on an HA cluster
            # 3. The control plane kicker is disabled
            # 4. dqlite has less than 4 nodes
            if (not is_cluster_ready() or not is_ha_enabled() or
                    not is_service_expected_to_start('control-plane-kicker')):
                start_control_plane_services()
                continue

            info = get_dqlite_info()
            if len(info) <= 3:
                start_control_plane_services()
                continue

            local_ips = []
            for interface in netifaces.interfaces():
                if netifaces.AF_INET not in netifaces.ifaddresses(interface):
                    continue
                for link in netifaces.ifaddresses(interface)[
                        netifaces.AF_INET]: