Merge "Fixed bug with report total"
This commit is contained in:
commit
ea21f9761b
@ -30,11 +30,15 @@ class ReportManager(base.Manager):
|
||||
def list_tenants(self):
|
||||
return self.client.get(self.base_url + "/tenants").json()
|
||||
|
||||
def get_total(self, tenant_id, begin=None, end=None):
|
||||
url = self.base_url + "/total?tenant_id=%s" % tenant_id
|
||||
filter = [url]
|
||||
def get_total(self, tenant_id=None, begin=None, end=None):
|
||||
url = self.base_url + "/total"
|
||||
filters = list()
|
||||
if tenant_id:
|
||||
filters.append("tenant_id=%s" % tenant_id)
|
||||
if begin:
|
||||
filter.append("begin=%s" % begin.isoformat())
|
||||
filters.append("begin=%s" % begin.isoformat())
|
||||
if end:
|
||||
filter.append("end=%s" % end.isoformat())
|
||||
return self.client.get("&".join(filter)).json()
|
||||
filters.append("end=%s" % end.isoformat())
|
||||
if filters:
|
||||
url += "?%s" % ('&'.join(filters))
|
||||
return self.client.get(url).json()
|
||||
|
@ -13,6 +13,7 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from __future__ import print_function
|
||||
|
||||
from cloudkittyclient.common import utils
|
||||
|
||||
@ -26,7 +27,8 @@ def do_report_tenant_list(cc, args):
|
||||
|
||||
@utils.arg('-t', '--tenant-id',
|
||||
help='Tenant id',
|
||||
required=False, dest='total_tenant_id')
|
||||
required=False,
|
||||
dest='total_tenant_id')
|
||||
@utils.arg('-b', '--begin',
|
||||
help='Begin timestamp',
|
||||
required=False)
|
||||
@ -36,7 +38,7 @@ def do_report_tenant_list(cc, args):
|
||||
def do_total_get(cc, args):
|
||||
begin = utils.ts2dt(args.begin) if args.begin else None
|
||||
end = utils.ts2dt(args.end) if args.end else None
|
||||
total = cc.reports.get_total(args.total_tenant_id,
|
||||
total = cc.reports.get_total(tenant_id=args.total_tenant_id,
|
||||
begin=begin,
|
||||
end=end)
|
||||
utils.print_dict({'Total': total or 0.0})
|
||||
|
Loading…
Reference in New Issue
Block a user