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 choose_vmss_at_random(filter, configuration, secrets): vmss = fetch_resources(filter, RES_TYPE_VMSS, secrets, configuration) if not vmss: logger.warning("No virtual machine scale sets found") raise FailedActivity("No virtual machine scale sets found") else: logger.debug("Found virtual machine scale sets: {}".format( [x['name'] for x in vmss])) return random.choice(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 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 count_instances(filter: str = None, configuration: Configuration = None, secrets: Secrets = None) -> int: """ Return count of VMSS instances. Parameters ---------- filter : str Filter the VMSS instance. 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( "Starting count_instances: configuration='{}', filter='{}'".format( configuration, filter)) instances = fetch_resources(filter, RES_TYPE_VMSS, secrets, configuration) return len(instances)
def describe_machines(filter: str = None, configuration: Configuration = None, secrets: Secrets = None): """ Describe 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 describe_machines: configuration='{}', filter='{}'".format( configuration, filter)) machines = fetch_resources(filter, RES_TYPE_VM, secrets, configuration) return machines
def count_webapps(filter: str = None, configuration: Configuration = None, secrets: Secrets = None) -> int: """ Return count of 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 count_machines: configuration='{}', filter='{}'".format( configuration, filter)) webapps = fetch_resources(filter, RES_TYPE_WEBAPP, secrets, configuration) return len(webapps)