Skip to content
Snippets Groups Projects
Commit 3f3ba062 authored by Alexander van Amesfoort's avatar Alexander van Amesfoort
Browse files

Task #9939: add RADB RPC getResourceAllocationConfig() to be able to apply max...

Task #9939: add RADB RPC getResourceAllocationConfig() to be able to apply max fill ratios in Resource Assigner
parent 5e146420
No related branches found
No related tags found
No related merge requests found
......@@ -1616,6 +1616,16 @@ class RADatabase:
return all_usages_list
def getResourceAllocationConfig(self, sql_like_name_pattern=None):
''' The argument sql_like_name_pattern is e.g. 'max_fill_ratio%'
'''
query = "SELECT name, value FROM resource_allocation.config"
if sql_like_name_pattern is not None:
query += " WHERE name LIKE '%s'" % sql_like_name_pattern
return list(self._executeQuery(query, fetch=_FETCH_ALL))
if __name__ == '__main__':
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
level=logging.INFO)
......@@ -1658,4 +1668,5 @@ if __name__ == '__main__':
resultPrint(db.getSpecifications)
resultPrint(db.getResourceClaims)
resultPrint(db.getResourceClaimProperties)
resultPrint(db.getResourceAllocationConfig)
......@@ -271,6 +271,10 @@ class RARPC(RPCWrapper):
def getUnits(self):
return self.rpc('GetUnits')
def getResourceAllocationConfig(self, sql_like_name_pattern=None):
return self.rpc('GetResourceAllocationConfig',
sql_like_name_pattern=sql_like_name_pattern)
def do_tests(busname=DEFAULT_BUSNAME, servicename=DEFAULT_SERVICENAME):
with RARPC(busname=busname, servicename=servicename) as rpc:
#for i in range(0, 10):
......@@ -316,6 +320,7 @@ def do_tests(busname=DEFAULT_BUSNAME, servicename=DEFAULT_SERVICENAME):
#print rpc.getTasks()
#print rpc.getResourceClaims()
#print rpc.getResourceAllocationConfig()
......
......@@ -76,7 +76,8 @@ class RADBHandler(MessageHandlerInterface):
'InsertSpecification': self._insertSpecification,
'DeleteSpecification': self._deleteSpecification,
'UpdateSpecification': self._updateSpecification,
'GetUnits': self._getUnits}
'GetUnits': self._getUnits,
'GetResourceAllocationConfig': self._getResourceAllocationConfig}
def prepare_loop(self):
self.radb = radb.RADatabase(dbcreds=self.dbcreds, log_queries=self.log_queries)
......@@ -194,8 +195,8 @@ class RADBHandler(MessageHandlerInterface):
def _getResourceGroups(self):
return self.radb.getResourceGroups()
def _getResourceGroupNames(self, resourceGroupTypeName):
return self.radb.getResourceGroupNames(resourceGroupTypeName)
def _getResourceGroupNames(self, **kwargs):
return self.radb.getResourceGroupNames(resourceGroupTypeName=kwargs.get('resourceGroupTypeName'))
def _getResourceGroupMemberships(self):
rg_memberships = self.radb.getResourceGroupMemberships()
......@@ -335,6 +336,10 @@ class RADBHandler(MessageHandlerInterface):
def _getUnits(self):
return self.radb.getUnits()
def _getResourceAllocationConfig(self, **kwargs):
return self.radb.getResourceAllocationConfig(sql_like_name_pattern=kwargs.get('sql_like_name_pattern'))
def createService(busname=DEFAULT_BUSNAME, servicename=DEFAULT_SERVICENAME, broker=None, dbcreds=None, log_queries=False, verbose=False):
return Service(servicename,
RADBHandler,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment