apache / cloudstack-cloudmonkey

Apache Cloudstack Cloudmonkey
Apache License 2.0
91 stars 60 forks source link

hour value in the startdate,enddate parameter for command list usagerecords is ignored #143

Closed rajujith closed 8 months ago

rajujith commented 8 months ago

ISSUE

Ideally the command below should return the usage records only for 1 hour. But CMK reports the usage for the whole day.

cmk list usagerecords type=27 startdate=2023-12-08 05:00:00 enddate=2023-12-08 05:59:59

v6.2.0

Either the filtering is not working or I am not passing the value correctly.

GutoVeronezi commented 8 months ago

@rajujith, if you set the debug mode, you can see the way CMK is generating the URL and observe that the hour is being ignored (at least on 6.1, I did not check the newest version):

🐱 > list usagerecords type=27 startdate=2023-12-08 05:00:00 enddate=2023-12-08 05:59:59
[debug] ExecLine line:list usagerecords type=27 startdate=2023-12-08 05:00:00 enddate=2023-12-08 05:59:59
[debug] ExecCmd args: list, usagerecords, type=27, startdate=2023-12-08, 05:00:00, enddate=2023-12-08, 05:59:59
[debug] NewAPIRequest API request URL:[...]command=listUsageRecords&enddate=2023-12-08&response=json&startdate=2023-12-08&type=27[...]

Could you try putting the value between quotes? e.g:

🐱 > list usagerecords type=27 startdate="2023-12-08 05:00:00" enddate="2023-12-08 05:59:59"
[debug] ExecLine line:list usagerecords type=27 startdate="2023-12-08 05:00:00" enddate="2023-12-08 05:59:59"
[debug] ExecCmd args: list, usagerecords, type=27, startdate=2023-12-08 05:00:00, enddate=2023-12-08 05:59:59
[debug] NewAPIRequest API request URL:[...]command=listUsageRecords&enddate=2023-12-08+05%3A59%3A59&response=json&startdate=2023-12-08+05%3A00%3A00&type=27[...]
rajujith commented 8 months ago

@GutoVeronezi yes quotes are required, works now. Thanks.