6 commits - client/tools
by Michael Mraka
client/tools/rhnpush/archive.py | 55 ++++++++++++++++++++----------------
client/tools/rhnpush/solaris2mpm.py | 21 ++++++++-----
2 files changed, 44 insertions(+), 32 deletions(-)
New commits:
commit b21f24b4001db14453f5e49e1b0975ccc374b7a1
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Nov 22 15:43:59 2011 +0100
replaced external zip with zipfile module
diff --git a/client/tools/rhnpush/archive.py b/client/tools/rhnpush/archive.py
index d716926..694009c 100644
--- a/client/tools/rhnpush/archive.py
+++ b/client/tools/rhnpush/archive.py
@@ -202,9 +202,11 @@ class ArchiveParser(object):
os.chdir(parent_dir)
zip_file = os.path.join(self._parent_dir, "%s.zip" % zip_dir)
-
- cmd = "zip -q -r %s %s" % (zip_file, zip_dir)
- stat = _my_popen(cmd)
+ fd = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED)
+ for base, dirs, files in os.walk(zip_dir):
+ fd.write(base)
+ for f in files:
+ fd.write(os.path.join(base, f))
os.chdir(cwd)
commit e88fe4d7ef91729a84a652e1b03481e99c3d1df9
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Nov 22 14:36:48 2011 +0100
replaced external tar with tarfile module
diff --git a/client/tools/rhnpush/archive.py b/client/tools/rhnpush/archive.py
index c3d49f7..d716926 100644
--- a/client/tools/rhnpush/archive.py
+++ b/client/tools/rhnpush/archive.py
@@ -21,6 +21,7 @@ import shutil
import tempfile
import select
import zipfile
+import tarfile
# exceptions -------------------------------------------------------------
@@ -249,20 +250,23 @@ class ZipParser(ArchiveParser):
# parser for tar archives ------------------------------------------------
class TarParser(ArchiveParser):
+ def __init__(self, archive, tempdir="/tmp/"):
+ self.tar_file = tarfile.open(archive, 'r')
+ ArchiveParser.__init__(self, archive, tempdir)
def _get_archive_dir(self):
- list_cmd = "tar -tf %s" % (self._archive,)
- return os.popen(list_cmd).readlines()[0][:-2]
-
- def _explode_cmd(self):
- """Return the appropriate command for exploding a tar archive"""
-
- if not _has_executable("tar"):
- raise ArchiveException("cannot open %s, 'tar' not found" % self._archive)
+ return self.tar_file.getnames()[0]
+ def _explode(self, archive):
+ """Explode tar archive"""
self._archive_dir = os.path.join(self._temp_dir, self._get_archive_dir())
- return "cd %s; tar xf %s" % (self._temp_dir, self._archive)
+ try:
+ self.tar_file.extractall(path=self._temp_dir)
+ except Exception, e:
+ raise InvalidArchiveError("Archive did not expand to %s: %s" %
+ (self._archive_dir, str(e)))
+ return
# parser for cpio archives -----------------------------------------------
commit fee88932ae0990f1ca91da160eb6069a27def06c
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Nov 22 14:07:44 2011 +0100
don't call os.path.join() over and over
diff --git a/client/tools/rhnpush/solaris2mpm.py b/client/tools/rhnpush/solaris2mpm.py
index 53ab6db..97086ab 100644
--- a/client/tools/rhnpush/solaris2mpm.py
+++ b/client/tools/rhnpush/solaris2mpm.py
@@ -369,11 +369,12 @@ def create_patch_mpm(archive_parser, prefix="", archive=""):
header.update(dct)
# a patch can patch multiple packages
- subdir = ''
+ patch_path = prefix
+ patch_path_with_subdir = os.path.join('patches/', patch_path)
# recent format has files in patches subdir
- if os.path.isdir(os.path.join(archive_parser._archive_dir, 'patches/', prefix)):
- subdir = 'patches/'
- pkgs, x = archive_parser.list(os.path.join(subdir, prefix))
+ if os.path.isdir(os.path.join(archive_parser._archive_dir, patch_path_with_subdir)):
+ patch_path = patch_path_with_subdir
+ pkgs, x = archive_parser.list(patch_path)
for pkg in pkgs:
pkginfo_file = os.path.join(prefix, pkg, 'pkginfo')
@@ -407,7 +408,7 @@ def create_patch_mpm(archive_parser, prefix="", archive=""):
header['package_size'] = os.path.getsize(archive)
package.payload_stream = open(archive)
else:
- zip_file = archive_parser.zip(os.path.join(subdir,prefix))
+ zip_file = archive_parser.zip(patch_path)
_temp_files.append(zip_file)
header['package_name'] = os.path.basename(zip_file)
commit 5543c3e8e5ef32baab50165094a27cd9f4f81c0c
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Nov 10 14:20:15 2011 +0100
don't read 2GB file into memory at once
fixing
Error creating mpm for 10_Recommended.zip: MemoryError()
diff --git a/client/tools/rhnpush/solaris2mpm.py b/client/tools/rhnpush/solaris2mpm.py
index 243fb3a..53ab6db 100644
--- a/client/tools/rhnpush/solaris2mpm.py
+++ b/client/tools/rhnpush/solaris2mpm.py
@@ -664,7 +664,12 @@ def md5sum_for_stream(data_stream):
format"""
md5obj = hashlib.new('md5')
- md5obj.update(data_stream.read())
+ while True:
+ buf = data_stream.read(1024000)
+ if buf:
+ md5obj.update(buf)
+ else:
+ break
data_stream.seek(0)
return md5obj.hexdigest()
commit 17bbe7bb16e6de39864f23f879e13e321687535a
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Nov 22 14:00:34 2011 +0100
don't hide original error message
diff --git a/client/tools/rhnpush/archive.py b/client/tools/rhnpush/archive.py
index 1818c48..c3d49f7 100644
--- a/client/tools/rhnpush/archive.py
+++ b/client/tools/rhnpush/archive.py
@@ -241,8 +241,9 @@ class ZipParser(ArchiveParser):
try:
self.zip_file.extractall(self._temp_dir)
- except:
- raise InvalidArchiveError("Archive did not expand to %s" % self._archive_dir)
+ except Exception, e:
+ raise InvalidArchiveError("Archive did not expand to %s: %s" %
+ (self._archive_dir, str(e)))
return
# parser for tar archives ------------------------------------------------
diff --git a/client/tools/rhnpush/solaris2mpm.py b/client/tools/rhnpush/solaris2mpm.py
index 1cc048c..243fb3a 100644
--- a/client/tools/rhnpush/solaris2mpm.py
+++ b/client/tools/rhnpush/solaris2mpm.py
@@ -235,8 +235,7 @@ def _run(archives=sys.argv[1:]):
raise MPMInputError("'%s' does not appear to contain Solaris content")
except Exception, e:
- print "Error creating mpm for %s:" % archive
- # print str(e)
+ print "Error creating mpm for %s: %s" % (archive, repr(e))
# cleanup as we go
if options.CLEANUP:
commit 52d29ee4980270fb62f9ffab40e94dc10f4b5e96
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Nov 10 10:18:50 2011 +0100
replaced external unzip with zipfile module
diff --git a/client/tools/rhnpush/archive.py b/client/tools/rhnpush/archive.py
index 8c9ea26..1818c48 100644
--- a/client/tools/rhnpush/archive.py
+++ b/client/tools/rhnpush/archive.py
@@ -20,6 +20,7 @@ import subprocess
import shutil
import tempfile
import select
+import zipfile
# exceptions -------------------------------------------------------------
@@ -227,23 +228,22 @@ class ArchiveParser(object):
# parser for zip archives ------------------------------------------------
class ZipParser(ArchiveParser):
+ def __init__(self, archive, tempdir="/tmp/"):
+ self.zip_file = zipfile.ZipFile(archive, 'r')
+ ArchiveParser.__init__(self, archive, tempdir)
def _get_archive_dir(self):
- list_cmd = "unzip -l %s" % (self._archive,)
- file = os.popen(list_cmd).readlines()[3].split()[3][:-1]
- # file is usually top most dir... but not always
- # take first directory from relative path
- return file.split('/')[0]
-
- def _explode_cmd(self):
- """Return the appropriate command for exploding a zip archive"""
-
- if not _has_executable("unzip"):
- raise ArchiveException("cannot open %s, 'unzip' not found" % self._archive)
+ return self.zip_file.namelist()[0]
+ def _explode(self, archive):
+ """Explode zip archive"""
self._archive_dir = os.path.join(self._temp_dir, self._get_archive_dir())
- return "unzip -q -n %s -d %s" % (self._archive, self._temp_dir)
+ try:
+ self.zip_file.extractall(self._temp_dir)
+ except:
+ raise InvalidArchiveError("Archive did not expand to %s" % self._archive_dir)
+ return
# parser for tar archives ------------------------------------------------
12 years, 4 months
Branch 'ipv6' - backend/server
by Miroslav Suchý
backend/server/rhnServer/server_hardware.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 8bcbe9c688373bbeee6b8dc5b3266e05fa694e96
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Nov 24 11:17:40 2011 +0100
IPv6: uploaded_iface is just reference to ifaces items, so modification of uploaded_iface will change iface as well and I want to avoid that
diff --git a/backend/server/rhnServer/server_hardware.py b/backend/server/rhnServer/server_hardware.py
index 98bdd5f..7b25d8e 100644
--- a/backend/server/rhnServer/server_hardware.py
+++ b/backend/server/rhnServer/server_hardware.py
@@ -439,7 +439,7 @@ class NetIfaceInformation(Device):
deletes.append({'server_id' : server_id, 'name' : name})
continue
- uploaded_iface = ifaces[name]
+ uploaded_iface = ifaces[name].copy()
del ifaces[name]
if _hash_eq(uploaded_iface, iface):
# Same value
12 years, 4 months
Changes to 'refs/tags/spacewalk-backend-1.6.42-1'
by aparsons
Tag 'spacewalk-backend-1.6.42-1' created by Aron Parsons <parsonsa(a)bit-sys.com> at 2011-11-23 20:29 +0000
Tagging package [spacewalk-backend] version [1.6.42-1] in directory [backend/].
Changes since spacecmd-1.6.9-1:
Aron Parsons (2):
improve performance of query_client_get_file on PostgreSQL
Automatic commit of package [spacewalk-backend] release [1.6.42-1].
---
backend/server/handlers/config/rhn_config_management.py | 8 ++++++--
backend/spacewalk-backend.spec | 6 +++++-
rel-eng/packages/spacewalk-backend | 2 +-
3 files changed, 12 insertions(+), 4 deletions(-)
---
12 years, 4 months
2 commits - backend/server backend/spacewalk-backend.spec rel-eng/packages
by aparsons
backend/server/handlers/config/rhn_config_management.py | 8 ++++++--
backend/spacewalk-backend.spec | 6 +++++-
rel-eng/packages/spacewalk-backend | 2 +-
3 files changed, 12 insertions(+), 4 deletions(-)
New commits:
commit aed4e55bdca8673a1d4dc200bdd71628a3f69464
Author: Aron Parsons <parsonsa(a)bit-sys.com>
Date: Wed Nov 23 15:29:55 2011 -0500
Automatic commit of package [spacewalk-backend] release [1.6.42-1].
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index a63e8d2..3da7a2f 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -12,7 +12,7 @@ Name: spacewalk-backend
Summary: Common programs needed to be installed on the Spacewalk servers/proxies
Group: Applications/Internet
License: GPLv2 and Python
-Version: 1.6.41
+Version: 1.6.42
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -675,6 +675,10 @@ rm -f %{rhnconf}/rhnSecret.py*
# $Id$
%changelog
+* Wed Nov 23 2011 Aron Parsons <parsonsa(a)bit-sys.com> 1.6.42-1
+- improve performance of query_client_get_file on PostgreSQL (parsonsa@bit-
+ sys.com)
+
* Wed Nov 23 2011 Jan Pazdziora 1.6.41-1
- Need to name a subselect.
diff --git a/rel-eng/packages/spacewalk-backend b/rel-eng/packages/spacewalk-backend
index d0b230f..1bababb 100644
--- a/rel-eng/packages/spacewalk-backend
+++ b/rel-eng/packages/spacewalk-backend
@@ -1 +1 @@
-1.6.41-1 backend/
+1.6.42-1 backend/
commit 1e64dc4546d96c58dd84a88c3c634b2d2ce164a4
Author: Aron Parsons <parsonsa(a)bit-sys.com>
Date: Wed Nov 23 15:27:22 2011 -0500
improve performance of query_client_get_file on PostgreSQL
use a nested query to join the rhnChecksumView instead of a left join,
which was terribly slow on PostgreSQL because it was doing a sequence
scan instead of an index scan on rhnChecksumView, which has millions of
rows
diff --git a/backend/server/handlers/config/rhn_config_management.py b/backend/server/handlers/config/rhn_config_management.py
index f65b98e..8eebd93 100644
--- a/backend/server/handlers/config/rhn_config_management.py
+++ b/backend/server/handlers/config/rhn_config_management.py
@@ -196,8 +196,12 @@ class ConfigManagement(configFilesHandler.ConfigFilesHandler):
rhnConfigRevision cr
left join rhnConfigContent ccont
on cr.config_content_id = ccont.id
- left join rhnChecksumView c
- on ccont.checksum_id = c.id,
+ left join
+ (select cs.id, cs.checksum_type, cs.checksum
+ from rhnChecksumView cs
+ inner join rhnConfigContent ccont
+ on ccont.checksum_id = cs.id) c
+ on c.id = ccont.checksum_id,
rhnServerConfigChannel scc,
rhnConfigFile cf,
rhnConfigFileType cft,
12 years, 4 months
Changes to 'refs/tags/spacecmd-1.6.9-1'
by aparsons
Tag 'spacecmd-1.6.9-1' created by Aron Parsons <parsonsa(a)bit-sys.com> at 2011-11-23 20:15 +0000
Tagging package [spacecmd] version [1.6.9-1] in directory [spacecmd/].
Changes since spacewalk-java-1.6.79-1:
Aron Parsons (7):
spacecmd: activationkey_clone cleanup
spacecmd: cosmetics
spacecmd: cosmetics
spacecmd: cleaned up error messages
spacecmd: changed some non-critical errors to warnings
spacecmd: fix some errors in system_runscript
Automatic commit of package [spacecmd] release [1.6.9-1].
Jan Pazdziora (1):
Removing contrib/rhn-clone-errata.py, it now lives in scripts/clone-errata/rhn-clone-errata.py.
Speagle, Andy (1):
Users can choose to sync all configured channels at once; default behavior has been changed with regard to errata missing packages.
Steve Hardy (3):
spacecmd enhancement : Add activationkey_export command
spacecmd enhancement : Add activationkey_import command
spacecmd enhancement : Add activationkey_clone command
---
contrib/rhn-clone-errata.py | 112 ----------
rel-eng/packages/spacecmd | 2
scripts/clone-errata/README | 15 +
scripts/clone-errata/rhn-clone-errata.py | 235 ++++++++++++---------
spacecmd/spacecmd.spec | 20 +
spacecmd/src/lib/activationkey.py | 337 +++++++++++++++++++++++++++++++
spacecmd/src/lib/system.py | 23 +-
spacecmd/src/lib/utils.py | 30 ++
8 files changed, 555 insertions(+), 219 deletions(-)
---
12 years, 4 months
10 commits - rel-eng/packages spacecmd/spacecmd.spec spacecmd/src
by aparsons
rel-eng/packages/spacecmd | 2
spacecmd/spacecmd.spec | 20 ++
spacecmd/src/lib/activationkey.py | 337 ++++++++++++++++++++++++++++++++++++++
spacecmd/src/lib/system.py | 23 +-
spacecmd/src/lib/utils.py | 30 +++
5 files changed, 399 insertions(+), 13 deletions(-)
New commits:
commit bdcf5e881724442be87ab87e12e356f91a548b1b
Author: Aron Parsons <parsonsa(a)bit-sys.com>
Date: Wed Nov 23 15:15:27 2011 -0500
Automatic commit of package [spacecmd] release [1.6.9-1].
diff --git a/rel-eng/packages/spacecmd b/rel-eng/packages/spacecmd
index 6e6f67f..af32ade 100644
--- a/rel-eng/packages/spacecmd
+++ b/rel-eng/packages/spacecmd
@@ -1 +1 @@
-1.6.7-1 spacecmd/
+1.6.9-1 spacecmd/
diff --git a/spacecmd/spacecmd.spec b/spacecmd/spacecmd.spec
index d5d5ece..d4e9c61 100644
--- a/spacecmd/spacecmd.spec
+++ b/spacecmd/spacecmd.spec
@@ -4,7 +4,7 @@
%endif
Name: spacecmd
-Version: 1.6.7
+Version: 1.6.9
Release: 1%{?dist}
Summary: Command-line interface to Spacewalk and Satellite servers
@@ -61,6 +61,24 @@ touch %{buildroot}/%{python_sitelib}/spacecmd/__init__.py
%doc %{_mandir}/man1/spacecmd.1.gz
%changelog
+* Wed Nov 23 2011 Aron Parsons <parsonsa(a)bit-sys.com> 1.6.9-1
+- spacecmd: fix some errors in system_runscript (parsonsa(a)bit-sys.com)
+- spacecmd: changed some non-critical errors to warnings (parsonsa(a)bit-sys.com)
+- spacecmd: cleaned up error messages (parsonsa(a)bit-sys.com)
+- spacecmd: activationkey_clone cleanup (parsonsa(a)bit-sys.com)
+- spacecmd enhancement : Add activationkey_clone command (shardy(a)redhat.com)
+- spacecmd enhancement : Add activationkey_import command (shardy(a)redhat.com)
+- spacecmd enhancement : Add activationkey_export command (shardy(a)redhat.com)
+
+* Wed Nov 23 2011 Aron Parsons <parsonsa(a)bit-sys.com>
+- spacecmd: fix some errors in system_runscript (parsonsa(a)bit-sys.com)
+- spacecmd: changed some non-critical errors to warnings (parsonsa(a)bit-sys.com)
+- spacecmd: cleaned up error messages (parsonsa(a)bit-sys.com)
+- spacecmd: activationkey_clone cleanup (parsonsa(a)bit-sys.com)
+- spacecmd enhancement : Add activationkey_clone command (shardy(a)redhat.com)
+- spacecmd enhancement : Add activationkey_import command (shardy(a)redhat.com)
+- spacecmd enhancement : Add activationkey_export command (shardy(a)redhat.com)
+
* Wed Nov 16 2011 Aron Parsons <aparsons(a)redhat.com> 1.6.7-1
- spacecmd: remove comma from softwarechannel_setorgaccess output
(aparsons(a)redhat.com)
commit 8ea73edad86104331f377b6c376097cfeb86689d
Author: Aron Parsons <parsonsa(a)bit-sys.com>
Date: Wed Nov 23 15:02:52 2011 -0500
spacecmd: fix some errors in system_runscript
diff --git a/spacecmd/src/lib/system.py b/spacecmd/src/lib/system.py
index ccc00b7..7080c4a 100644
--- a/spacecmd/src/lib/system.py
+++ b/spacecmd/src/lib/system.py
@@ -335,19 +335,19 @@ def do_system_runscript(self, args):
options.start_time = prompt_user('Start Time [now]:')
options.start_time = parse_time_input(options.start_time)
- script_file = prompt_user('Script File [create]:')
+ options.file = prompt_user('Script File [create]:')
# read the script provided by the user
- if script_file:
+ if options.file:
keep_script_file = True
- options.script = read_file(os.path.abspath(script_file))
+ script_contents = read_file(os.path.abspath(options.file))
else:
# have the user write their script
- (options.script, script_file) = editor('#!/bin/bash')
+ (script_contents, options.file) = editor('#!/bin/bash')
keep_script_file = False
- if not options.script:
+ if not script_contents:
logging.error('No script provided')
return
else:
@@ -360,7 +360,8 @@ def do_system_runscript(self, args):
logging.error('A script file is required')
return
- options.script = read_file(options.file)
+ script_contents = read_file(options.file)
+ keep_script_file = True
# display a summary
print
@@ -371,7 +372,7 @@ def do_system_runscript(self, args):
print
print 'Script Contents'
print '---------------'
- print options.script
+ print script_contents
# have the user confirm
if not self.user_confirm(): return
@@ -389,7 +390,7 @@ def do_system_runscript(self, args):
options.user,
options.group,
options.timeout,
- options.script,
+ script_contents,
options.start_time)
logging.info('Action ID: %i' % action_id)
@@ -408,7 +409,7 @@ def do_system_runscript(self, args):
options.user,
options.group,
options.timeout,
- options.script,
+ script_contents,
options.start_time)
logging.info('Action ID: %i' % action_id)
@@ -422,9 +423,9 @@ def do_system_runscript(self, args):
# don't delete a pre-existing script that the user provided
if not keep_script_file:
try:
- os.remove(script_file)
+ os.remove(options.file)
except OSError:
- logging.error('Could not remove %s' % script_file)
+ logging.error('Could not remove %s' % options.file)
####################
commit 59b48c006f6a4262d5f05a298ead4a1ac76c4e30
Author: Aron Parsons <parsonsa(a)bit-sys.com>
Date: Wed Nov 23 14:29:25 2011 -0500
spacecmd: changed some non-critical errors to warnings
diff --git a/spacecmd/src/lib/activationkey.py b/spacecmd/src/lib/activationkey.py
index e8134bb..aad3208 100644
--- a/spacecmd/src/lib/activationkey.py
+++ b/spacecmd/src/lib/activationkey.py
@@ -1061,8 +1061,7 @@ def import_activationkey_fromdetails(self, keydetails):
existing_keys = self.do_activationkey_list('', True)
if keydetails['key'] in existing_keys:
- logging.error("ERROR : key %s already exists! Skipping!" % \
- keydetails['key'])
+ logging.warning("%s already exists! Skipping!" % keydetails['key'])
return False
else:
# create the key, we need to drop the org prefix from the key name
@@ -1216,7 +1215,7 @@ def do_activationkey_clone(self, args):
new_child_channel_labels.append(newc)
else:
- logging.error("Found child channel %s key %s, but %s" % \
+ logging.warning("Found child channel %s key %s, but %s" % \
(c, keydetails['key'], newc) + \
" does not exist, skipping!")
@@ -1241,7 +1240,7 @@ def do_activationkey_clone(self, args):
new_config_channels.append(newcc)
else:
- logging.error("Found config channel %s for key %s, but %s " % \
+ logging.warning("Found config channel %s for key %s, but %s " % \
(cc, keydetails['key'], newcc) + \
"does not exist, skipping!")
commit 6781aa1ad6819588d9f406ae85cc2ca262bedaa0
Author: Aron Parsons <parsonsa(a)bit-sys.com>
Date: Wed Nov 23 14:25:38 2011 -0500
spacecmd: cleaned up error messages
diff --git a/spacecmd/src/lib/activationkey.py b/spacecmd/src/lib/activationkey.py
index 7152d5b..e8134bb 100644
--- a/spacecmd/src/lib/activationkey.py
+++ b/spacecmd/src/lib/activationkey.py
@@ -996,8 +996,7 @@ def do_activationkey_export(self, args):
(args, keys))
if (len(keys) == 0):
- logging.error("Error, no valid key passed, check key-name is " + \
- " correct with spacecmd activationkey_list")
+ logging.error("Invalid activation key passed")
return
if len(filename) == 0:
@@ -1026,7 +1025,7 @@ def do_activationkey_export(self, args):
return
if json_dump_to_file(keydetails_list, filename) != True:
- logging.error("Error saving exported keys to file" % filename)
+ logging.error("Failed to save exported keys to file" % filename)
return
####################
@@ -1053,7 +1052,7 @@ def do_activationkey_import(self, args):
for keydetails in keydetails_list:
if self.import_activationkey_fromdetails(keydetails) != True:
- logging.error("Error importing activationkey %s" % \
+ logging.error("Failed to import key %s" % \
keydetails['key'])
# create a new key based on the dict from export_activationkey_getdetails
@@ -1087,7 +1086,7 @@ def import_activationkey_fromdetails(self, keydetails):
keydetails['entitlements'],
keydetails['universal_default'])
if len(newkey) == 0:
- logging.error("Error, activation key import failed for %s" % \
+ logging.error("Failed to import key %s" % \
keyname)
return False
@@ -1226,7 +1225,7 @@ def do_activationkey_clone(self, args):
keydetails['child_channel_labels'] = new_child_channel_labels
else:
- logging.error("Error, regex-replacement results in new " + \
+ logging.error("Regex-replacement results in new " + \
"base-channel %s which does not exist!" % newbasech)
# Finally, any config-channels
@@ -1253,7 +1252,7 @@ def do_activationkey_clone(self, args):
# Finally : import the key from the modified keydetails dict
if self.import_activationkey_fromdetails(keydetails) != True:
- logging.error("Error cloning activationkey %s to %s" % \
+ logging.error("Failed to clone %s to %s" % \
(options.name, options.clonename))
# vim:ts=4:expandtab:
commit 29bf21fb886c8c2ad738f37e9d7079a44cc36d82
Author: Aron Parsons <parsonsa(a)bit-sys.com>
Date: Wed Nov 23 14:23:14 2011 -0500
spacecmd: cosmetics
diff --git a/spacecmd/src/lib/activationkey.py b/spacecmd/src/lib/activationkey.py
index 43481b3..7152d5b 100644
--- a/spacecmd/src/lib/activationkey.py
+++ b/spacecmd/src/lib/activationkey.py
@@ -920,8 +920,9 @@ def do_activationkey_setuniversaldefault(self, args):
####################
def help_activationkey_export(self):
- print 'activationkey_export: export activation key(s) to json format file'
- print '''usage: activationkey_export <KEY> <KEY> [options]
+ print 'activationkey_export: Export activation key(s) to JSON format file'
+ print '''usage: activationkey_export [options] [<KEY> ...]
+
options:
-f outfile.json : specify an output filename, defaults to <KEY>.json
if exporting a single key, akeys.json for multiple keys,
@@ -946,6 +947,7 @@ def export_activationkey_getdetails(self, key):
except Exception, E:
logging.debug("activationkey.listConfigChannel threw an exeception, \
probably not provisioning entitled, setting config_channels=False")
+
cclist = [ c['label'] for c in ccdlist ]
logging.debug("Got config channel label list of %s" % cclist)
details['config_channels'] = cclist
@@ -961,8 +963,10 @@ def export_activationkey_getdetails(self, key):
grp_detail_list=[]
for grp in details['server_group_ids']:
grp_details = self.client.systemgroup.getDetails(self.session, grp)
+
if grp_details:
grp_detail_list.append(grp_details)
+
details['server_groups'] = [ g['name'] for g in grp_detail_list ]
# Now append the details dict describing the key to the specified file
@@ -990,10 +994,12 @@ def do_activationkey_export(self, args):
keys = filter_results(self.do_activationkey_list('', True), args)
logging.debug("activationkey_export called with args %s, keys=%s" % \
(args, keys))
+
if (len(keys) == 0):
logging.error("Error, no valid key passed, check key-name is " + \
" correct with spacecmd activationkey_list")
return
+
if len(filename) == 0:
# No filename arg, so we try to do something sensible:
# If we are exporting exactly one key, we default to keyname.json
@@ -1011,12 +1017,14 @@ def do_activationkey_export(self, args):
logging.debug("About to dump %d keys to %s" % \
(len(keydetails_list), filename))
+
# Check if filepath exists, if it is an existing file
# we prompt the user for confirmation
if os.path.isfile(filename):
if not self.user_confirm("File %s exists, confirm overwrite file? (y/n)" % \
filename):
return
+
if json_dump_to_file(keydetails_list, filename) != True:
logging.error("Error saving exported keys to file" % filename)
return
@@ -1024,23 +1032,25 @@ def do_activationkey_export(self, args):
####################
def help_activationkey_import(self):
- print 'activationkey_import: import activation key(s) from json file'
- print '''usage: activationkey_import <JSONFILES...>'''
+ print 'activationkey_import: import activation key(s) from JSON file(s)'
+ print '''usage: activationkey_import <JSONFILE ...>'''
def do_activationkey_import(self, args):
(args, options) = parse_arguments(args)
if len(args) == 0:
- logging.error("Error, no filename passed")
+ logging.error("No filename passed")
self.help_activationkey_import()
return
for filename in args:
logging.debug("Passed filename do_activationkey_import %s" % filename)
keydetails_list = json_read_from_file(filename)
+
if len(keydetails_list) == 0:
- logging.error("Error, could not read json data from %s" % filename)
+ logging.error("Could not read json data from %s" % filename)
return
+
for keydetails in keydetails_list:
if self.import_activationkey_fromdetails(keydetails) != True:
logging.error("Error importing activationkey %s" % \
@@ -1048,9 +1058,9 @@ def do_activationkey_import(self, args):
# create a new key based on the dict from export_activationkey_getdetails
def import_activationkey_fromdetails(self, keydetails):
-
# First we check that an existing key with the same name does not exist
existing_keys = self.do_activationkey_list('', True)
+
if keydetails['key'] in existing_keys:
logging.error("ERROR : key %s already exists! Skipping!" % \
keydetails['key'])
@@ -1060,6 +1070,7 @@ def import_activationkey_fromdetails(self, keydetails):
keyname = re.sub('^[0-9]-', '', keydetails['key'])
logging.info("Found key %s, importing as %s" % \
(keydetails['key'], keyname))
+
if keydetails['usage_limit'] != 0:
newkey = self.client.activationkey.create(self.session,
keyname,
@@ -1079,9 +1090,11 @@ def import_activationkey_fromdetails(self, keydetails):
logging.error("Error, activation key import failed for %s" % \
keyname)
return False
+
# add child channels
self.client.activationkey.addChildChannels(self.session, newkey,\
keydetails['child_channel_labels'])
+
# set config channel options and channels (missing are skipped)
if keydetails['config_deploy'] != 0:
self.client.activationkey.enableConfigDeployment(self.session,\
@@ -1089,9 +1102,11 @@ def import_activationkey_fromdetails(self, keydetails):
else:
self.client.activationkey.disableConfigDeployment(self.session,\
newkey)
+
if len(keydetails['config_channels']) > 0:
self.client.activationkey.addConfigChannels(self.session, [newkey],\
keydetails['config_channels'], False)
+
# set groups (missing groups are created)
gids = []
for grp in keydetails['server_groups']:
@@ -1101,8 +1116,10 @@ def import_activationkey_fromdetails(self, keydetails):
grpdetails = self.client.systemgroup.create(self.session, grp,\
grp)
gids.append(grpdetails.get('id'))
+
logging.debug("Adding groups %s to key %s" % (gids, newkey))
self.client.activationkey.addServerGroups(self.session, newkey, gids)
+
# Finally add the package list
self.client.activationkey.addPackages(self.session, newkey, \
keydetails['packages'])
commit ef0f7397d04f159301e2717a03df93b6d8f88160
Author: Aron Parsons <parsonsa(a)bit-sys.com>
Date: Wed Nov 23 14:18:04 2011 -0500
spacecmd: cosmetics
diff --git a/spacecmd/src/lib/activationkey.py b/spacecmd/src/lib/activationkey.py
index 3921e3b..43481b3 100644
--- a/spacecmd/src/lib/activationkey.py
+++ b/spacecmd/src/lib/activationkey.py
@@ -1189,6 +1189,7 @@ def do_activationkey_clone(self, args):
# If it doesn't we can only skip it and print a warning
all_childch = self.list_child_channels(system=None,\
parent=newbasech, subscribed=False)
+
new_child_channel_labels = []
for c in keydetails['child_channel_labels']:
newc = re.sub(findstr, replacestr, c)
@@ -1196,13 +1197,16 @@ def do_activationkey_clone(self, args):
logging.debug("Found child channel %s for key %s, " % \
(c, keydetails['key']) + \
"replacing with %s" % newc)
+
new_child_channel_labels.append(newc)
else:
logging.error("Found child channel %s key %s, but %s" % \
(c, keydetails['key'], newc) + \
" does not exist, skipping!")
+
logging.debug("Processed all child channels, " + \
"new_child_channel_labels=%s" % new_child_channel_labels)
+
keydetails['child_channel_labels'] = new_child_channel_labels
else:
logging.error("Error, regex-replacement results in new " + \
@@ -1213,17 +1217,21 @@ def do_activationkey_clone(self, args):
allccs = self.do_configchannel_list('', True)
for cc in keydetails['config_channels']:
newcc = re.sub(findstr, replacestr, cc)
+
if newcc in allccs:
logging.debug("Found config channel %s for key %s, " % \
(cc, keydetails['key']) + \
"replacing with %s" % newcc)
+
new_config_channels.append(newcc)
else:
logging.error("Found config channel %s for key %s, but %s " % \
(cc, keydetails['key'], newcc) + \
"does not exist, skipping!")
+
logging.debug("Processed all config channels, " + \
"new_config_channels = %s" % new_config_channels)
+
keydetails['config_channels'] = new_config_channels
# Finally : import the key from the modified keydetails dict
commit fd9ad7a0209c3749b052c1e7028938ee084d6789
Author: Aron Parsons <parsonsa(a)bit-sys.com>
Date: Wed Nov 23 14:16:54 2011 -0500
spacecmd: activationkey_clone cleanup
diff --git a/spacecmd/src/lib/activationkey.py b/spacecmd/src/lib/activationkey.py
index 341d60c..3921e3b 100644
--- a/spacecmd/src/lib/activationkey.py
+++ b/spacecmd/src/lib/activationkey.py
@@ -1112,7 +1112,7 @@ def import_activationkey_fromdetails(self, keydetails):
####################
def help_activationkey_clone(self):
- print 'activationkey_clone: Clone a Kickstart profile'
+ print 'activationkey_clone: Clone an activation key'
print '''usage: activationkey_clone [options]
options:
@@ -1140,26 +1140,24 @@ def do_activationkey_clone(self, args):
print '\n'.join(sorted(allkeys))
print
- options.name = prompt_user('Origianl Profile:', noblank = True)
+ options.name = prompt_user('Original Key:', noblank = True)
- options.clonename = prompt_user('Cloned Profile:', noblank = True)
+ options.clonename = prompt_user('Cloned Key:', noblank = True)
else:
-
if not options.name:
- logging.error('The Activationkey name is required')
+ logging.error('The --name option is required')
return
if not options.clonename:
- logging.error('The Activationkey clone name is required')
+ logging.error('The --clonename option is required')
return
if not options.name in allkeys:
- logging.error("Error, key %s does not seem to exist satellite?"\
- % options.name)
+ logging.error("Key %s does not exist" % options.name)
return
if options.clonename in allkeys:
- logging.error("Error, clone name %s already exists!" % options.name)
+ logging.error("Key %s already exists" % options.clonename)
return
# Replace the key-name with the clonename specified by the user
@@ -1233,5 +1231,4 @@ def do_activationkey_clone(self, args):
logging.error("Error cloning activationkey %s to %s" % \
(options.name, options.clonename))
-
# vim:ts=4:expandtab:
commit 165ab4ca10c021a1893933719c3d85bee06e8272
Author: Steve Hardy <shardy(a)redhat.com>
Date: Thu Nov 17 17:55:04 2011 +0000
spacecmd enhancement : Add activationkey_clone command
Add new command to clone activationkeys, including regex-replacement
of the key content
Signed-off-by: Steve Hardy <shardy(a)redhat.com>
Signed-off-by: Aron Parsons <parsonsa(a)bit-sys.com>
diff --git a/spacecmd/src/lib/activationkey.py b/spacecmd/src/lib/activationkey.py
index bccc324..341d60c 100644
--- a/spacecmd/src/lib/activationkey.py
+++ b/spacecmd/src/lib/activationkey.py
@@ -1109,4 +1109,129 @@ def import_activationkey_fromdetails(self, keydetails):
return True
+####################
+
+def help_activationkey_clone(self):
+ print 'activationkey_clone: Clone a Kickstart profile'
+ print '''usage: activationkey_clone [options]
+
+options:
+ -n NAME : Name of the key to be cloned
+ -c CLONE_NAME : Name of the resulting key
+ -x "s/foo/bar" : Optional regex replacement, replaces foo with bar in the
+ clone description, base-channel label, child-channel
+ labels, config-channel names '''
+
+def complete_activationkey_clone(self, text, line, beg, end):
+ return tab_completer(self.do_activationkey_list('', True), text)
+
+def do_activationkey_clone(self, args):
+ options = [ Option('-n', '--name', action='store'),
+ Option('-c', '--clonename', action='store'),
+ Option('-x', '--regex', action='store') ]
+
+ (args, options) = parse_arguments(args, options)
+ allkeys = self.do_activationkey_list('', True)
+
+ if is_interactive(options):
+ print
+ print 'Activation Keys'
+ print '------------------'
+ print '\n'.join(sorted(allkeys))
+ print
+
+ options.name = prompt_user('Origianl Profile:', noblank = True)
+
+ options.clonename = prompt_user('Cloned Profile:', noblank = True)
+ else:
+
+ if not options.name:
+ logging.error('The Activationkey name is required')
+ return
+
+ if not options.clonename:
+ logging.error('The Activationkey clone name is required')
+ return
+
+ if not options.name in allkeys:
+ logging.error("Error, key %s does not seem to exist satellite?"\
+ % options.name)
+ return
+
+ if options.clonename in allkeys:
+ logging.error("Error, clone name %s already exists!" % options.name)
+ return
+
+ # Replace the key-name with the clonename specified by the user
+ keydetails = self.export_activationkey_getdetails(options.name)
+ keydetails['key'] = options.clonename
+
+ # If the -x/--regex option is passed, do a sed-style replacement over
+ # everything contained by the key. This makes it easier to clone when
+ # content is based on a known naming convention
+ if options.regex:
+ # Expect this option to be formatted like a sed-replacement, s/foo/bar
+ findstr = options.regex.split("/")[1]
+ replacestr = options.regex.split("/")[2]
+ logging.debug("Regex option selected with %s, replacing %s with %s" % \
+ (options.regex, findstr, replacestr))
+
+ # First we do the description
+ newdesc = re.sub(findstr, replacestr, keydetails['description'])
+ keydetails['description'] = newdesc
+
+ # Then the base-channel label
+ newbasech = re.sub(findstr, replacestr, \
+ keydetails['base_channel_label'])
+ if newbasech in self.list_base_channels():
+ keydetails['base_channel_label'] = newbasech
+ # Now iterate over any child-channel labels
+ # Since we have the new base-channel, we can check if the new child
+ # label exists under the new base-channel:
+ # If it doesn't we can only skip it and print a warning
+ all_childch = self.list_child_channels(system=None,\
+ parent=newbasech, subscribed=False)
+ new_child_channel_labels = []
+ for c in keydetails['child_channel_labels']:
+ newc = re.sub(findstr, replacestr, c)
+ if newc in all_childch:
+ logging.debug("Found child channel %s for key %s, " % \
+ (c, keydetails['key']) + \
+ "replacing with %s" % newc)
+ new_child_channel_labels.append(newc)
+ else:
+ logging.error("Found child channel %s key %s, but %s" % \
+ (c, keydetails['key'], newc) + \
+ " does not exist, skipping!")
+ logging.debug("Processed all child channels, " + \
+ "new_child_channel_labels=%s" % new_child_channel_labels)
+ keydetails['child_channel_labels'] = new_child_channel_labels
+ else:
+ logging.error("Error, regex-replacement results in new " + \
+ "base-channel %s which does not exist!" % newbasech)
+
+ # Finally, any config-channels
+ new_config_channels = []
+ allccs = self.do_configchannel_list('', True)
+ for cc in keydetails['config_channels']:
+ newcc = re.sub(findstr, replacestr, cc)
+ if newcc in allccs:
+ logging.debug("Found config channel %s for key %s, " % \
+ (cc, keydetails['key']) + \
+ "replacing with %s" % newcc)
+ new_config_channels.append(newcc)
+ else:
+ logging.error("Found config channel %s for key %s, but %s " % \
+ (cc, keydetails['key'], newcc) + \
+ "does not exist, skipping!")
+ logging.debug("Processed all config channels, " + \
+ "new_config_channels = %s" % new_config_channels)
+ keydetails['config_channels'] = new_config_channels
+
+ # Finally : import the key from the modified keydetails dict
+ if self.import_activationkey_fromdetails(keydetails) != True:
+ logging.error("Error cloning activationkey %s to %s" % \
+ (options.name, options.clonename))
+
+
# vim:ts=4:expandtab:
commit a18748f55be11a740e7bd29942832ca3bd3dbfbd
Author: Steve Hardy <shardy(a)redhat.com>
Date: Thu Nov 17 17:48:52 2011 +0000
spacecmd enhancement : Add activationkey_import command
Adds option to import activationkeys from JSON files as generated
with spacecmd activationkey_export
Signed-off-by: Steve Hardy <shardy(a)redhat.com>
Signed-off-by: Aron Parsons <parsonsa(a)bit-sys.com>
diff --git a/spacecmd/src/lib/activationkey.py b/spacecmd/src/lib/activationkey.py
index 221ba6d..bccc324 100644
--- a/spacecmd/src/lib/activationkey.py
+++ b/spacecmd/src/lib/activationkey.py
@@ -1021,4 +1021,92 @@ def do_activationkey_export(self, args):
logging.error("Error saving exported keys to file" % filename)
return
+####################
+
+def help_activationkey_import(self):
+ print 'activationkey_import: import activation key(s) from json file'
+ print '''usage: activationkey_import <JSONFILES...>'''
+
+def do_activationkey_import(self, args):
+ (args, options) = parse_arguments(args)
+
+ if len(args) == 0:
+ logging.error("Error, no filename passed")
+ self.help_activationkey_import()
+ return
+
+ for filename in args:
+ logging.debug("Passed filename do_activationkey_import %s" % filename)
+ keydetails_list = json_read_from_file(filename)
+ if len(keydetails_list) == 0:
+ logging.error("Error, could not read json data from %s" % filename)
+ return
+ for keydetails in keydetails_list:
+ if self.import_activationkey_fromdetails(keydetails) != True:
+ logging.error("Error importing activationkey %s" % \
+ keydetails['key'])
+
+# create a new key based on the dict from export_activationkey_getdetails
+def import_activationkey_fromdetails(self, keydetails):
+
+ # First we check that an existing key with the same name does not exist
+ existing_keys = self.do_activationkey_list('', True)
+ if keydetails['key'] in existing_keys:
+ logging.error("ERROR : key %s already exists! Skipping!" % \
+ keydetails['key'])
+ return False
+ else:
+ # create the key, we need to drop the org prefix from the key name
+ keyname = re.sub('^[0-9]-', '', keydetails['key'])
+ logging.info("Found key %s, importing as %s" % \
+ (keydetails['key'], keyname))
+ if keydetails['usage_limit'] != 0:
+ newkey = self.client.activationkey.create(self.session,
+ keyname,
+ keydetails['description'],
+ keydetails['base_channel_label'],
+ keydetails['usage_limit'],
+ keydetails['entitlements'],
+ keydetails['universal_default'])
+ else:
+ newkey = self.client.activationkey.create(self.session,
+ keyname,
+ keydetails['description'],
+ keydetails['base_channel_label'],
+ keydetails['entitlements'],
+ keydetails['universal_default'])
+ if len(newkey) == 0:
+ logging.error("Error, activation key import failed for %s" % \
+ keyname)
+ return False
+ # add child channels
+ self.client.activationkey.addChildChannels(self.session, newkey,\
+ keydetails['child_channel_labels'])
+ # set config channel options and channels (missing are skipped)
+ if keydetails['config_deploy'] != 0:
+ self.client.activationkey.enableConfigDeployment(self.session,\
+ newkey)
+ else:
+ self.client.activationkey.disableConfigDeployment(self.session,\
+ newkey)
+ if len(keydetails['config_channels']) > 0:
+ self.client.activationkey.addConfigChannels(self.session, [newkey],\
+ keydetails['config_channels'], False)
+ # set groups (missing groups are created)
+ gids = []
+ for grp in keydetails['server_groups']:
+ grpdetails = self.client.systemgroup.getDetails(self.session, grp)
+ if grpdetails == None:
+ logging.info("System group %s doesn't exist, creating" % grp)
+ grpdetails = self.client.systemgroup.create(self.session, grp,\
+ grp)
+ gids.append(grpdetails.get('id'))
+ logging.debug("Adding groups %s to key %s" % (gids, newkey))
+ self.client.activationkey.addServerGroups(self.session, newkey, gids)
+ # Finally add the package list
+ self.client.activationkey.addPackages(self.session, newkey, \
+ keydetails['packages'])
+
+ return True
+
# vim:ts=4:expandtab:
diff --git a/spacecmd/src/lib/utils.py b/spacecmd/src/lib/utils.py
index 491b1c4..2ee4c4e 100644
--- a/spacecmd/src/lib/utils.py
+++ b/spacecmd/src/lib/utils.py
@@ -580,4 +580,17 @@ def json_dump_to_file(obj, filename, indent = 2):
return True
+def json_read_from_file(filename):
+ try:
+ data = open(filename).read()
+ try:
+ jsondata = json.loads(data)
+ return jsondata
+ except:
+ print "could not read in data from %s" % filename
+ except IOError, E:
+ if verbose:
+ print "could not open file %s for reading, check permissions?" % filename
+ return None
+
# vim:ts=4:expandtab:
commit e1c18dc76a8e102450930a90cb8ee4a0c1256a1b
Author: Steve Hardy <shardy(a)redhat.com>
Date: Thu Nov 17 17:47:59 2011 +0000
spacecmd enhancement : Add activationkey_export command
Adds command which exports activationkeys to JSON format files
Signed-off-by: Steve Hardy <shardy(a)redhat.com>
Signed-off-by: Aron Parsons <parsonsa(a)bit-sys.com>
diff --git a/spacecmd/src/lib/activationkey.py b/spacecmd/src/lib/activationkey.py
index 519201f..221ba6d 100644
--- a/spacecmd/src/lib/activationkey.py
+++ b/spacecmd/src/lib/activationkey.py
@@ -917,4 +917,108 @@ def do_activationkey_setuniversaldefault(self, args):
self.client.activationkey.setDetails(self.session, key, details)
+####################
+
+def help_activationkey_export(self):
+ print 'activationkey_export: export activation key(s) to json format file'
+ print '''usage: activationkey_export <KEY> <KEY> [options]
+options:
+ -f outfile.json : specify an output filename, defaults to <KEY>.json
+ if exporting a single key, akeys.json for multiple keys,
+ or akey_all.json of no KEY specified (export ALL)
+
+Note : KEY list is optional, default is to export ALL keys '''
+
+def complete_activationkey_export(self, text, line, beg, end):
+ return tab_completer(self.do_activationkey_list('', True), text)
+
+def export_activationkey_getdetails(self, key):
+ # Get the key details
+ logging.info("Getting activation key details for %s" % key)
+ details = self.client.activationkey.getDetails(self.session, key)
+
+ # Get the key config-channel data, add it to the existing details
+ logging.debug("activationkey.listConfigChannels %s" % key)
+ ccdlist = []
+ try:
+ ccdlist = self.client.activationkey.listConfigChannels(self.session, \
+ key)
+ except Exception, E:
+ logging.debug("activationkey.listConfigChannel threw an exeception, \
+ probably not provisioning entitled, setting config_channels=False")
+ cclist = [ c['label'] for c in ccdlist ]
+ logging.debug("Got config channel label list of %s" % cclist)
+ details['config_channels'] = cclist
+
+ logging.debug("activationkey.checkConfigDeployment %s" % key)
+ details['config_deploy'] = \
+ self.client.activationkey.checkConfigDeployment(self.session, key)
+
+ # Get group details, as the server group IDs are not necessarily the same
+ # across servers, so we need the group name on import
+ details['server_groups'] = []
+ if len(details['server_group_ids']) != 0:
+ grp_detail_list=[]
+ for grp in details['server_group_ids']:
+ grp_details = self.client.systemgroup.getDetails(self.session, grp)
+ if grp_details:
+ grp_detail_list.append(grp_details)
+ details['server_groups'] = [ g['name'] for g in grp_detail_list ]
+
+ # Now append the details dict describing the key to the specified file
+ return details
+
+def do_activationkey_export(self, args):
+ options = [ Option('-f', '--file', action='store') ]
+ (args, options) = parse_arguments(args, options)
+
+ filename=""
+ if options.file != None:
+ logging.debug("Passed filename do_activationkey_export %s" % \
+ options.file)
+ filename=options.file
+
+ # Get the list of keys to export and sort out the filename if required
+ keys=[]
+ if not len(args):
+ if len(filename) == 0:
+ filename="akey_all.json"
+ logging.info("Exporting ALL activation keys to %s" % filename)
+ keys = self.do_activationkey_list('', True)
+ else:
+ # allow globbing of activationkey channel names
+ keys = filter_results(self.do_activationkey_list('', True), args)
+ logging.debug("activationkey_export called with args %s, keys=%s" % \
+ (args, keys))
+ if (len(keys) == 0):
+ logging.error("Error, no valid key passed, check key-name is " + \
+ " correct with spacecmd activationkey_list")
+ return
+ if len(filename) == 0:
+ # No filename arg, so we try to do something sensible:
+ # If we are exporting exactly one key, we default to keyname.json
+ # otherwise, generic akeys.json name
+ if len(keys) == 1:
+ filename="%s.json" % keys[0]
+ else:
+ filename="akeys.json"
+
+ # Dump as a list of dict
+ keydetails_list=[]
+ for k in keys:
+ logging.info("Exporting key %s to %s" % (k, filename))
+ keydetails_list.append(self.export_activationkey_getdetails(k))
+
+ logging.debug("About to dump %d keys to %s" % \
+ (len(keydetails_list), filename))
+ # Check if filepath exists, if it is an existing file
+ # we prompt the user for confirmation
+ if os.path.isfile(filename):
+ if not self.user_confirm("File %s exists, confirm overwrite file? (y/n)" % \
+ filename):
+ return
+ if json_dump_to_file(keydetails_list, filename) != True:
+ logging.error("Error saving exported keys to file" % filename)
+ return
+
# vim:ts=4:expandtab:
diff --git a/spacecmd/src/lib/utils.py b/spacecmd/src/lib/utils.py
index a8fd5ee..491b1c4 100644
--- a/spacecmd/src/lib/utils.py
+++ b/spacecmd/src/lib/utils.py
@@ -562,5 +562,22 @@ def parse_api_args(args, sep=','):
def json_dump(obj, fp, indent=2, **kwargs):
json.dump(obj, fp, ensure_ascii=False, indent=indent, **kwargs)
+def json_dump_to_file(obj, filename, indent = 2):
+
+ json_data = json.dumps(obj, indent)
+ if json_data == None:
+ logging.error("Could not generate json data object!" % k)
+ return False
+ try:
+ fd = open(filename, 'w')
+ fd.write(json_data)
+ fd.close()
+ except IOError, E:
+ logging.error("Could not open file %s for writing, permissions?" % \
+ filename)
+ print E.strerror
+ return False
+
+ return True
# vim:ts=4:expandtab:
12 years, 4 months
Branch 'ipv6' - backend/server
by Miroslav Suchý
backend/server/rhnServer/server_hardware.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 952a131c6efe1753222e58ff9e00a5a37fe5e74d
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Nov 23 16:34:04 2011 +0100
IPv6: params is list of dictionaries, do the filtering level up
diff --git a/backend/server/rhnServer/server_hardware.py b/backend/server/rhnServer/server_hardware.py
index 2fac31b..98bdd5f 100644
--- a/backend/server/rhnServer/server_hardware.py
+++ b/backend/server/rhnServer/server_hardware.py
@@ -611,6 +611,8 @@ class NetIfaceAddress(Device):
address = iface['address']
if not self.ifaces.has_key(iface['address']):
# To be deleted
+ # filter out params, which are not used in query
+ iface = dict((column, iface[column]) for column in self.unique)
deletes.append(iface)
continue
uploaded_iface = ifaces[address]
@@ -654,9 +656,7 @@ class NetIfaceAddress(Device):
columns = self.unique
wheres = map(lambda x: '%s = :%s' % (x, x), columns)
h = rhnSQL.prepare(q % (self.table, string.join(wheres, " and ")))
- # filter out params, which are not used in query
- bind_params = dict((c, params[c]) for c in columns)
- return _dml(h, bind_params)
+ return _dml(h, params)
def _update(self, params):
q = """update %s
12 years, 4 months
2 commits - contrib/rhn-clone-errata.py scripts/clone-errata
by Jan Pazdziora
contrib/rhn-clone-errata.py | 112 --------------
scripts/clone-errata/README | 15 +
scripts/clone-errata/rhn-clone-errata.py | 235 ++++++++++++++++++-------------
3 files changed, 156 insertions(+), 206 deletions(-)
New commits:
commit 82788f843583c33827dc660d0f64960c419c4d76
Author: Speagle, Andy <andy.speagle(a)wichita.edu>
Date: Wed Nov 23 16:28:24 2011 +0100
Users can choose to sync all configured channels at once; default behavior has been changed with regard to errata missing packages.
diff --git a/scripts/clone-errata/README b/scripts/clone-errata/README
index 0ea1010..8076ed2 100644
--- a/scripts/clone-errata/README
+++ b/scripts/clone-errata/README
@@ -36,6 +36,13 @@ options:
-e EDATE, --end-date=EDATE
Ending Date: ie. "19001231" (defaults to TODAY)
-i, --publish Publish Errata (into destination channels)
+ -I, --ignoremissing Default behavior is to skip errata for which
+ there are missing packages, this option
+ allows the errata to be created without
+ packages that it should have.
+ -A, --sync-all-channels
+ This option clones errata for all channels
+ configured in the config file.
-x PROXY, --proxy=PROXY
Proxy server and port to use (e.g.
proxy.company.com:3128)
@@ -54,3 +61,11 @@ options:
I'm presently working on adding in support for CVEs
but am running into an issue. Probably done in
version 1.6 ...
+
+2011/11/17 - Andy speagle
+
+ Default behavior of how errata with missing packages
+ are handled has been changed. If an errata is missing
+ packages, the script will now, by default, skip creating
+ that errata. You can use "-I" to ignore missing packages
+ and continue creating the errata.
diff --git a/scripts/clone-errata/rhn-clone-errata.py b/scripts/clone-errata/rhn-clone-errata.py
index 0ddfe87..1374858 100644
--- a/scripts/clone-errata/rhn-clone-errata.py
+++ b/scripts/clone-errata/rhn-clone-errata.py
@@ -90,6 +90,18 @@
#
# Add some code to handle transparent proxies.
#
+# 0.9.0 - 2011-11-17 - Andy Speagle
+#
+# Included patch from Pierre Casenove <pcasenove(a)gmail.com> that gives an option for a
+# full sync of all channels listed in the configuration file.
+#
+# Thanks, Pierre!
+#
+# Additionally, changed the default behaviour of how the script handles errata that are
+# missing packages on the system. The script now skips any errata that is missing one
+# or more packages on the system. However, I've added an option to allow the script
+# to ignore missing packages so that the old behaviour remains.
+#
import xmlrpclib, httplib
from optparse import OptionParser
@@ -559,6 +571,8 @@ def parse_args():
help="Ending Date: ie. \"19001231\" (defaults to TODAY)")
parser.add_option("-i", "--publish", action="store_true", dest="publish", default=False,
help="Publish Errata (into destination channels)")
+ parser.add_option("-I", "--ignore-missing-packages", action="store_true", dest="ignoremissing", default=False,
+ help="Ignore Missing Packages")
parser.add_option("-x", "--proxy", type="string", dest="proxy",
help="Proxy server and port to use (e.g. proxy.company.com:3128)")
parser.add_option("--no-spw-proxy", action="store_true", dest="nospwproxy", default=False,
@@ -567,6 +581,8 @@ def parse_args():
help="Don't proxy the RHN server connection. (Proxy by default, if proxy is set)")
parser.add_option("-F", "--format-header", action="store_true", dest="format", default=False,
help="Format header for logfiles")
+ parser.add_option("-A", "--sync-all-channels", action="store_true", dest="fullsync", default=False,
+ help="Synchronize erratas of all channels listed in the provided configuration file")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False)
parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False)
@@ -616,8 +632,14 @@ def main():
chanMap = {}
- for chan in config.options('ChanMap'):
- chanMap[chan] = config.get('ChanMap', chan)
+ if options.fullsync:
+ for chan in config.options('ChanMap'):
+ chanMap[chan] = config.get('ChanMap', chan)
+ else:
+ if options.src_channel is None:
+ print "Source channel not given, aborting"
+ sys.exit(2)
+ chanMap[options.src_channel] = config.get('ChanMap', options.src_channel)
# Here we also setup mappings from RHN channels to errata suffixes.
# Since we can't easily publish automagically, while ensuring that
@@ -643,10 +665,6 @@ def main():
print "try: "+sys.argv[0]+" --help"
sys.exit(2)
- if chanMap[options.src_channel] is None:
- print "Invalid Channel!"
- sys.exit(2)
-
rhnProxy = 0
spwProxy = 0
@@ -663,98 +681,127 @@ def main():
dateToday = strftime("%Y%m%d", localtime())
dateEnd = options.edate or dateToday
- if options.format:
- print >>sys.stdout, "%s:CLONE:%s" % (dateToday, options.src_channel)
- print >>sys.stderr, "%s:CLONE:%s" % (dateToday, options.src_channel)
-
- for rhnErrata in myRHN.listChannelErrata(options.src_channel,dateStart,dateEnd,0):
- if not options.quiet and not options.format:
- print rhnErrata['errata_advisory']
-
-# Now, let's check if we already have this errata locally...
- spwErrataName = rhnErrata['errata_advisory']+':'+chanSuffixMap[options.src_channel]
- spwErrCheck = mySPW.getErrataDetails (spwErrataName,0)
-
- if not spwErrCheck:
-# Ok, so the errata doesn't already exists... let's get busy creating it.
- spwErrSolution = "Before applying this update, make sure that all "+\
- "previously-released errata relevant to your system have been applied."
-
- spwErrPackages = []
- for pkg in myRHN.getErrataPackages(rhnErrata['errata_advisory'],0):
- pkgFind = mySPW.searchNVREA(pkg['package_name'],\
- pkg['package_version'],\
- pkg['package_release'],\
- '',\
- pkg['package_arch_label'],\
- 0)
-
- for pkgChan in pkg['providing_channels']:
- if pkgChan != options.src_channel:
- continue
- else:
- if not pkgFind:
- if options.format:
- print >>sys.stderr, "%s:%s:Hmmm... "+\
- "Package Missing: %s" % (dateToday, rhnErrata['errata_advisory'], pkg['package_name'])
- else:
- print "Hmmm... Package Missing: %s" % pkg['package_name']
- else:
- spwErrPackages.append(pkgFind[0]['id'])
- break
+ for chan in chanMap:
+ if chanMap[chan] is None:
+ print "Invalid Channel!"
+ sys.exit(2)
- spwErrDetails = myRHN.getErrataDetails(rhnErrata['errata_advisory'],0)
- spwErrKeywords = myRHN.getErrataKeywords(rhnErrata['errata_advisory'],0)
- spwErrCVEs = myRHN.getErrataCVEs(rhnErrata['errata_advisory'],0)
+ if options.format:
+ print >>sys.stdout, "%s:CLONE:%s" % (dateToday, chan)
+ print >>sys.stderr, "%s:CLONE:%s" % (dateToday, chan)
- spwErrBugs = []
- tmpBugs = myRHN.getErrataBugs(rhnErrata['errata_advisory'],0)
+ for rhnErrata in myRHN.listChannelErrata(chan,dateStart,dateEnd,0):
+ if not options.quiet and not options.format:
+ print rhnErrata['errata_advisory']
- for bug in tmpBugs:
- spwErrBugs.append({'id': int(bug), 'summary': tmpBugs[bug]})
+# Now, let's check if we already have this errata locally...
+ spwErrataName = rhnErrata['errata_advisory']+':'+chanSuffixMap[chan]
+ spwErrCheck = mySPW.getErrataDetails (spwErrataName,0)
- if not options.quiet and not options.format:
- print "\t%s - %s" % (spwErrDetails['errata_issue_date'],spwErrDetails['errata_synopsis'])
-
- spwErrObject = mySPW.errataCreate ({ 'synopsis': spwErrDetails['errata_synopsis'],\
- 'advisory_name': spwErrataName,\
- 'advisory_release': 1,\
- 'advisory_type': spwErrDetails['errata_type'],\
- 'product': 'RHEL',\
- 'topic': spwErrDetails['errata_topic'],\
- 'description': spwErrDetails['errata_description'],\
- 'references': spwErrDetails['errata_references'],\
- 'notes': spwErrDetails['errata_notes'],\
- 'solution': spwErrSolution },\
- spwErrBugs,\
- spwErrKeywords,\
- spwErrPackages,\
- 0,\
- [chanMap[options.src_channel]],\
- 0)
-
- if options.format:
- print "%s#%s#Errata Created#" % (dateToday, spwErrataName),
- else:
- print "\tErrata Created: %d" % spwErrObject['id']
-
- if options.publish:
- spwPublish = mySPW.errataPublish (spwErrataName, [chanMap[options.src_channel]], 0)
- if options.format:
- print "Errata Published"
- else:
- print "\tErrata Published!"
- else:
- if options.format:
- print "Errata Not Published"
- else:
- print "\tErrata Not Published!"
- else:
- if options.format:
- print "%s#%s#Errata Already Exists" % (dateToday, spwErrataName)
- elif not options.quiet:
- print "\tErrata Already Exists. %s" % spwErrataName
- continue
+ if not spwErrCheck:
+# Ok, so the errata doesn't already exists... let's get busy creating it.
+ spwErrSolution = "Before applying this update, make sure that all "+\
+ "previously-released errata relevant to your system have been applied."
+
+ spwErrPackages = []
+
+ missingcheck = 0
+
+ for pkg in myRHN.getErrataPackages(rhnErrata['errata_advisory'],0):
+ pkgFind = mySPW.searchNVREA(pkg['package_name'],\
+ pkg['package_version'],\
+ pkg['package_release'],\
+ '',\
+ pkg['package_arch_label'],\
+ 0)
+
+ for pkgChan in pkg['providing_channels']:
+ if pkgChan != chan:
+ continue
+ else:
+ if not pkgFind:
+ missingcheck += 1
+
+ if options.format:
+ print >>sys.stderr, "%s:%s:Hmmm... "+\
+ "Package Missing: %s" % (dateToday, rhnErrata['errata_advisory'], pkg['package_name'])
+ else:
+ print "Hmmm... Package Missing: %s" % pkg['package_name']
+
+ else:
+ spwErrPackages.append(pkgFind[0]['id'])
+ break
+
+ if missingcheck:
+ if options.ignoremissing:
+ skiptext = "Ignoring missing package(s) and continuing..."
+
+ if options.format:
+ print >>sys.stderr, "%s" % skiptext
+ else:
+ print "%s" % skiptext
+ else:
+ skiptext = "Skipping errata due to missing package(s)..."
+
+ if options.format:
+ print >>sys.stderr, "%s" % skiptext
+ else:
+ print "%s" % skiptext
+
+ continue
+
+ spwErrDetails = myRHN.getErrataDetails(rhnErrata['errata_advisory'],0)
+ spwErrKeywords = myRHN.getErrataKeywords(rhnErrata['errata_advisory'],0)
+ spwErrCVEs = myRHN.getErrataCVEs(rhnErrata['errata_advisory'],0)
+
+ spwErrBugs = []
+ tmpBugs = myRHN.getErrataBugs(rhnErrata['errata_advisory'],0)
+
+ for bug in tmpBugs:
+ spwErrBugs.append({'id': int(bug), 'summary': tmpBugs[bug]})
+
+ if not options.quiet and not options.format:
+ print "\t%s - %s" % (spwErrDetails['errata_issue_date'],spwErrDetails['errata_synopsis'])
+
+ spwErrObject = mySPW.errataCreate ({ 'synopsis': spwErrDetails['errata_synopsis'],\
+ 'advisory_name': spwErrataName,\
+ 'advisory_release': 1,\
+ 'advisory_type': spwErrDetails['errata_type'],\
+ 'product': 'RHEL',\
+ 'topic': spwErrDetails['errata_topic'],\
+ 'description': spwErrDetails['errata_description'],\
+ 'references': spwErrDetails['errata_references'],\
+ 'notes': spwErrDetails['errata_notes'],\
+ 'solution': spwErrSolution },\
+ spwErrBugs,\
+ spwErrKeywords,\
+ spwErrPackages,\
+ 0,\
+ [chanMap[chan]],\
+ 0)
+
+ if options.format:
+ print "%s#%s#Errata Created#" % (dateToday, spwErrataName),
+ else:
+ print "\tErrata Created: %d" % spwErrObject['id']
+
+ if options.publish:
+ spwPublish = mySPW.errataPublish (spwErrataName, [chanMap[chan]], 0)
+ if options.format:
+ print "Errata Published"
+ else:
+ print "\tErrata Published!"
+ else:
+ if options.format:
+ print "Errata Not Published"
+ else:
+ print "\tErrata Not Published!"
+ else:
+ if options.format:
+ print "%s#%s#Errata Already Exists" % (dateToday, spwErrataName)
+ elif not options.quiet:
+ print "\tErrata Already Exists. %s" % spwErrataName
+ continue
if __name__ == "__main__":
main()
commit 4662c52e523c6e8b595458aa9f909fba6c6b4be9
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Wed Nov 23 16:22:15 2011 +0100
Removing contrib/rhn-clone-errata.py, it now lives in scripts/clone-errata/rhn-clone-errata.py.
diff --git a/contrib/rhn-clone-errata.py b/contrib/rhn-clone-errata.py
deleted file mode 100755
index e929975..0000000
--- a/contrib/rhn-clone-errata.py
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/bin/env python
-# API Script used to communicate with RHN Satellite
-# Copyright (C) 2008 Red Hat
-#
-# Author: Lars Jonsson (ljonsson(a)redhat.com)
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-
-import xmlrpclib
-from optparse import OptionParser
-import sys
-
-class RHNServer:
- def __init__(self,servername,user,passwd):
- self.rhnServerName = servername
- self.login = user
- self.password = passwd
- self.rhnUrl = 'https://'+self.rhnServerName+'/rpc/api'
- self.server = xmlrpclib.Server(self.rhnUrl)
- self.rhnSession=self.rhnLogin(self.login,self.password)
-
- def rhnLogin(self, login, password):
- try:
- rhnSession=self.server.auth.login(login,password)
- except xmlrpclib.Fault, f:
- if f.faultCode==-20:
- print "Session expired"
- self.rhnLogin(login,password)
- else:
- print "Failed to login",f
- raise
- return rhnSession
-
- def cloneErrata(self,dest_chan,errata):
- out=[]
- try:
- print "Clone errata in progress, please be patient.."
- out = self.server.errata.clone(self.rhnSession,dest_chan,errata)
- except xmlrpclib.Fault, f:
- if f.faultCode==-20:
- self.rhnLogin(self.login,self.password)
- return self.server.errata.clone(self.rhnSession,dest_chan,errata)
- else:
- raise
- return out
-
- def listChannelErrata(self,channel_label):
- out=[]
- try:
- out = self.server.errata.listByDate(self.rhnSession,channel_label)
- except xmlrpclib.Fault, f:
- if f.faultCode==-20:
- self.rhnLogin(self.login,self.password)
- return self.server.errata.listByDate(self.rhnSession,channel_label)
- else:
- raise
- return out
-
-def parse_args():
- parser = OptionParser()
- parser.add_option("-s", "--server", type="string", dest="servername",
- help="RHN Satellite server hostname")
- parser.add_option("-l", "--login", type="string", dest="login",
- help="RHN Login")
- parser.add_option("-p", "--password", type="string", dest="passwd",
- help="RHN password")
- parser.add_option("", "--src-channel", type="string", dest="src_channel",
- help="channel label: ie.\"rhel-i386-as-4\"")
- parser.add_option("", "--dest-channel", type="string", dest="dest_channel",
- help="channel label: ie.\"my-rhel-i386-as-4\"")
- parser.add_option("", "--clone-up-to-date", type="string", dest="cdate",
- help="Date: ie. \"20080403T16:53:00\"")
- parser.add_option("", "--list", action="store_true", dest="list", default=False,
- help="List source channel errata by date")
-
- (options,args) = parser.parse_args()
- return options
-
-def main():
-
- options = parse_args()
-
- if (options.servername and options.login and options.passwd) is None:
- print "try: "+sys.argv[0]+" --help"
- sys.exit(2)
- myserver = RHNServer(options.servername,options.login,options.passwd)
-
- if options.list and options.src_channel:
- for c in myserver.listChannelErrata(options.src_channel):
- print "%s\t%s (%s)" % (c['date'],c['advisory_synopsis'],c['advisory_name'])
- if options.cdate:
- aerrata = []
- for c in myserver.listChannelErrata(options.src_channel):
- if c['date'] <= options.cdate:
- aerrata.append(c['advisory_name'])
- myserver.cloneErrata(options.dest_channel, aerrata)
-
-if __name__ == "__main__":
- main()
12 years, 4 months
Branch 'ipv6' - 2 commits - backend/server
by Miroslav Suchý
backend/server/rhnServer/server_hardware.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
New commits:
commit 97d2de42f4f2e5fc64e9eab459b79fd8d2a24d28
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Nov 23 16:22:12 2011 +0100
IPv6: filter out params, which are not used in query
addressing:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/spacewalk/server/apacheRequest.py", line 123, in call_function
response = apply(func, params)
File "/usr/share/rhn/server/handlers/xmlrpc/registration.py", line 999, in refresh_hw_profile
server.save_hardware()
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_wrapper.py", line 90, in save_hardware
ret = self.save_hardware_byid(self.server["id"])
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_hardware.py", line 917, in save_hardware_byid
hw.save(sysid)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_hardware.py", line 473, in save
info['ipv6'].save(self.get_server_id(server_id, name))
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_hardware.py", line 635, in save
self._delete(deletes)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_hardware.py", line 657, in _delete
return _dml(h, params)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_hardware.py", line 742, in _dml
rowcount = apply(statement.executemany, (), params)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 172, in executemany
return apply(self._execute_wrapper, (self._executemany, ) + p, kw)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnSQL/driver_cx_Oracle.py", line 108, in _execute_wrapper
retval = apply(function, p, kw)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnSQL/driver_cx_Oracle.py", line 208, in _executemany
self._real_cursor.executemany(None, arr)
SQLError: (1036, 'ORA-01036: illegal variable name/number\n', 'delete from rhnServerNetAddress6 where interface_id =
+:interface_id and address = :address and scope = :scope')
diff --git a/backend/server/rhnServer/server_hardware.py b/backend/server/rhnServer/server_hardware.py
index 43a465f..2fac31b 100644
--- a/backend/server/rhnServer/server_hardware.py
+++ b/backend/server/rhnServer/server_hardware.py
@@ -654,7 +654,9 @@ class NetIfaceAddress(Device):
columns = self.unique
wheres = map(lambda x: '%s = :%s' % (x, x), columns)
h = rhnSQL.prepare(q % (self.table, string.join(wheres, " and ")))
- return _dml(h, params)
+ # filter out params, which are not used in query
+ bind_params = dict((c, params[c]) for c in columns)
+ return _dml(h, bind_params)
def _update(self, params):
q = """update %s
commit b28d0d9f41c015293013cfe47f95d78f32e17e82
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Nov 23 15:51:19 2011 +0100
IPv6: do not pass to oracle more params then is necessary
oracle binds all parameter it get and if it could match the type to
some SQL type it will raise an error.
Exception Handler Information
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/spacewalk/server/apacheRequest.py", line 123, in call_function
response = apply(func, params)
File "/usr/share/rhn/server/handlers/xmlrpc/registration.py", line 999, in refresh_hw_profile
server.save_hardware()
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_wrapper.py", line 90, in save_hardware
ret = self.save_hardware_byid(self.server["id"])
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_hardware.py", line 913, in save_hardware_byid
hw.save(sysid)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_hardware.py", line 463, in save
self._update(updates)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_hardware.py", line 528, in _update
return _dml(h, params)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnServer/server_hardware.py", line 738, in _dml
rowcount = apply(statement.executemany, (), params)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 172, in executemany
return apply(self._execute_wrapper, (self._executemany, ) + p, kw)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnSQL/driver_cx_Oracle.py", line 108, in _execute_wrapper
retval = apply(function, p, kw)
File "/usr/lib/python2.4/site-packages/spacewalk/server/rhnSQL/driver_cx_Oracle.py", line 208, in _executemany
self._real_cursor.executemany(None, arr)
SQLError: (None, 'Variable_TypeByValue(): unhandled data type instance', 'update rhnServerNetInterface set hw_addr =
+:hw_addr, module = :module where server_id = :server_id and name = :name')
diff --git a/backend/server/rhnServer/server_hardware.py b/backend/server/rhnServer/server_hardware.py
index 68073da..43a465f 100644
--- a/backend/server/rhnServer/server_hardware.py
+++ b/backend/server/rhnServer/server_hardware.py
@@ -445,6 +445,10 @@ class NetIfaceInformation(Device):
# Same value
continue
uploaded_iface.update({'name' : name, 'server_id' : server_id})
+ if 'ipv4' in uploaded_iface:
+ del(uploaded_iface['ipv4'])
+ if 'ipv6' in uploaded_iface:
+ del(uploaded_iface['ipv6'])
updates.append(uploaded_iface)
# Everything else in self.ifaces has to be inserted
12 years, 4 months
Changes to 'refs/tags/spacewalk-java-1.6.79-1'
by Jan Pazdziora
Tag 'spacewalk-java-1.6.79-1' created by Jan Pazdziora <jpazdziora(a)redhat.com> at 2011-11-23 15:13 +0000
Tagging package [spacewalk-java] version [1.6.79-1] in directory [java/].
Changes since spacewalk-schema-1.6.29-1:
Jan Pazdziora (2):
No scrubbing of key description and custom key value, also escape the value which can now contain full range of characters.
Automatic commit of package [spacewalk-java] release [1.6.79-1].
---
java/code/webapp/WEB-INF/pages/systems/sdc/listcustomdata.jsp | 2 +-
java/code/webapp/WEB-INF/struts-config.xml | 2 ++
java/spacewalk-java.spec | 6 +++++-
rel-eng/packages/spacewalk-java | 2 +-
4 files changed, 9 insertions(+), 3 deletions(-)
---
12 years, 4 months