def getStatisticTable(self,buildId,tables = ()): request = remotecontrolportapi_pb2.Request() request.type = remotecontrolportapi_pb2.Request.TYPE_REQUEST_QUERY request.query.type = remotecontrolportapi_pb2.TYPE_QUERY_STATISTICTABLE request.query.statisticTable.buildId = buildId for table in tables: request.query.statisticTable.names.append(table) response = self._sendMessage(request) if response.type == remotecontrolportapi_pb2.Response.TYPE_RESPONSE_QUERY: if response.query.type == remotecontrolportapi_pb2.TYPE_QUERY_STATISTICTABLE: tables = {} for table in response.query.statisticTable.tables: tableData = [] for row in table.rows: rowData = [] for value in row.values: rowData.append(fromAny(value)) tableData.append(tuple(rowData)) tables[table.name] = (tuple(table.labels),tuple(tableData)) return tables else: raise ControlPortException('malformed statisticTable query response') else: raise ControlPortException('malformed query response')
def getConfiguration(self,buildId,parameters = ()): request = remotecontrolportapi_pb2.Request() request.type = remotecontrolportapi_pb2.Request.TYPE_REQUEST_QUERY request.query.type = remotecontrolportapi_pb2.TYPE_QUERY_CONFIGURATION request.query.configuration.buildId = buildId for parameter in parameters: request.query.configuration.names.append(parameter) response = self._sendMessage(request) if response.type == remotecontrolportapi_pb2.Response.TYPE_RESPONSE_QUERY: if response.query.type == remotecontrolportapi_pb2.TYPE_QUERY_CONFIGURATION: configuration = {} for parameter in response.query.configuration.parameters: values = [] for value in parameter.values: values.append(fromAny(value)) configuration[parameter.name] = tuple(values) return configuration else: raise ControlPortException('malformed configuration query response') else: raise ControlPortException('malformed query response')
def getManifest(self): request = remotecontrolportapi_pb2.Request() request.type = remotecontrolportapi_pb2.Request.TYPE_REQUEST_QUERY request.query.type = remotecontrolportapi_pb2.TYPE_QUERY_MANIFEST response = self._sendMessage(request) if response.type == remotecontrolportapi_pb2.Response.TYPE_RESPONSE_QUERY: if response.query.type == remotecontrolportapi_pb2.TYPE_QUERY_MANIFEST: manifest = {} for nem in response.query.manifest.nems: layers = [] for component in nem.components: if component.type == remotecontrolportapi_pb2.Response.Query.Manifest.NEM.Component.TYPE_COMPONENT_PHY: name = 'PHY' elif component.type == remotecontrolportapi_pb2.Response.Query.Manifest.NEM.Component.TYPE_COMPONENT_MAC: name = 'MAC' elif component.type == remotecontrolportapi_pb2.Response.Query.Manifest.NEM.Component.TYPE_COMPONENT_SHIM: name = 'SHIM' else: name = 'TRANSPORT' layers.append((component.buildId,name,component.plugin)) manifest[nem.id] = tuple(layers) return manifest else: raise ControlPortException('malformed manifest query response') else: raise ControlPortException('malformed query response')
def setLogLevel(self,level): request = remotecontrolportapi_pb2.Request() request.type = remotecontrolportapi_pb2.Request.TYPE_REQUEST_UPDATE request.update.type = remotecontrolportapi_pb2.TYPE_UPDATE_LOGLEVEL request.update.logLevel.level = level response = self._sendMessage(request) if response.type == remotecontrolportapi_pb2.Response.TYPE_RESPONSE_UPDATE: if response.update.type == remotecontrolportapi_pb2.TYPE_UPDATE_LOGLEVEL: return else: raise ControlPortException('malformed log level update response') else: raise ControlPortException('malformed update response')
def clearTable(self,buildId,tables = ()): request = remotecontrolportapi_pb2.Request() request.type = remotecontrolportapi_pb2.Request.TYPE_REQUEST_UPDATE request.update.type = remotecontrolportapi_pb2.TYPE_UPDATE_STATISTICTABLECLEAR request.update.statisticTableClear.buildId = buildId for table in tables: request.update.statisticTableClear.names.append(table) response = self._sendMessage(request) if response.type == remotecontrolportapi_pb2.Response.TYPE_RESPONSE_UPDATE: if response.update.type == remotecontrolportapi_pb2.TYPE_UPDATE_STATISTICTABLECLEAR: return else: raise ControlPortException('malformed statistic table clear update response') else: raise ControlPortException('malformed update response')
def clearStatistic(self,buildId,elements = ()): request = remotecontrolportapi_pb2.Request() request.type = remotecontrolportapi_pb2.Request.TYPE_REQUEST_UPDATE request.update.type = remotecontrolportapi_pb2.TYPE_UPDATE_STATISTICCLEAR request.update.statisticClear.buildId = buildId for element in elements: request.update.statisticClear.names.append(element) response = self._sendMessage(request) if response.type == remotecontrolportapi_pb2.Response.TYPE_RESPONSE_UPDATE: if response.update.type == remotecontrolportapi_pb2.TYPE_UPDATE_STATISTICCLEAR: return else: raise ControlPortException('malformed statistic clear update response') else: raise ControlPortException('malformed update response')
def updateConfiguration(self,buildId,updates): request = remotecontrolportapi_pb2.Request() request.type = remotecontrolportapi_pb2.Request.TYPE_REQUEST_UPDATE request.update.type = remotecontrolportapi_pb2.TYPE_UPDATE_CONFIGURATION request.update.configuration.buildId = buildId for (name,dataType,values) in updates: parameter = request.update.configuration.parameters.add() parameter.name = name for value in values: any = parameter.values.add() toAny(any,value,dataType) response = self._sendMessage(request) if response.type == remotecontrolportapi_pb2.Response.TYPE_RESPONSE_UPDATE: if response.update.type == remotecontrolportapi_pb2.TYPE_UPDATE_CONFIGURATION: return else: raise ControlPortException('malformed configuration update response') else: raise ControlPortException('malformed update response')
def getStatistic(self,buildId,elements = ()): request = remotecontrolportapi_pb2.Request() request.type = remotecontrolportapi_pb2.Request.TYPE_REQUEST_QUERY request.query.type = remotecontrolportapi_pb2.TYPE_QUERY_STATISTIC request.query.statistic.buildId = buildId for element in elements: request.query.statistic.names.append(element) response = self._sendMessage(request) if response.type == remotecontrolportapi_pb2.Response.TYPE_RESPONSE_QUERY: if response.query.type == remotecontrolportapi_pb2.TYPE_QUERY_STATISTIC: statistics = {} for element in response.query.statistic.elements: statistics[element.name] = fromAny(element.value) return statistics else: raise ControlPortException('malformed statistic query response') else: raise ControlPortException('malformed query response')