Ejemplo 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
}
Ejemplo 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
}
Ejemplo 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
}