1
0

Accepting request 566073 from home:adamm:branches:systemsmanagement:wbem

- 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

OBS-URL: https://build.opensuse.org/request/show/566073
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:wbem/cmpi-provider-register?expand=0&rev=23
This commit is contained in:
Klaus Kämpf 2018-01-16 12:20:44 +00:00 committed by Git OBS Bridge
parent 233eee6067
commit d679ac99e6
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

View File

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

View File

@ -1,7 +1,7 @@
#
# 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
# remain the property of their copyright owners, unless otherwise agreed
@ -17,9 +17,8 @@
Name: cmpi-provider-register
Version: 1.0.1
Version: 1.1.0
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Summary: CIMOM neutral provider registration utility
License: BSD-3-Clause
Group: System/Management
@ -28,7 +27,8 @@ Requires: python-pywbem
BuildRequires: cim-schema
BuildRequires: python-pywbem
BuildArch: noarch
Source0: %{name}.py
Source0: cmpi-provider-register.py
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
A utility allowing CMPI provider packages to register with whatever
@ -40,10 +40,10 @@ CIMOM(s) happens to be present on the system.
%install
%{__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
%defattr(-,root,root)
/usr/sbin/*
/usr/sbin/cmpi-provider-register
%changelog