func (store *LibvirtMachinerep) List(machines *models.VirtualMachineList) error { domains, err := store.conn.ListAllDomains(0) if err != nil { return err } for _, domain := range domains { vm := &models.VirtualMachine{} if err := store.fillVm(vm, domain); err != nil { return err } machines.Add(vm) } return nil }
func (store *OVZMachinerep) List(machines *models.VirtualMachineList) error { var out bytes.Buffer cmd := exec.Command("vzlist", "-j", "-a") cmd.Stdout = &out if err := cmd.Run(); err != nil { return err } vzinfos := []*VZInfo{} if err := json.Unmarshal(out.Bytes(), &vzinfos); err != nil { return fmt.Errorf("failed to parse vzlist output: %s", err) } for _, vzinfo := range vzinfos { vm := &models.VirtualMachine{} fillOvzVm(vm, vzinfo) machines.Add(vm) } return nil }