Re: [Spacewalk-devel] patch for rhn-entitlement-report

2013-09-05 Thread Jan Dobes
Hi Shannon,
I reviewed and commited your patch as:
18d5b2f5ecaed6598a5ccb13d38abaf88a16442a

Thanks!

-- 
Jan Dobes
Satellite Engineering, Red Hat

- Original Message -
 From: Shannon Hughes shug...@redhat.com
 To: spacewalk-devel spacewalk-devel@redhat.com
 Sent: Wednesday, September 4, 2013 10:45:41 PM
 Subject: [Spacewalk-devel] patch for rhn-entitlement-report
 
 rhn-entitlement-report crashes with stack trace when you unentitle
 software channels from systems and leave unentitled:
 
 [root@litmus ~]# rhn-entitlement-report
 Software Channel Entitlements Across RHN Satellite :
Channel LabelTotal   Regular Used Available
 Total Flex Flex Used Available Flex
- --  -
 -- - --
 Traceback (most recent call last):
File /usr/bin/rhn-entitlement-report, line 100, in module
  main()
File /usr/bin/rhn-entitlement-report, line 21, in main
  printAcrossSatelliteUsage();
File /usr/bin/rhn-entitlement-report, line 38, in
 printAcrossSatelliteUsage
  for item in list:
 TypeError: 'NoneType' object is not iterable
 
 
 duplicated by setting up a few flex guests systems and then entitlement
 them.
 
 attaching patch that checks if the list is empty, print  and then return.
 
 will attach to bz 883242
 
 Regards,
 
 Shannon Hughes
 Senior SEG/GSS
 
 ___
 Spacewalk-devel mailing list
 Spacewalk-devel@redhat.com
 https://www.redhat.com/mailman/listinfo/spacewalk-devel

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


[Spacewalk-devel] patch for rhn-entitlement-report

2013-09-04 Thread Shannon Hughes
rhn-entitlement-report crashes with stack trace when you unentitle 
software channels from systems and leave unentitled:


[root@litmus ~]# rhn-entitlement-report
Software Channel Entitlements Across RHN Satellite :
  Channel LabelTotal   Regular Used Available 
Total Flex Flex Used Available Flex
  - --  - 
-- - --

Traceback (most recent call last):
  File /usr/bin/rhn-entitlement-report, line 100, in module
main()
  File /usr/bin/rhn-entitlement-report, line 21, in main
printAcrossSatelliteUsage();
  File /usr/bin/rhn-entitlement-report, line 38, in 
printAcrossSatelliteUsage

for item in list:
TypeError: 'NoneType' object is not iterable


duplicated by setting up a few flex guests systems and then entitlement 
them.


attaching patch that checks if the list is empty, print  and then return.

will attach to bz 883242

Regards,

Shannon Hughes
Senior SEG/GSS
From 05223dabd04711cd5b600f69d46b7d7a3b88fdf5 Mon Sep 17 00:00:00 2001
From: Shannon Hughes shug...@redhat.com
Date: Wed, 4 Sep 2013 16:39:55 -0400
Subject: [PATCH] check for empty result before printing software entitlement
 usage

---
 backend/satellite_tools/rhn-entitlement-report |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/backend/satellite_tools/rhn-entitlement-report b/backend/satellite_tools/rhn-entitlement-report
index 80c4b4b..86452d0 100755
--- a/backend/satellite_tools/rhn-entitlement-report
+++ b/backend/satellite_tools/rhn-entitlement-report
@@ -32,6 +32,10 @@ def printAcrossSatelliteUsage():
print (Software Channel Entitlements Across RHN Satellite :)
query = SELECT cfo.label,SUM(cfo.max_members) as total,SUM(cfo.current_members) as used,(SELECT (cfo2.max_members) - (cfo2.current_members) FROM rhnChannelFamilyOverview cfo2 WHERE cfo2.label = cfo.label AND cfo2.org_id = 1) as available,SUM(cfo.fve_max_members) as total_flex,SUM(cfo.fve_current_members) as used_flex,(SELECT (cfo2.fve_max_members) - (cfo2.fve_current_members) FROM rhnChannelFamilyOverview cfo2 WHERE cfo2.label = cfo.label AND cfo2.org_id = 1) as available_flex FROM rhnChannelFamilyOverview cfo WHERE cfo.max_members is not null and (cfo.current_members !=0 or cfo.fve_current_members!=0) GROUP BY cfo.label, cfo.name HAVING (SUM(cfo.max_members) is not null) ORDER by cfo.name DESC 
list = run_query(query)
+   if list == None:
+  print()
+  return
+
print(%35s %s %s %s %s %s %s % (Channel Label,   Total  ,Regular Used,Available,Total Flex,Flex Used,Available Flex))
print(%35s %s %s %s %s %s %s % (-,--,,-,--,-,--))
 
-- 
1.7.7.6

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel