Bug 1274128

Summary: RFE: provide "unlike" operator
Product: [Retired] Beaker Reporter: Wayne Sun <gsun>
Component: schedulerAssignee: beaker-dev-list
Status: CLOSED WONTFIX QA Contact: tools-bugs <tools-bugs>
Severity: high Docs Contact:
Priority: low    
Version: 21CC: bpeck, dcallagh, haliu, kbaker, kzhang, mcsontos, mjia, phan, rjoost, rmancy
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 610745 Environment:
Last Closed: 2015-10-27 22:15:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 610745, 741496    
Bug Blocks:    

Comment 1 Dan Callaghan 2015-10-23 05:26:48 UTC
We already have <not> which negates anything inside of it, so you can write:

<not><system><model op="like" value="%x3250%"/></system></not>

Can you use that?

Comment 2 Wayne Sun 2015-10-23 06:57:21 UTC
Don't know that, and as I tested, it works:
# bkr list-systems --xml-filter='<not><system><model op="like" value="%x3250%"/></system></not>' |grep x3250

So is it supported in bkr.client yet? As 'like' only got in recently in bug 1010355.

Comment 3 Dan Callaghan 2015-10-26 00:35:38 UTC
bkr client has allowed you to pass any XML to --hostrequire for a long time, so you can use it already:

    --hostrequire '<not><system><model op="like" value="%x3250%"/></system></not>'

What you are talking about for bug 1010355 is the shortcut syntax which translates

    --hostrequire 'a like b'

into <a op="like" value="b"/>.

I'm not sure what shortcut syntax we could invent for <not/>, maybe a ! prefix or something, but I don't see much point in continuing to invent more and more extra bits of syntax for the --hostrequire option when we already have an entire filtering language in XML already.

Comment 4 Dan Callaghan 2015-10-26 00:37:02 UTC
BTW the <model/> filter is already inaccessible from the --hostrequire shortcut syntax since it needs to be wrapped in <system/>. I think at this level of complexity you're better off just passing the XML as is rather than having an extra layer of translation.

Comment 5 Wayne Sun 2015-10-27 06:18:38 UTC
I originally thought the translation is the only way to get the 'like' or syntax <not/> into the job xml in our CI, turns out we could passing XML directly like you said. I put the xml with <and/>, <not/> into hostrequire list in the JSON file for CI and it also works.

e.g.
 "hostrequire": [
                        "arch=X86_64", 
                        "memory>=7000",
                        "<and><system><name op='like' value='%ibm%'/></system></and>",
                        "<not><system><model op='like' value='%x3250%'/></system></not>",
                        "<not><system><model op='like' value='%x3850%'/></system></not>"
                    ], 

So I think this bug is resolved and could be closed now, thx.

Comment 6 Dan Callaghan 2015-10-27 22:15:00 UTC
Yes if you have a complicated <hostRequires/> filter the best option is to build it as XML and pass that straight through, then you can make use of the full filtering language.