def Run(self, args): bios_version = None services = None if platform.system() == "Linux": bios_version = subprocess.check_output(self.BIOS_VERSION_COMMAND) elif platform.system() == "Windows": cmd = [ "%s\\System32\\sc.exe" % os.environ.get("SYSTEMROOT", r"C:\Windows"), "query" ] services = subprocess.check_output(cmd) else: # Interrogate shouldn't call this client action on OS X machines at all, # so raise. raise RuntimeError("Only linux and windows cloud vms supported.") result_list = [] instance_type = None for request in args.requests: if self.IsCloud(request, bios_version, services): instance_type = request.instance_type result_list.append(self.GetMetaData(request)) if result_list: self.SendReply( cloud.CloudMetadataResponses(responses=result_list, instance_type=instance_type))
def GetCloudVMMetadata(self, args): result_list = [] for request in args.requests: result_list.append( cloud.CloudMetadataResponse(label=request.label or request.url, text=request.label)) return [ cloud.CloudMetadataResponses(responses=result_list, instance_type="GOOGLE") ]