@ -3,50 +3,84 @@ package VM::CBSD::Poller;
use 5.006 ;
use strict ;
use warnings ;
use base 'Error::Helper' ;
use JSON ;
= head1 NAME
VM::CBSD:: Poller - The great new VM::CBSD:: Poller !
VM::CBSD:: Poller - Polls the status of VMs managed by CBSD .
= head1 VERSION
Version 0.0 1
Version 0.0 .0
= cut
our $ VERSION = '0.0 1 ';
our $ VERSION = '0.0 .0 ';
= head1 SYNOPSIS
Quick summary of what the module does .
Perhaps a little code snippet .
use VM::CBSD::Poller ;
my $ foo = VM::CBSD::Poller - > new ( ) ;
...
my $ cbsd_vm_poller = VM::CBSD::Poller - > new ( ) ;
= head1 EXPORT
head1 METHODS
A list of functions that can be exported . You can delete this section
if you don ' t export anything , such as for a purely object - oriented module .
= head2 new
= head1 SUBROUTINES / METHODS
= head2 function1
This initiates the object .
= cut
sub function1 {
}
sub new {
my $ self = {
perror = > undef ,
error = > undef ,
errorString = > "" ,
errorExtra = > {
flags = > {
1 = > 'cbsdError' ,
}
} ,
} ;
bless $ self ;
return $ self ;
= head2 function2
= cut
}
sub function2 {
sub poll {
my $ self = $ _ [ 0 ] ;
my $ raw = `cbsd bls header=0 display=nodename,jname,jid,vm_ram,vm_curmem,vm_cpus,pcpu,vm_os_type,ip6_addr,status,vnc_port` ;
if ( $? != 0 ) {
$ self - > { error } = 1 ;
$ self - > { errorString } = '"cbsd bls header=0 display=nodename,jname,jid,vm_ram,vm_curmem,vm_cpus,pcpu,vm_os_type,ip6_addr,status,vnc_port" exited with a non-zero value' ;
$ self - > warn ;
return undef ;
}
my @ raw_split = split ( /\n/ , $ raw ) ;
my % return_hash ;
foreach my $ line ( @ raw_split ) {
my ( $ nodename , $ jname , $ jid , $ vm_ram , $ vm_curmem , $ vm_cpus , $ pcpu , $ vm_os_type , $ ip4_addr , $ status , $ vnc_port ) = split ( /[\t ]+/ , $ line ) ;
$ return_hash { $ jname } = {
jname = > $ jname ,
nodename = > $ nodename ,
jid = > $ jid ,
vm_ram = > $ vm_ram ,
vm_curmem = > $ vm_curmem ,
pcpu = > $ pcpu ,
vm_os_type = > $ vm_os_type ,
ip4_addr = > $ ip4_addr ,
status = > $ status ,
vnc_port = > $ vnc_port ,
}
}
return % return_hash ;
}
= head1 AUTHOR