rel-eng/packages/spacecmd | 2 -
spacecmd/spacecmd.spec | 5 ++-
spacecmd/src/lib/system.py | 68 +++++++++++++++++++++++++++++++++++++++------
spacecmd/src/lib/utils.py | 5 ++-
4 files changed, 69 insertions(+), 11 deletions(-)
New commits:
commit 0504adc9a79961fa2b340adef2354df3cca85970
Author: Aron Parsons <aparsons(a)redhat.com>
Date: Thu Dec 23 12:45:20 2010 -0500
Automatic commit of package [spacecmd] release [1.3.7-1].
diff --git a/rel-eng/packages/spacecmd b/rel-eng/packages/spacecmd
index c9c461f..fe5d588 100644
--- a/rel-eng/packages/spacecmd
+++ b/rel-eng/packages/spacecmd
@@ -1 +1 @@
-1.3.6-1 spacecmd/
+1.3.7-1 spacecmd/
diff --git a/spacecmd/spacecmd.spec b/spacecmd/spacecmd.spec
index a4741cc..ba6e156 100644
--- a/spacecmd/spacecmd.spec
+++ b/spacecmd/spacecmd.spec
@@ -4,7 +4,7 @@
%endif
Name: spacecmd
-Version: 1.3.6
+Version: 1.3.7
Release: 1%{?dist}
Summary: Command-line interface to Spacewalk and Satellite servers
@@ -61,6 +61,9 @@ touch %{buildroot}/%{python_sitelib}/spacecmd/__init__.py
%doc %{_mandir}/man1/spacecmd.1.gz
%changelog
+* Thu Dec 23 2010 Aron Parsons <aparsons(a)redhat.com> 1.3.7-1
+- added system_syncpackages function
+
* Wed Dec 22 2010 Aron Parsons <aparsons(a)redhat.com> 1.3.6-1
- added organization functions
commit 383da4175791e7de56e80f98c03c0aa89d6faab4
Author: Aron Parsons <aparsons(a)redhat.com>
Date: Thu Dec 23 12:41:39 2010 -0500
spacecmd: added system_syncpackages function
diff --git a/spacecmd/src/lib/system.py b/spacecmd/src/lib/system.py
index 162fb04..0fd47df 100644
--- a/spacecmd/src/lib/system.py
+++ b/spacecmd/src/lib/system.py
@@ -33,7 +33,7 @@ __PKG_COMPARISONS = { 0 : 'Same',
4 : 'Newer there' }
def print_package_comparison(self, results):
- max_name = max_length( map(itemgetter('package_name'), results) )
+ max_name = max_length(map(itemgetter('package_name'), results), min=7)
# sometimes 'this_system' or 'other_system' can be None
tmp_this = []
@@ -42,10 +42,10 @@ def print_package_comparison(self, results):
tmp_this.append(str(item.get('this_system')))
tmp_other.append(str(item.get('other_system')))
- max_this = max_length(tmp_this)
- max_other = max_length(tmp_other)
+ max_this = max_length(tmp_this, min=11)
+ max_other = max_length(tmp_other, min=12)
- max_comparison = 11
+ max_comparison = 10
# print headers
print '%s %s %s %s' % (
@@ -2365,10 +2365,7 @@ def help_system_comparepackages(self):
print 'usage: system_comparepackages SOME_SYSTEM ANOTHER_SYSTEM'
def complete_system_comparepackages(self, text, line, beg, end):
- parts = line.split(' ')
-
- if len(parts) < 3:
- return self.tab_complete_systems(text)
+ return tab_completer(self.get_system_names(), text)
def do_system_comparepackages(self, args):
(args, options) = parse_arguments(args)
@@ -2386,4 +2383,59 @@ def do_system_comparepackages(self, args):
self.print_package_comparison(results)
+####################
+
+def help_system_syncpackages(self):
+ print 'system_syncpackages: Sync packages between two systems'
+ print 'usage: system_syncpackages SOURCE TARGET'
+
+def complete_system_syncpackages(self, text, line, beg, end):
+ return tab_completer(self.get_system_names(), text)
+
+def do_system_syncpackages(self, args):
+ (args, options) = parse_arguments(args)
+
+ if len(args) != 2:
+ self.help_system_syncpackages()
+ return
+
+ (source, target) = args
+
+ source_id = self.get_system_id(source)
+ target_id = self.get_system_id(target)
+
+ if not source_id or not target_id:
+ return
+
+ # show a comparison and ask for confirmation
+ self.do_system_comparepackages('%s %s' % (source_id, target_id))
+
+ if not self.user_confirm('Sync packages [y/N]:'):
+ return
+
+ start_time = parse_time_input('now')
+
+ # get package IDs
+ packages = self.client.system.listPackages(self.session, source_id)
+
+ if self.check_api_version('10.16'):
+ package_ids = [p.get('id') for p in packages]
+ else:
+ package_names = build_package_names(packages)
+
+ package_ids = []
+
+ for name in package_names:
+ pkg_id = self.get_package_id(name)
+
+ # filter out invalid package IDs
+ if pkg_id:
+ package_ids.append(pkg_id)
+
+ self.client.system.scheduleSyncPackagesWithSystem(self.session,
+ target_id,
+ source_id,
+ package_ids,
+ start_time)
+
# vim:ts=4:expandtab:
commit 7b3ec891cf32c5337c5fef038c18e29412e7ae14
Author: Aron Parsons <aparsons(a)redhat.com>
Date: Thu Dec 23 12:41:13 2010 -0500
spacecmd: allow a minimum length in max_length()
diff --git a/spacecmd/src/lib/utils.py b/spacecmd/src/lib/utils.py
index baa9508..812f4db 100644
--- a/spacecmd/src/lib/utils.py
+++ b/spacecmd/src/lib/utils.py
@@ -442,12 +442,15 @@ def list_locales():
# find the longest string in a list
-def max_length(items):
+def max_length(items, min=0):
max_size = 1
for item in items:
if len(item) > max_size:
max_size = len(item)
+ if max_size < min:
+ max_size = min
+
return max_size