This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

get_objects_filtered

Apparently the "get_objects_filtered" command recently was disabled at the command line.  Does anyone know the replacement?

Cheers - Bob


This thread was automatically locked due to age.
  • Which version(s) are you seeing this in?
  • Yes, get_objects_filtered appears to be missing.

    Here is a proof-of-concept of a work-alike for "get_objects_filtered".  Use at your own risk - and in test environments only.

    It isn't 100% identical in output and the blind eval has the potential to be very dangerous but it should be enough to test/review/comment.

    Comments/patches/documentation welcome.


    #!/usr/bin/perl

    #
    #       get_objects_filtered work-alike
    #
    #       v. 20141223-poc-1
    #
    #       teched.net
    #

    #
    #
    #       Proof of Concept, not for production use
    #
    #

    #
    #       PoC (has warnings)
    #use warnings;
    #
    use strict;

    use Astaro::ConfdPlRPC;
    use Data:[[[:D]]]umper;


    $Data:[[[:D]]]umper::Terse = 1;

    my $confd = Astaro::ConfdPlRPC->new or die 'connect failed';


    $confd->lock or die 'lock failed';

    for $_ (@{ $confd->get_objects() or die 'get failed'}) {
    #
    # PoC, blind eval from command line
    #
            if (eval @ARGV[0]) {
                    print Data:[[[:D]]]umper->Dump([$_], []);
            }
    }

    $confd->disconnect;

    exit 0;


    An example usage and output:


    test:/root/pl # perl gof.pl '$_->{data}->{address} eq "127.0.0.1"'
    {
              'lock' => 'global',
              'ref' => 'REF_NetworkLocalhost',
              'data' => {
                          'name' => 'Localhost',
                          'resolved' => 1,
                          'hostnames' => [],
                          'reverse_dns' => 0,
                          'resolved6' => 1,
                          'address6' => '::1',
                          'comment' => 'Loopback interface address',
                          'interface' => '',
                          'address' => '127.0.0.1',
                          'macs' => [],
                          'duids' => []
                        },
              'class' => 'network',
              'type' => 'host',
              'hidden' => 1,
              'autoname' => 0,
              'nodel' => ''
            }