Accepting request 566406 from systemsmanagement:wbem

OBS-URL: https://build.opensuse.org/request/show/566406
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/cmpi-provider-register?expand=0&rev=19
This commit is contained in:
Dominique Leuenberger 2018-01-17 20:57:56 +00:00 committed by Git OBS Bridge
commit 168fafba91
3 changed files with 65 additions and 39 deletions

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Mon Jan 15 16:29:37 UTC 2018 - adam.majer@suse.de
- Fix upgrade paths from SLE11 (bnc#1072564)
+ Adapt cmpi-provider-register to continue to function and
maintain sblim-sfcb's providers irrespective if sblim-sfcb is
present or not. This prevents dangling symlinks and subsequent
failures in registration/deregistration RPM scriptlets.
+ Adapt sfcb_init_script to function with all supported
codestreams.
- Adapt to python3
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Jun 9 13:10:02 UTC 2017 - adam.majer@suse.de Fri Jun 9 13:10:02 UTC 2017 - adam.majer@suse.de

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/python
#******************************************************************************* #*******************************************************************************
# Copyright (C) 2008 Novell, Inc. All rights reserved. # Copyright (C) 2008 Novell, Inc. All rights reserved.
# #
@ -39,7 +39,16 @@ from subprocess import call, PIPE, STDOUT, Popen
from getpass import getpass from getpass import getpass
import pywbem import pywbem
sfcb_init_script = '/usr/sbin/rcsblim-sfcb' sfcb_init_script = None
for filename in ['rcsblim-sfcb', 'rcsfcb']:
try:
os.lstat('/usr/sbin/' + filename)
sfcb_init_script = '/usr/sbin/' + filename
break
except OSError:
# doesn't exist, continue to next filename
pass
pegasus_init_script = '/etc/init.d/tog-pegasus' pegasus_init_script = '/etc/init.d/tog-pegasus'
pegasus_cimserver_exe = '/usr/sbin/cimserver' pegasus_cimserver_exe = '/usr/sbin/cimserver'
@ -103,10 +112,10 @@ class SimpleCompiler(MOFCompiler):
return self.rval return self.rval
self.rval.append((ns, filename)) self.rval.append((ns, filename))
def process_sfcb(mof, stage, remove=False): def process_sfcb(mof, stage, remove=False):
mofcomp = SimpleCompiler() mofcomp = SimpleCompiler()
files = [] files = []
files = mofcomp.compile_file(mof, None) files = mofcomp.compile_file(mof, None)
for file_ in files: for file_ in files:
@ -119,7 +128,7 @@ def process_sfcb(mof, stage, remove=False):
if remove: if remove:
try: try:
os.unlink(dest) os.unlink(dest)
except OSError, e: except OSError as e:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
else: else:
@ -128,17 +137,17 @@ def process_sfcb(mof, stage, remove=False):
os.unlink(dest) os.unlink(dest)
try: try:
os.symlink(src, dest) os.symlink(src, dest)
except OSError, e: except OSError as e:
if e.errno != errno.EEXIST: if e.errno != errno.EEXIST:
raise raise
if os.readlink(dest) != src: if os.readlink(dest) != src:
print 'Warning: %s already exists' % dest print('Warning: %s already exists' % dest)
for src in sfcb_regs: for src in sfcb_regs:
dest = stage + '/regs/' + os.path.basename(src) dest = stage + '/regs/' + os.path.basename(src)
if remove: if remove:
try: try:
os.unlink(dest) os.unlink(dest)
except OSError, e: except OSError as e:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
else: else:
@ -147,11 +156,11 @@ def process_sfcb(mof, stage, remove=False):
os.unlink(dest) os.unlink(dest)
try: try:
os.symlink(src, dest) os.symlink(src, dest)
except OSError, e: except OSError as e:
if e.errno != errno.EEXIST: if e.errno != errno.EEXIST:
raise raise
if os.readlink(dest) != src: if os.readlink(dest) != src:
print 'Warning: %s already exists' % dest print('Warning: %s already exists' % dest)
if g_restart: if g_restart:
@ -161,6 +170,10 @@ def process_sfcb(mof, stage, remove=False):
run([sfcb_init_script, 'stop']) run([sfcb_init_script, 'stop'])
try: try:
run_check(['sfcbrepos','-f']) run_check(['sfcbrepos','-f'])
except OSError as e:
if e.errno != errno.EEXIST:
raise
print("Warning: `sfcbrepos` doesn't exist. Ignoring.")
finally: finally:
if sfcb_running: if sfcb_running:
run([sfcb_init_script, 'start']) run([sfcb_init_script, 'start'])
@ -181,9 +194,13 @@ def run_check(command, *args, **kwargs):
err = Error("Error running '%s', returned %s" %(command, rc)) err = Error("Error running '%s', returned %s" %(command, rc))
err.last_output = output err.last_output = output
raise err raise err
return rc return 0
def run(command, *args, **kwargs): def run(command, *args, **kwargs):
if command == None or (isinstance(command, list) and command[0] == None):
# No command to execute
return 1
global g_last_output global g_last_output
if g_verbose: if g_verbose:
return call(command, *args, **kwargs) return call(command, *args, **kwargs)
@ -212,7 +229,7 @@ def process_pegasus(mof, mofcomp, init_script, cimserver_exe, remove=False,
peg_running = False peg_running = False
run_check([cimserver_exe, run_check([cimserver_exe,
'enableIndicationService=false', 'enableIndicationService=false',
'enableHttpsConnection=false', 'enableHttpsConnection=false',
'enableHttpConnection=false'], env=env) 'enableHttpConnection=false'], env=env)
try: try:
@ -243,14 +260,14 @@ def process_pegasus(mof, mofcomp, init_script, cimserver_exe, remove=False,
if not os.path.exists(dest): if not os.path.exists(dest):
try: try:
os.symlink(reg, dest) os.symlink(reg, dest)
except OSError, e: except OSError as e:
print e print(e)
else: else:
if os.path.islink(dest): if os.path.islink(dest):
try: try:
os.unlink(dest) os.unlink(dest)
except OSError, e: except OSError as e:
print e print(e)
for provider in providers: for provider in providers:
libname = 'lib' + provider + '.so' libname = 'lib' + provider + '.so'
@ -260,8 +277,8 @@ def process_pegasus(mof, mofcomp, init_script, cimserver_exe, remove=False,
if os.path.exists(src) and not os.path.exists(dest): if os.path.exists(src) and not os.path.exists(dest):
try: try:
os.symlink(src, dest) os.symlink(src, dest)
except OSError, e: except OSError as e:
print e print(e)
# don't remove, in case the provider is shared with other # don't remove, in case the provider is shared with other
# packages (like pyCmpiProvider) # packages (like pyCmpiProvider)
# #
@ -269,8 +286,8 @@ def process_pegasus(mof, mofcomp, init_script, cimserver_exe, remove=False,
# if os.path.islink(dest): # if os.path.islink(dest):
# try: # try:
# os.unlink(dest) # os.unlink(dest)
# except OSError, e: # except OSError as e:
# print e # print(e)
@ -326,12 +343,12 @@ if __name__ == '__main__':
oparser.error('No directory given') oparser.error('No directory given')
options.dir = os.path.abspath(options.dir) options.dir = os.path.abspath(options.dir)
if not os.path.isdir(options.dir): if not os.path.isdir(options.dir):
print 'Error: %s is not a directory' % options.dir print('Error: %s is not a directory' % options.dir)
sys.exit(1) sys.exit(1)
moffile = options.dir + '/deploy.mof' moffile = options.dir + '/deploy.mof'
if not os.path.exists(moffile): if not os.path.exists(moffile):
print 'Error: missing file:', moffile print('Error: missing file:', moffile)
sys.exit(1) sys.exit(1)
elems = os.listdir(options.dir) elems = os.listdir(options.dir)
@ -344,7 +361,6 @@ if __name__ == '__main__':
g_verbose = options.verbose g_verbose = options.verbose
g_restart = not options.no_restart g_restart = not options.no_restart
do_sfcb = sfcb_installed() and sfcb_regs
do_pegasus = pegasus_installed() and peg_regs do_pegasus = pegasus_installed() and peg_regs
do_scx = scx_installed() and peg_regs do_scx = scx_installed() and peg_regs
@ -352,7 +368,7 @@ if __name__ == '__main__':
do_pegasus = do_pegasus and (options.url == ':tog-pegasus:' or do_pegasus = do_pegasus and (options.url == ':tog-pegasus:' or
not options.url) not options.url)
if do_sfcb: if sfcb_regs:
process_sfcb(moffile, options.stage, options.remove) process_sfcb(moffile, options.stage, options.remove)
search = options.search search = options.search
@ -362,10 +378,10 @@ if __name__ == '__main__':
pegs = [] pegs = []
if not pegasus_installed() and options.url == ':tog-pegasus:': if not pegasus_installed() and options.url == ':tog-pegasus:':
print 'Error: tog-pegasus is not installed' print('Error: tog-pegasus is not installed')
sys.exit(1) sys.exit(1)
if not scx_installed() and options.url == ':scx:': if not scx_installed() and options.url == ':scx:':
print 'Error: SCX is not installed' print('Error: SCX is not installed')
sys.exit(1) sys.exit(1)
if do_pegasus: if do_pegasus:
@ -429,16 +445,14 @@ if __name__ == '__main__':
process_pegasus(moffile, mofcomp, peg['init'], peg['exe'], process_pegasus(moffile, mofcomp, peg['init'], peg['exe'],
remove=options.remove, provider_dir=peg['provider_dir'], remove=options.remove, provider_dir=peg['provider_dir'],
env=peg['env']) env=peg['env'])
except MOFParseError, pe: except MOFParseError as pe:
sys.exit(1) sys.exit(1)
except pywbem.CIMError, ce: except pywbem.CIMError as ce:
sys.exit(1) sys.exit(1)
except Error, e: except Error as e:
print str(e) print(str(e))
if hasattr(e, 'last_output'): if hasattr(e, 'last_output'):
print e.last_output print(e.last_output)
sys.exit(1) sys.exit(1)

View File

@ -1,7 +1,7 @@
# #
# spec file for package cmpi-provider-register # spec file for package cmpi-provider-register
# #
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -17,9 +17,8 @@
Name: cmpi-provider-register Name: cmpi-provider-register
Version: 1.0.1 Version: 1.1.0
Release: 0 Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Summary: CIMOM neutral provider registration utility Summary: CIMOM neutral provider registration utility
License: BSD-3-Clause License: BSD-3-Clause
Group: System/Management Group: System/Management
@ -28,7 +27,8 @@ Requires: python-pywbem
BuildRequires: cim-schema BuildRequires: cim-schema
BuildRequires: python-pywbem BuildRequires: python-pywbem
BuildArch: noarch BuildArch: noarch
Source0: %{name}.py Source0: cmpi-provider-register.py
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description %description
A utility allowing CMPI provider packages to register with whatever A utility allowing CMPI provider packages to register with whatever
@ -40,10 +40,10 @@ CIMOM(s) happens to be present on the system.
%install %install
%{__mkdir} -p $RPM_BUILD_ROOT/usr/sbin %{__mkdir} -p $RPM_BUILD_ROOT/usr/sbin
install -m 755 %{S:0} $RPM_BUILD_ROOT/usr/sbin/%{name} install -m 755 %{S:0} $RPM_BUILD_ROOT/usr/sbin/cmpi-provider-register
%files %files
%defattr(-,root,root) %defattr(-,root,root)
/usr/sbin/* /usr/sbin/cmpi-provider-register
%changelog %changelog