예제 #1
0
파일: reset.py 프로젝트: ubuntu/microk8s
def disable_addons(destroy_storage):
    """
    Iterate over all addons and disable the enabled ones.
    """
    print("Disabling all addons")

    available_addons_info = get_available_addons(get_current_arch())
    enabled, disabled = get_status(available_addons_info, True)
    for addon in available_addons_info:
        # Do not disable HA
        if addon["name"] == "ha-cluster":
            continue

        # Do not disable the community repository
        if addon["name"] == "community":
            continue

        print(f"Disabling addon : {addon['repository']}/{addon['name']}")
        # Do not disable disabled addons
        if addon in disabled:
            continue

        if (addon["name"] == "hostpath-storage" or addon["name"] == "storage") and destroy_storage:
            disable_addon(addon["repository"], f"{addon['name']}", ["destroy-storage"])
        else:
            disable_addon(addon["repository"], addon["name"])
    print("All addons are disabled.")
예제 #2
0
def test_get_available_addons(snap_common_mock, listdir_mock, strict_mock,
                              confinement, result):
    strict_mock.return_value = confinement
    listdir_mock.return_value = ["/a/path/"]
    snap_common_mock.return_value = Path("/common_dir")

    with patch("common.utils.open", mock_open(read_data=REPO_YAML)):
        addons = get_available_addons("amd64")
        assert len(addons) == len(result)
        for addon in addons:
            assert addon["name"] in result
예제 #3
0
        "--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)
        else:
            if yaml_short: