Exemplo n.º 1
0
func (this *ExampleProbe) discoverPMs() ([]*proto.EntityDTO, error) {
	var result []*proto.EntityDTO

	pms := this.topoSource.GetPMs()
	for _, pm := range pms {
		commoditiesSold := createPMCommoditiesSold(pm)

		entityDTO, err := builder.NewEntityDTOBuilder(proto.EntityDTO_PHYSICAL_MACHINE, pm.UUID).
			DisplayName(pm.Name).
			SellsCommodities(commoditiesSold).
			Create()
		if err != nil {
			return nil, fmt.Errorf("Error creating entityDTO for PM %s: %v", pm.Name, err)
		}
		result = append(result, entityDTO)
	}

	return result, nil
}
Exemplo n.º 2
0
func (this *ExampleProbe) discoverVMs() ([]*proto.EntityDTO, error) {
	var result []*proto.EntityDTO

	vms := this.topoSource.GetVMs()
	for _, vm := range vms {
		commoditiesSold := createVMCommoditiesSold(vm)
		commoditiesBought := createVMCommoditiesBought(vm)

		entityDTO, err := builder.NewEntityDTOBuilder(proto.EntityDTO_VIRTUAL_MACHINE, vm.UUID).
			DisplayName(vm.Name).
			SellsCommodities(commoditiesSold).
			SetProviderWithTypeAndID(proto.EntityDTO_PHYSICAL_MACHINE, vm.providerID).
			BuysCommodities(commoditiesBought).
			Create()
		if err != nil {
			return nil, fmt.Errorf("Error creating entityDTO for VM %s: %v", vm.Name, err)
		}
		result = append(result, entityDTO)
	}

	return result, nil
}