[one-users] list of ip addresses of network deployed in the frontend

Miguel Morillo Iruela miguel.morillo at gmail.com
Mon Dec 17 03:57:25 PST 2012


Hello,

I wrote a perl script to extract the information that I need from XML-RPC:
http://opennebula.org/documentation:rel3.8:api#onevmpoolinfo

The sniped code:

my @vmpoolany = &getVMPoolInfo(-1,-1,-1,-1); # Información de maquinas en
estado Any state, except DONE
my @ips = &getVMPoolFilterInfo(@vmpoolany ,"IP"); # Devuelve la información
extraída del XML de getVMPoolInfo, en nuestro caso las IPs


sub getVMPoolInfo {
    my $flag;
    my $start;
    my $end;
    my $filter;
    ($flag,$start,$end,$filter) = @_;

    my @response = $server->call('one.vmpool.info', $one_auth,
$flag,$start,$end,$filter);

    return @response;
}


sub getVMPoolFilterInfo {
    my @vmpoolinfo;
    my $filter;
    my $vmpoolinfoparam;

    ($vmpoolinfoparam,$filter) = @_;

    @vmpoolinfo =  @{$vmpoolinfoparam};


    if($vmpoolinfo[2] != 0){
            $errorcode = $vmpoolinfo[2];
    }
    $XML = $vmpoolinfo[1];

    # Limpiamos XML recibido
    $XML =~ s/\"/\'/g;
    $XML =~ s/<!\[CDATA\[//g;
    $XML =~ s/\]\]>//g;

    #
http://oreilly.com/perl/excerpts/system-admin-with-perl/ten-minute-xpath-utorial.html
    my $xp = XML::XPath->new($XML);

    my $nodeset = $xp->find("//$filter/text()");
    my @infofilter;

    foreach my $node ($nodeset->get_nodelist) {
        push(@infofilter, XML::XPath::XMLParser::as_string($node));
    }

    return @infofilter;

}


Regards
Miguel


2012/12/17 Jaime Melis <jmelis at opennebula.org>

> Hi,
>
> probably by doing 'onevm list -x' and grepping. Or writing a small ruby
> script using OpenNebula's OCA (about 10 lines) [1].
>
> [1] http://opennebula.org/documentation:rel3.8:ruby
>
> cheers,
> Jaime
>
> --
> Jaime Melis
> Project Engineer
> OpenNebula - The Open Source Toolkit for Cloud Computing
> www.OpenNebula.org | jmelis at opennebula.org
>
>
> On Mon, Dec 17, 2012 at 12:40 PM, Juan Ángel Ferreiro <
> juanferrla at gmail.com> wrote:
>
>> Hi everyone!
>>
>> I would like to know which is the easiest way to extract all ip of the
>> virtual machines deployed in the opennebula frontend.
>>
>> Best regards,
>>
>> --
>> Juan Ángel Ferreiro Lage
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opennebula.org
>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>
>>
>
>
> --
> Jaime Melis
> Project Engineer
> OpenNebula - The Open Source Toolkit for Cloud Computing
> www.OpenNebula.org | jmelis at opennebula.org
>
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20121217/b71220d2/attachment-0002.htm>


More information about the Users mailing list