Last active
February 15, 2018 20:03
-
-
Save mccun934/50e183034a2b2fe6f288ff6bf55f6281 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################### | |
# USAGE: | |
# ./subs-export.csv.bash <ORG NAME> | |
# | |
# NOTE: If you run this without the | |
# organization name as a parameter | |
# it will return 0 results. | |
################################### | |
echo "Name,Organization,Subscriptions" | |
echo "SELECT '\"' || f.element || '\"','\"' || o.displayname || '\"','\"\"\"'||e.quantity||'|'||p.productid||'|'||p.productname||'|'||p.contractnumber||'|'||p.accountnumber||'\"\"\"' FROM | |
cp_consumer c, | |
cp_owner o, | |
cp_pool p, | |
cp_entitlement e, | |
cp_consumer_facts f | |
WHERE c.owner_id = o.id AND | |
e.consumer_id = c.id AND | |
p.id = e.pool_id AND | |
f.cp_consumer_id = c.id AND | |
f.mapkey = 'network.fqdn' AND | |
o.displayname = '$1';" | sudo -u postgres psql -d candlepin -t -A -F',' | awk -F '"""' '{if ($2!="") print }' - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment