Re: New GROUPS API and Groups CLI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/20/2009 07:22 AM, makkalot wrote:
Hi ML,

In last a few days i've been working on new pluggable groups api.
The public group code is now independent from the backend of the
groups. Current code supports 2 backends :
   - Configuration file (the old one)
   - sqlite backend

The default groups backend is configuration file for now because
it is a little bit faster than sqlite backend.If you need to change
to sqlite backend what you need to do is go to : /etc/func/overlord.conf
and change:
   backend = sqlite
   group_db = /path/you/want

    Has the groups config file changed formats any?

A new addition is groups cli, we will be able to control groups api
via cli with new stuff. Let see some cli examples :

(For testing purposes i added 100 test nonexisting minions range(100))
---------------------------------------------------------------------
Listing all of the current stuff
[root@fedorabig func]# func "*" group --la
Group : group5
          Host : 1
          Host : 3
          Host : 2
          Host : 5
          Host : 4
-----------------------------------------------------------------------
Adding a new group :
[root@fedorabig func]# func "*" group --ag "newgr"
[root@fedorabig func]#

    I'd tend to prefer --add-group, --list-all etc style long options.
We could maybe do both, or do short options as well (-ag, -la) though
some folks don't really like multichar short options.

    The output format could maybe be a little plainer? Might make
it easier for apps that want to parse the output. That said, I'm not
sure it makes that much sense to need to parse the output. But
maybe something like

func "*" group --list-all
group5
    1
    2
    3
    4
    5

?

hierarchical data like that never really seems to work great for
command line apps to parse though, so maybe it's not worth trying
to make it easier.


[root@fedorabig func]# func "*" group --la
Group : group5
          Host : 1
          Host : 3
          Host : 2
          Host : 5
          Host : 4
Group : newgr
----------------------------------------------------------------------
Listing some of the groups by glob:
[root@fedorabig func]# func "*" group --lg "gr*"
GROUPS :
           ['group5']
    Looks good.

[root@fedorabig func]#
-----------------------------------------------------------------------
Removing a group

[root@fedorabig func]# func "*" group --ag "tmpgr1"
[root@fedorabig func]# func "*" group --ag "tmpgr2"
[root@fedorabig func]# func "*" group --ag "tmpgr3"
[root@fedorabig func]# func "*" group --lg "*"
GROUPS :
           ['group5', 'newgr', 'tmpgr2', 'tmpgr3', 'tmpgr1']
[root@fedorabig func]# func "*" group --rg "tmpgr1"
    Yup.

[root@fedorabig func]# func "*" group --lg "*"
GROUPS :
           ['group5', 'newgr', 'tmpgr2', 'tmpgr3']
----------------------------------------------------------------------
Removing groups by globbing :
[root@fedorabig func]# func "*" group --rg "tmp*"
[root@fedorabig func]# func "*" group --lg "*"
GROUPS :
           ['group5', 'newgr']
    Looks good.

----------------------------------------------------------------------
Adding hosts in group by globbing: (adding host from 0-9 in groups)

[root@fedorabig func]# func "*" group --ah "@group5:[0-9]"
[root@fedorabig func]# func "*" group --la
Group : group5
          Host : 1
          Host : 0
          Host : 3
          Host : 2
          Host : 5
          Host : 4
          Host : 7
          Host : 6
          Host : 9
          Host : 8
Group : newgr

    Cool. Does this store the glob in the group defination, or
just populate the group with what matches the glob at
population time? (aka, or the groups "smart"?)


--------------------------------------------------------------------

Adding hosts in group by globbing with exclusion :

[root@fedorabig func]# func "*" group --e "@group:[1][2,4]" --ah "@group5:[1]
[0-5]"
[root@fedorabig func]# func "*" group --la
Group : group5
          Host : 1
          Host : 0
          Host : 3
          Host : 2
          Host : 5
          Host : 4
          Host : 7
          Host : 6
          Host : 9
          Host : 8
          Host : 11
          Host : 10
          Host : 13
          Host : 15
Group : newgr

In above example we added all [1][0-5] and excluded [1][2,4] with that option
we dont need anymore the need of subgrouping, we subgroup on the fly :)

--------------------------------------------------------------------------
Listing hosts via globbing :

[root@fedorabig func]# func "*" group --lh "@group5"
['11', '10', '13', '15', '1', '0', '3', '2', '5', '4', '7', '6', '9', '8']
[root@fedorabig func]# func "*" group --lh "@group5:[1][0-5]"
['11', '10', '13', '15']

Example of exclusion :
[root@fedorabig func]# func "*" group --e "@group5:[1,3,5,7,9]" --lh
"@group5:*"
['11', '10', '13', '15', '0', '2', '4', '6', '8']

--------------------------------------------------------------------------

Removing hosts from a group via globbing :
[root@fedorabig func]# func "*" group --rh "@group5:[1-5]"
[root@fedorabig func]# func "*" group --lh "@group5:*"
['11', '10', '13', '15', '0', '7', '6', '9', '8']

Removing hosts via exclusion:
[root@fedorabig func]# func "*" group --e "@group5:[0,2,4,6,8]" --rh
"@group5:*"
[root@fedorabig func]# func "*" group --lh "@group5:*"
['0', '8', '6']

-------------------------------------------------------------------------------
You can also do the above operations on multiple groups at the same cli:

Adding on multiple groups :

[root@fedorabig func]# func "*" group --la
Group : group5
          Host : 0
          Host : 6
          Host : 8
Group : newgr

[root@fedorabig func]# func "*" group --ah "@group5:[1][5-9];@newgr:[2][0-5]"
[root@fedorabig func]# func "*" group --la
Group : group5
          Host : 0
          Host : 6
          Host : 8
          Host : 19
          Host : 18
          Host : 15
          Host : 17
          Host : 16
Group : newgr
          Host : 24
          Host : 25
          Host : 20
          Host : 21
          Host : 22
          Host : 23
    Cool. I'm not sure I would of even worried about that case, but if
we can do it, all the better. I assume a case like:

    func "*" group --ah "@group5:hostblah,hostfoo,hostblippy"
works as well?

    I wonder about "group" being a subcommand being weird though.
Aka, requiring a host glob even when it doesn't really make sense. It
would be the only command that we do that way, but maybe we can find
a better approach.

Listing on multiple

root@fedorabig func]# func "*" group --lh "@group5:[1][5-9];@newgr:[2][0-5]"
['24', '25', '23', '15', '21', '17', '16', '19', '18', '22', '20']

Removing on multiple:

[root@fedorabig func]# func "*" group --rh "@group5:[1][5-9];@newgr:[2][0-5]"
[root@fedorabig func]# func "*" group --la
Group : group5
          Host : 0
          Host : 6
          Host : 8
Group : newgr

You can also use the --exclude keyword when working on multiple groups,but you
should be
sure that the number of operations match. If you work on 3 groups you should
have 3 groups
on exclude parameter also.

------------------------------------------------------------------------------------------------
ADDING NEW BACKENDS :

Adding new backends to groups shouldnt be hard what you need to do is just :
   -put a file in /func/overlord/group directory
   -extend the class /func/overlord/group/base.py BaseBackend and implement all
of its methods
   -add your backend into choose_backend method in /func/overlord/group/base.py
    We should be able to make that a touch more dynamic so it doesn't
have to get a case added in base.py. It would nice if we could just drop
in a new backend module and specify it in the config file, without changing
otherwise "packaged" code.


Looks excellent though, nice work.


Adrian

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux