in src/hpc/autoscale/cost/azurecost.py [0:0]
def get_nodearray(self, fout, start, end)-> None:
def _process_usage_with_retail(az_fmt_t, fout, usage: dict):
writer = csv.writer(fout, delimiter=',')
for e in usage['usage'][0]['breakdown']:
if e['category'] != 'nodearray':
continue
array_name = e['node']
for a in e['details']:
sku_name = a['vm_size']
region = a['region']
hours = a['hours']
core_count = a['core_count']
spot = False
if a['priority'] == 'Spot':
spot = True
if self.do_meter_lookup(sku_name=sku_name,region=region,spot=spot):
pass
# use retail data
data = self.get_retail_rate(armskuname=sku_name, armregionname=region, spot=spot)
rate = data['retailPrice']
cost = (hours/core_count) * rate
array_fmt = az_fmt_t(sku_name=sku_name, region=region,spot=spot,core_hours=hours, cost=cost,
nodearray=array_name,meterid=data['meterId'],meter=data['meterName'],
metercat=data['serviceName'], rate=data['retailPrice'], currency=data['currencyCode'])
row = []
for f in az_fmt_t._fields:
row.append(array_fmt._asdict()[f])
writer.writerow(row)
return
usage = self.get_usage(start, end, 'total')
_fmt = self.get_nodearray_format()
if _fmt.__name__ == 'az_array_retail_t':
return _process_usage_with_retail(_fmt, fout, usage)