[Pulp-list] How do you execute search queries

Kodiak Firesmith kfiresmith at gmail.com
Thu Jul 7 18:11:24 UTC 2016


I have the beginnings of a script in progress that so far works for package
name searches.  It was made to iterate over all repos  a user has access
to.  It's really slow right now (serial FTL), and there may be bugs other
than listed, but hopefully it helps.  Hope the formatting isn't crap,
sending from mobile.

#!/bin/bash
#
#
# Known issues / missing features:
#  - Missing ability to parallelize repo searches, which would really speed
things up.  Easy fix: Gnu Parallel, widely compatible fix: bash wait.
#  - Missing ability to speed up searches by limiting scope to just Red Hat
and/or just IT repos
#  - Missing option checking and help feedback in the event of bad input
#  - Missing ability to limit number of matches returned.  This is probably
functionality that exists in pulp-admin but hasn't been added to script.
#

# ## search items ##
# Metadata is used for fields search; eg: --fields="foo,bar"
# Metadata: Arch Buildhost Checksum Checksumtype Description Epoch Filename
License Name Provides Release Requires Vendor Version
# Greppable aspects from '-d' switch:
# Created, Id, Repo Id, Unit Id, Unit Type Id, Updated

# Ensure user is logged in, if not, attempt, if fail, bail 22.
function ensure_login {
  if pulp-admin tasks list > /dev/null; then
    LOGGEDIN="true"
  else
    echo "You need to be logged in to Pulp first; enter your full AD
username (eg: jimbob_mgr at AD.COLLEGE.EDU) :"
      read username
      pulp-admin login -u $username
      if ! pulp-admin tasks list > /dev/null; then
        echo "login not successful"
        LOGGEDIN="false"
        exit 22
      fi
  fi
}

ensure_login

# This has to be done because we get JSON errors if we try to do in-line
escapes, vars, etc.  Problem w/ pulp-admin input validation I belive.
PREAMBLE="--filter '{\"name\":{\"\$regex\":\""
SEARCHSTR="$1"
EPILOGUE="\",\"\$options\":\"i\"}}'"
FILTER="$PREAMBLE$SEARCHSTR$EPILOGUE"

for repos in $(pulp-admin rpm repo list | grep Id | awk '{print $2}');do
  SEARCHCMD="pulp-admin rpm repo content rpm --repo-id=$repos $FILTER -d"
  #Running the search on each repo using input from $1 only works when we
echo the command into bash...
  echo "$SEARCHCMD" | /bin/bash | egrep 'Repo Id:|Filename:' | sort -r |
uniq
done
On Jul 7, 2016 11:01 AM, "Lutchy Horace (Mailing List)" <
mailinglist.subscriptions at lhprojects.net> wrote:

> Hello,
>
> I am having trouble finding any documentation on how to properly use the
> various command arguments, ie --str-eq, --match, etc. I am trying to run
> a query for a package, that after several syncs, doesn't seem to appear.
>
> For example:
>
> pulp-admin rpm repo content rpm --repo-id=centos7-x86_64-updates
> --match="id=device-mapper".
>
> Here is a snippet of my mongodb logs:
>
> 2016-07-07T16:01:55.361+0000 [conn663] warning: log line attempted
> (78k) over max size (10k), printing beginning and end ... query
> pulp_database.units_rpm query: { $query: { _id: { $in:
> [ "eb82791c-fb37-4ae3-827 7-d472fec0a466",
> "6a6b3390-68df-4be5-8883-dd6ea17c2144",
> "54a27a18-3644-4992-8f77-16571337db5b",
> "a0897f8f-adca-42cc-a4c1-5a7125196a72",
> "992c7246-93fa-47fc-9eaa-52d76e4ccde4",
> "00611cab-dd43-4359-8aae-86ef58299 b6f",
> "f452eca5-870d-48b8-91e5-787b718b5a11",
> "f65a20d0-5ed5-473e-8786-fd4405838666",
> "ea23de3b-f834-4da1-9837-50ec3e4969bf",
> "2a757f63-eb67-4164-b304-c24f73ad4ca0", <snip>.
>
> Am I wrong to believe that packages are not stored with their names? If
> that's the case, how would one translate
> 6a6b3390-68df-4be5-8883-dd6ea17c2144 to a package name? Is this a bug
> that needs to be reported?
>
> Regards
>
> --
> Lutchy Horace
> Owner/Operator/Administrator [http://www.lhprojects.net]
> Owner/Operator/Administrator [http://www.bombshellz.net]
> Owner/Operator/Administrator [http://www.animehouse.club]
> About Me [http://about.me/lhprojects]
> USA
>
> _______________________________________________
> Pulp-list mailing list
> Pulp-list at redhat.com
> https://www.redhat.com/mailman/listinfo/pulp-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/pulp-list/attachments/20160707/fa36642e/attachment.htm>


More information about the Pulp-list mailing list