def get_expression(user_input=False, op=">"):
    if since_date_or_version(date="2015-04-30", version="5.4.0.0.25"):
        expression = "fill_count(Host / Node.VMs, %s" % op
    else:
        expression = "fill_count(Host.VMs, %s" % op
    if user_input:
        return expression + ")"
    else:
        return expression + ", %d)"
Esempio n. 2
0
def random_host_condition():
    if since_date_or_version(date="2015-04-30"):  # TODO: Add version when in DS build
        expression = "fill_count(Host / Node.Files, >, 150)"
    else:
        expression = "fill_count(Host.Files, >, 150)"
    cond = explorer.HostCondition(
        fauxfactory.gen_alphanumeric(),
        expression=expression,
    )
    cond.create()
    yield cond
    cond.delete()
def test_custom_vm_report(soft_assert, report_vms):
    if since_date_or_version(version="5.4.0.0.25"):
        cluster = "Cluster / Deployment Role Name"
        host = "Host / Node Name"
    else:
        cluster = "Cluster Name"
        host = "Host Name"
    for row in report_vms:
        if row["Name"].startswith("test_"):
            continue  # Might disappear meanwhile
        provider_name = row[version.pick({
            version.LOWEST:
            "Provider : Name",
            "5.3":
            "Cloud/Infrastructure Provider Name",
        })]
        provider = get_mgmt_by_name(provider_name)
        provider_hosts_and_ips = utils.net.resolve_ips(provider.list_host())
        provider_datastores = provider.list_datastore()
        provider_clusters = provider.list_cluster()
        soft_assert(
            provider.does_vm_exist(row["Name"]),
            "VM {} does not exist in {}!".format(row["Name"], provider_name))
        if row[cluster]:
            soft_assert(
                row[cluster] in provider_clusters,
                "Cluster {} not found in {}!".format(row[cluster],
                                                     str(provider_clusters)))
        if row["Datastore Name"]:
            soft_assert(
                row["Datastore Name"] in provider_datastores,
                "Datastore {} not found in {}!".format(
                    row["Datastore Name"], str(provider_datastores)))
        # Because of mixing long and short host names, we have to use both-directional `in` op.
        if row[host]:
            found = False
            possible_ips_or_hosts = utils.net.resolve_ips((row[host], ))
            for possible_ip_or_host in possible_ips_or_hosts:
                for host_ip in provider_hosts_and_ips:
                    if possible_ip_or_host in host_ip or host_ip in possible_ip_or_host:
                        found = True
            soft_assert(
                found,
                "Host {} not found in {}!".format(possible_ips_or_hosts,
                                                  provider_hosts_and_ips))
def test_custom_vm_report(soft_assert, report_vms):
    if since_date_or_version(version="5.4.0.0.25"):
        cluster = "Cluster / Deployment Role Name"
        host = "Host / Node Name"
    else:
        cluster = "Cluster Name"
        host = "Host Name"
    for row in report_vms:
        if row["Name"].startswith("test_"):
            continue  # Might disappear meanwhile
        provider_name = row[version.pick({
            version.LOWEST: "Provider : Name",
            "5.3": "Cloud/Infrastructure Provider Name",
        })]
        provider = get_mgmt_by_name(provider_name)
        provider_hosts_and_ips = utils.net.resolve_ips(provider.list_host())
        provider_datastores = provider.list_datastore()
        provider_clusters = provider.list_cluster()
        soft_assert(provider.does_vm_exist(row["Name"]), "VM {} does not exist in {}!".format(
            row["Name"], provider_name
        ))
        if row[cluster]:
            soft_assert(
                row[cluster] in provider_clusters,
                "Cluster {} not found in {}!".format(row[cluster], str(provider_clusters))
            )
        if row["Datastore Name"]:
            soft_assert(
                row["Datastore Name"] in provider_datastores,
                "Datastore {} not found in {}!".format(
                    row["Datastore Name"], str(provider_datastores))
            )
        # Because of mixing long and short host names, we have to use both-directional `in` op.
        if row[host]:
            found = False
            possible_ips_or_hosts = utils.net.resolve_ips((row[host], ))
            for possible_ip_or_host in possible_ips_or_hosts:
                for host_ip in provider_hosts_and_ips:
                    if possible_ip_or_host in host_ip or host_ip in possible_ip_or_host:
                        found = True
            soft_assert(
                found,
                "Host {} not found in {}!".format(possible_ips_or_hosts, provider_hosts_and_ips)
            )
Esempio n. 5
0
def test_host_condition_crud(soft_assert):
    if since_date_or_version(date="2015-04-30"):  # TODO: Add version when in DS build
        expression = "fill_count(Host / Node.Files, >, 150)"
    else:
        expression = "fill_count(Host.Files, >, 150)"
    condition = explorer.HostCondition(
        fauxfactory.gen_alphanumeric(),
        expression=expression
    )
    # CR
    condition.create()
    soft_assert(condition.exists, "The condition {} does not exist!".format(
        condition.description
    ))
    # U
    with update(condition):
        condition.notes = "Modified!"
    sel.force_navigate("host_condition_edit", context={"condition_name": condition.description})
    soft_assert(sel.text(condition.form.notes).strip() == "Modified!", "Modification failed!")
    # D
    condition.delete()
    soft_assert(not condition.exists, "The condition {} exists!".format(
        condition.description
    ))