6 commits - client/debian rel-eng/packages
by Šimon Lukašík
client/debian/apt-spacewalk/spacewalk.py | 263 ---------------------
client/debian/apt-spacewalk/src/50spacewalk | 13 +
client/debian/apt-spacewalk/src/apt-spacewalk.spec | 25 +
client/debian/apt-spacewalk/src/post_invoke.py | 35 ++
client/debian/apt-spacewalk/src/pre_invoke.py | 77 ++++++
client/debian/apt-spacewalk/src/spacewalk | 262 ++++++++++++++++++++
rel-eng/packages/apt-spacewalk | 1
7 files changed, 413 insertions(+), 263 deletions(-)
New commits:
commit e0ad96408f7e69b529d4570ebb2dd45492b3644c
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Thu Mar 17 17:41:58 2011 +0100
Automatic commit of package [apt-spacewalk] release [1.0.1-1].
diff --git a/client/debian/apt-spacewalk/src/apt-spacewalk.spec b/client/debian/apt-spacewalk/src/apt-spacewalk.spec
index f3441e2..6888177 100644
--- a/client/debian/apt-spacewalk/src/apt-spacewalk.spec
+++ b/client/debian/apt-spacewalk/src/apt-spacewalk.spec
@@ -20,3 +20,6 @@ to acquire content from Spacewalk server
%defattr(-,root,root,-)
%changelog
+* Thu Mar 17 2011 Simon Lukasik <slukasik(a)redhat.com> 1.0.1-1
+- new package
+
diff --git a/rel-eng/packages/apt-spacewalk b/rel-eng/packages/apt-spacewalk
new file mode 100644
index 0000000..70aaad7
--- /dev/null
+++ b/rel-eng/packages/apt-spacewalk
@@ -0,0 +1 @@
+1.0.1-1 client/debian/apt-spacewalk/src/
commit 07f002a1823de0388694f8911b264f06a8268434
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Thu Mar 17 17:41:02 2011 +0100
Added dummy spec file for Tito to track versions and build tgz
diff --git a/client/debian/apt-spacewalk/src/apt-spacewalk.spec b/client/debian/apt-spacewalk/src/apt-spacewalk.spec
new file mode 100644
index 0000000..f3441e2
--- /dev/null
+++ b/client/debian/apt-spacewalk/src/apt-spacewalk.spec
@@ -0,0 +1,22 @@
+# This is a dummy spec file used by tito
+# only for tagging and building tarballs
+
+Name: apt-spacewalk
+Summary: Spacewalk plugin for Advanced Packaging tool.
+Version: 1.0.1
+Release: 1%{?dist}
+License: GPLv2
+Source0: https://example.com/%{name}-%{version}.tar.gz
+URL: https://fedorahosted.org/spacewalk
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildArch: noarch
+BuildRequires: python
+
+%description
+apt-spacewalk is plugin used on Debian clients
+to acquire content from Spacewalk server
+
+%files
+%defattr(-,root,root,-)
+
+%changelog
commit 4cf9326504ec257638e07fe4b778d04716e0521c
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Sun Mar 13 21:16:25 2011 +0100
Configuration file for APT
diff --git a/client/debian/apt-spacewalk/src/50spacewalk b/client/debian/apt-spacewalk/src/50spacewalk
new file mode 100644
index 0000000..dc4f918
--- /dev/null
+++ b/client/debian/apt-spacewalk/src/50spacewalk
@@ -0,0 +1,13 @@
+#
+# The configuration for apt-spacewalk
+#
+
+APT {
+ List-Refresh "true";
+ Update::Pre-Invoke {
+ "/usr/lib/apt-spacewalk/pre_invoke.py";
+ };
+};
+DPkg::Post-Invoke {
+ "/usr/lib/apt-spacewalk/post_invoke.py";
+};
commit 42679763bfd2ff92841cc708a07488394ff077c4
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Sun Mar 13 21:15:07 2011 +0100
The hook for updating sources.list
diff --git a/client/debian/apt-spacewalk/src/pre_invoke.py b/client/debian/apt-spacewalk/src/pre_invoke.py
new file mode 100755
index 0000000..2610eba
--- /dev/null
+++ b/client/debian/apt-spacewalk/src/pre_invoke.py
@@ -0,0 +1,77 @@
+#!/usr/bin/python
+#
+# APT::Update::Pre-Invoke hook for updating sources.list
+#
+# Author: Simon Lukasik
+# Date: 2011-03-14
+# License: GPLv2
+#
+#
+
+import sys
+import os
+from urlparse import urlparse
+from aptsources import sourceslist
+import apt_pkg
+
+# Once we have the up2date stuff in a site-packages,
+# we don't have to do path magic
+import warnings
+warnings.filterwarnings("ignore",
+ message='the md5 module is deprecated; use hashlib instead')
+sys.path.append('/usr/share/rhn/')
+from up2date_client import config
+from up2date_client import rhnChannel
+from up2date_client import up2dateAuth
+from up2date_client import up2dateErrors
+
+
+def get_channels():
+ """Return channels associated with a machine"""
+ try:
+ channels = ['main']
+ for channel in rhnChannel.getChannelDetails():
+ if channel['parent_channel']:
+ channels.append(channel['label'])
+ return channels
+ except up2dateErrors.Error:
+ return []
+
+def get_server():
+ """Spacewalk server fqdn"""
+ up2date_cfg = config.initUp2dateConfig()
+ return urlparse(up2date_cfg['serverURL']).netloc
+
+def get_conf_file():
+ """Path to spacewalk.list configuration file"""
+ apt_pkg.init_config()
+ directory = apt_pkg.config.get('Dir::Etc::sourceparts',
+ 'sources.list.d')
+ if not os.path.isabs(directory):
+ directory = os.path.join('/etc/apt', directory)
+ return os.path.join(directory, 'spacewalk.list')
+
+def update_sources_list():
+ sources = sourceslist.SourcesList()
+ sw_source = []
+ for source in sources.list:
+ if source.uri.startswith('spacewalk://'):
+ source.set_enabled(False)
+ sw_source.append(source)
+
+ if up2dateAuth.getSystemId():
+ channels = get_channels()
+ if len(channels):
+ for source in sw_source:
+ sources.remove(source)
+ sources.add(type='deb',
+ uri='spacewalk://' + get_server(),
+ dist='channels:',
+ orig_comps=channels,
+ file=get_conf_file()
+ )
+ sources.save()
+
+if __name__ == '__main__':
+ print "Apt-Spacewalk: Updating sources.list"
+ update_sources_list()
commit e5ba1f4e81638ba42eccd3be85382b07d1fe7cfd
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Sun Mar 13 21:14:29 2011 +0100
The hook for updating Debian package profile
diff --git a/client/debian/apt-spacewalk/src/post_invoke.py b/client/debian/apt-spacewalk/src/post_invoke.py
new file mode 100755
index 0000000..4183b9f
--- /dev/null
+++ b/client/debian/apt-spacewalk/src/post_invoke.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+#
+# DPkg::Post-Invoke hook for updating Debian package profile
+#
+# Author: Simon Lukasik
+# Date: 2011-03-14
+# License: GPLv2
+#
+#
+
+import sys
+
+# Once we have the up2date stuff in a site-packages,
+# we won't have to do path magic.
+import warnings
+warnings.filterwarnings("ignore",
+ message='the md5 module is deprecated; use hashlib instead')
+sys.path.append("/usr/share/rhn/")
+from up2date_client import up2dateAuth
+from up2date_client import up2dateErrors
+from up2date_client import rhnserver
+from up2date_client import rpmUtils
+
+
+if __name__ == '__main__':
+ systemid = up2dateAuth.getSystemId()
+ if systemid:
+ try:
+ print "Apt-Spacewalk: Updating package profile"
+ s = rhnserver.RhnServer()
+ s.registration.update_packages(systemid,
+ rpmUtils.getInstalledPackageList(getArch=1))
+ except up2dateErrors.RhnServerException, e:
+ print "Package profile information could not be sent."
+ print str(e)
commit 80a91b84c69ca4a993185d56006c6c84c922dfc6
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Sun Mar 13 21:13:33 2011 +0100
Spacewalk method was moved to src directory
diff --git a/client/debian/apt-spacewalk/spacewalk.py b/client/debian/apt-spacewalk/spacewalk.py
deleted file mode 100755
index d1faedf..0000000
--- a/client/debian/apt-spacewalk/spacewalk.py
+++ /dev/null
@@ -1,263 +0,0 @@
-#!/usr/bin/python -u
-#
-# Very early prototype of apt-transport-spacewalk
-#
-# Author: Simon Lukasik <xlukas08 [at] stud.fit.vutbr.cz>
-# Date: 2011-01-01
-# License: GPLv2
-#
-#
-
-import sys
-import re
-import hashlib
-
-import warnings
-warnings.filterwarnings("ignore", message="the md5 module is deprecated; use hashlib instead")
-sys.path.append("/usr/share/rhn/")
-
-from urlparse import urlparse
-from rhn.connections import HTTPConnection, HTTPSConnection
-from up2date_client import config
-from up2date_client import rhnChannel
-from up2date_client import up2dateAuth
-from up2date_client import up2dateErrors
-
-
-
-class pkg_acquire_method:
- """
- This is slightly modified python variant of apt-pkg/acquire-method.
- It is a skeleton class that implements only very basic of apt methods
- functionality.
- """
- __eof = False
-
- def __init__(self):
- print "100 Capabilities\nVersion: 1.0\nSingle-Instance: true\n\n",
-
- def __get_next_msg(self):
- """
- Apt uses for communication with its methods the text protocol similar
- to http. This function parses the protocol messages from stdin.
- """
- if self.__eof:
- return None
- result = {};
- line = sys.stdin.readline()
- if not line:
- self.__eof = True
- return None
- s = line.split(" ", 1)
- result['_number'] = int(s[0])
- result['_text'] = s[1].strip()
-
- while not self.__eof:
- line = sys.stdin.readline()
- if not line:
- self.__eof = True
- return result
- if line == '\n':
- return result
- s = line.split(":", 1)
- result[s[0]] = s[1].strip()
-
- def __dict2msg(self, msg):
- """Convert dictionary to http like message"""
- result = ""
- for item in msg.keys():
- if msg[item] != None:
- result += item + ": " + msg[item] + "\n"
- return result
-
- def status(self, **kwargs):
- print "102 Status\n%s\n" % self.__dict2msg(kwargs),
-
- def uri_start(self, msg):
- print "200 URI Start\n%s\n" % self.__dict2msg(msg),
-
- def uri_done(self, msg):
- print "201 URI Done\n%s\n" % self.__dict2msg(msg),
-
- def uri_failure(self, msg):
- print "400 URI Failure\n%s\n" % self.__dict2msg(msg),
-
- def run(self):
- """Loop through requests on stdin"""
- while True:
- msg = self.__get_next_msg()
- if msg == None:
- return 0
- if msg['_number'] == 600:
- try:
- self.fetch(msg)
- except Exception, e:
- self.fail(e.__class__.__name__ + ": " + str(e))
- except up2dateErrors.Error, e:
- self.fail(e.__class__.__name__ + ": " + str(e))
- else:
- return 100
-
-
-
-def get_ssl_ca_cert(up2date_cfg):
- if not (up2date_cfg.has_key('sslCACert') and up2date_cfg['sslCACert']):
- raise BadSslCaCertConfig
-
- ca_certs = up2date_cfg['sslCACert']
- if type(ca_certs) == list:
- return ca_certs
- return [ca_certs]
-
-
-
-class spacewalk_method(pkg_acquire_method):
- """
- Spacewalk acquire method
- """
- up2date_cfg = None
- login_info = None
- current_url = None
- svr_channels = None
- http_headers = None
- base_channel = None
- conn = None
- not_registered_msg = 'This system is not registered with the spacewalk server'
-
- def fail(self, message = not_registered_msg):
- self.uri_failure({'URI': self.uri,
- 'Message': message})
-
-
- def __load_config(self):
- if self.up2date_cfg == None:
- self.up2date_cfg = config.initUp2dateConfig()
- self.up2date_server = urlparse(self.up2date_cfg['serverURL'])
- # TODO: proxy settings
-
-
- def __login(self):
- if self.login_info == None:
- self.status(URI = self.uri, Message = 'Logging into the spacewalk server')
- self.login_info = up2dateAuth.getLoginInfo()
- if not self.login_info:
- raise up2date_client.AuthenticationError(self.not_registered_msg)
- self.status(URI = self.uri, Message = 'Logged in')
-
-
- def __init_channels(self):
- if self.svr_channels == None:
- self.svr_channels = rhnChannel.getChannelDetails()
- for channel in self.svr_channels:
- if channel['parent_channel'] == '':
- self.base_channel = channel['label']
-
-
- def __init_headers(self):
- if self.http_headers == None:
- rhn_needed_headers = ['X-RHN-Server-Id',
- 'X-RHN-Auth-User-Id',
- 'X-RHN-Auth',
- 'X-RHN-Auth-Server-Time',
- 'X-RHN-Auth-Expire-Offset']
- self.http_headers = {};
- for header in rhn_needed_headers:
- if not self.login_info.has_key(header):
- raise up2date_client.AuthenticationError(
- "Missing required login information %s" % (header))
- self.http_headers[header] = self.login_info[header]
- self.http_headers['X-RHN-Transport-Capability'] = 'follow-redirects=3'
-
-
- def __make_conn(self):
- if self.conn == None:
- if self.up2date_server.scheme == 'http' \
- or self.up2date_cfg['useNoSSLForPackages'] == 1:
- self.conn = HTTPConnection(self.up2date_server.netloc)
- else:
- self.conn = HTTPSConnection(self.up2date_server.netloc,
- trusted_certs=get_ssl_ca_cert(self.up2date_cfg))
-
-
- def __transform_document(self, document):
- """Transform url given by apt to real spacewalk url"""
- document = document.replace('dists/channels:/main/',
- 'dists/channels:/' + self.base_channel + '/', 1)
- document = re.sub('/binary-[\d\w]*/', '/repodata/', document, 1)
- document = document.replace('dists/channels:/', '/XMLRPC/GET-REQ/', 1)
- return document
-
-
- def fetch(self, msg):
- """
- Fetch the content from spacewalk server to the file.
-
- Acording to the apt protocol msg must contain: 'URI' and 'Filename'.
- Other possible keys are: 'Last-Modified', 'Index-File', 'Fail-Ignore'
- """
- self.uri = msg['URI']
- self.uri_parsed = urlparse(msg['URI'])
- self.filename = msg['Filename']
-
- self.__load_config()
- if self.uri_parsed.netloc != self.up2date_server.netloc:
- return self.fail()
- self.__login()
- self.__init_channels()
-
- document = self.__transform_document(self.uri_parsed.path)
-
- self.__init_headers()
- self.__make_conn()
-
- self.conn.request("GET", "/" + document, headers = self.http_headers)
- self.status(URI = self.uri, Message = 'Waiting for headers')
-
- res = self.conn.getresponse()
- if res.status != 200:
- self.uri_failure({'URI': self.uri,
- 'Message': str(res.status) + ' ' + res.reason,
- 'FailReason': 'HttpError' + str(res.status)})
- while True:
- data = res.read(4096)
- if not len(data): break
- res.close()
- return
-
- self.uri_start({'URI': self.uri,
- 'Size': res.getheader('content-length'),
- 'Last-Modified': res.getheader('last-modified')})
-
- f = open(self.filename, "w")
- hash_sha256 = hashlib.sha256()
- hash_md5 = hashlib.md5()
- while True:
- data = res.read(4096)
- if not len(data):
- break
- hash_sha256.update(data)
- hash_md5.update(data)
- f.write(data)
- res.close()
- f.close()
-
- self.uri_done({'URI': self.uri,
- 'Filename': self.filename,
- 'Size': res.getheader('content-length'),
- 'Last-Modified': res.getheader('last-modified'),
- 'MD5-Hash': hash_md5.hexdigest(),
- 'MD5Sum-Hash': hash_md5.hexdigest(),
- 'SHA256-Hash': hash_sha256.hexdigest()})
-
-
- def __del__(self):
- if self.conn:
- self.conn.close()
-
-
-
-if __name__ == '__main__':
- method = spacewalk_method()
- ret = method.run()
- sys.exit(ret)
-
diff --git a/client/debian/apt-spacewalk/src/spacewalk b/client/debian/apt-spacewalk/src/spacewalk
new file mode 100755
index 0000000..5ddd770
--- /dev/null
+++ b/client/debian/apt-spacewalk/src/spacewalk
@@ -0,0 +1,262 @@
+#!/usr/bin/python -u
+#
+# The Spacewalk Acquire Method
+#
+# Author: Simon Lukasik <xlukas08 [at] stud.fit.vutbr.cz>
+# Date: 2011-01-01
+# License: GPLv2
+#
+#
+
+import sys
+import re
+import hashlib
+
+import warnings
+warnings.filterwarnings("ignore", message="the md5 module is deprecated; use hashlib instead")
+sys.path.append("/usr/share/rhn/")
+
+from urlparse import urlparse
+from rhn.connections import HTTPConnection, HTTPSConnection
+from up2date_client import config
+from up2date_client import rhnChannel
+from up2date_client import up2dateAuth
+from up2date_client import up2dateErrors
+
+
+
+class pkg_acquire_method:
+ """
+ This is slightly modified python variant of apt-pkg/acquire-method.
+ It is a skeleton class that implements only very basic of apt methods
+ functionality.
+ """
+ __eof = False
+
+ def __init__(self):
+ print "100 Capabilities\nVersion: 1.0\nSingle-Instance: true\n\n",
+
+ def __get_next_msg(self):
+ """
+ Apt uses for communication with its methods the text protocol similar
+ to http. This function parses the protocol messages from stdin.
+ """
+ if self.__eof:
+ return None
+ result = {};
+ line = sys.stdin.readline()
+ if not line:
+ self.__eof = True
+ return None
+ s = line.split(" ", 1)
+ result['_number'] = int(s[0])
+ result['_text'] = s[1].strip()
+
+ while not self.__eof:
+ line = sys.stdin.readline()
+ if not line:
+ self.__eof = True
+ return result
+ if line == '\n':
+ return result
+ s = line.split(":", 1)
+ result[s[0]] = s[1].strip()
+
+ def __dict2msg(self, msg):
+ """Convert dictionary to http like message"""
+ result = ""
+ for item in msg.keys():
+ if msg[item] != None:
+ result += item + ": " + msg[item] + "\n"
+ return result
+
+ def status(self, **kwargs):
+ print "102 Status\n%s\n" % self.__dict2msg(kwargs),
+
+ def uri_start(self, msg):
+ print "200 URI Start\n%s\n" % self.__dict2msg(msg),
+
+ def uri_done(self, msg):
+ print "201 URI Done\n%s\n" % self.__dict2msg(msg),
+
+ def uri_failure(self, msg):
+ print "400 URI Failure\n%s\n" % self.__dict2msg(msg),
+
+ def run(self):
+ """Loop through requests on stdin"""
+ while True:
+ msg = self.__get_next_msg()
+ if msg == None:
+ return 0
+ if msg['_number'] == 600:
+ try:
+ self.fetch(msg)
+ except Exception, e:
+ self.fail(e.__class__.__name__ + ": " + str(e))
+ except up2dateErrors.Error, e:
+ self.fail(e.__class__.__name__ + ": " + str(e))
+ else:
+ return 100
+
+
+
+def get_ssl_ca_cert(up2date_cfg):
+ if not (up2date_cfg.has_key('sslCACert') and up2date_cfg['sslCACert']):
+ raise BadSslCaCertConfig
+
+ ca_certs = up2date_cfg['sslCACert']
+ if type(ca_certs) == list:
+ return ca_certs
+ return [ca_certs]
+
+
+
+class spacewalk_method(pkg_acquire_method):
+ """
+ Spacewalk acquire method
+ """
+ up2date_cfg = None
+ login_info = None
+ current_url = None
+ svr_channels = None
+ http_headers = None
+ base_channel = None
+ conn = None
+ not_registered_msg = 'This system is not registered with the spacewalk server'
+
+ def fail(self, message = not_registered_msg):
+ self.uri_failure({'URI': self.uri,
+ 'Message': message})
+
+
+ def __load_config(self):
+ if self.up2date_cfg == None:
+ self.up2date_cfg = config.initUp2dateConfig()
+ self.up2date_server = urlparse(self.up2date_cfg['serverURL'])
+ # TODO: proxy settings
+
+
+ def __login(self):
+ if self.login_info == None:
+ self.status(URI = self.uri, Message = 'Logging into the spacewalk server')
+ self.login_info = up2dateAuth.getLoginInfo()
+ if not self.login_info:
+ raise up2date_client.AuthenticationError(self.not_registered_msg)
+ self.status(URI = self.uri, Message = 'Logged in')
+
+
+ def __init_channels(self):
+ if self.svr_channels == None:
+ self.svr_channels = rhnChannel.getChannelDetails()
+ for channel in self.svr_channels:
+ if channel['parent_channel'] == '':
+ self.base_channel = channel['label']
+
+
+ def __init_headers(self):
+ if self.http_headers == None:
+ rhn_needed_headers = ['X-RHN-Server-Id',
+ 'X-RHN-Auth-User-Id',
+ 'X-RHN-Auth',
+ 'X-RHN-Auth-Server-Time',
+ 'X-RHN-Auth-Expire-Offset']
+ self.http_headers = {};
+ for header in rhn_needed_headers:
+ if not self.login_info.has_key(header):
+ raise up2date_client.AuthenticationError(
+ "Missing required login information %s" % (header))
+ self.http_headers[header] = self.login_info[header]
+ self.http_headers['X-RHN-Transport-Capability'] = 'follow-redirects=3'
+
+
+ def __make_conn(self):
+ if self.conn == None:
+ if self.up2date_server.scheme == 'http' \
+ or self.up2date_cfg['useNoSSLForPackages'] == 1:
+ self.conn = HTTPConnection(self.up2date_server.netloc)
+ else:
+ self.conn = HTTPSConnection(self.up2date_server.netloc,
+ trusted_certs=get_ssl_ca_cert(self.up2date_cfg))
+
+
+ def __transform_document(self, document):
+ """Transform url given by apt to real spacewalk url"""
+ document = document.replace('dists/channels:/main/',
+ 'dists/channels:/' + self.base_channel + '/', 1)
+ document = re.sub('/binary-[\d\w]*/', '/repodata/', document, 1)
+ document = document.replace('dists/channels:/', '/XMLRPC/GET-REQ/', 1)
+ return document
+
+
+ def fetch(self, msg):
+ """
+ Fetch the content from spacewalk server to the file.
+
+ Acording to the apt protocol msg must contain: 'URI' and 'Filename'.
+ Other possible keys are: 'Last-Modified', 'Index-File', 'Fail-Ignore'
+ """
+ self.uri = msg['URI']
+ self.uri_parsed = urlparse(msg['URI'])
+ self.filename = msg['Filename']
+
+ self.__load_config()
+ if self.uri_parsed.netloc != self.up2date_server.netloc:
+ return self.fail()
+ self.__login()
+ self.__init_channels()
+
+ document = self.__transform_document(self.uri_parsed.path)
+
+ self.__init_headers()
+ self.__make_conn()
+
+ self.conn.request("GET", "/" + document, headers = self.http_headers)
+ self.status(URI = self.uri, Message = 'Waiting for headers')
+
+ res = self.conn.getresponse()
+ if res.status != 200:
+ self.uri_failure({'URI': self.uri,
+ 'Message': str(res.status) + ' ' + res.reason,
+ 'FailReason': 'HttpError' + str(res.status)})
+ while True:
+ data = res.read(4096)
+ if not len(data): break
+ res.close()
+ return
+
+ self.uri_start({'URI': self.uri,
+ 'Size': res.getheader('content-length'),
+ 'Last-Modified': res.getheader('last-modified')})
+
+ f = open(self.filename, "w")
+ hash_sha256 = hashlib.sha256()
+ hash_md5 = hashlib.md5()
+ while True:
+ data = res.read(4096)
+ if not len(data):
+ break
+ hash_sha256.update(data)
+ hash_md5.update(data)
+ f.write(data)
+ res.close()
+ f.close()
+
+ self.uri_done({'URI': self.uri,
+ 'Filename': self.filename,
+ 'Size': res.getheader('content-length'),
+ 'Last-Modified': res.getheader('last-modified'),
+ 'MD5-Hash': hash_md5.hexdigest(),
+ 'MD5Sum-Hash': hash_md5.hexdigest(),
+ 'SHA256-Hash': hash_sha256.hexdigest()})
+
+
+ def __del__(self):
+ if self.conn:
+ self.conn.close()
+
+
+
+if __name__ == '__main__':
+ method = spacewalk_method()
+ ret = method.run()
+ sys.exit(ret)
13 years, 1 month
15 commits - monitoring/nocpulse-common monitoring/NPalert monitoring/PerlModules monitoring/SatConfig monitoring/SputLite
by Michael Mraka
monitoring/NPalert/AlertDB.pm | 10 +----
monitoring/PerlModules/NP/OracleDB/CF_DB.pm | 8 ++--
monitoring/PerlModules/NP/OracleDB/DBRecord.pm | 15 +-------
monitoring/PerlModules/NP/OracleDB/OracleDB.pm | 17 +---------
monitoring/PerlModules/NP/Probe/monitoring-data-cleanup | 7 ----
monitoring/SatConfig/general/InstallSoftwareConfig.pm | 8 ----
monitoring/SatConfig/general/NOCpulse-ini | 7 ----
monitoring/SputLite/html/cgi-bin/fetch_nocpulseini.cgi | 10 -----
monitoring/SputLite/html/cgi-bin/fetch_nocpulseini_internal.cgi | 10 -----
monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm | 17 +++-------
10 files changed, 22 insertions(+), 87 deletions(-)
New commits:
commit c5ea28ce391367365a6e2cb2cdc7dac38ebb236a
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 17:11:54 2011 +0100
fixed sysdate error (PG)
fixing
ERROR: column "sysdate" does not exist at character 437
STATEMENT: SELECT instance_id,netsaint_id,command_line,effective_user,effective_gro
up,restartable,notify_email,timeout,target_type,TO_CHAR(expiration_date, 'YYYY MM DD HH2
4 MI SS')
FROM rhn_command_queue_commands cmd, rhn_command_queue_instances ins, rhn_
command_queue_execs exec
WHERE netsaint_id = $1 AND target_type = $2 AND exec.instance_id = ins.recid AND
ins.command_id = cmd.recid AND date_executed is null AND expiration_date > sysdate
diff --git a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
index f21e7b8..1895796 100644
--- a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
+++ b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
@@ -883,7 +883,7 @@ $self->dprint(1, "*** *** DATEFORMAT IS: ", $self->dateformat, " *** ***");
"exec.instance_id = ins.recid",
"ins.command_id = cmd.recid",
"date_executed is null",
- "expiration_date > sysdate");
+ "expiration_date > current_timestamp");
my @bind = ($nsid, $type);
commit c8863459700321fee6296797e8eaa285ef36d88b
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 17:03:56 2011 +0100
replaced aliases with table names (PG)
fixing
ERROR: relation "command_queue_commands" does not exist at character 186
STATEMENT: SELECT instance_id,netsaint_id,command_line,effective_user,effective_group,restartable,notify_email,timeout,target_type,TO_CHAR(expiration_date,
'YYYY MM DD HH24 MI SS')
FROM command_queue_commands cmd,command_queue_instances
ins,command_queue_execs exec
diff --git a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
index 18e6319..f21e7b8 100644
--- a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
+++ b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
@@ -80,7 +80,7 @@ sub CQ_Commands {
my $bindvars = shift || [];
my $orderby = shift || [];
- my $table = "RHN_COMMAND_QUEUE_COMMANDS";
+ my $table = "COMMAND_QUEUE_COMMANDS";
my $idseq = "COMMAND_Q_COMMAND_RECID_SEQ.NEXTVAL";
my $keycol = 'RECID';
my @cols = qw(RECID DESCRIPTION
@@ -875,8 +875,8 @@ $self->dprint(1, "*** *** DATEFORMAT IS: ", $self->dateformat, " *** ***");
push(@cols, sprintf("TO_CHAR(expiration_date, '%s') as expdate",
$self->dateformat));
- my $tables = "command_queue_commands cmd,command_queue_instances ins," .
- "command_queue_execs exec";
+ my $tables = "rhn_command_queue_commands cmd, rhn_command_queue_instances ins," .
+ "rhn_command_queue_execs exec";
my @where = ("netsaint_id = ?",
"target_type = ?",
commit 6f4d30f504d36ee99a78584d3150c3ba6483b9ab
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 17:03:56 2011 +0100
replaced alias with table name (PG)
fixing
ERROR: relation "sat_node" does not exist at character 205
STATEMENT: SELECT
RECID,TARGET_TYPE,LAST_UPDATE_USER,TO_CHAR(LAST_UPDATE_DATE, 'YYYY-MM-DD
HH24:MI:SS'),MAC_ADDRESS,MAX_CONCURRENT_CHECKS,SAT_CLUSTER_ID,IP,SCHED_LOG_LEVEL,SPUT_LOG_LEVEL,DQ_LOG_LEVEL
FROM SAT_NODE
diff --git a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
index aa54db3..18e6319 100644
--- a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
+++ b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
@@ -80,7 +80,7 @@ sub CQ_Commands {
my $bindvars = shift || [];
my $orderby = shift || [];
- my $table = "COMMAND_QUEUE_COMMANDS";
+ my $table = "RHN_COMMAND_QUEUE_COMMANDS";
my $idseq = "COMMAND_Q_COMMAND_RECID_SEQ.NEXTVAL";
my $keycol = 'RECID';
my @cols = qw(RECID DESCRIPTION
commit 8df8567bdae5fb5904bf07ee32721ba613ececf4
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 17:03:56 2011 +0100
replaced alias with table name (PG)
fixing
ERROR: relation "sat_node" does not exist at character 205
STATEMENT: SELECT
RECID,TARGET_TYPE,LAST_UPDATE_USER,TO_CHAR(LAST_UPDATE_DATE, 'YYYY-MM-DD
HH24:MI:SS'),MAC_ADDRESS,MAX_CONCURRENT_CHECKS,SAT_CLUSTER_ID,IP,SCHED_LOG_LEVEL,SPUT_LOG_LEVEL,DQ_LOG_LEVEL
FROM SAT_NODE
diff --git a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
index b2342a1..aa54db3 100644
--- a/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
+++ b/monitoring/PerlModules/NP/OracleDB/CF_DB.pm
@@ -448,7 +448,7 @@ sub Node {
my $bindvars = shift || [];
my $orderby = shift || [];
- my $table = 'SAT_NODE';
+ my $table = 'RHN_SAT_NODE';
my $idseq = 'COMMAND_TARGET_RECID_SEQ.NEXTVAL';
my $keycol = 'RECID';
commit 4cc34467e0f3fb05de30765a2f035c37fc3d84da
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:03:34 2011 +0100
reuse RHN:DB for db connection in DBRecord.pm (PG)
fixing
[Thu Mar 17 11:47:59 2011] [error] [client 127.0.0.1]
install_driver(Oracle) failed: Can't locate DBD/Oracle.pm in @INC (@INC
contains: /var/www/lib
/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .
/etc/httpd) at (eval 32) line 3.\nPerhaps the DBD::Oracle perl module
hasn't been fully installed,\nor perhaps the capitalisation of 'Oracle'
isn't right.\nAvailable drivers: DBM, ExampleP, File, Pg, Proxy,
Sponge.\n at /usr/lib/perl5/vendor_perl/5.8.8/NOCpulse/DBRecord.pm line
106\n
diff --git a/monitoring/PerlModules/NP/OracleDB/DBRecord.pm b/monitoring/PerlModules/NP/OracleDB/DBRecord.pm
index e85ce8f..0912c99 100644
--- a/monitoring/PerlModules/NP/OracleDB/DBRecord.pm
+++ b/monitoring/PerlModules/NP/OracleDB/DBRecord.pm
@@ -91,19 +91,8 @@ sub DatabaseConnection
if (NOCpulse::DBRecord->getClassInstVar('DatabaseConnection')) {
return NOCpulse::DBRecord->getClassInstVar('DatabaseConnection');
} else {
- use DBI;
- use NOCpulse::Config;
- my $config = NOCpulse::Config->new;
- my $dbd = $class->DBD($config);
- my $dbname = $class->DBName($config);
- my $username = $class->Username($config);
- my $password = $class->Password($config);
- my $orahome = $class->OraHome($config);
- my $attrs = NOCpulse::DBRecord->getClassVar('ConnectionAttributes');
- $attrs = { } unless ($attrs);
- $attrs->{AutoCommit} = 0;
- $ENV{'ORACLE_HOME'} = $orahome; # base dir for Oracle
- if (my $dbMain = DBI->connect("DBI:$dbd:$dbname", $username, $password, $attrs)) {
+ use RHN:DB;
+ if (my $dbMain = RHN::DB->connect) {
NOCpulse::DBRecord->setClassVar('DatabaseConnection', $dbMain);
return $dbMain;
}
commit d0d1737a678710fd41e18e9502d67a673fc2ea61
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:03:34 2011 +0100
reuse RHN:DB for db connection in OracleDB.pm (PG)
fixing
2011-03-17 10:59:18 NPBootstrap: !! STDOUT: Requesting
https://satellite.fqdn.com/satconfig/cgi-bin/fetch_netsaintid.cgi?ssk=eda...
Error on attempt 1: Status: '500 Internal Server Error'; content:
diff --git a/monitoring/PerlModules/NP/OracleDB/OracleDB.pm b/monitoring/PerlModules/NP/OracleDB/OracleDB.pm
index 8236df3..525bd95 100644
--- a/monitoring/PerlModules/NP/OracleDB/OracleDB.pm
+++ b/monitoring/PerlModules/NP/OracleDB/OracleDB.pm
@@ -9,7 +9,7 @@ use strict;
use DBI;
use NOCpulse::Debug;
use NOCpulse::Config;
-
+use RHN::DB;
# Global defaults
my $DEFAULTDATEFORMAT = 'YYYY-MM-DD HH24:MI:SS';
@@ -127,19 +127,8 @@ sub connect {
my $RaiseError = $paramHash{RaiseError} || 1;
my $AutoCommit = $paramHash{AutoCommit} || 0;
- $ENV{'ORACLE_HOME'} = $self->oracle_home() unless $ENV{'ORACLE_HOME'};
-
- # Open a connection to the DB
- my $dbd = $self->dbd;
- my $dbname = $self->dbname;
- my $dbuname = $self->dbuname;
- my $dbpasswd = $self->dbpasswd;
-
- $self->dprint(2, "Connecting to DBI:$dbd:$dbname as $dbuname/$dbpasswd\n");
- my $dbh = DBI->connect("DBI:$dbd:$dbname", $dbuname, $dbpasswd,
- { RaiseError => $RaiseError,
- PrintError => $PrintError,
- AutoCommit => $AutoCommit });
+ $self->dprint(2, "Connecting to DB\n");
+ my $dbh = RHN::DB->connect;
if ($DBI::err) { $@ = $DBI::errstr ; return undef }
commit 13bbc7875583b1d32d8d07c84148d83a4e58b97d
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:03:34 2011 +0100
reuse RHN:DB for db connection in AlertDB.pm (PG)
diff --git a/monitoring/NPalert/AlertDB.pm b/monitoring/NPalert/AlertDB.pm
index f817286..07f196a 100644
--- a/monitoring/NPalert/AlertDB.pm
+++ b/monitoring/NPalert/AlertDB.pm
@@ -10,6 +10,7 @@ use Class::MethodMaker
use Data::Dumper; # for debugging
use DBI;
use NOCpulse::Config;
+use RHN::DB;
use NOCpulse::Log::Logger;
my $Log = NOCpulse::Log::Logger->new(__PACKAGE__);
@@ -24,11 +25,6 @@ sub connect {
# $adb->connect ( 'PrintError'=>0, 'RaiseError'=>0, 'AutoCommit'=>0 );
my $cfg = new NOCpulse::Config;
- $ENV{'ORACLE_HOME'} = $cfg->get('oracle', 'ora_home');
- my $DBD = $cfg->get('cf_db', 'dbd');
- my $DBNAME = $cfg->get('cf_db', 'name');
- my $DBUNAME = $cfg->get('cf_db', 'notification_username');
- my $DBPASS = $cfg->get('cf_db', 'notification_password');
my $PrintError = $paramHash{PrintError} || 0;
my $RaiseError = $paramHash{RaiseError} || 0;
@@ -40,9 +36,7 @@ sub connect {
}
# Open a connection to the DB
- my $dbh =
- DBI->connect("DBI:$DBD:$DBNAME", $DBUNAME, $DBPASS,
- { RaiseError => $RaiseError, AutoCommit => $AutoCommit });
+ my $dbh = RHN::DB->connect;
if ($dbh) {
commit e46a28824fdfc526ff7643a491fd513612729fc6
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:03:34 2011 +0100
fixed db connection in fetch_nocpulseini*.cgi (PG)
according to change in 8a0dd90bbc2e7c27764bdee82499c6bc8dd27723
diff --git a/monitoring/SputLite/html/cgi-bin/fetch_nocpulseini.cgi b/monitoring/SputLite/html/cgi-bin/fetch_nocpulseini.cgi
index 09d896f..aeb9485 100755
--- a/monitoring/SputLite/html/cgi-bin/fetch_nocpulseini.cgi
+++ b/monitoring/SputLite/html/cgi-bin/fetch_nocpulseini.cgi
@@ -10,18 +10,10 @@ use PhysCluster;
my $q = CGI->new;
$NOCpulse::Object::config = NOCpulse::Config->new('/etc/rc.d/np.d/SysV.ini');
-my $cluster = PhysCluster->newInitialized();
-my $localConfig = $cluster->get_LocalConfig;
-my $config = (values(%$localConfig))[0];
-my $dbd = $config->get_dbd;
-my $dbname = $config->get_dbname;
-my $orahome = $config->get_orahome;
-my $username = $config->get_username;
-my $password = $config->get_password;
my $ini = NOCpulse::NOCpulseini->new();
-$ini->connect($dbd,$dbname,$username,$password,$orahome);
+$ini->connect();
$ini->fetch_nocpulseini('EXTERNAL');
diff --git a/monitoring/SputLite/html/cgi-bin/fetch_nocpulseini_internal.cgi b/monitoring/SputLite/html/cgi-bin/fetch_nocpulseini_internal.cgi
index 7315b47..65370c6 100755
--- a/monitoring/SputLite/html/cgi-bin/fetch_nocpulseini_internal.cgi
+++ b/monitoring/SputLite/html/cgi-bin/fetch_nocpulseini_internal.cgi
@@ -6,18 +6,10 @@ use lib qw(/etc/rc.d/np.d);
use PhysCluster;
$NOCpulse::Object::config = NOCpulse::Config->new('/etc/rc.d/np.d/SysV.ini');
-my $cluster = PhysCluster->newInitialized();
-my $localConfig = $cluster->get_LocalConfig;
-my $config = (values(%$localConfig))[0];
-my $dbd = $config->get_dbd;
-my $dbname = $config->get_dbname;
-my $orahome = $config->get_orahome;
-my $username = $config->get_username;
-my $password = $config->get_password;
my $ini = NOCpulse::NOCpulseini->new();
-$ini->connect($dbd,$dbname,$username,$password,$orahome);
+$ini->connect();
$ini->fetch_nocpulseini('INTERNAL');
commit 1ccc1f57ca02859c1058103fee875c4e0c7fd6d3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:03:34 2011 +0100
fixed db connection in NOCpulse-ini (PG)
according to change in 8a0dd90bbc2e7c27764bdee82499c6bc8dd27723
diff --git a/monitoring/SatConfig/general/NOCpulse-ini b/monitoring/SatConfig/general/NOCpulse-ini
index b262d95..b1bbb09 100644
--- a/monitoring/SatConfig/general/NOCpulse-ini
+++ b/monitoring/SatConfig/general/NOCpulse-ini
@@ -65,12 +65,7 @@ my $localConfig = $cluster->get_LocalConfig;
my $ini = NOCpulse::NOCpulseini->new;
if (%$localConfig) {
- my $config = (values(%$localConfig))[0];
- my $dbd = $config->get_dbd;
- my $dbname = $config->get_dbname;
- my $username = $config->get_username;
- my $password = $config->get_password;
- $ini->connect($dbd, $dbname, $username, $password);
+ $ini->connect();
$ini->raw($raw);
$ini->fetch_nocpulseini('INTERNAL');
} else {
commit 56dc25a80d9e28d981d55fc1014e96fc7873bd5e
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:03:34 2011 +0100
fixed db connection in monitoring-data-cleanup (PG)
according to change in 8a0dd90bbc2e7c27764bdee82499c6bc8dd27723
diff --git a/monitoring/PerlModules/NP/Probe/monitoring-data-cleanup b/monitoring/PerlModules/NP/Probe/monitoring-data-cleanup
index da8556c..1ee6e07 100755
--- a/monitoring/PerlModules/NP/Probe/monitoring-data-cleanup
+++ b/monitoring/PerlModules/NP/Probe/monitoring-data-cleanup
@@ -50,12 +50,7 @@ my $localConfig = $cluster->get_LocalConfig;
my $ini = NOCpulse::NOCpulseini->new;
if (%$localConfig) {
- my $config = (values(%$localConfig))[0];
- my $dbd = $config->get_dbd;
- my $dbname = $config->get_dbname;
- my $username = $config->get_username;
- my $password = $config->get_password;
- $ini->connect($dbd, $dbname, $username, $password);
+ $ini->connect();
$ini->fetch_nocpulseini('INTERNAL');
} else {
print "Error: This script can be run only on monitoring backend.\n";
commit e6214b51643fbaa7b61a2a0b1c522f2b9843f18a
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:16:33 2011 +0100
fixed function decode(...) does not exist (PG)
2011-03-17 10:20:19 InstallSoftwareConfig: !! RHN::Exception:
DBD::Pg::st execute failed: ERROR: function decode(character varying,
unknown, unknown, character varying) does not exist at character 203
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.
diff --git a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
index 14b53a7..bc3d5d7 100644
--- a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
+++ b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
@@ -132,8 +132,8 @@ sub fetch_params {
SELECT cgrp.description, cparam.group_name, cparam.name, cparam.value
FROM rhn_config_group cgrp, rhn_config_parameter cparam
WHERE cparam.group_name = cgrp.name
- AND ? = DECODE(cparam.security_type, 'ALL', ?,
- cparam.security_type)
+ AND ? = case cparam.security_type when 'ALL' then ?
+ else cparam.security_type end
ORDER BY cparam.group_name, cparam.name};
my $rv = $self->do_fetch($sql, $sec_type, $sec_type);
# Create a parameter database, expanding macros as we go
commit d347f40a137622b4b12a9400a5d4ca8dfdb6ede9
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:16:33 2011 +0100
fixed relation "config_parameter" does not exist (PG)
2011-03-17 10:15:55 InstallSoftwareConfig: !! RHN::Exception:
DBD::Pg::st execute failed: ERROR: relation "config_parameter" does not
exist at character 114
diff --git a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
index 3115761..14b53a7 100644
--- a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
+++ b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
@@ -130,7 +130,7 @@ sub fetch_params {
# Fetch parameters from the database
my $sql = q{
SELECT cgrp.description, cparam.group_name, cparam.name, cparam.value
- FROM rhn_config_group cgrp, config_parameter cparam
+ FROM rhn_config_group cgrp, rhn_config_parameter cparam
WHERE cparam.group_name = cgrp.name
AND ? = DECODE(cparam.security_type, 'ALL', ?,
cparam.security_type)
commit 566bbf371d4cf831705c4a3afe19bb1e7f9efe81
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:16:33 2011 +0100
fixed relation "config_group" does not exist (PG)
2011-03-17 10:15:55 InstallSoftwareConfig: !! RHN::Exception:
DBD::Pg::st execute failed: ERROR: relation "config_group" does not
exist at character 91
diff --git a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
index c2d61e9..3115761 100644
--- a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
+++ b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
@@ -130,7 +130,7 @@ sub fetch_params {
# Fetch parameters from the database
my $sql = q{
SELECT cgrp.description, cparam.group_name, cparam.name, cparam.value
- FROM config_group cgrp, config_parameter cparam
+ FROM rhn_config_group cgrp, config_parameter cparam
WHERE cparam.group_name = cgrp.name
AND ? = DECODE(cparam.security_type, 'ALL', ?,
cparam.security_type)
commit d292753948be6718cee2639c68b7a98d58c2f11a
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:16:33 2011 +0100
fixed relation "config_macro" does not exist (PG)
2011-03-17 10:15:55 InstallSoftwareConfig: !! RHN::Exception:
DBD::Pg::st execute failed: ERROR: relation "config_macro" does not
exist at character 58
diff --git a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
index 068f179..c2d61e9 100644
--- a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
+++ b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
@@ -106,7 +106,7 @@ sub fetch_macros {
# Fetch macros
my $sql = q{
SELECT name, definition, description
- FROM config_macro
+ FROM rhn_config_macro
};
my $list = $self->do_fetch_hash($sql);
# First, create a database of unexpanded macros
commit 8d12dd201d777633a20b2aad9e2322a1d4ae2aea
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Mar 17 15:03:34 2011 +0100
reuse RHN:DB for db connection in monitoring (PG)
fixing
2011-03-17 10:06:15 InstallSoftwareConfig: !! install_driver(Oracle) failed: Can't locate DBD/Oracle.pm in @INC (@INC contains: /etc/rc.d/np.d /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at (eval 333) line 3.
diff --git a/monitoring/SatConfig/general/InstallSoftwareConfig.pm b/monitoring/SatConfig/general/InstallSoftwareConfig.pm
index b4f5267..b4c3a0b 100644
--- a/monitoring/SatConfig/general/InstallSoftwareConfig.pm
+++ b/monitoring/SatConfig/general/InstallSoftwareConfig.pm
@@ -18,14 +18,8 @@ sub startActions
if (%$localConfig) {
$self->dprint(1,'Grabbing local config info');
- my $config = (values(%$localConfig))[0];
- my $dbd = $config->get_dbd;
- my $dbname = $config->get_dbname;
- my $orahome = $config->get_orahome;
- my $username = $config->get_username;
- my $password = $config->get_password;
eval {
- $ini->connect($dbd, $dbname, $username, $password, $orahome);
+ $ini->connect();
$ini->fetch_nocpulseini('INTERNAL');
$ini->save();
};
diff --git a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
index 8002123..068f179 100644
--- a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
+++ b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
@@ -5,6 +5,7 @@ use DBI;
use NOCpulse::Config;
use IO::AtomicFile;
use LWP::UserAgent;
+use RHN::DB;
use Class::MethodMaker
get_set =>
@@ -39,15 +40,9 @@ sub remove_config_file {
sub connect {
my $self = shift;
- my $dbd = shift;
- my $dbname = shift;
- my $username = shift;
- my $password = shift;
- my $orahome = shift;
- $ENV{'ORACLE_HOME'} = $orahome; # base dir for Oracle
# Make DB connection
- my $dbh = DBI->connect("DBI:$dbd:$dbname", $username, $password);
+ my $dbh = RHN::DB->connect;
# Set up for graceful exit
$SIG{'INT'} = $self->can('bailout');
unless (defined($dbh)) {
13 years, 1 month
client/rhel
by Miroslav Suchý
client/rhel/yum-rhn-plugin/rhnplugin.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
New commits:
commit 6da41679b8fe50538f108111fabe5b5cfc46e636
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Mar 17 11:50:52 2011 +0100
684342 - beside repo.id, cache even repo.name
diff --git a/client/rhel/yum-rhn-plugin/rhnplugin.py b/client/rhel/yum-rhn-plugin/rhnplugin.py
index d2ac6a7..5f938e2 100644
--- a/client/rhel/yum-rhn-plugin/rhnplugin.py
+++ b/client/rhel/yum-rhn-plugin/rhnplugin.py
@@ -61,15 +61,16 @@ def init_hook(conduit):
cachefilename = os.path.join(cachedir, cachedRHNReposFile)
if os.access(cachefilename, os.R_OK):
cachefile = open(cachefilename, 'r')
- repolist = [ line.rstrip() for line in cachefile.readlines()]
+ repolist = [ line.rstrip().split(' ', 1) for line in cachefile.readlines()]
cachefile.close()
- for reponame in repolist:
- repodir = os.path.join(cachedir, reponame)
+ for (repoid, reponame) in repolist:
+ repodir = os.path.join(cachedir, repoid)
if os.path.isdir(repodir):
- repo = YumRepository(reponame)
+ repo = YumRepository(repoid)
repo.basecachedir = cachedir
repo.baseurl = ['file:///' + repodir ]
repo.urls = repo.baseurl
+ repo.name = reponame
repo.enable()
if not repos.findRepos(repo.id):
repos.add(repo)
@@ -174,7 +175,7 @@ def prereposetup_hook(conduit):
repos.delete(repo.id)
repos.add(repo)
if cachefile:
- cachefile.write(repo.id + "\n")
+ cachefile.write("%s %s\n" % (repo.id, repo.name))
if cachefile:
cachefile.close()
13 years, 1 month
Changes to 'refs/tags/rhn-client-tools-1.4.7-1'
by Miroslav Suchý
Tag 'rhn-client-tools-1.4.7-1' created by Miroslav Suchý <msuchy(a)redhat.com> at 2011-03-17 09:17 +0000
Tagging package [rhn-client-tools] version [1.4.7-1] in directory [client/rhel/rhn-client-tools/].
Changes since rhn-client-tools-1.4.6-1:
Michael Mraka (1):
fixed package_removal_failures in postgresql
Miroslav Suchý (3):
680124 - define new function cpu_count()
680124 - do not count cpu from /proc/cpuinfo, but rather utilize new function cpu_count()
Automatic commit of package [rhn-client-tools] release [1.4.7-1].
---
client/rhel/rhn-client-tools/rhn-client-tools.spec | 5 +
client/rhel/rhn-client-tools/src/up2date_client/hardware.py | 33 ++++++++----
rel-eng/packages/rhn-client-tools | 2
web/modules/rhn/RHN/DB/DataSource/xml/Package_queries.xml | 3 -
4 files changed, 30 insertions(+), 13 deletions(-)
---
13 years, 1 month
client/rhel rel-eng/packages
by Miroslav Suchý
client/rhel/rhn-client-tools/rhn-client-tools.spec | 5 ++++-
rel-eng/packages/rhn-client-tools | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
New commits:
commit 45acaec3174777e9e681a7d95cdfd8cb16bd14be
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Mar 17 10:17:55 2011 +0100
Automatic commit of package [rhn-client-tools] release [1.4.7-1].
diff --git a/client/rhel/rhn-client-tools/rhn-client-tools.spec b/client/rhel/rhn-client-tools/rhn-client-tools.spec
index 4b96934..b9b492d 100644
--- a/client/rhel/rhn-client-tools/rhn-client-tools.spec
+++ b/client/rhel/rhn-client-tools/rhn-client-tools.spec
@@ -4,7 +4,7 @@ Group: System Environment/Base
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
URL: https://fedorahosted.org/spacewalk
Name: rhn-client-tools
-Version: 1.4.6
+Version: 1.4.7
Release: 1%{?dist}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
@@ -292,6 +292,9 @@ make -f Makefile.rhn-client-tools test
%endif
%changelog
+* Thu Mar 17 2011 Miroslav Suchý <msuchy(a)redhat.com> 1.4.7-1
+- 680124 - do not count cpu from /proc/cpuinfo, but use /sys/devices/system/cpu
+
* Wed Mar 16 2011 Miroslav Suchý <msuchy(a)redhat.com> 1.4.6-1
- 684245 - lookup of the subscription-manager page via localized title is
volatile, let's use its __module__ name. (jpazdziora(a)redhat.com)
diff --git a/rel-eng/packages/rhn-client-tools b/rel-eng/packages/rhn-client-tools
index 2a1cfe4..0034b66 100644
--- a/rel-eng/packages/rhn-client-tools
+++ b/rel-eng/packages/rhn-client-tools
@@ -1 +1 @@
-1.4.6-1 client/rhel/rhn-client-tools/
+1.4.7-1 client/rhel/rhn-client-tools/
13 years, 1 month
2 commits - client/rhel
by Miroslav Suchý
client/rhel/rhn-client-tools/src/up2date_client/hardware.py | 33 ++++++++----
1 file changed, 23 insertions(+), 10 deletions(-)
New commits:
commit 3ecd060daf6b53baf63122c80c1d52fdbcba6c38
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Mar 17 10:06:13 2011 +0100
680124 - do not count cpu from /proc/cpuinfo, but rather utilize new function cpu_count()
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
index ff88b9d..3e7b271 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
@@ -170,7 +170,7 @@ def read_cpuinfo():
continue
count = count + 1
if count > 1:
- continue # just count the rest
+ break # no need to parse rest
for cpu_attr in string.split(cpu, "\n"):
if not len(cpu_attr):
continue
@@ -180,7 +180,7 @@ def read_cpuinfo():
continue
name, value = string.strip(vals[0]), string.strip(vals[1])
tmpdict[string.lower(name)] = value
- return [count, tmpdict]
+ return tmpdict
if not os.access("/proc/cpuinfo", os.R_OK):
return {}
@@ -193,6 +193,7 @@ def read_cpuinfo():
cpulist = open("/proc/cpuinfo", "r").read()
uname = string.lower(os.uname()[4])
+ count = cpu_count()
# This thing should return a hwdict that has the following
# members:
@@ -206,7 +207,7 @@ def read_cpuinfo():
}
if uname[0] == "i" and uname[-2:] == "86" or (uname == "x86_64"):
# IA32 compatible enough
- (count, tmpdict) = get_cpulist_as_dict(cpulist)
+ tmpdict = get_cpulist_as_dict(cpulist)
if uname == "x86_64":
hwdict['platform'] = 'x86_64'
@@ -232,7 +233,7 @@ def read_cpuinfo():
hwdict['speed'] = -1
elif uname in["alpha", "alphaev6"]:
# Treat it as an an Alpha
- (count, tmpdict) = get_cpulist_as_dict(cpulist)
+ tmpdict = get_cpulist_as_dict(cpulist)
hwdict['platform'] = "alpha"
hwdict['count'] = get_entry(tmpdict, 'cpus detected')
@@ -253,7 +254,7 @@ def read_cpuinfo():
except ValueError:
hwdict['speed'] = -1
elif uname in ["ia64"]:
- (count, tmpdict) = get_cpulist_as_dict(cpulist)
+ tmpdict = get_cpulist_as_dict(cpulist)
hwdict['platform'] = uname
hwdict['count'] = count
@@ -270,7 +271,7 @@ def read_cpuinfo():
hwdict['other'] = get_entry(tmpdict, 'features')
elif uname in ['ppc64']:
- (count, tmpdict) = get_cpulist_as_dict(cpulist)
+ tmpdict = get_cpulist_as_dict(cpulist)
hwdict['platform'] = uname
hwdict['count'] = count
@@ -296,7 +297,7 @@ def read_cpuinfo():
hwdict['platform'] = uname
hwdict['type'] = get_entry(tmpdict,'vendor_id')
hwdict['model'] = uname
- hwdict['count'] = get_entry(tmpdict, '# processors')
+ hwdict['count'] = count
hwdict['bogomips'] = get_entry(tmpdict, 'bogomips per cpu')
hwdict['model_number'] = ""
hwdict['model_ver'] = ""
@@ -309,7 +310,7 @@ def read_cpuinfo():
else:
# XXX: expand me. Be nice to others
hwdict['platform'] = uname
- hwdict['count'] = 1 # Good as any
+ hwdict['count'] = count
hwdict['type'] = uname
hwdict['model'] = uname
hwdict['model_number'] = ""
commit 823888291bdc6f9cd4d843d18bd7ea88241fac89
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Mar 17 09:54:28 2011 +0100
680124 - define new function cpu_count()
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
index 2063896..ff88b9d 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
@@ -17,7 +17,7 @@
"""Used to read hardware info from kudzu, /proc, etc"""
from socket import gethostname, AF_INET, AF_INET6
import socket
-
+import re
import os
import sys
import string
@@ -139,7 +139,19 @@ def read_installinfo():
installdict[vals[0]] = string.strip(string.join(vals[1:]))
return installdict
-
+def cpu_count():
+ """ returns number of CPU in system
+
+ Beware that it can be different from number of active CPU (e.g. on s390x architecture
+ """
+ try:
+ dir = os.listdir('/sys/devices/system/cpu/')
+ except OSError:
+ dir = []
+
+ re_cpu = re.compile(r"^cpu[0-9]+$")
+ return len([i for i in dir if re_cpu.match(i)])
+
# This has got to be one of the ugliest fucntions alive
def read_cpuinfo():
13 years, 1 month
web/modules
by Michael Mraka
web/modules/rhn/RHN/DB/DataSource/xml/Package_queries.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 0bc916c6d67640554abbb0d9108bb4826d7f0a62
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Mar 16 13:50:09 2011 +0100
fixed package_removal_failures in postgresql
diff --git a/web/modules/rhn/RHN/DB/DataSource/xml/Package_queries.xml b/web/modules/rhn/RHN/DB/DataSource/xml/Package_queries.xml
index e5009fa..e71117e 100644
--- a/web/modules/rhn/RHN/DB/DataSource/xml/Package_queries.xml
+++ b/web/modules/rhn/RHN/DB/DataSource/xml/Package_queries.xml
@@ -108,7 +108,8 @@ ORDER BY UPPER(PN.name || '-' || PE.version || '-' || PE.release || (CASE WHEN P
<mode name="package_removal_failures">
<query params="sid, action_id">
SELECT PN.name || '-' || evr_t_as_vre_simple(PE.evr) AS PACKAGE,
- PC.name || DECODE(PC.version, NULL, '', '-' || PC.version) AS NEEDED_CAPABILITY,
+ PC.name || case when PC.version is NULL then ''
+ else '-' || PC.version end AS NEEDED_CAPABILITY,
(SELECT name FROM rhnPackageName WHERE id = APRF.suggested) AS SUGGESTED_PACKAGE,
APRF.flags AS FLAGS,
APRF.sense AS SENSE
13 years, 1 month
Changes to 'refs/tags/rhnlib-2.5.36-1'
by Miroslav Suchý
Tag 'rhnlib-2.5.36-1' created by Miroslav Suchý <msuchy(a)redhat.com> at 2011-03-16 08:09 +0000
Tagging package [rhnlib] version [2.5.36-1] in directory [client/rhel/rhnlib/].
Changes since spacewalk-java-1.4.18-1:
Miroslav Suchý (3):
Merge remote-tracking branch 'origin/master'
code cleanup - remove HTTPResponse.read() override
Automatic commit of package [rhnlib] release [2.5.36-1].
Simon Lukasik (2):
687885 - do not treat expired token as a fault
Automatic commit of package [spacewalk-backend] release [1.4.21-1].
---
backend/satellite_tools/xmlWireSource.py | 7 +++++-
backend/spacewalk-backend.spec | 5 +++-
client/rhel/rhnlib/rhn/connections.py | 36 -------------------------------
client/rhel/rhnlib/rhnlib.spec | 5 +++-
rel-eng/packages/rhnlib | 2 -
rel-eng/packages/spacewalk-backend | 2 -
6 files changed, 16 insertions(+), 41 deletions(-)
---
13 years, 1 month
Changes to 'refs/tags/rhn-client-tools-1.4.6-1'
by Miroslav Suchý
Tag 'rhn-client-tools-1.4.6-1' created by Miroslav Suchý <msuchy(a)redhat.com> at 2011-03-16 08:09 +0000
Tagging package [rhn-client-tools] version [1.4.6-1] in directory [client/rhel/rhn-client-tools/].
Changes since spacewalk-java-1.4.18-1:
Miroslav Suchý (4):
Merge remote-tracking branch 'origin/master'
code cleanup - remove HTTPResponse.read() override
Automatic commit of package [rhnlib] release [2.5.36-1].
Automatic commit of package [rhn-client-tools] release [1.4.6-1].
Simon Lukasik (2):
687885 - do not treat expired token as a fault
Automatic commit of package [spacewalk-backend] release [1.4.21-1].
---
backend/satellite_tools/xmlWireSource.py | 7 +++-
backend/spacewalk-backend.spec | 5 ++
client/rhel/rhn-client-tools/rhn-client-tools.spec | 7 +++-
client/rhel/rhnlib/rhn/connections.py | 36 ---------------------
client/rhel/rhnlib/rhnlib.spec | 5 ++
rel-eng/packages/rhn-client-tools | 2 -
rel-eng/packages/rhnlib | 2 -
rel-eng/packages/spacewalk-backend | 2 -
8 files changed, 23 insertions(+), 43 deletions(-)
---
13 years, 1 month
3 commits - client/rhel rel-eng/packages
by Miroslav Suchý
client/rhel/rhn-client-tools/rhn-client-tools.spec | 7 +++-
client/rhel/rhnlib/rhn/connections.py | 36 ---------------------
client/rhel/rhnlib/rhnlib.spec | 5 ++
rel-eng/packages/rhn-client-tools | 2 -
rel-eng/packages/rhnlib | 2 -
5 files changed, 12 insertions(+), 40 deletions(-)
New commits:
commit 6ef8e1e32b935de57d16c1094d699ce53aeb2a56
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Mar 16 09:09:22 2011 +0100
Automatic commit of package [rhn-client-tools] release [1.4.6-1].
diff --git a/client/rhel/rhn-client-tools/rhn-client-tools.spec b/client/rhel/rhn-client-tools/rhn-client-tools.spec
index 89ff635..4b96934 100644
--- a/client/rhel/rhn-client-tools/rhn-client-tools.spec
+++ b/client/rhel/rhn-client-tools/rhn-client-tools.spec
@@ -4,7 +4,7 @@ Group: System Environment/Base
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
URL: https://fedorahosted.org/spacewalk
Name: rhn-client-tools
-Version: 1.4.5
+Version: 1.4.6
Release: 1%{?dist}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
@@ -292,6 +292,11 @@ make -f Makefile.rhn-client-tools test
%endif
%changelog
+* Wed Mar 16 2011 Miroslav Suchý <msuchy(a)redhat.com> 1.4.6-1
+- 684245 - lookup of the subscription-manager page via localized title is
+ volatile, let's use its __module__ name. (jpazdziora(a)redhat.com)
+- 624748 - report virtual network interfaces (mzazrivec(a)redhat.com)
+
* Fri Mar 11 2011 Miroslav Suchý <msuchy(a)redhat.com> 1.4.5-1
- declare that we are using utf-8
diff --git a/rel-eng/packages/rhn-client-tools b/rel-eng/packages/rhn-client-tools
index 7b848c2..2a1cfe4 100644
--- a/rel-eng/packages/rhn-client-tools
+++ b/rel-eng/packages/rhn-client-tools
@@ -1 +1 @@
-1.4.5-1 client/rhel/rhn-client-tools/
+1.4.6-1 client/rhel/rhn-client-tools/
commit a4fee5b69766173d0b97818b3e59a1deff0ea315
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Mar 16 09:09:08 2011 +0100
Automatic commit of package [rhnlib] release [2.5.36-1].
diff --git a/client/rhel/rhnlib/rhnlib.spec b/client/rhel/rhnlib/rhnlib.spec
index 07554f4..97c196f 100644
--- a/client/rhel/rhnlib/rhnlib.spec
+++ b/client/rhel/rhnlib/rhnlib.spec
@@ -4,7 +4,7 @@ Summary: Python libraries for the RHN project
Name: rhnlib
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
-Version: 2.5.35
+Version: 2.5.36
Release: 1%{?dist}
Group: Development/Libraries
@@ -61,6 +61,9 @@ rm -rf $RPM_BUILD_ROOT
%{python_sitelib}/*
%changelog
+* Wed Mar 16 2011 Miroslav Suchý <msuchy(a)redhat.com> 2.5.36-1
+- code cleanup - remove HTTPResponse.read() override
+
* Fri Mar 11 2011 Miroslav Suchý <msuchy(a)redhat.com> 2.5.35-1
- 683200 - create idn_ascii_to_pune() and idn_pune_to_unicode(), which will
take care about corner cases of encodings.idna
diff --git a/rel-eng/packages/rhnlib b/rel-eng/packages/rhnlib
index 6cfdd9f..07a2d67 100644
--- a/rel-eng/packages/rhnlib
+++ b/rel-eng/packages/rhnlib
@@ -1 +1 @@
-2.5.35-1 client/rhel/rhnlib/
+2.5.36-1 client/rhel/rhnlib/
commit f7b8620874aa3a483413c977c08596812fcc0ec8
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Mar 16 09:08:42 2011 +0100
code cleanup - remove HTTPResponse.read() override
this has been fixed in python 2.0?
Anyway fix is definitelly in python in RHEL5
no need to have it here
see http://python.org/sf/988120
diff --git a/client/rhel/rhnlib/rhn/connections.py b/client/rhel/rhnlib/rhn/connections.py
index 884de9e..a1b5431 100644
--- a/client/rhel/rhnlib/rhn/connections.py
+++ b/client/rhel/rhnlib/rhn/connections.py
@@ -25,42 +25,6 @@ class HTTPResponse(httplib.HTTPResponse):
self.fp = nonblocking.NonBlockingFile(self.fp)
self.fp.set_callback(rs, ws, ex, user_data, callback)
- # Fix a bug in the upstream read() method - partial reads will incorrectly
- # update self.length with the intended, not the real, amount of bytes
- # See http://python.org/sf/988120
- def read(self, amt=None):
- if self.fp is None:
- return ''
-
- if self.chunked:
- return self._read_chunked(amt)
-
- if amt is None:
- # unbounded read
- if self.will_close:
- s = self.fp.read()
- else:
- s = self._safe_read(self.length)
- self.close() # we read everything
- return s
-
- if self.length is not None:
- if amt > self.length:
- # clip the read to the "end of response"
- amt = self.length
-
- # we do not use _safe_read() here because this may be a .will_close
- # connection, and the user is reading more bytes than will be provided
- # (for example, reading in 1k chunks)
- s = self.fp.read(amt)
-
- if self.length is not None:
- # Update the length with the amount of bytes we actually read
- self.length = self.length - len(s)
-
- return s
-
-
class HTTPConnection(httplib.HTTPConnection):
response_class = HTTPResponse
13 years, 1 month