"cps": find_cps, "version": find_version, "workloads": find_workload, "alerts": find_alert } execfunc = metricmap.get(arg, lambda: print("Invalid Attribute")) execfunc(args.operator, args.value) configuration = configuration.Configuration(psm_config_path=HOME + "/.psm/config.json", interactive_mode=True) configuration.verify_ssl = False # These create the instances of the API, for ease of access in the functions client = api_client.ApiClient(configuration) api_instance = ClusterV1Api(client) response = api_instance.list_distributed_service_card() telemetry_instance = TelemetryQueryV1Api(client) workload_instance = WorkloadV1Api(client) network_instance = NetworkV1Api(client) search_instance = SearchV1Api(client) # This function will list the DSC's whose connections per second meet the operator and value passed in by the user def find_cps(oper, val): print("List of DSC's that meet query:") for dsc in response.items: query_response = telemetry_instance.post_metrics( { "queries": [{
import pensando_lib from pensando_lib.psm import configuration, api_client from pensando_lib.psm.apis import WorkloadV1Api from workload_utils import getDscFromWorkload import warnings warnings.simplefilter("ignore") HOME = os.environ['HOME'] cfg = configuration.Configuration(psm_config_path=HOME + "/.psm/config.json", interactive_mode=True) cfg.verify_ssl = False client = api_client.ApiClient(cfg) workload_instance = WorkloadV1Api(client) workload_response = workload_instance.list_workload("default") #an existing workload try: print( getDscFromWorkload(client, "default", workload_response.items[0]["meta"]["name"], workload_instance)) except IndexError: print("No workloads found. Skipping test case") #an invalid workload name name = "invalidworkloadname"
from pensando_lib.psm.model.tech_support_request_spec_node_selector_spec import TechSupportRequestSpecNodeSelectorSpec from utils.workload_utils import getDscFromWorkload from utils.filesystem_utils import saveBinary import warnings warnings.simplefilter("ignore") HOME = os.environ['HOME'] config = configuration.Configuration(psm_config_path=HOME + "/.psm/config.json", interactive_mode=True) config.verify_ssl = False client = api_client.ApiClient(config) monitoring_instance = MonitoringV1Api(client) cluster_instance = ClusterV1Api(client) objstore_instance = ObjstoreV1Api(client) parser = argparse.ArgumentParser() parser.add_argument("-w", "--workloads", dest="workloads", metavar='', required=True, help='name or UUIDs of Workloads') parser.add_argument("-d", "--dir", dest="dir", metavar='',