Change metering exported format to csv.

Signed-off-by: Rao Yunkun <yunkunrao@yunify.com>
This commit is contained in:
Rao Yunkun
2021-03-02 10:27:53 +08:00
parent e9073f0486
commit 5bddda51e7
7 changed files with 133 additions and 28 deletions

View File

@@ -64,16 +64,17 @@ func (h *tenantHandler) QueryMeteringsHierarchy(req *restful.Request, resp *rest
func (h *tenantHandler) HandlePriceInfoQuery(req *restful.Request, resp *restful.Response) {
var priceInfoResponse metering.PriceInfo
priceInfoResponse.Init()
meterConfig, err := monitoring.LoadYaml()
if err != nil {
klog.Error(err)
klog.Warning(err)
resp.WriteAsJson(priceInfoResponse)
return
}
priceInfo := meterConfig.GetPriceInfo()
priceInfoResponse.Currency = "CNY"
priceInfoResponse.Currency = priceInfo.CurrencyUnit
priceInfoResponse.CpuPerCorePerHour = priceInfo.CpuPerCorePerHour
priceInfoResponse.MemPerGigabytesPerHour = priceInfo.MemPerGigabytesPerHour
priceInfoResponse.IngressNetworkTrafficPerGiagabytesPerHour = priceInfo.IngressNetworkTrafficPerGiagabytesPerHour