HP Matrix Operating Environment Software manual Sample Python Client

Page 100

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

Image 100
Contents API and CLI Operations Reference Guide Abstract7.1 Update 1 7.1Contents CMS Data Model Contents Exceptions Example UsageAccessing the Chargeback Web Service Interfaces Sample Java ClientRequiredParameterException Part I Matrix API Introduction Integration interface overview New features in 7.1 UpdateIntroduction PowerCycleLogicalServers New featuresNew features in 7.1 EditLogicalServers RemoveLogicalServers QuiesceCms UnquiesceCms GetCmsQuiesceStatusLogicalServerGroupDetails LogicalServerInfoServiceInfo ChargebackRequestInfo TemplateInfoAccessing the Web Service Interfaces Accessing WsdlCommand Line Interface SecurityOperations ImportTemplateExportTemplate List TemplateInfoService ListServicesGetService CreateServiceDeleteService DeactivateServiceChangeServiceLease ActivateServicePowerOffService PowerOnService DeleteReplicaServiceRequest ListRequestsGetRequestInfo GetRequestSetRequestApprovalState ContinueRequestCancelRequest Logical Server GroupGetLogicalServerGroup AddServersToLogicalServerGroupAddDiskToLogicalServerGroup AddNewDiskToLogicalServerGroupSetLogicalServerGroupActiveServerCount RawMappingTypeEnumGetLogicalServer DeactivateLogicalServersLogicalServerInfo LogicalServerDetailsPowerOffLogicalServers PowerOnLogicalServersActivateLogicalServers LogicalServerNotFound Exception Logical ServerPowerCycleLogicalServers EditLogicalServersRemoveLogicalServers ByteSizeEnumServer Pool ListServerPoolsGetServerPool CreateServerPoolMoveServerToServerPool DeleteServerPoolAssignUsersToServerPool Server UnassignUsersFromServerPoolGetComputeServer GetVmHostSoftware SubnetListSanVolumes GetSanVolumeListSanVolumeTemplates GetSanVolumeTemplateOrganization ListOrganizationsGetOrganization AssignTemplateToOrganizationBy a Service Provider Administrator AssignServerToOrganizationUnassignServerFromOrganization OrganizationName Returns None ExceptionsUnassignSubnetFromOrganization AssignSubnetToOrganizationAssignSoftwareToOrganization UnassignSoftwareFromOrganization BeginCmsMaintenanceSyncOrganizations EndCmsMaintenance CountRunningRequestsForCmsAddCms QuiesceCmsLoadBalancer GetCmsQuiesceStatusListLoadBalancers AddLoadBalancerSetLoadBalancerPassword RemoveLoadBalancerAddLoadBalancerCertificate RemoveLoadBalancerCertificateUnsetLoadBalancerPassword LogicalLoadBalancerCreateLogicalLoadBalancerGroup DeleteLogicalLoadBalancerGroupFirewallRuleGroup AddLogicalLoadBalancerGroupMemberRemoveLogicalLoadBalancerGroupMember GetFirewallRuleGroupAddRuleToFirewallRuleGroup RemoveRuleFromFirewallRuleGroupSyncFirewallRuleGroups Name AddRuleToFirewallRuleFloatingIPAddress AddFloatingIPAddressMoveFloatingIPAddress RemoveFloatingIPAddressServerSnapshot ReleaseFloatingIPAddressListUnassociatedFloatingIPAddresses ListServerSnapshotsRevertServerSnapshot CreateServerSnapshotDeleteServerSnapshot Snapshot, recursively. Defaults to false Data Model Data ModelByteSize ByteSizeEnumCidrIpRange CmsQuiesceStateCost CostFrequencyCostFrequencyEnum CustomAddressAssignmentTypeAttributeCustomStorageVolumeAttribute CustomProcessorAttributeCustomSubnetBindingAttribute CustomTemplateAttributesDeploymentService DeploymentServiceTypeDeploymentServiceTypeEnum DrModeFirewallRule FirewallRuleGroupInfoFirewallRuleGroupDetails ImageTypeIPType IPTypeEnumLeasePeriod LoadBalancerInfoLogicalFirewallRuleGroup LogicalDiskLogicalIPAddress LogicalLoadBalancerDetails LogicalLoadBalancerGroupDetailsLogicalLoadBalancerGroupInfo LogicalLoadBalancerGroupMemberLogicalLoadBalancerProtocol LogicalLoadBalancerProtocolEnumLogicalNetworkInterface LogicalServerDetailsLogicalServerGroupInfo ServiceEntityStatus statusLogicalServerInfo LogicalSoftware LogicalSubnetMessageSeverity MessageSeverityEnumNatEntry NatTypePacketProtocol PacketProtocolEnumProcessorArchitecture ProcessorArchitectureEnumRequestDetails RequestHistoryItemRequestHistoryItemLevel RequestHistoryItemLevelEnumRequestStatus RequestStatusEnumRequestType RequestTypeEnumSanVolumeState SanVolumeSanVolumeStateEnum SanVolumeTemplate ServerPoolState cannot be determined IDs of the cloud capacity pools in the server poolServiceAction ServiceActionTrigger triggerServerPoolResourceNote ServerResourceServiceActionTrigger ServiceActionTriggerEnumServiceDetails ServiceEntityStatusServiceInfo SoftwareDiskDefinitionSoftwareType SoftwareTypeEnumStorageProvisioningType StorageProvisioningTypeEnumStorageType StorageTypeEnumVirtualizationType TemplateInfoVirtualizationTypeEnum VirtualSwitch VmHostVmHostDataStore WorkflowExceptions SanVolumeNotFoundException SanVolumeTemplateNotFoundExceptionServiceNotFoundException OrganizationNotFoundExceptionSoftwareNotFoundException SubnetNotFoundExceptionTemplateNotFoundException UserNotFoundExceptionPhysical Server Maintenance Example Physical Server Maintenance ExampleExample Usage Sample Code Sample Java ClientSample Java Client Sample Code Sample Java Client IOClientPasswordHandler.java Sample Java Client Sample VisualStudio/.NET/C# Client Add this codeSample VisualStudio/.NET/C# Client String.Format0s, DateTime.NowPage Part II Chargeback API Chargeback Soap API Chargeback Soap APIAccessing the Chargeback Web Service Interfaces Accessing the Chargeback Web Service InterfacesHttps//cms-ip-address55443/hpio/chargeback/soap/v1?wsdl Summary Usage Report OperationsDetailed Usage Report Aggregated Usage Report List ServiceFilterOne entry with consolidated data for the entire period ServiceUsagePage Data Model ServiceFilter ServiceFilterAttribute enumFilterConnector enum PeriodServiceInformation ResourceUsageSummaryServerUsageSummary DiskUsageSummaryServiceUsagePage ServiceUsageSummaryAggregateServiceUsage ServiceUsageDetailPageDiskUsageDetail IpAddressUsageDetailAuthenticationException AuthorizationExceptionChargebackDataBaseException ChargebackExceptionPeriodStartDateGreaterThanEndDateException PeriodStartDateTooOldExceptionRequiredParameterException PeriodStartDateGreaterThanEndDateExceptionSample Python Client Sample Python ClientPage Example 2 reports.py Pageindex =Page Sample Python Client 101 Sample Python Client Example 3 GUI.py 103Sample Python Client 105 Example 4 reportsfile.py Sample Chargeback Usage Report 107References ReferencesHow to contact HP Support and other resourcesInformation to collect before contacting HP Information to collect before contacting HPWarranty information HP authorized resellersDocumentation feedback Subscribing to security bulletinsDocumentation and support Related informationRelated information
Related manuals
Manual 79 pages 57.42 Kb Manual 12 pages 7.25 Kb