Esempio n. 1
0
func createVMCommoditiesBought(vm *VirtualMachine) []*proto.CommodityDTO {
	var commoditiesBought []*proto.CommodityDTO
	vCpuCommBought := builder.NewCommodityDTOBuilder(proto.CommodityDTO_CPU).
		Used(vm.ResourceStat.vCpuUsed).
		Create()
	commoditiesBought = append(commoditiesBought, vCpuCommBought)

	vMemCommBought := builder.NewCommodityDTOBuilder(proto.CommodityDTO_MEM).
		Used(vm.ResourceStat.vMemCapacity).
		Create()
	commoditiesBought = append(commoditiesBought, vMemCommBought)

	return commoditiesBought
}
Esempio n. 2
0
func createVMCommoditiesSold(vm *VirtualMachine) []*proto.CommodityDTO {
	var commoditiesSold []*proto.CommodityDTO
	vmResourceStat := vm.ResourceStat

	vCpuComm := builder.NewCommodityDTOBuilder(proto.CommodityDTO_VCPU).
		Capacity(vmResourceStat.vCpuCapacity).
		Used(vmResourceStat.vCpuUsed).
		Create()
	commoditiesSold = append(commoditiesSold, vCpuComm)

	vMemComm := builder.NewCommodityDTOBuilder(proto.CommodityDTO_VMEM).
		Capacity(vmResourceStat.vMemCapacity).
		Used(vmResourceStat.vMemUsed).
		Create()
	commoditiesSold = append(commoditiesSold, vMemComm)

	return commoditiesSold
}
Esempio n. 3
0
func createPMCommoditiesSold(pm *PhysicalMachine) []*proto.CommodityDTO {
	var commoditiesSold []*proto.CommodityDTO
	pmResourceStat := pm.ResourceStat

	cpuComm := builder.NewCommodityDTOBuilder(proto.CommodityDTO_CPU).
		Capacity(pmResourceStat.cpuCapacity).
		Used(pmResourceStat.cpuUsed).
		Create()
	commoditiesSold = append(commoditiesSold, cpuComm)

	memComm := builder.NewCommodityDTOBuilder(proto.CommodityDTO_MEM).
		Capacity(pmResourceStat.memCapacity).
		Used(pmResourceStat.memUsed).
		Create()
	commoditiesSold = append(commoditiesSold, memComm)

	return commoditiesSold
}