Re: [UPDATE]Func Facts

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

 



UPDATE 

Here are the updates to facts after comments(thanks btw :) ) :


1. A method to check conflicts for global tags :

[root@fedorabig func]# func "*" call fact list_fact_methods True
{'localhost.localdomain': {'__conflict__': {'kernel': ['kernel_version',
                                                       'cpu_model'],
                                            'runlevel': ['run_level',
                                                         'os_name']}}}

---------------------------------------------------------------------------------------------------------
2. Simplified api,so we again use the Overlord :

In [1]: import func.overlord.client as fc

In [2]: f = fc.Overlord("*")


In [4]: f.filter(runlevel=5,os__icontains="fedora").echo.run_string("ho ho ")
Out[4]: {}

In [5]: f = fc.Overlord("*")

In [6]: f.filter(runlevel=5,os__icontains="fedora").echo.run_string("ho ho ")
Out[6]: {'localhost.localdomain': 'ho ho '}

-----------------------------------------------------------------------------------------------------------------------
3. Added a new method for OR operations

In [9]: f = fc.Overlord("*")
In [10]: f.filter_or(runlevel=5,os__icontains="ubuntu").echo.run_string("ho ho 
")
Out[10]: {'localhost.localdomain': 'ho ho '}

-------------------------------------------------------------------------------------------------------------------------
4.For chaining purposes i tried to find an easier way instead of using Q 
complexity,and created those methods and_and,and_or,or_and,or_or. They work as 
follow:
the first keyword in the method name means the outside connector which will 
connect 2 queries,and second keyword is for inside operation. Examples are 
easier :to understand.

 
#chaining examples outsideConnector_insideConnector
In [12]: f = fc.Overlord("*")

In [13]:
f.and_and(runlevel__gte=3,runlevel__lte=6).or_and(os__icontains="fedora",kernel__icontains="2.16").echo.run_string("hey")
The final query is like :  (OR: (AND: ('runlevel__gte', 3),
('runlevel__lte',6)), (AND: ('kernel__icontains', '2.16'), 
('os__icontains','fedora')))

In [15]: f = fc.Overlord("*")

In [16]: 
f.and_and(runlevel__gte=3,runlevel__lte=6).or_or(os__icontains="fedora",kernel__icontains="2.16").echo.run_string("hey")
The final query is like :  (OR: (AND: ('runlevel__gte', 3), ('runlevel__lte', 
6)), (OR: ('kernel__icontains', '2.16'), ('os__icontains', 'fedora')))

In [17]: f = fc.Overlord("*")

In [18]: 
f.and_and(runlevel__gte=3,runlevel__lte=6).and_or(os__icontains="fedora",kernel__icontains="2.16").echo.run_string("hey")
The final query is like :  (AND: ('runlevel__gte', 3), ('runlevel__lte', 6),
(OR: ('kernel__icontains', '2.16'), ('os__icontains', 'fedora')))

In [19]: f = fc.Overlord("*")

In [20]: 
f.and_or(runlevel__gte=3,runlevel__lte=6).and_or(os__icontains="fedora",kernel__icontains="2.16").echo.run_string("hey")
The final query is like :  (AND: (OR: ('runlevel__gte', 3), ('runlevel__lte', 
6)), (OR: ('kernel__icontains', '2.16'), ('os__icontains', 'fedora')))


Therefore when you need something simple you can use filter and filter_or 
methods and when need more chaining operations use the 4 methods above ?
------------------------------------------------------------------------------------------------------------------------------------------------------
5. Removed the all english words for fact methods except tag.


Comments to changes  and any suggestions for commandline usage ? 

_______________________________________________
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