Beispiel #1
0
def __fetch_machines(filter, configuration, secrets) -> []:
    machines = fetch_resources(filter, RES_TYPE_VM, secrets, configuration)
    if not machines:
        logger.warning("No virtual machines found")
        raise FailedActivity("No virtual machines found")
    else:
        logger.debug("Fetched virtual machines: {}".format(
            [x['name'] for x in machines]))
    return machines
def fetch_webapps(filter, configuration, secrets):
    webapps = fetch_resources(filter, RES_TYPE_WEBAPP, secrets, configuration)
    if not webapps:
        logger.warning("No web apps found")
        raise FailedActivity("No web apps found")
    else:
        logger.debug("Fetched web apps: {}".format(
            [x['name'] for x in webapps]))
    return webapps
def fetch_vmss(filter, configuration, secrets) -> List[dict]:
    vmss = fetch_resources(filter, RES_TYPE_VMSS, secrets, configuration)

    if not vmss:
        raise FailedActivity("No VMSS found")

    else:
        logger.debug("Fetched VMSS: {}".format([set['name'] for set in vmss]))

    return vmss
def node_resource_group_query(query, configuration, secrets):
    aks = fetch_resources(query, RES_TYPE_AKS, secrets, configuration)
    if not aks:
        logger.warning("No AKS clusters found")
        raise FailedActivity("No AKS clusters found")
    else:
        logger.debug(
            "Found AKS clusters: {}".format(
                [x['name'] for x in aks]))
    choice = random.choice(aks)
    node_resource_group = choice['properties']['nodeResourceGroup']
    return "where resourceGroup =~ '{}'".format(node_resource_group)
def count_machines(filter: str = None,
                   configuration: Configuration = None,
                   secrets: Secrets = None) -> int:
    """
    Return count of Azure virtual machines.

    Parameters
    ----------
    filter : str
        Filter the virtual machines. If the filter is omitted all machines in
        the subscription will be selected for the probe.
        Filtering example:
        'where resourceGroup=="myresourcegroup" and name="myresourcename"'
    """
    logger.debug(
        "Start count_machines: configuration='{}', filter='{}'".format(
            configuration, filter))

    machines = fetch_resources(filter, RES_TYPE_VM, secrets, configuration)
    return len(machines)
def describe_webapps(filter: str = None,
                     configuration: Configuration = None,
                     secrets: Secrets = None):
    """
    Describe Azure web apps.

    Parameters
    ----------
    filter : str
        Filter the web apps. If the filter is omitted all web apps in
        the subscription will be selected for the probe.
        Filtering example:
        'where resourceGroup=="myresourcegroup" and name="myresourcename"'
    """
    logger.debug(
        "Start describe_webapps: configuration='{}', filter='{}'".format(
            configuration, filter))

    webapps = fetch_resources(filter, RES_TYPE_WEBAPP, secrets, configuration)
    return webapps