[cura-tools] master: add man page for lmishell (dc2eb83)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit dc2eb837609ba4fcfdb0d9c28457316fe11ba137
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Jul 23 22:37:47 2013 +0200
add man page for lmishell
>---------------------------------------------------------------
configure.ac | 1 +
makefile.am | 4 +-
man/lmishell.1 | 571 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
man/makefile.am | 1 +
4 files changed, 576 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index e6f1d1c..4786daa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,6 +11,7 @@ AC_PYTHON_MODULE([pywbem])
AC_CONFIG_FILES([
makefile
+ man/makefile
cli-tools/makefile
cli-tools/lmi/makefile
])
diff --git a/makefile.am b/makefile.am
index 366817a..2ec4e9d 100644
--- a/makefile.am
+++ b/makefile.am
@@ -1 +1,3 @@
-SUBDIRS = cli-tools
\ No newline at end of file
+SUBDIRS = \
+ man \
+ cli-tools
diff --git a/man/lmishell.1 b/man/lmishell.1
new file mode 100644
index 0000000..7790749
--- /dev/null
+++ b/man/lmishell.1
@@ -0,0 +1,571 @@
+.TH lmishell "1" "July 2013" "openlmi-tools version 0.5" "User Commands"
+.SH NAME
+lmishell \- (non)interactive WBEM client and interpreter.
+.SH SYNOPSIS
+.B lmishell
+[\fB\-i\fR] [\fB\-\-interact\fR] script [script-options]
+.SH DESCRIPTION
+lmishell provides a (non)interactive or interactive way how to access CIM
+objects provided by OpenPegasus or sblim-sfcb CIMOM.
+
+OpenLMI Shell is based on a python interpreter and added logic, therefore what
+you can do in pure python, it is possible in LMIShell. There are classes added
+to manipulate with CIM classes, instance names, instances, etc. Additional
+classes are added to fulfill wrapper pattern and expose only those methods,
+which are necessary for the purpose of a shell. Following scheme depicts a
+structure of the OpenLMI Shell.
+.SH OPTIONS
+\fB\-h\fR \fB\-\-help\fR Print summary of usage, command line options and exit.
+.TP
+\fB-h\fR \fB\-\-interact\fR Enter interactive mode, when the script passed
+as the first positional argument is executed.
+.SH HOW TO USE THE SHELL
+The following text covers basic use-cases.
+
+\fBNOTE:\fR The purpose of all the code listings is to show the LMIShell's features usage. Code listings mostly use service and account providers; there are also other CIM classes used. The code listings assume, that a proper connection object has been created in the LMIShell (See section \fBEstablish a connection\fR).
+.SS START AND QUIT
+By running the following, you will gain an interactive interface of the shell.
+The LMIShell is waiting for the end of an input to quit -- by hitting
+`<ctrl+d>` you can exit from it.
+
+ $ lmishell
+ > <ctrl+d>
+ $
+
+or
+
+ $ lmishell
+ > quit()
+ $
+.SS ESTABLISH A CONNECTION
+Following examples demonstrate, how to connect to a CIMOM.
+.TP 4
+.B USERNAME/PASSWORD CONNECTION
+To access CIM objects provided by a broker, you have to create a connection
+object, which does the communication, eg. by running:
+
+ > c = connect("host", "username")
+ password: # <not echoed>
+ >
+
+or
+
+ > c = connect("host", "username", "password")
+ >
+.TP 4
+.B UNIX SOCKET
+LMIShell can connect directly to the CIMOM using unix socket. For this type of
+connection, the shell needs to be run under root user and the destination
+machine has to be either "localhost", "127.0.0.1" or "::1". This type of
+connection is supported by Tog-Pegasus and there needs to be a unix socket
+file present at /var/run/tog-pegasus/cimxml.socket. If the condition is not
+met, classic username/password method will be used. See following example:
+
+ # lmishell
+ > c = connect("localhost")
+ >
+.TP 4
+.B CREDENTIALS VALIDATION
+Function `connect()` returns either `LmiConnection`, if provided credentials
+are OK, otherwise `None` is returned:
+
+ > # correct username or password
+ > c = connect("host", "username", "password"}
+ > type(c) == lmi.lmi_client_shell.LmiConnection
+ > # bad login username or password
+ > c = connect("host", "bad_username", "bad_password")
+ > type(c) == None
+ >
+.SH NAMESPACES
+Namespaces in CIM and LMIShell provide a natural way, how to organize all
+available classes. In the shell, they provide a hierarchic access point to
+other namespaces and corresponding classes.
+
+The "root" namespace plays a special role in the managed system; it is the
+first entry point from the connection object and provides the access to other
+clamped namespaces.
+.SS AVAILABLE NAMESPACES
+To get a root namespace object of OpenLMI Shell, run following:
+
+ > root_namespace = c.root
+ >
+
+To list all available namespace from the root one, run following code:
+
+ > c.root.print_namespaces()
+ ...
+ > ns_lst = c.root.namespaces
+ >
+
+If you want to access any namespace deeper (eg. cimv2), run this:
+
+ > cimv2_namespace = c.root.cimv2
+ >
+.SS AVAILABLE CLASSES
+Each namespace object can print its available classes. To print/get the list
+of the classes, run this:
+
+ > c.root.cimv2.print_classes()
+ ...
+ > classes_lst = c.root.cimv2.classes()
+.SH CLASSES
+Each class in LMIShell represents a class provided by a CIMOM. You can get a
+list of its properties, methods, instances, instance names and ValueMap
+properties. It is also possible to print a documentation string, create a new
+instance or new instance name.
+.SS GET A CLASS OBJECT
+To get a class which is provided by a broker, you can do following:
+
+ > lmi_service_class = c.root.cimv2.LMI_Service
+ >
+.SS METHODS
+A class object can return a list of its methods, properties and valuemap
+properties. Following example covers methods' retrieval:
+
+ > lmi_service_class = c.root.cimv2.LMI_Service
+ > lmi_service_class.print_methods()
+ ...
+ > lmi_service_class_methods = lmi_service_class.methods()
+ >
+.SS PROPERTIES
+To get a list of properties of a specific object, run following code:
+
+ > lmi_service_class = c.root.cimv2.LMI_Service
+ > lmi_service_class.print_properties()
+ ...
+ > service_properties_lst = lmi_service_class.properties()
+ >
+.SS VALUEMAP PROPERTIES
+A CIM class may contain ValueMap properties (aliases for constant values) in
+its MOF definition. These properties contain constant values, which can be
+useful, when calling a method, or checking a returned value. To work with the
+ValueMap properties, see following code:
+
+ > c.root.cimv2.CIM_ConcreteJob.print_valuemap_properties()
+ ...
+ > lmi_valuemap_properties = c.root.cimv2.CIM_ConcreteJob.valuemap_properties()
+ >
+.SS GET VALUEMAP PROPERTY VALUE
+By using a ValueMap properties, you can retrieve a constant value defined in
+the MOF file. To get a list of all available constants, their values, use the
+following code:
+
+ > cim_concrete_job = c.root.cimv2.CIM_ConcreteJob
+ > cim_concrete_job.JobStateValues.print_values()
+ ...
+ >
+
+To retrieve a constant value, see the next example:
+
+ > constant_value_names_lst = cim_concrete_job.values()
+ > cim_concrete_job.JobStateValues.Completed
+ 7
+ >
+.SS GET INSTANCES
+Using a class object, you can access its instances. You can easily get a list
+of (filtered) instances, or the first one from the list. The filtering is uses
+input dictionary, if present, where the dictionary keys represent the instance
+properties and the dictionary values represent your desired instance property
+values. See following example:
+
+ > inst = c.root.cimv2.LMI_Service.first_instance()
+ > inst_lst = c.root.cimv2.LMI_Service.instances()
+ >
+.SS GET INSTANCE NAMES
+The CIMInstanceName objects clearly identify CIMInstance objects. The shell
+can retrieve wrapped CIMInstanceNames objects, by calling following:
+
+ > inst_name = c.root.cimv2.LMI_Service.first_instance_name()
+ > inst_names_lst = c.root.cimv2.LMI_Service.instance_names()
+ >
+.SS FILTERING
+Both methods `.instances()` or `.instance_names()` can filter returned objects
+by their keys/values. The filtering is achieved by passing a dictionary of
+`{property : value`} to the corresponding method. See following example:
+
+ > inst_lst = c.root.cimv2.LMI_Service.instances({"Name" : "sshd.service"})
+ > inst_names_lst = c.root.cimv2.LMI_Service.instance_names({"Name" : "sshd.service"})
+ >
+.SS NEW INSTANCE NAME
+LMIShell is able to create a new wrapped CIMInstanceName, if you know all the
+primary keys of a remote object. This instance name object can be then used to
+retrieve the whole instance object. See the next example:
+
+ > inst_name = c.root.cimv2.LMI_SoftwareIdentity({InstanceID : "LMI:LMI_SoftwareIdentity:sblim-sfcb-0:1.3.16-3.fc19.x86_64"})
+ > inst = inst_name.to_instance()
+ >
+.SS CLASS NAME
+Every class object can return a string of the CIM class, see following:
+
+ > c.root.cimv2.LMI_Service.classname
+ LMI_Service
+.SS NAMESPACE
+Every class belongs to certain namespace, to get a string containing the
+corresponding namespace for each class, run following:
+
+ > c.root.cimv2.LMI_Service.namespace
+ root/cimv2
+ >
+.SS DOCUMENTATION
+To see a class documentation (based on MOF definitions), run:
+
+ > c.root.cimv2.LMI_Service.doc()
+ ... pretty verbose output displayed in a pages (can be modified by setting environment variable PAGER) ...
+ >
+.SS CREATE A NEW INSTANCE
+LMIShell is able to create an object of specific class, if the provider
+support this operation. The next example shows, how to add a specific user
+account to the desired group.
+
+ > group = c.root.cimv2.LMI_Group.first_instance({"Name" : "groupname"})
+ > identity = c.root.cimv2.LMI_Identity.first_instance({"ElementName" : "user"})
+ > member_of_group_class = c.root.cimv2.LMI_MemberOfGroup
+ > # add user to the group
+ > member_of_group_class.create_instance({"Collection" : group, "Member" : identity})
+ >
+.SS FETCHING A CIMCLASS
+Objects of LMIClass use lazy fetching method of CIMClass, because some methods
+do not need the CIMClass object. To manually fetch the CIMClass object, call
+following:
+
+ > service_class = c.root.cimv2.LMI_Service
+ > service_class.fetch()
+ >
+
+The methods, which need the CIMClass object to be fetched from CIMOM, do this
+action automatically, without the need of calling `.fetch()` by hand.
+.SH INSTANCES
+Each instance in LMIShell represents an instance provided by a CIMOM. You can
+get/set its properties, list/print/execute its methods, print a documentation
+string, get a list of associated or association objects, push a modified
+object to CIMOM or delete a single instance from the CIMOM.
+.SS METHODS
+To get a list of methods, run following:
+
+ > sshd = c.root.cimv2.LMI_Service.first_instance({"Name" : "sshd.service"})
+ > sshd.print_methods()
+ ...
+ > sshd_methods = sshd.methods()
+ >
+
+To execute a method within an object, run this:
+
+ > sshd = c.root.cimv2.LMI_Service.first_instance({"Name" : "sshd.service"})
+ > sshd.RestartService()
+ https://host: ok (0)
+ >
+
+See the result string after a method was executed. This kind of "display
+sugar" is used only in the interactive mode. It displays a hostname, on which
+the object method was executed and its return value "ok" or "fail" (it also
+includes a return value in the parenthesis).
+.SS PROPERTIES
+You can also access an instance object properties. To get a property, see the
+following example.
+
+ > root_account = c.root.cimv2.LMI_Account.first_instance()
+ > root_account.LoginShell
+ /bin/bash
+ >
+
+To modify a property, execute following:
+
+ > root_account = c.root.cimv2.LMI_Account.first_instance()
+ > root_account.LoginShell = "/usr/bin/zsh"
+ > root_account.push()
+ https://host: ok (0)
+ >
+
+\fBNOTE:\fR If you change an instance object property, you have to execute a `.push()` method to propagate the change to the CIMOM.
+.SS DELETE AN INSTANCE
+A single instance can be removed from the CIMOM by executing:
+
+ > instance.delete()
+ >
+
+\fBNOTE:\fR After executing the `.delete()` method, all the object properties, methods will become inaccessible.
+.SS CLASS NAME
+Each instance object provide a property, that returns its class name. To get a
+string of the class name, run following:
+
+ > instance.classname
+ >
+.SS NAMESPACE
+Each instance object also provides a property, that returns a namespace name.
+To get a string of the namespace name, run following:
+
+ > instance.namespace
+ root/cimv2
+ >
+.SS PATH
+To retrieve a unique identification object for an instance, CIMNamespaceName,
+execute following:
+
+ > sshd_instance.path
+ root/cimv2:LMI_Service.CreationClassName="LMI_Service",SystemName="localhost.localdomain",Name="sshd",SystemCreationClassName="Linux_ComputerSystem"
+ >
+.SS DOCUMENTATION
+For an instance object, you can also use a documentation method, which will
+display verbose information of its properties and values. See next example:
+
+ > instance.doc()
+ ... pretty verbose output displayed in a pages (can be modified by setting environment variable PAGER) ...
+ >
+.SS MOF REPRESENTATION
+An instance object can also print out its MOF representation. This can be
+achieved by running:
+
+ > instance.tomof()
+ ... verbose output of the instance in MOF syntax ...
+ >
+.SH INSTANCE NAMES
+Instance name is a object, which holds a set of primary keys and their values.
+This type of object exactly identifies an instance.
+.SS KEY PROPERTIES
+To get a list of key properties, see following example:
+
+ > instance_name.print_key_properties()
+ ...
+ > instance_name.key_properties()
+ ...
+ > instance_name.SomeKeyProperty
+ ...
+ >
+.SS CLASS NAME
+To get a class name of the instance name, execute:
+
+ > instance_name.classname
+ >
+.SS PATH
+To get a path string from the instance name, execute following:
+
+ > instance_name.path
+ ...
+ >
+.SS CONVERSION TO AN INSTANCE
+This type of object may be returned from a method call. Each instance name can
+be converted into the instance, see next example:
+
+ > instance = instance_name.to_instance()
+ >
+.SH ASSOCIATED OBJECTS
+In CIMOM broker, there is a association relationship defined, in case, you
+want to get list of associated objects with a given object, run following:
+
+ > associated_objects = instance.associators()
+ > first_associated_object = instance.first_associator()
+ >
+
+You can also get AssociatorNames:
+
+ > associated_object_names = instance.associator_names()
+ > first_associated_object_name = instance.first_associator_name()
+ >
+.SH ASSOCIATION OBJECTS
+An association object is the object, which defines the relationship between
+two other objects.
+
+To get association objects that refer to a particular target object, run
+following:
+
+ > association_objects = instance.references()
+ > first_association_object = instance.first_reference()
+ >
+
+To get association instance names, run following:
+
+ > association_object_names = instance.reference_names()
+ > first_association_object_name = instance.first_reference_name()
+ >
+.SH INDICATIONS
+Indication is a reaction to some specific event that occurs in response to a
+change to a particular change in data. LMIShell can perform a indication
+subcription, by which we can receive such event responses.
+.SS SUBSCRIBING TO AN INDICATION
+The shell is capable of creating an indication subscription with the filter
+and handler objects in one single step. This example is based upon sblim-cmpi-
+base provider. How to subscribe to an indication, please, follow next example:
+
+ > # When connecting to CIMOM, ensure, that the user account can create objects in the namespace root/PG_InterOp
+ > c = connect("host", "privileged_user", "password")
+ > # Create an indication
+ > c.root.PG_InterOp.create_indication(
+ ... FilterCreationClassName="CIM_IndicationFilter",
+ ... FilterSystemCreationClassName="CIM_ComputerSystem",
+ ... FilterSourceNamespace="root/cimv2",
+ ... QueryLanguage="WQL",
+ ... Query='SELECT * FROM CIM_InstModification',
+ ... Name="cpu",
+ ... HandlerCreationClassName="CIM_IndicationHandlerCIMXML",
+ ... HandlerSystemCreationClassName="CIM_ComputerSystem",
+ ... Destination="http://192.168.122.1:5988" # this is the destination computer, where all the indications will be delivered
+ ... )
+ https://hostname: ok (True)
+ >
+
+In this state, we have a indication subscription created.
+.TP 4
+.B AUTO-DELETE SUBSCRIPTIONS
+By default all subscriptions created by LMIShell will be auto-deleted, when
+the shell quits. To change this behavior, you can pass `Permanent=True`
+keyword parameter to `.subscribe_indication()` call, which will prevent
+LMIShell from deleting the subscription.
+.SS LISTING SUBSCRIBED INDICATIONS
+To list all the subscribed indications, run following code:
+
+ > c.print_subscribed_indications()
+ ...
+ > subscribed_ind_lst = c.subscribed_indications()
+ >
+.SS UNSUBSCRIBING FROM AN INDICATIONS
+By default, the subscriptions created by the shell are auto-deleted, when the
+shell quits. If you want to delete the subscriptions sooner, you can use
+following methods:
+
+ > c.unsubscribe_indication(indication_name)
+ https://hostname: ok (True)
+ > c.unsubscribe_all_indications()
+ >
+.SS INDICATION HANDLER
+In the previous example, there is a local computer specified (the one, which
+runs the shell), now we need to start a indication listener with our
+indication handler function defined. This example continues (see previous
+one). It is also possible to start another shell, script and start the
+indication listener there.
+
+ > def handler(ind, arg1, arg2, **kwargs):
+ ... exported_objects = ind.exported_objects()
+ ... do_something_with(exported_objects)
+ > listener = LmiIndicationListener("0.0.0.0", listening_port)
+ > listener.add_handler("indication-name-XXXXXXXX", handler, arg1, arg2, **kwargs)
+ > listener.start()
+ >
+
+The first argument of the handler is LmiIndication object, which contains list
+of export methods and exported objects by the indication. Other parameters are
+user specific; those arguments need to be specified, when adding a handler to
+the listener. In the example, there is a special string used in the
+`.add_handler()` call; note the eight "X" characters. Those characters will be
+replaced by random string, which is generated by the listeners to avoid
+handler name clasing. If you want to use that random-based string, start
+indication listener first, then subscribe to an indication, so the
+\fBDestination\fR property of a handler object contains `<schema>://<hostname
+>/<random-based string>`.
+.SH RETURN VALUES
+Method calls return an object, that represents a return value of the given
+method. This type of object can be converted into python's typical 3-item
+tuple and consists of 3 items:
+
+ * `rval` -- return value
+ * `rparams` -- return value parameters
+ * `errorstr` -- error string, if any
+
+Following example shows, how to use and convert ReturnValue object to tuple:
+
+ > return_value = instance.MethodCall()
+ > return_value.rval
+ 0
+ > return_value.rparams
+ []
+ > return_value.errorstr
+
+ > (rval, rparams, errorstr) = return_value
+ > rval
+ 0
+ > rparams
+ []
+ > errorstr
+
+ >
+.SH INTERACTIVE INTERFACE
+This section covers some features, that are present in the interactive
+interface or are related to the LMIShell.
+.SS HISTORY
+When using the interactive interface of the shell, you can use up/down arrows
+to navigate in history of all the commands you previously used. If you want to
+clear the history, simply run:
+
+ > clear_history()
+ >
+.SS REVERSED SEARCH
+The LMIShell can also search in the history of commands by hitting ` <ctrl+r>
+` and typing the command prefix (as your default shell does).
+
+ (reverse-i-search)`connect': c = connect("host", "username")
+.SS DISPLAY SUGAR
+Interactive interface by default uses "display sugar" when calling a method in
+the format `"http(s)://hostname: ok/fail (numberic_value)"` as a display
+replacement for object of a `ReturnValue` class. This feature can be disabled
+by executing:
+
+ > use_display_sugar(False)
+ >
+.SS EXCEPTION HANDLING
+Exception handling by the shell can be turned off -- since then, all the
+exceptions need to be handled by your code. To allow all the exceptions to
+propagate to your code, run this:
+
+ > use_exceptions()
+ >
+
+To turn exception handling by the shell back on, run this:
+
+ > use_exceptions(False)
+ >
+.SS CACHE
+The shell's connection objects use a temporary cache for storing CIM class
+names and CIM classes to save network communication.
+
+The cache can be cleared, see following example:
+
+ > c.clear_cache()
+ >
+
+The cache can be also turned off, see next example:
+
+ > c.use_cache(False) # disables the cache usage
+ >
+.TP 4
+.B TAB-COMPLETION
+Interactive interface also supports tab-completion for basic programming
+structures and also for CIM objects (such as namespace, classes, methods and
+properties completion, ). Following code shows a few examples:
+
+ > c = conn<tab> # expands to: see next line
+ > c = connect(
+
+ > lmi_service_class = c.root.c<tab> # see next line
+ > lmi_service_class = c.root.cimv2
+ > lmi_service_class = c.root.cimv2.lmi_ser<tab> # see next line
+ > lmi_service_class = c.root.cimv2.LMI_Service # it also fixes upper/lower case in the class name
+
+ > sshd_service = lmi_s<tab> # see next line
+ > sshd_service = lmi_service_class
+
+ > sshd_service.Stat<tab> # see next line
+ > sshd_service.Status
+
+ > sshd_service.Res<tab> # see next line
+ > sshd_service.RestartService(
+.SS CONFIGURATION FILE
+The LMIShell has a tiny configuration file with location `~/.lmishellrc`. In
+configuration file, you can set these properties:
+
+ # location of the history used by interactive mode
+ history_file = "~/.lmishell_history"
+ # length of history file, -1 for unlimited
+ history_length = -1
+ # default value for cache usage
+ use_cache = True
+ # default value for exceptions
+ use_exceptions = False
+.SS INSPECTING A SCRIPT
+If you want to inspect a script after it has been interpreted by the shell,
+run this:
+
+ $ lmishell -i some_script.py
+ # some stuff done
+ >
+.SH "AUTHORS"
+.LP
+Peter Hatina <phatina(a)redhat.com>
diff --git a/man/makefile.am b/man/makefile.am
new file mode 100644
index 0000000..d776893
--- /dev/null
+++ b/man/makefile.am
@@ -0,0 +1 @@
+dist_man_MANS = lmishell.1
\ No newline at end of file
10 years, 10 months
[cura-tools] master: code cleanup in LmiConnection::unsubscribe_indication() (53671e2)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 53671e291799a97b4ecd1db00372001567c10948
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Jul 22 16:23:04 2013 +0200
code cleanup in LmiConnection::unsubscribe_indication()
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_shell.py | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index ba1a533..51fd9b1 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -2887,12 +2887,19 @@ class LmiConnection(object):
errorstr = "No such indication"
if LmiBaseClient._get_use_exceptions():
raise LmiIndicationError(errorstr)
- return LmiReturnValue(rval = False, errorstr = errorstr)
+ return LmiReturnValue(
+ rval = False,
+ errorstr = errorstr,
+ use_display_hook = True,
+ hostname = self._client.hostname
+ )
indication = self._indications.pop(name)
indication.delete()
- return LmiReturnValue(rval = True,
+ return LmiReturnValue(
+ rval = True,
use_display_hook = True,
- hostname = self._client.hostname)
+ hostname = self._client.hostname
+ )
def unsubscribe_all_indications(self):
"""
10 years, 10 months
[cura-tools] master: introduce Permanent option in LmiConnection::subscribe_indication() (ebd26a1)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit ebd26a16987885cb15104e522158d9d70463327d
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Jul 22 15:25:51 2013 +0200
introduce Permanent option in LmiConnection::subscribe_indication()
This flag marks an indicataion subscription as permanent and it will not be auto-deleted, when the shell quits.
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_shell.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index 6fa43a3..ba1a533 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -2774,6 +2774,8 @@ class LmiConnection(object):
Name -- string of indication name
CreationNamespace -- string of the creation namespace
SubscriptionCreationClassName -- string of the subscription object class name
+ Permanent -- bool flag, if to preserve the created subscription on shell's
+ quit
Arguments for filter object created by the shell:
FilterCreationClassName -- string of the creation class name of the filter object
@@ -2868,7 +2870,9 @@ class LmiConnection(object):
raise LmiIndicationError(errorstr)
return _return_value(False, errorstr)
# XXX: Should we auto-delete all the indications?
- atexit.register(lambda: self.unsubscribe_indication(kwargs["Name"]))
+ autodelete = not kwargs["Permanent"] if "Permanent" in kwargs else True
+ if autodelete:
+ atexit.register(lambda: self.unsubscribe_indication(kwargs["Name"]))
return _return_value(True)
def unsubscribe_indication(self, name):
10 years, 10 months
[cura-tools] master: introduce _LmiClass::print_valuemap_properties() (35ade76)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 35ade766c84fdcc13e1b4d58b7fbd768d34aa9fe
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Jul 22 15:24:28 2013 +0200
introduce _LmiClass::print_valuemap_properties()
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_shell.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index 1dba86c..6fa43a3 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -1314,6 +1314,15 @@ class _LmiClass(BaseObject):
return self._valuemap_properties_list
@lmi_class_fetch_lazy
+ @lmi_return_if_fail(lambda obj: obj._namespace)
+ def print_valuemap_properties(self):
+ """
+ Prints out the list of string of constant names.
+ """
+ for i in self._valuemap_properties_list:
+ sys.stdout.write("%s\n" % i)
+
+ @lmi_class_fetch_lazy
@lmi_return_val_if_fail(lambda obj: obj._namespace, [])
def properties(self):
"""
10 years, 10 months
[cura-tools] master: code cleanup in _LmiInstanceMethod::__transform_return_values() (86456bd)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 86456bdd9499aa285cba8e285238c639186e0ba9
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Jul 22 09:28:38 2013 +0200
code cleanup in _LmiInstanceMethod::__transform_return_values()
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_shell.py | 68 ++++++++++++++++++-------------------
1 files changed, 33 insertions(+), 35 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index b454e54..1dba86c 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -1517,44 +1517,42 @@ class _LmiInstanceMethod(BaseObject):
"""
return job.JobState in range(7, 11)
- def __transform_return_values(self, rparams):
- """
- Transforms returned values from a method call into LMI wrapped objects.
- Returns a dictionary with the same keys as in argument rparams, but with wrapped
- CIMInstance objects into _LmiInstance.
-
- Arguments:
- rparams -- dictionary of returned parameters from a method call
- """
- lmi_rparams = pywbem.NocaseDict()
- for (key, value) in rparams.iteritems():
- if isinstance(value, pywbem.cim_obj.CIMInstance):
- lmi_namespace = None
- if not value.path is None:
- lmi_namespace = _LmiNamespace(self._client, value.path.namespace)
- lmi_class = _LmiClass(self._client, lmi_namespace, value.classname)
- lmi_rparams[key] = _LmiInstance(self._client, lmi_class, value)
- elif isinstance(value, pywbem.cim_obj.CIMInstanceName):
- lmi_rparams[key] = _LmiInstanceName(self._client, value)
- elif isinstance(value, pywbem.CIMInt):
- lmi_rparams[key] = int(value)
- elif isinstance(value, pywbem.CIMFloat):
- lmi_rparams[key] = float(value)
- elif type(value) == list:
- result = []
- for m in value:
- if isinstance(m, pywbem.cim_obj.CIMInstance):
- (lmi_class, _, errorstr) = self._client._get_class(m.classname,
- m.namespace, LocalOnly = False)
- if not lmi_class:
- return None
- lmi_rparams[key] = _LmiInstance(self._client, lmi_class, m)
- elif isinstance(m, pywbem.cim_obj.CIMInstanceName):
- result.append(_LmiInstanceName(self._client, m))
- lmi_rparams[key] = result
- else:
- lmi_rparams[key] = value
- return lmi_rparams
+ def __transform_return_values(self, value):
+ """
+ Transforms returned values from a method call into LMI wrapped objects. Returns
+ transformed input, where CIMInstance and CIMInstanceName are wrapped into LMI
+ wrapper classes and primitive types are cast to python native types.
+
+ Arguments:
+ value -- object to be transformed into python type from pywbem one
+ """
+ if isinstance(value, pywbem.cim_obj.CIMInstance):
+ lmi_namespace = None
+ if not value.path is None:
+ lmi_namespace = _LmiNamespace(self._client, value.path.namespace)
+ lmi_class = _LmiClass(self._client, lmi_namespace, value.classname)
+ return _LmiInstance(self._client, lmi_class, value)
+ elif isinstance(value, pywbem.cim_obj.CIMInstanceName):
+ return _LmiInstanceName(self._client, value)
+ elif isinstance(value, pywbem.CIMInt):
+ return int(value)
+ elif isinstance(value, pywbem.CIMFloat):
+ return float(value)
+ elif type(value) == dict:
+ return dict(
+ zip(value.keys(),
+ map(self.__transform_return_values, value.values()))
+ )
+ elif type(value) == pywbem.NocaseDict:
+ return pywbem.NocaseDict(
+ zip(value.keys(),
+ map(self.__transform_return_values, value.values()))
+ )
+ elif type(value) == list:
+ return map(self.__transform_return_values, value)
+ elif type(value) == tuple:
+ return tuple(map(self.__transform_return_values, value))
+ return value
def __handle_synchro_method_call_indication(self, job_inst):
"""
10 years, 10 months
[cura-tools] master: introduce _LmiInstance::is_deleted property (a79499f)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit a79499f3c592f3918b3c77929f049631e8bb0d66
Author: Peter Hatina <phatina(a)redhat.com>
Date: Sat Jul 20 16:36:46 2013 +0200
introduce _LmiInstance::is_deleted property
It indicates, if the instance was deleted from the CIMOM
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_shell.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index 8b77822..b454e54 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -2453,6 +2453,13 @@ class _LmiInstance(BaseObject):
rval = self._client._delete_instance(self.path)
self._deleted = rval.rval == 0
+ @property
+ def is_deleted(self):
+ """
+ Property returning a bool indicator, if the instance was deleted from the CIMOM.
+ """
+ return self._deleted
+
class _LmiShellCache(object):
"""
Class representing a shell cache. Currently, it caches retrieved classes from the
10 years, 10 months
[cura-tools] master: fix wrong text expression in _LmiInstance::delete() decorator (4213c92)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 4213c92392b95482450c62a49cc32baa3699535b
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Jul 19 12:23:12 2013 +0200
fix wrong text expression in _LmiInstance::delete() decorator
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_shell.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index a611d11..ba5ffe3 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -2483,7 +2483,7 @@ class _LmiInstance(BaseObject):
errorstr = errorstr)
@lmi_possibly_deleted(None)
- @lmi_return_if_fail(lambda obj: obj._lmi_class._namespace)
+ @lmi_return_if_fail(lambda obj: obj._cim_instance.path)
def delete(self):
"""
Deletes this instance from the CIMOM.
10 years, 10 months
[cura-tools] master: drop unused LmiReturnValue::instance_classname property (8c24011)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 8c2401156d0becd7bed56ad3234d664979b29917
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Jul 19 12:43:10 2013 +0200
drop unused LmiReturnValue::instance_classname property
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_base.py | 8 --------
cli-tools/lmi/lmi_client_shell.py | 2 --
2 files changed, 0 insertions(+), 10 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py
index 7339cf3..56bd36f 100644
--- a/cli-tools/lmi/lmi_client_base.py
+++ b/cli-tools/lmi/lmi_client_base.py
@@ -88,14 +88,6 @@ class LmiReturnValue(_RValue):
"""
return self._properties["hostname"]
- @property
- def instance_classname(self):
- """
- Property returning instance class name. Used in the interactive mode's output
- hook.
- """
- return self._properties["instance"].classname if self._properties["instance"] else ""
-
def __new__(self, **kwargs):
"""
Creates a new instance of LmiReturnValue. At least rval keyword argument must be
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index 88319da..9735fa7 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -1846,7 +1846,6 @@ class _LmiInstanceMethod(BaseObject):
return LmiReturnValue(rval = rval, errorstr = errorstr)
return LmiReturnValue(
hostname = self._client.hostname,
- instance = self._lmi_instance,
use_display_hook = True,
rval = rval,
rparams = call_rparams,
@@ -2476,7 +2475,6 @@ class _LmiInstance(BaseObject):
(rval, rparams, errorstr) = self._client._modify_instance(self._cim_instance)
return LmiReturnValue(
hostname = self._client.hostname,
- instance = self._cim_instance,
use_display_hook = True,
rval = rval,
rparams = rparams,
10 years, 10 months
[cura-tools] master: fix return value _LmiSubscription::__lt__() (4f05946)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 4f05946b2948ad3b85a43c2dfd145ce88ad9844a
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Jul 19 12:30:08 2013 +0200
fix return value _LmiSubscription::__lt__()
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_shell.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index 2cb6c17..88319da 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -607,7 +607,7 @@ class _LmiSubscription(BaseObject):
Arguments:
other -- seconds subscription object
"""
- name < other._name
+ return name < other._name
def delete(self):
"""
10 years, 10 months
[cura-tools] master: remane default shell history file (dca75b7)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit dca75b78d17491c820d28af8e100abf5875611b1
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Jul 19 13:21:17 2013 +0200
remane default shell history file
>---------------------------------------------------------------
cli-tools/lmishell | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli-tools/lmishell b/cli-tools/lmishell
index 024ba20..f99521f 100755
--- a/cli-tools/lmishell
+++ b/cli-tools/lmishell
@@ -315,7 +315,7 @@ class LmiInteractiveShellConfig(object):
configuration from the file and provides a unified API to access these settings.
"""
DEFAULT_CONFIG_FILE = "~/.lmishellrc"
- DEFAULT_HISTORY_FILE = "~/.lmi_shell_history"
+ DEFAULT_HISTORY_FILE = "~/.lmishell_history"
DEFAULT_HISTORY_LENGTH = -1
DEFAULT_USE_CACHE = True
DEFAULT_USE_EXCEPTIONS = False
10 years, 10 months