Hello community, here is the log from the commit of package python-pywbem checked in at Mon Oct 27 17:12:20 CET 2008. -------- --- python-pywbem/python-pywbem.changes 2008-09-27 20:17:21.000000000 +0200 +++ /mounts/work_src_done/STABLE/python-pywbem/python-pywbem.changes 2008-10-24 08:18:55.310667000 +0200 @@ -1,0 +2,6 @@ +Thu Oct 23 21:17:00 MDT 2008 - bwhiteley@suse.de + +- update to latest svn +- symlink new wbemcli utility to /usr/bin/ + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- pywbem-0.6.20080927.1.tar.gz New: ---- pywbem-0.6.20081023.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pywbem.spec ++++++ --- /var/tmp/diff_new_pack.L19821/_old 2008-10-27 17:11:22.000000000 +0100 +++ /var/tmp/diff_new_pack.L19821/_new 2008-10-27 17:11:22.000000000 +0100 @@ -17,12 +17,12 @@ # norootforbuild -%define srcversion 0.6.20080927.1 +%define srcversion 0.6.20081023.1 Name: python-pywbem BuildRequires: python-devel python-xml Version: 0.7 -Release: 4 +Release: 5 Group: System/Management Summary: Python module for making CIM operation calls using the WBEM protocol License: LGPL v2.1 or later @@ -53,8 +53,10 @@ python setup.py install --prefix=%{_prefix} \ --root $RPM_BUILD_ROOT --record-rpm=INSTALLED_FILES chmod +x $RPM_BUILD_ROOT%{py_sitedir}/pywbem/mof_compiler.py +chmod +x $RPM_BUILD_ROOT%{py_sitedir}/pywbem/wbemcli.py install -d $RPM_BUILD_ROOT/usr/bin ln -s %{py_sitedir}/pywbem/mof_compiler.py $RPM_BUILD_ROOT/usr/bin/mofcomp +ln -s %{py_sitedir}/pywbem/wbemcli.py $RPM_BUILD_ROOT/usr/bin/pywbemcli # END OF INSTALL %clean @@ -63,9 +65,13 @@ %files -f INSTALLED_FILES %defattr(-,root,root,-) /usr/bin/mofcomp +/usr/bin/pywbemcli %doc README %changelog +* Thu Oct 23 2008 bwhiteley@suse.de +- update to latest svn +- symlink new wbemcli utility to /usr/bin/ * Sat Sep 27 2008 bwhiteley@suse.de - Updated to latest svn in preparation for update to soon-to-be- released 0.7. @@ -117,14 +123,14 @@ * Add InvokeMethod() support in Twisted Python client. (Tim Potter) plus lots of bugfixes -* Thu Nov 02 2006 bwhiteley@suse.de +* Wed Nov 01 2006 bwhiteley@suse.de - Update to pywbem-0.5 * Sat Sep 23 2006 aj@suse.de - Fix build with python 2.5. * Wed Apr 26 2006 bwhiteley@suse.de - Renamed package from python-wbem to python-pywbem per request from upstream maintainer -* Fri Apr 07 2006 bwhiteley@suse.de +* Thu Apr 06 2006 bwhiteley@suse.de - Update to CVS snapshot. This includes several fixes which enable method invocation. * Tue Feb 28 2006 jmatejek@suse.cz @@ -136,5 +142,5 @@ * Tue Nov 15 2005 bwhiteley@suse.de - Updated to real version 0.4. Previously version 0.4 was a pre- release "under the table" distribution from Tim Potter -* Fri Oct 07 2005 bwhiteley@suse.de +* Thu Oct 06 2005 bwhiteley@suse.de - Initial package ++++++ pywbem-0.6.20080927.1.tar.gz -> pywbem-0.6.20081023.1.tar.gz ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pywbem-0.6.20080927.1/cim_provider2.py new/pywbem-0.6.20081023.1/cim_provider2.py --- old/pywbem-0.6.20080927.1/cim_provider2.py 2008-09-20 01:58:30.000000000 +0200 +++ new/pywbem-0.6.20081023.1/cim_provider2.py 2008-10-06 22:58:14.000000000 +0200 @@ -90,29 +90,6 @@ _fbp = Py_FooBarProvider() return {'Py_Foo':_fbp, 'Py_Bar':_fbp} - get_initial_polling_interval(env): - Return the number of seconds before the first call to poll. - - If this method returns zero, then the poll method is never called. - - Arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - - poll(env): - Do some work, and return the number of seconds until the next poll. - - A polled provider's poll function will be called periodically by - the CIMOM. The polled provider can use this opportunity to do - some work, such as checking on some conditions, and generating - indications. The poll function returns the number of seconds the - CIMOM should wait before calling poll again. A return value of -1 - indicates to the CIMOM that the previous poll value should be used. - A return value of 0 indicates that the poll function should never - be called again. - - Arguments: - env -- Provider Environment (pycimmb.ProviderEnvironment) - can_unload(env): Return True if the provider can be unloaded. @@ -139,27 +116,54 @@ Arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) - ns -- The namespace where the even occurred + ns -- The namespace where the event occurred handler_instance -- indication_instance -- The indication + authorize_filter (env, filter, ns, classes, + owner): + Allow or disallow an indication subscription request. + + Arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + filter -- The WQL select statement + namespace -- The namepace where the indication is registered for + classes -- The classpath of the indication registered for + owner -- The name of the principal (cimom user) + activate_filter (env, filter, ns, classes, first_activation): + Activate an indication subscription. + Arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) - filter -- - namespace -- - classes -- - first_activation -- + filter -- The WQL select statement + namespace -- The namepace where the indication is registered for + classes -- The classpath of the indication registered for + first_activation -- boolean - whether first activation deactivate_filter(env, filter, ns, classes, last_activation): + Deactivate an indication subscription. + + Arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + filter -- The WQL select statement + ns -- The namepace where the indication is registered for + classes -- The classpath of the indication registered for + last_activation -- boolean - whether last activation + + enable_indications(env): + Enable indications. + + Arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + + disable_indications(env): + Disable indications. + Arguments: env -- Provider Environment (pycimmb.ProviderEnvironment) - filter -- - ns -- - classes -- - last_activation -- Provider Environment @@ -873,8 +877,7 @@ (rval, outs) = method(env=env, object_name=objectName, **new_inputs) except TypeError, e: - raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, - e.message) + raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, str(e)) def add_type(v): if isinstance(v, pywbem.CIMParameter): @@ -921,6 +924,62 @@ continue del inst.properties[pname] + def authorize_filter (env, filter, ns, classes, + owner): + """Allow or disallow an indication subscription request. + + Arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + filter -- The WQL select statement + namespace -- The namepace where the indication is registered for + classes -- The classpath of the indication registered for + owner -- The name of the principal (cimom user) + """ + pass + + def activate_filter (env, filter, ns, classes, + first_activation): + """Activate an indication subscription. + + Arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + filter -- The WQL select statement + namespace -- The namepace where the indication is registered for + classes -- The classpath of the indication registered for + first_activation -- boolean - whether first activation + """ + pass + + def deactivate_filter(env, filter, ns, classes, + last_activation): + """Deactivate an indication subscription. + + Arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + filter -- The WQL select statement + ns -- The namepace where the indication is registered for + classes -- The classpath of the indication registered for + last_activation -- boolean - whether last activation + """ + pass + + def enable_indications(env): + """Enable indications. + + Arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + """ + pass + + def disable_indications(env): + """Disable indications. + + Arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + """ + pass + + def codegen (cc): """Generate a Python Provider template. @@ -1096,6 +1155,7 @@ mappings = {'classname':cc.classname, 'classname_l':cc.classname.lower()} isAssoc = 'association' in cc.qualifiers + isIndication = 'indication' in cc.qualifiers code = '''"""Python Provider for %(classname)s @@ -1405,12 +1465,105 @@ code+= ''' ## end of class %(classname)sProvider - + +## get_providers() for associating CIM Class Name to python provider class name + def get_providers(env): %(classname_l)s_prov = %(classname)s(env) return {'%(classname)s': %(classname_l)s_prov} ''' % mappings + if isIndication: + code+= ''' + +## Indication support methods... +## Use these methods if this class will deliver indications. +## Remove these methods if this class will not deliver indications.''' + args = inspect.getargspec(CIMProvider2.authorize_filter)[0] + args = format_desc(', '.join(args), 19).strip() + code+= ''' + + +def authorize_filter(%s): + """%s""" + + logger = env.get_logger() + logger.log_debug('Entering %%s.authorize_filter()' \\ + %% self.__class__.__name__) + ch = env.get_cimom_handle() + #raise pywbem.CIMError(pywbem.CIM_ERR_***) to indicate failure + #otherwise just fall through for success''' % \ + (args, CIMProvider2.authorize_filter.__doc__ or "Doc Goes Here") + + args = inspect.getargspec(CIMProvider2.enable_indications)[0] + args = format_desc(', '.join(args), 19).strip() + code+= ''' + + +def enable_indications(%s): + """%s""" + + logger = env.get_logger() + logger.log_debug('Entering %%s.enable_indications()' \\ + %% self.__class__.__name__) + ch = env.get_cimom_handle() + #raise pywbem.CIMError(pywbem.CIM_ERR_***) to indicate failure + #otherwise just fall through for success''' % \ + (args, CIMProvider2.enable_indications.__doc__ or "Doc Goes Here") + + args = inspect.getargspec(CIMProvider2.disable_indications)[0] + args = format_desc(', '.join(args), 19).strip() + code+= ''' + + +def disable_indications(%s): + """%s""" + + logger = env.get_logger() + logger.log_debug('Entering %%s.disable_indications()' \\ + %% self.__class__.__name__) + ch = env.get_cimom_handle() + #raise pywbem.CIMError(pywbem.CIM_ERR_***) to indicate failure + #otherwise just fall through for success''' % \ + (args, CIMProvider2.disable_indications.__doc__ or "Doc Goes Here") + + args = inspect.getargspec(CIMProvider2.activate_filter)[0] + args = format_desc(', '.join(args), 19).strip() + code+= ''' + + +def activate_filter(%s): + """%s""" + + logger = env.get_logger() + logger.log_debug('Entering %%s.activate_filter()' \\ + %% self.__class__.__name__) + ch = env.get_cimom_handle() + #raise pywbem.CIMError(pywbem.CIM_ERR_***) to indicate failure + #otherwise just fall through for success''' % \ + (args, CIMProvider2.activate_filter.__doc__ or "Doc Goes Here") + + + args = inspect.getargspec(CIMProvider2.deactivate_filter)[0] + args = format_desc(', '.join(args), 19).strip() + code+= ''' + + +def deactivate_filter(%s): + """%s""" + + logger = env.get_logger() + logger.log_debug('Entering %%s.deactivate_filter()' \\ + %% self.__class__.__name__) + ch = env.get_cimom_handle() + #raise pywbem.CIMError(pywbem.CIM_ERR_***) to indicate failure + #otherwise just fall through for success''' % \ + (args, CIMProvider2.deactivate_filter.__doc__ or "Doc Goes Here") + + code+= ''' + +## End of Indication Support Methods''' + owtypes = ['1', 'Instance'] pegtypes = ['2', 'Instance'] sfcbtypes = 'instance' @@ -1565,15 +1718,22 @@ """Check timestamp of loaded python provider module, and if it has changed since load, then reload the provider module. """ - if (sys.modules[self.provider_module_name].provmod_timestamp \ - != os.path.getmtime(self.provid)): + try: + mod = sys.modules[self.provider_module_name] + except KeyError: + mod = None + if (mod is None or \ + mod.provmod_timestamp != os.path.getmtime(self.provid)): print "Need to reload provider at %s" %self.provid #first unload the module - if hasattr(self.provmod, "shutdown"): + if self.provmod and hasattr(self.provmod, "shutdown"): self.provmod.shutdown(env) #now reload and reinit module - del sys.modules[self.provider_module_name] + try: + del sys.modules[self.provider_module_name] + except KeyError: + pass try: self._load_provider_source() self._init_provider(env) @@ -1853,36 +2013,6 @@ return rval ############################################################################## - def MI_poll (self, env): - logger = env.get_logger() - logger.log_debug('CIMProvider2 MI_poll called') - self._reload_if_necessary(env) - if hasattr(self.provmod, 'poll'): - rval = self.provmod.poll(env) - elif hasattr(self.provmod, 'MI_poll'): - rval = self.provmod.MI_poll(env) - else: - raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, - "Provider %s has no support for polling"%self.provid) - logger.log_debug('CIMProvider2 MI_poll returning %s' % str(rval)) - return rval - -############################################################################## - def MI_getInitialPollingInterval (self, env): - logger = env.get_logger() - logger.log_debug('CIMProvider2 MI_poll called') - self._reload_if_necessary(env) - if hasattr(self.provmod, 'get_initial_polling_interval'): - rval = self.provmod.get_initial_polling_interval(env) - elif hasattr(self.provmod, 'MI_getInitialPollingInterval'): - rval = self.provmod.MI_getInitialPollingInterval(env) - else: - raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, - "Provider %s has no support for polling"%self.provid) - logger.log_debug('CIMProvider2 MI_poll returning %s' % str(rval)) - return rval - -############################################################################## def MI_authorizeFilter (self, env, filter, @@ -1893,16 +2023,16 @@ logger.log_debug('CIMProvider2 MI_authorizeFilter called') self._reload_if_necessary(env) if hasattr(self.provmod, 'authorize_filter'): - rval = self.provmod.authorize_filter(env, filter, classname, + self.provmod.authorize_filter(env, filter, classname, classPath, owner) elif hasattr(self.provmod, 'MI_authorizeFilter'): - rval = self.provmod.MI_authorizeFilter(env, filter, classname, + self.provmod.MI_authorizeFilter(env, filter, classname, classPath, owner) else: - raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, - "Provider %s has no support for authorize filter"%self.provid) + # if not instrumented in provider, assume success + logger.log_debug("Provider %s has no support for authorize filter"%self.provid) logger.log_debug('CIMProvider2 MI_authorizeFilter returning') - return rval + return ############################################################################## @@ -1921,10 +2051,11 @@ elif hasattr(self.provmod, 'MI_activateFilter'): self.provmod.MI_activateFilter(env, filter, namespace, classes, firstActivation) - else: - raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, - "Provider %s has no support for activate filter"%self.provid) + else: + # if not instrumented in provider, assume success + logger.log_debug("Provider %s has no support for activate filter"%self.provid) logger.log_debug('CIMProvider2 MI_activateFilter returning') + return ############################################################################## @@ -1944,9 +2075,44 @@ self.provmod.MI_deActivateFilter(env, filter, namespace, classes, lastActivation) else: - raise pywbem.CIMError(pywbem.CIM_ERR_FAILED, - "Provider %s has no support for deactivate filter"%self.provid) + # if not instrumented in provider, assume success + logger.log_debug("Provider %s has no support for deactivate filter"%self.provid) logger.log_debug('CIMProvider2 MI_deActivateFilter returning') + return + + +############################################################################## + def MI_enableIndications(self, + env): + logger = env.get_logger() + logger.log_debug('CIMProvider2 MI_enableIndications called') + self._reload_if_necessary(env) + if hasattr(self.provmod, 'enable_indications'): + self.provmod.enable_indications(env) + elif hasattr(self.provmod, 'MI_enableIndications'): + self.provmod.MI_enableIndications(env) + else: + # if not instrumented in provider, assume success + logger.log_debug("Provider %s has no support for enable indications"%self.provid) + logger.log_debug('CIMProvider2 MI_enableIndications returning') + return + + +############################################################################## + def MI_disableIndications(self, + env): + logger = env.get_logger() + logger.log_debug('CIMProvider2 MI_disableIndications called') + self._reload_if_necessary(env) + if hasattr(self.provmod, 'disable_indications'): + self.provmod.disable_indications(env) + elif hasattr(self.provmod, 'MI_disableIndications'): + self.provmod.MI_disableIndications(env) + else: + # if not instrumented in provider, assume success + logger.log_debug("Provider %s has no support for disable indications"%self.provid) + logger.log_debug('CIMProvider2 MI_disableIndications returning') + return ############################################################################## diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pywbem-0.6.20080927.1/mof_compiler.py new/pywbem-0.6.20081023.1/mof_compiler.py --- old/pywbem-0.6.20080927.1/mof_compiler.py 2008-09-27 01:09:55.000000000 +0200 +++ new/pywbem-0.6.20081023.1/mof_compiler.py 2008-09-30 22:04:06.000000000 +0200 @@ -165,6 +165,9 @@ def p_error(p): ex = MOFParseError() + if p is None: + ex.message = 'Unexpected end of file' + raise ex ex.file = p.lexer.parser.file ex.lineno = p.lineno ex.column = _find_column(p.lexer.parser.mof, p) @@ -1596,8 +1599,12 @@ return rv except MOFParseError, pe: self.parser.log('Syntax error:') - self.parser.log('%s:%s:' % (pe.file, pe.lineno)) - self.parser.log('\n'.join(pe.context)) + if hasattr(pe, 'file') and hasattr(pe, 'lineno'): + self.parser.log('%s:%s:' % (pe.file, pe.lineno)) + if hasattr(pe, 'context'): + self.parser.log('\n'.join(pe.context)) + if pe.message: + self.parser.log(pe.message) raise except CIMError, ce: if hasattr(ce, 'file_line'): diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pywbem-0.6.20080927.1/PKG-INFO new/pywbem-0.6.20081023.1/PKG-INFO --- old/pywbem-0.6.20080927.1/PKG-INFO 2008-09-27 19:45:06.000000000 +0200 +++ new/pywbem-0.6.20081023.1/PKG-INFO 2008-10-24 05:11:55.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: pywbem -Version: 0.6.20080927.1 +Version: 0.6.20081023.1 Summary: Python WBEM client library Home-page: http://pywbem.sf.net/ Author: Tim Potter diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pywbem-0.6.20080927.1/setup.py new/pywbem-0.6.20081023.1/setup.py --- old/pywbem-0.6.20080927.1/setup.py 2008-09-27 18:51:14.000000000 +0200 +++ new/pywbem-0.6.20081023.1/setup.py 2008-10-24 05:11:51.000000000 +0200 @@ -35,7 +35,7 @@ 'long_description': __doc__, 'platforms': ['any'], 'url': 'http://pywbem.sf.net/', - 'version': '0.6.20080927.1', + 'version': '0.6.20081023.1', 'license': 'LGPLv2', 'packages': ['pywbem'], # Make packages in root dir appear in pywbem module diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pywbem-0.6.20080927.1/twisted_client.py new/pywbem-0.6.20081023.1/twisted_client.py --- old/pywbem-0.6.20080927.1/twisted_client.py 2007-12-03 01:49:49.000000000 +0100 +++ new/pywbem-0.6.20081023.1/twisted_client.py 2008-10-16 01:42:48.000000000 +0200 @@ -29,7 +29,12 @@ from twisted.web import http, client, error from pywbem import CIMClass, CIMClassName, CIMInstance, CIMInstanceName, CIMError, cim_types, cim_xml -from elementtree.ElementTree import fromstring, tostring + +try: + from elementtree.ElementTree import fromstring, tostring +except ImportError, arg: + from xml.etree.ElementTree import fromstring, tostring + import string from types import StringTypes from datetime import datetime, timedelta diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/pywbem-0.6.20080927.1/wbemcli.py new/pywbem-0.6.20081023.1/wbemcli.py --- old/pywbem-0.6.20080927.1/wbemcli.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pywbem-0.6.20081023.1/wbemcli.py 2008-10-24 02:45:17.000000000 +0200 @@ -0,0 +1,296 @@ +#!/usr/bin/python + +# (C) Copyright 2008 Hewlett-Packard Development Company, L.P. + +# This program 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 of the +# License, or (at your option) any later version. + +# This program 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 program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Author: Tim Potter <tpot@hp.com> + +# +# A small utility to wrap up a PyWBEM session in a Python interactive +# console. +# +# Usage: +# +# wbemcli.py HOSTNAME [-u USERNAME -p PASSWORD] [-n namespace] [--no-ssl] \ +# [--port PORT] +# +# CIM operations can be executed by using the PyWBEM connection object +# called 'cli' in the global scope. There are two sets of aliases +# available for usage in the interpreter. For example the following +# three commands are equivalent: +# +# >>> cli.EnumerateInstanceNames('SMX_ComputerSystem') +# >>> EnumerateInstanceNames('SMX_ComputerSystem') +# >>> ein('SMX_ComputerSystem') +# +# Pretty-printing of results is also available using the 'pp' +# function. For example: +# +# >>> cs = ei('SMX_ComputerSystem')[0] +# >>> pp(cs.items()) +# [(u'RequestedState', 12L), +# (u'Dedicated', [1L]), +# (u'StatusDescriptions', [u'System is Functional']), +# (u'IdentifyingNumber', u'6F880AA1-F4F5-11D5-8C45-C0116FBAE02A'), +# ... +# + +import os, stat, sys, string, getpass, errno +from pywbem import * +from code import InteractiveConsole +from optparse import OptionParser +from pprint import pprint as pp + +# Conditional support of readline module + +have_readline = False + +try: + import readline + have_readline = True +except ImportError, arg: + pass + +# +# Parse command line args +# + +optparser = OptionParser( + usage = '%prog HOSTNAME [-u USER -p PASS] [-n NAMESPACE] [--no-ssl]') + +# Username and password + +optparser.add_option('-u', '--user', dest = 'user', + action = 'store', type = 'string', + help = 'user to connect as') + +optparser.add_option('-p', '--password', dest = 'password', + action = 'store', type = 'string', + help = 'password to connect user as') + +# Change the default namespace used + +optparser.add_option('-n', '--namespace', dest = 'namespace', + action = 'store', type = 'string', default = 'root/cimv2', + help = 'default namespace to use') + +# Don't use SSL for remote connections + +optparser.add_option('--no-ssl', dest = 'no_ssl', action = 'store_true', + help = 'don\'t use SSL') + +# Specify non-standard port + +optparser.add_option('--port', dest = 'port', action = 'store', type = 'int', + help = 'port to connect as', default = None) + +# Check usage + +(opts, argv) = optparser.parse_args() + +if len(argv) != 1: + optparser.print_usage() + sys.exit(1) + +# +# Set up a client connection +# + +def remote_connection(): + """Initiate a remote connection, via PyWBEM.""" + + if argv[0][0] == '/': + url = argv[0] + else: + proto = 'https' + + if opts.no_ssl: + proto = 'http' + + url = '%s://%s' % (proto, argv[0]) + + if opts.port is not None: + url += ':%d' % opts.port + + creds = None + + if opts.user is not None and opts.password is None: + opts.password = getpass.getpass('Enter password for %s: ' % opts.user) + + if opts.user is not None or opts.password is not None: + creds = (opts.user, opts.password) + + cli = WBEMConnection(url, creds, default_namespace = opts.namespace) + + cli.debug = True + + return cli + +cli = remote_connection() + +# +# Create some convenient global functions to reduce typing +# + +def EnumerateInstanceNames(classname, namespace = None): + """Enumerate the names of the instances of a CIM Class (including the + names of any subclasses) in the target namespace.""" + + return cli.EnumerateInstanceNames(classname, namespace = namespace) + +def EnumerateInstances(classname, namespace = None, LocalOnly = True, + DeepInheritance = True, IncludeQualifiers = False, + IncludeClassOrigin = False): + """Enumerate instances of a CIM Class (includeing the instances of + any subclasses in the target namespace.""" + + return cli.EnumerateInstances(classname, + namespace = namespace, + DeepInheritance = DeepInheritance, + IncludeQualifiers = IncludeQualifiers, + IncludeClassOrigin = IncludeClassOrigin) + + +def GetInstance(instancename, LocalOnly = True, IncludeQualifiers = False, + IncludeClassOrigin = False): + """Return a single CIM instance corresponding to the instance name + given.""" + + return cli.GetInstance(instancename, + LocalOnly = LocalOnly, + IncludeQualifiers = IncludeQualifiers, + IncludeClassOrigin = IncludeClassOrigin) + +def DeleteInstance(instancename): + """Delete a single CIM instance.""" + + return cli.DeleteInstance(instancename) + +def ModifyInstance(*args, **kwargs): + return cli.ModifyInstance(*args, **kwargs) + +def CreateInstance(*args, **kwargs): + return cli.CreateInstance(*args, **kwargs) + +def InvokeMethod(*args, **kwargs): + return cli.InvokeMethod(*args, **kwargs) + +def AssociatorNames(*args, **kwargs): + return cli.AssociatorNames(*args, **kwargs) + +def Associators(*args, **kwargs): + return cli.Associators(*args, **kwargs) + +def ReferenceNames(*args, **kwargs): + return cli.ReferenceNames(*args, **kwargs) + +def References(*args, **kwargs): + return cli.References(*args, **kwargs) + +def EnumerateClassNames(*args, **kwargs): + return cli.EnumerateClassNames(*args, **kwargs) + +def EnumerateClasses(*args, **kwargs): + return cli.EnumerateClasses(*args, **kwargs) + +def GetClass(*args, **kwargs): + return cli.GetClass(*args, **kwargs) + +def DeleteClass(*args, **kwargs): + return cli.DeleteClass(*args, **kwargs) + +def ModifyClass(*args, **kwargs): + return cli.ModifyClass(*args, **kwargs) + +def CreateClass(*args, **kwargs): + return cli.CreateClass(*args, **kwargs) + +def EnumerateQualifiers(*args, **kwargs): + return cli.EnumerateQualifiers(*args, **kwargs) + +def GetQualifier(*args, **kwargs): + return cli.GetQualifier(*args, **kwargs) + +def SetQualifier(*args, **kwargs): + return cli.SetQualifier(*args, **kwargs) + +def DeleteQualifier(*args, **kwargs): + return cli.DeleteQualifier(*args, **kwargs) + +# Aliases for global functions above + +ein = EnumerateInstanceNames +ei = EnumerateInstances +gi = GetInstance +di = DeleteInstance +mi = ModifyInstance +ci = CreateInstance + +im = InvokeMethod + +an = AssociatorNames +ao = Associators +rn = ReferenceNames +re = References + +ecn = EnumerateClassNames +ec = EnumerateClasses +gc = GetClass +dc = DeleteClass +mc = ModifyClass +cc = CreateClass + +eq = EnumerateQualifiers +gq = GetQualifier +sq = SetQualifier +dq = DeleteQualifier + +# +# Enter interactive console +# + +def get_banner(): + + result = '' + + # Note how we are connected + + result += 'Connected to %s' % cli.url + if cli.creds is not None: + result += ' as %s' % cli.creds[0] + + return result + +# Read previous command line history + +histfile = '%s/.wbemcli_history' % os.environ['HOME'] + +try: + if have_readline: + readline.read_history_file(histfile) +except IOError, arg: + if arg[0] != errno.ENOENT: + raise + +# Interact + +i = InteractiveConsole(globals()) +i.interact(get_banner()) + +# Save command line history + +if have_readline: + readline.write_history_file(histfile) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@Hilbert.suse.de