Esempio n. 1
0
 public function index()
 {
     $conn = libvirt_connect('qemu+tcp://localhost/system', false);
     $doms = libvirt_list_domains($conn);
     $r_doms = [];
     foreach ($doms as $dom) {
         $r_dom = new \stdClass();
         $res = libvirt_domain_lookup_by_name($conn, $dom);
         $dd = libvirt_domain_get_info($res);
         $r_dom->name = $dom;
         $r_dom->cpu = $dd['nrVirtCpu'];
         $r_dom->memory = $dd['maxMem'] / 1024 / 1024;
         $r_dom->state = $dd['state'];
         $r_doms[] = $r_dom;
     }
     return $r_doms;
     return Vm::orderBy('created_at', 'asc')->get();
 }