def get_vm_region()

in src/local_gpu_verifier/src/verifier/config.py [0:0]


    def get_vm_region(cls):
        if not cls.AZURE_VM_REGION:
            # Fetch the VM region from IMDS
            try:
                headers = {"Metadata": "true"}
                response = requests.get(cls.AZURE_IMDS_URL, headers=headers)
                if response.status_code == 200:
                    data = json.loads(response.text)
                    cls.AZURE_VM_REGION = data.get("compute", {}).get("location", "")
                    event_log.debug("VM region is " + cls.AZURE_VM_REGION)
            except Exception as e:
                event_log.error("IMDS exception: " + str(e))

            # If the VM region is still not fetched, set it to lab
            if not cls.AZURE_VM_REGION:
                event_log.error("Unable to fetch the VM region")
                cls.AZURE_VM_REGION = "lab"