diff --git a/dblogger/producer/manila.py b/dblogger/producer/manila.py index 6cc38e10ccbbc08c8270e955f97a1bbe9e8a1575..33f50c0e83de8bf39a78bf2c9ce692f072f708eb 100644 --- a/dblogger/producer/manila.py +++ b/dblogger/producer/manila.py @@ -16,6 +16,8 @@ class Manila(BaseDB): # Create table mapping self.Quota = self.db.map_table('quotas') + self.ProjectShareTypeQuota = self.db.map_table( + 'project_share_type_quotas') self.QuotaUsage = self.db.map_table('quota_usages') self.Shares = self.db.map_table('shares') self.ShareInstances = self.db.map_table('share_instances') @@ -286,31 +288,38 @@ class Manila(BaseDB): # SELECT # quota_usages.project_id, # quota_usages.resource, - # share_types.name, - # sum(in_use), - # max(hard_limit) + # share_types.name AS share_type, + # sum(in_use) AS quota_usage, + # max(hard_limit) AS quota_limit # FROM quota_usages - # LEFT JOIN quotas - # ON quotas.project_id = quota_usages.project_id - # AND quotas.resource = quota_usages.resource + # LEFT JOIN project_share_type_quotas + # ON project_share_type_quotas.project_id = quota_usages.project_id + # AND project_share_type_quotas.resource = quota_usages.resource + # AND project_share_type_quotas.share_type_id = + # quota_usages.share_type_id # LEFT JOIN share_types # ON share_types.id = quota_usages.share_type_id - # WHERE share_type_id IS NOT NULL - # GROUP BY resource, project_id, share_type_id - # ORDER BY project_id, name, resource; + # WHERE quota_usages.share_type_id IS NOT NULL + # GROUP BY resource, project_id, quota_usages.share_type_id + # ORDER BY project_id, name, RESOURCE; return ( self.db.query( self.QuotaUsage.project_id.label("project_id"), self.QuotaUsage.resource.label("resource"), self.ShareTypes.name.label("share_type"), func.sum(self.QuotaUsage.in_use).label("quota_usage"), - func.max(self.Quota.hard_limit).label("quota_limit") + func.max(self.ProjectShareTypeQuota.hard_limit).label( + "quota_limit") ) .join( - self.Quota, + self.ProjectShareTypeQuota, and_( - self.Quota.project_id == self.QuotaUsage.project_id, - self.Quota.resource == self.QuotaUsage.resource + self.ProjectShareTypeQuota.project_id + == self.QuotaUsage.project_id, + self.ProjectShareTypeQuota.resource + == self.QuotaUsage.resource, + self.ProjectShareTypeQuota.share_type_id + == self.QuotaUsage.share_type_id ), isouter=True )