HP CloudSystem Matrix/Matrix Operating Environment 7.1 Integration Interfaces API and CLI Operations Reference Guide
 paging.pageIndex = PAGE_INDEX
 paging.pageSize = PAGE_SIZE
 filters = []
 if self.filters :
 filters = self.filters.getFiltersObj(self.chargebackservice)
 if len(filters) > 0:
 print "[" + str(datetime.datetime.now()) + "]" + "getServiceUsagePage: start" 
 result = self.chargebackservice.service.getServiceUsagePage(dataPeriod, paging, filters)
 print "[" + str(datetime.datetime.now()) + "]" + "getServiceUsagePage: end" 
 else:
 result = self.chargebackservice.service.getServiceUsagePage(dataPeriod, paging)
 if result.pagingInformation and len (result.ServiceUsageSummary) > 0:
 pages = result.pagingInformation
 services = result.ServiceUsageSummary
 Elements.extend(report_Summary(len(services), self.period))
 reportTable = [[]]
 reportTable[0] = ["Organization", "Billing Code", "Owner", "Service", "Total Cost ($)"]
 billingCost = 0.0
 for item in services:
 organizationName = get_organization(item)
 billingCode = get_billingcode(item)
 owner = get_owner(item)
 serviceName = get_servicename(item)
 serviceCost = self.get_serviceCost(item)
 billingCost += serviceCost
 reportLine = [organizationName, billingCode, owner, serviceName, 
str(locale.currency(val=serviceCost,symbol=False, grouping=True)) ]
 reportTable.append(reportLine) 
 reportTable.append(["", "", "", "Total", str(locale.currency( val=billingCost, symbol=False, 
grouping=True))])
 t = Table (reportTable, style=[('LINEABOVE', (0,0), (-1,0), 0.25, colors.black),
 ('LINEABOVE', (0,-1), (-1,-1), 0.25, colors.black),
 ('FONTSIZE', (0,0), (-1,0), 10),
 ('FONTSIZE', (0,1), (-1, -1), 9),
 ('ALIGN',(-1,1),(-1,-1),'RIGHT'),
 ('BACKGROUND',(0,0), (-1,0), colors.blue),
 ('TEXTCOLOR',(0,0), (-1,0), colors.white)
 ])
 t.hAlign = "LEFT"
 Elements.append(t)
 else:
 print "Result: " + result
 return Elements
 def generate (self, outputfile):
 usageReport = root.reports.reports.Report(self.title, self.footer)
 usageReport.generate (self.format_data(), outputfile) 
class ServiceUsageDetailReport (object):
 def __init__ (self, periodInformation, connection, filters=None, title="Title", footer="Footer"):
 self.title = title 
 self.data = footer
 self.footer = ""
 self.period = periodInformation
 self.filters = filters
 self.chargebackservice = connection.client
 def addserversdetails(self, servers, serviceData):
 serviceData.append(["Servers", "", "", "", ""])
 serviceData.append(["Hostname", "Type", "Allocation time (hrs)", "Allocation cost($)", "Up time (hrs)"
 ])
 for server in servers.serverUsageDetail:
 serviceData.append([str(server.hostName), server.resourceType, server.allocationHours, 
str(locale.currency(val=server.allocationCost,symbol=False, grouping=True)), server.uptimeHours])
 return len(servers.serverUsageDetail)
 def adddisksdetails(self, disks, serviceData):
 serviceData.append (["Disks", "", "", "", ""])
 serviceData.append(["Name", "Size (Gb)", "Allocation time (hrs)", "Allocation cost($)", "In cloud?"])
 for disk in disks.diskUsageDetail:
 serviceData.append([disk.logicalDiskName, disk.sizeGb, disk.allocationHours, 
str(locale.currency(val=disk.allocationCost, symbol=False, grouping=True)), disk.isInCloud])
 return len(disks.diskUsageDetail)
 def addipaddressesdetails(self, ipAddresses, serviceData):
 serviceData.append (["IP Addresses", "", "", "", ""])
 serviceData.append(["IP Address", "Type", "Allocation time (hrs)", "Allocation cost($)", ""])
 for ipAddress in ipAddresses.ipAddressUsageDetail:
100 Sample Python Client










