Exemplo n.º 1
0
def profile_show(detailed):
    profiles = client.get_profile_names()

    if detailed:
        x = PrettyTable([
            "Name", "Host", "Orchestrator ID", "Workload ID", "Endpoint ID",
            "State"
        ])
        for name in profiles:
            members = client.get_profile_members(name)
            if not members:
                x.add_row([name, "None", "None", "None", "None", "None"])
                continue

            for endpoint in members:
                x.add_row([
                    name, endpoint.hostname, endpoint.orchestrator_id,
                    endpoint.workload_id, endpoint.endpoint_id, endpoint.state
                ])
    else:
        x = PrettyTable(["Name"])
        for name in profiles:
            x.add_row([name])

    print x.get_string(sortby="Name")
Exemplo n.º 2
0
def profile_show(detailed):
    profiles = client.get_profile_names()

    if detailed:
        x = PrettyTable(["Name", "Host", "Orchestrator ID", "Workload ID", "Endpoint ID", "State"])
        for name in profiles:
            members = client.get_profile_members(name)
            if not members:
                x.add_row([name, "None", "None", "None", "None", "None"])
                continue

            for endpoint in members:
                x.add_row(
                    [
                        name,
                        endpoint.hostname,
                        endpoint.orchestrator_id,
                        endpoint.workload_id,
                        endpoint.endpoint_id,
                        endpoint.state,
                    ]
                )
    else:
        x = PrettyTable(["Name"])
        for name in profiles:
            x.add_row([name])

    print x.get_string(sortby="Name")
Exemplo n.º 3
0
def profile_remove(profile_name, nocheck):
    """
    Remove a profile as long as it does not contain any endpoints.
    Allow user to explicitly remove the profile if desired.
    :param profile_name: The name of the profile to remove.
    :param nocheck: Flag saying to remove profile regardless of endpoints.
    :return: None.
    """
    # Check if the profile exists.
    if client.profile_exists(profile_name):
        rm_profile = False
        # Check that the nocheck flag was used
        if nocheck:
            rm_profile = True
        else:
            # Check if the the profile has endpoints associated with it
            members = client.get_profile_members(profile_name)
            if not members:
                rm_profile = True
        # Remove the profile if criteria was met
        if rm_profile:
            client.remove_profile(profile_name)
            print "Deleted profile %s" % profile_name
        else:
            # Members must exist if this branch is reached
            print "Cannot remove profile - profile in use by endpoint(s).\n" + \
                  "Use the '--no-check' flag to remove the profile anyway."
    else:
        print "Profile %s not found." % profile_name
Exemplo n.º 4
0
def profile_remove(profile_name, nocheck):
    """
    Remove a profile as long as it does not contain any endpoints.
    Allow user to explicitly remove the profile if desired.
    :param profile_name: The name of the profile to remove.
    :param nocheck: Flag saying to remove profile regardless of endpoints.
    :return: None.
    """
    # Check if the profile exists.
    if client.profile_exists(profile_name):
        rm_profile = False
        # Check that the nocheck flag was used
        if nocheck:
            rm_profile = True
        else:
            # Check if the the profile has endpoints associated with it
            members = client.get_profile_members(profile_name)
            if not members:
                rm_profile = True
        # Remove the profile if criteria was met
        if rm_profile:
            client.remove_profile(profile_name)
            print "Deleted profile %s" % profile_name
        else:
            # Members must exist if this branch is reached
            print "Cannot remove profile - profile in use by endpoint(s).\n" + "Use the '--no-check' flag to remove the profile anyway."
    else:
        print "Profile %s not found." % profile_name