[Spacewalk-devel] spacecmd - new function patch

2013-12-20 Thread Gregor Gruener

Hi spacewalkers,

I've updated the spacecmd package.py file, to add a new function 
package_listdependencies.

Can you review and add this patch upstream.

Cheers,
Gregor Grüner
From 28c227e56f6d3506a0ff97579576d9feeed7850c Mon Sep 17 00:00:00 2001
From: Gregor Gruener ggru...@redhat.com
Date: Fri, 20 Dec 2013 09:33:31 +0100
Subject: [PATCH] added function package_listdependencies

---
 spacecmd/spacecmd.spec  |  3 +++
 spacecmd/src/lib/package.py | 39 +++
 2 files changed, 42 insertions(+)

diff --git a/spacecmd/spacecmd.spec b/spacecmd/spacecmd.spec
index 3b81360..12c9ed3 100644
--- a/spacecmd/spacecmd.spec
+++ b/spacecmd/spacecmd.spec
@@ -64,6 +64,9 @@ touch %{buildroot}/%{python_sitelib}/spacecmd/__init__.py
 %doc %{_mandir}/man1/spacecmd.1.gz
 
 %changelog
+* Fri Dec 20 2013 Gregor Gruener ggru...@redhat.com 2.1.21-1
+- added function package_listdependencies
+
 * Fri Dec 13 2013 Milan Zazrivec mzazri...@redhat.com 2.1.20-1
 - 1009841 - don't attempt to write out 'None'
 
diff --git a/spacecmd/src/lib/package.py b/spacecmd/src/lib/package.py
index ea2f355..8bbc8a7 100644
--- a/spacecmd/src/lib/package.py
+++ b/spacecmd/src/lib/package.py
@@ -297,4 +297,43 @@ def do_package_listerrata(self, args):
 if len(errata):
 print '\n'.join(sorted([ e.get('advisory') for e in errata ]))
 
+
+
+def help_package_listdependencies(self):
+print 'package_listdependencies: List the dependencies for a package'
+print 'usage: package_listdependencies PACKAGE'
+
+def do_package_listdependencies(self, args):
+(args, options) = parse_arguments(args)
+
+if not len(args):
+self.help_package_listdependencies()
+return
+
+packages = []
+for package in args:
+packages.extend(self.do_package_search(' '.join(args), True))
+
+if not len(packages):
+logging.warning('No packages found')
+return
+
+add_separator = False
+
+for package in packages:
+if add_separator: print self.SEPARATOR
+add_separator = True
+
+package_id = self.get_package_id(package)
+
+if not package_id:
+logging.warning('%s is not a valid package' % package)
+continue
+
+package_id = int(package_id)
+pkgdeps = self.client.packages.list_dependencies(self.session, package_id)
+for dep in pkgdeps:
+print 'Package Name: %s' % package
+print 'Dependency: %s Type: %s Modifier: %s' % (dep['dependency'], dep['dependency_type'], dep['dependency_modifier'])
+
 # vim:ts=4:expandtab:
-- 
1.8.3.1

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

[Spacewalk-devel] spacecmd - Added new scap features

2013-08-05 Thread Gregor Gruener

Hi Spacewalkers,

I have added a few completely new openscap functions to spacecmd. The 
new file scap.py contains the new functions:

scap_getxccdfscandetails
scap_getxccdfscanruleresults
scap_listxccdfscans
scap_schedulexccdfscan

Can you review and add this patch upstream.

Cheers,
Gregor Grüner
From 297a9818d98864e6549429c79af983bbd75466c5 Mon Sep 17 00:00:00 2001
From: Gregor Gruener ggru...@redhat.com
Date: Mon, 5 Aug 2013 19:50:12 +0200
Subject: [PATCH] Added new scap features into spacecmd

---
 spacecmd/spacecmd.spec|  11 +++-
 spacecmd/src/lib/scap.py  | 158 ++
 spacecmd/src/lib/shell.py |   2 +-
 3 files changed, 168 insertions(+), 3 deletions(-)
 create mode 100644 spacecmd/src/lib/scap.py

diff --git a/spacecmd/spacecmd.spec b/spacecmd/spacecmd.spec
index ecb6b23..5b2d82d 100644
--- a/spacecmd/spacecmd.spec
+++ b/spacecmd/spacecmd.spec
@@ -64,8 +64,15 @@ touch %{buildroot}/%{python_sitelib}/spacecmd/__init__.py
 %doc %{_mandir}/man1/spacecmd.1.gz
 
 %changelog
-* Mon Aug 05 2013 Gregor Gruener ggru...@redhat.com
-- spacecmd - add new function is_monitoringenabled and list_proxies
+* Mon Aug 05 2013 Gregor Gruener ggru...@redhat.com 2.1.3-1
+- add new function scap_listxccdfscans
+- add new function scap_getxccdfscandetails
+- add new function scap_getxccdfscanruleresults
+- add new function scap_schedulexccdfscan
+
+* Mon Aug 05 2013 Gregor Gruener ggru...@redhat.com 2.1.2-1
+- add new function is_monitoringenabled
+- add new function list_proxies
 
 * Mon Jul 22 2013 Gregor Gruener ggru...@redhat.com 2.1.1-1
 - add new function custominfo_updatekey
diff --git a/spacecmd/src/lib/scap.py b/spacecmd/src/lib/scap.py
new file mode 100644
index 000..4be6512
--- /dev/null
+++ b/spacecmd/src/lib/scap.py
@@ -0,0 +1,158 @@
+#
+# Licensed under the GNU General Public License Version 3
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright 2013 Aron Parsons aronpars...@gmail.com
+# Copyright (c) 2013 Red Hat, Inc.
+#
+
+# NOTE: the 'self' variable is an instance of SpacewalkShell
+
+from optparse import Option
+from spacecmd.utils import *
+
+def help_scap_listxccdfscans(self):
+print 'scap_listxccdfscans: Return a list of finished OpenSCAP scans for given systems'
+print 'usage: scap_listxccdfscans SYSTEMS'
+
+def complete_system_scap_listxccdfscans(self, text, line, beg, end):
+return self.tab_complete_systems(text)
+
+def do_scap_listxccdfscans(self, args):
+(args, options) = parse_arguments(args)
+
+if not len(args):
+self.help_scap_listxccdfscans()
+return
+
+# use the systems listed in the SSM
+if re.match('ssm', args[0], re.I):
+systems = self.ssm.keys()
+else:
+systems = self.expand_systems(args)
+
+add_separator = False
+
+for system in sorted(systems):
+if add_separator: print self.SEPARATOR
+add_separator = True
+
+if len(systems)  1:
+print 'System: %s' % system
+print
+
+system_id = self.get_system_id(system)
+if not system_id: continue
+
+scan_list = self.client.system.scap.listXccdfScans(self.session, system_id)
+
+for s in scan_list:
+print 'XID: %d Profile: %s Path: (%s) Completed: %s' % (s['xid'], s['profile'], s['path'], s['completed'])
+
+
+
+def help_scap_getxccdfscanruleresults(self):
+print 'scap_getxccdfscanruleresults: Return a full list of RuleResults for given OpenSCAP XCCDF scan'
+print 'usage: scap_getxccdfscanruleresults XID'
+
+def do_scap_getxccdfscanruleresults(self, args):
+(args, options) = parse_arguments(args)
+
+if not len(args):
+self.help_scap_getxccdfscanruleresults()
+return
+
+add_separator = False
+
+for xid in args:
+if add_separator: print self.SEPARATOR
+add_separator = True
+
+if len(args)  1:
+print 'XID: %s' % xid
+print
+
+xid = int(xid)
+scan_results = self.client.system.scap.getXccdfScanRuleResults(self.session, xid)
+
+for s in scan_results:
+print 'IDref: %s Result: %s Idents: (%s)' % (s['idref'], s['result'], s['idents'])
+
+
+
+def help_scap_getxccdfscandetails(self):
+print

[Spacewalk-devel] spacecmd - new functions patch

2013-08-01 Thread Gregor Gruener

Hi spacewalkers,

I've updated the spacecmd misc.py file, to add new functions like 
is_monitoringenabled and list_proxies.

Can you review and add this patch upstream.

Cheers,
Gregor Grüner
From f668db7aaf3a39053513280b98ddb20809c9f667 Mon Sep 17 00:00:00 2001
From: Gregor Gruener ggru...@redhat.com
Date: Thu, 1 Aug 2013 09:52:40 +0200
Subject: [PATCH] add new function is_monitoringenabled and list_proxies

---
 rel-eng/packages/spacecmd |  2 +-
 spacecmd/spacecmd.spec|  6 +-
 spacecmd/src/lib/misc.py  | 21 +
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/rel-eng/packages/spacecmd b/rel-eng/packages/spacecmd
index f9ca916..c88f653 100644
--- a/rel-eng/packages/spacecmd
+++ b/rel-eng/packages/spacecmd
@@ -1 +1 @@
-2.1.1-1 spacecmd/
+2.1.2-1 spacecmd/
diff --git a/spacecmd/spacecmd.spec b/spacecmd/spacecmd.spec
index f167795..0b79f58 100644
--- a/spacecmd/spacecmd.spec
+++ b/spacecmd/spacecmd.spec
@@ -4,7 +4,7 @@
 %endif
 
 Name:spacecmd
-Version: 2.1.1
+Version: 2.1.2
 Release: 1%{?dist}
 Summary: Command-line interface to Spacewalk and Satellite servers
 
@@ -64,6 +64,10 @@ touch %{buildroot}/%{python_sitelib}/spacecmd/__init__.py
 %doc %{_mandir}/man1/spacecmd.1.gz
 
 %changelog
+* Thu Aug 1 2013 Gregor Gruener ggru...@redhat.com 2.1.2-1
+- add new function is_monitoringenabled
+- add new function list_proxies
+
 * Mon Jul 22 2013 Gregor Gruener ggru...@redhat.com 2.1.1-1
 - add new function custominfo_updatekey
 
diff --git a/spacecmd/src/lib/misc.py b/spacecmd/src/lib/misc.py
index 6273eb4..21d2806 100644
--- a/spacecmd/src/lib/misc.py
+++ b/spacecmd/src/lib/misc.py
@@ -137,6 +137,27 @@ def do_get_certificateexpiration(self, args):
 
 
 
+def help_is_monitoringenabled(self):
+print 'is_monitoringenabled: Indicates if monitoring is enabled '
+print   on the satellite   
+print 'usage: is_monitoringenabled'
+
+def do_is_monitoringenabled(self, args):
+monitoring = self.client.satellite.isMonitoringEnabled(self.session)
+print monitoring
+
+
+
+def help_list_proxies(self):
+print 'list_proxies: List the proxies wihtin the user\'s organization '
+print 'usage: list_proxies'
+
+def do_list_proxies(self, args):
+proxies = self.client.satellite.listProxies(self.session)
+print proxies
+
+
+
 def help_get_session(self):
 print 'get_session: Show the current session string'
 print 'usage: get_session'
-- 
1.8.3.1

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