Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit bfa9764d9fada1a704614fa2689ad9cd77e13911
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Jun 30 09:14:57 2014 +0200
bump release version to 0.9.2
>---------------------------------------------------------------
cli/lmi/shell/LMIShellVersion.py | 2 +-
cli/man/lmi.1 | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/shell/LMIShellVersion.py b/cli/lmi/shell/LMIShellVersion.py
index af52754..6df2b4e 100644
--- a/cli/lmi/shell/LMIShellVersion.py
+++ b/cli/lmi/shell/LMIShellVersion.py
@@ -13,4 +13,4 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-__version__ = "0.9.1.1"
+__version__ = "0.9.2"
diff --git a/cli/man/lmi.1 b/cli/man/lmi.1
index d3b771b..ee19e71 100644
--- a/cli/man/lmi.1
+++ b/cli/man/lmi.1
@@ -1,4 +1,4 @@
-.TH lmi 1 "June 2014" "openlmi-scripts 0.9.1.1" "User Commands"
+.TH lmi 1 "June 2014" "openlmi-scripts 0.9.2" "User Commands"
.SH NAME
lmi \- meta-command for managing systems with OpenLMI providers
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : openlmi-tools-lmiwbem
>---------------------------------------------------------------
commit b96f3ac9caf4f558922c51a43e1a8c0a9d36eaf7
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Jun 27 15:22:26 2014 +0200
allow root and pegasus members to connect via Unix socket
>---------------------------------------------------------------
cli/lmi/shell/LMICIMXMLClient.py | 40 +++++++++------------
cli/lmi/shell/LMIConnection.py | 71 ++++++++++++++++++++++++++------------
cli/lmi/shell/LMIUtil.py | 19 ++++++++++
3 files changed, 85 insertions(+), 45 deletions(-)
diff --git a/cli/lmi/shell/LMICIMXMLClient.py b/cli/lmi/shell/LMICIMXMLClient.py
index ba51b8d..a7c24c0 100644
--- a/cli/lmi/shell/LMICIMXMLClient.py
+++ b/cli/lmi/shell/LMICIMXMLClient.py
@@ -25,6 +25,7 @@ from lmi.shell.LMIUtil import lmi_raise_or_dump_exception
from lmi.shell.LMIUtil import lmi_get_use_exceptions
from lmi.shell.LMIUtil import lmi_set_use_exceptions
from lmi.shell.LMIUtil import lmi_instance_to_path
+from lmi.shell.LMIUtil import lmi_is_localhost
from lmi.shell.LMIDecorators import lmi_process_cim_exceptions
from lmi.shell.LMIDecorators import lmi_process_cim_exceptions_rval
@@ -34,17 +35,6 @@ from lmi.shell.LMIExceptions import ConnectionError
from lmi.shell.LMIExceptions import LMIFilterError
-LOCALHOST_VARIANTS = (
- "localhost",
- "localhost.localdomain",
- "localhost4",
- "localhost4.localdomain4",
- "localhost6",
- "localhost6.localdomain6",
- "127.0.0.1",
- "::1",
-)
-
def filter_kwargs(**kwargs):
return {k: v for k, v in kwargs.iteritems() if v is not None}
@@ -65,16 +55,19 @@ class LMICIMXMLClient(object):
QUERY_LANG_CQL = "DMTF:CQL"
QUERY_LANG_WQL = "WQL"
+ # Unix sockets used by TOG-Pegasus, SFCB or OpenWBEM.
+ PEGASUS_SOCKET = "/var/run/tog-pegasus/cimxml.socket"
+
def __init__(self, uri, username="", password="",
verify_server_cert=True,
key_file=None, cert_file=None):
- if not uri.startswith("http://") and \
- not uri.startswith("https://"):
- uri = "https://" + uri
self._uri = uri
+ if not self._uri.startswith("http://") and \
+ not self._uri.startswith("https://"):
+ self._uri = "https://" + uri
# Parse CIMOM URI
- _, hostname, _, _, username_, password_ = lmi_parse_uri(uri)
+ _, hostname, _, path, username_, password_ = lmi_parse_uri(self._uri)
if username_ is not None:
username = username_
password = password_
@@ -85,14 +78,13 @@ class LMICIMXMLClient(object):
"key_file": key_file
}
- # If we are running as root and the scheme has not been explicitly set,
- # we will use the local UNIX socket for higher performance (and skip
- # authentication).
- connect_locally = os.getuid() == 0 and \
- uri in LOCALHOST_VARIANTS and \
- parse_res.path != "/wsman" and \
- os.path.exists("/var/run/tog-pegasus/cimxml.socket") and \
- not username and not password
+ # If we are connecting to localhost without username or certificate
+ # set, we will use the local UNIX socket for higher performance (and
+ # skip authentication).
+ connect_locally = lmi_is_localhost(uri) and \
+ path != "/wsman" and \
+ not username and not password and \
+ not cert_file and not key_file
if HAVE_LMIWBEM:
# LMIWBEM
@@ -127,6 +119,7 @@ class LMICIMXMLClient(object):
self.disconnect()
del self._cliconn
+ @lmi_process_cim_exceptions(False)
def connect(self):
"""
Connects to CIMOM.
@@ -135,6 +128,7 @@ class LMICIMXMLClient(object):
"""
if HAVE_LMIWBEM:
self._cliconn.connect()
+ return LMIReturnValue(rval=True)
def disconnect(self):
"""
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index f763ff9..7ab9e2c 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -16,6 +16,7 @@
import os
import sys
import atexit
+import getpass
import readline
import urlparse
@@ -41,6 +42,7 @@ from lmi.shell.LMIExceptions import LMINamespaceNotFound
from lmi.shell.LMIShellLogger import lmi_get_logger
from lmi.shell.LMIUtil import lmi_raise_or_dump_exception
+from lmi.shell.LMIUtil import lmi_is_localhost
logger = lmi_get_logger()
@@ -54,38 +56,34 @@ def __lmi_raw_input(prompt, use_echo=True):
:returns: input string
:raises: :py:exc:`EOFError`
"""
- if not sys.stdout.isatty() and sys.stderr.isatty():
+ if not sys.stderr.isatty() and not sys.stdout.isatty():
+ logger.warn(
+ "Both stdout and stderr are detached from terminal, "
+ "using stdout for prompt")
+ elif not sys.stdout.isatty() and sys.stderr.isatty():
# read the input with prompt printed to stderr
- def get_input(prompt):
- sys.stderr.write(prompt)
- return raw_input()
stream = sys.stderr
else:
# read the input with prompt printed to stdout
- # NOTE: raw_input uses stdout only if the readline module is imported
- get_input = raw_input
stream = sys.stdout
- if not sys.stderr.isatty() and not sys.stdout.isatty():
- logger.warn(
- "Both stdout and stderr are detached from terminal, "
- "using stdout for prompt")
- if not use_echo:
- os.system("stty -echo")
+
+ # Define input function
+ if use_echo:
+ def get_input(prompt):
+ return raw_input(prompt)
+ else:
+ def get_input(prompt):
+ return getpass.getpass(prompt, stream)
+
try:
result = get_input(prompt)
except EOFError, e:
- if not use_echo:
- os.system("stty echo")
stream.write("\n")
return None
except KeyboardInterrupt, e:
- if not use_echo:
- os.system("stty echo")
raise e
- if not use_echo:
- os.system("stty echo")
- stream.write("\n")
- if result:
+
+ if result and use_echo:
cur_hist_len = readline.get_current_history_length()
if cur_hist_len > 1:
readline.remove_history_item(cur_hist_len - 1)
@@ -133,6 +131,30 @@ def connect(uri, username="", password="", interactive=False, use_cache=True,
"""
connection = None
+ if lmi_is_localhost(uri) and \
+ not username and not password and \
+ not cert_file and not key_file:
+ try:
+ # Try to get socket's permissions. If we can talk to TOG-Pegasus,
+ # stat() will return stat buf; OSError will be raised otherwise.
+ os.stat("/var/run/tog-pegasus/cimxml.socket")
+
+ connection = LMIConnection(
+ uri, interactive=interactive, use_cache=use_cache)
+
+ # Verify the connection
+ rval, _, errorstr = connection.connect()
+ if not rval:
+ logger.warning("Can't connect via Unix socket")
+ del connection
+ else:
+ logger.info("Connected via Unix socket")
+ return connection
+ except OSError, e:
+ # It is fine not to do anything here. User will be prompted for
+ # necessary credentials, if necessary.
+ pass
+
if interactive and not key_file and not cert_file:
try:
if not username:
@@ -150,6 +172,7 @@ def connect(uri, username="", password="", interactive=False, use_cache=True,
use_cache=use_cache, key_file=key_file, cert_file=cert_file,
verify_server_cert=verify_server_cert)
+ # Verify the connection
rval, _, errorstr = connection.connect()
if not rval:
@@ -336,9 +359,13 @@ class LMIConnection(object):
error string.
:rtype: :py:class:`LMIReturnValue`
"""
- self._client.connect()
+ # Connect to CIMOM. We may fail before the actual "dummy" request is
+ # sent. This only applies for LMIWBEM.
+ rval, _, errorstr = self._client.connect()
+ if not rval:
+ return LMIReturnValue(rval=False, errorstr=errorstr)
- # Perform "dummy" request to check connection and credentials
+ # Perform "dummy" request to check the connection and credentials.
return self._client.dummy()
def disconnect(self):
diff --git a/cli/lmi/shell/LMIUtil.py b/cli/lmi/shell/LMIUtil.py
index 18ad377..ed59851 100644
--- a/cli/lmi/shell/LMIUtil.py
+++ b/cli/lmi/shell/LMIUtil.py
@@ -23,6 +23,17 @@ from lmi.shell import wbem
from lmi.shell.LMIObjectFactory import LMIObjectFactory
+LOCALHOST_VARIANTS = (
+ "localhost",
+ "localhost.localdomain",
+ "localhost4",
+ "localhost4.localdomain4",
+ "localhost6",
+ "localhost6.localdomain6",
+ "127.0.0.1",
+ "::1",
+)
+
# By default, the LMIShell does not use exceptions; LMIReturnValue
# is used instead (with proper error string).
@@ -488,3 +499,11 @@ def lmi_instance_to_path(instance):
return instance.wrapped_object
raise TypeError(
"instance has to be wbem.CIMInstance(Name) or LMIInstance(Name)")
+
+def lmi_is_localhost(uri):
+ """
+ Helper function, which returns True, if URI points to localhost.
+
+ :param str uri: URI to check
+ """
+ return uri in LOCALHOST_VARIANTS
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : openlmi-tools-lmiwbem
>---------------------------------------------------------------
commit 05e7dea5b74b5bb585ec44b41ef4f398ceb25cac
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Jun 23 14:46:09 2014 +0200
fix unintended version bump
>---------------------------------------------------------------
cli/lmi/shell/LMIShellVersion.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli/lmi/shell/LMIShellVersion.py b/cli/lmi/shell/LMIShellVersion.py
index 02d4333..af52754 100644
--- a/cli/lmi/shell/LMIShellVersion.py
+++ b/cli/lmi/shell/LMIShellVersion.py
@@ -13,4 +13,4 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-__version__ = "1.0.0"
+__version__ = "0.9.1.1"
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : openlmi-tools-lmiwbem
>---------------------------------------------------------------
commit 3af55101ded02c581d0dab9e43f17a893a5ede58
Author: Michal Minar <miminar(a)redhat.com>
Date: Thu Jun 12 12:54:29 2014 +0200
doc: fixed typo
>---------------------------------------------------------------
doc/src/scripts/script-tutorial.rst | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/doc/src/scripts/script-tutorial.rst b/doc/src/scripts/script-tutorial.rst
index 0b59247..3e0490c 100644
--- a/doc/src/scripts/script-tutorial.rst
+++ b/doc/src/scripts/script-tutorial.rst
@@ -266,7 +266,7 @@ Now we can install it and test it:
.. code-block:: sh
# make sure the $WSP is in $PYTHONPATH
- python mylf/stup.py develop --install-dir=$WSP
+ python mylf/setup.py develop --install-dir=$WSP
lmi help
lmi help mylf
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : openlmi-tools-lmiwbem
>---------------------------------------------------------------
commit 48b5941435917613a6a9e23acbe381c1d1880cb4
Author: Michal Minar <miminar(a)redhat.com>
Date: Tue Jun 17 13:15:13 2014 +0200
lmi: extended manpage, improved help
>---------------------------------------------------------------
cli/lmi/scripts/_metacommand/toplevel.py | 10 +++++-----
cli/man/generate.sh | 27 ++++++++++++++++++++++++++-
cli/man/lmi.1 | 16 +++++++++++++++-
3 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/cli/lmi/scripts/_metacommand/toplevel.py b/cli/lmi/scripts/_metacommand/toplevel.py
index a0372a7..419a856 100644
--- a/cli/lmi/scripts/_metacommand/toplevel.py
+++ b/cli/lmi/scripts/_metacommand/toplevel.py
@@ -57,14 +57,14 @@ Options:
--version Print version of '%(cmd)s' in use and quit.
Handling hosts:
- If no --host or --hosts-file given the "localhost" is tried. When running
- under root with Pegasus CIMOM, this results in a connection over unix
- socket (without the need for credentials).
+ If no --host or --hosts-file are given, the "localhost" will be tried. When
+ running under root with Pegasus CIMOM, this results in a connection over
+ unix socket (no need to supply credentials).
Hosts may contain embedded credentials e.g.:
http://user:passwd@hostname:5988
- Avoid supplying them on command line though since arguments are visible in
- process table. Use --hosts-file option instead.
+ Avoid supplying them on command line though. Always prefer the --hosts-file
+ option.
"""
import docopt
diff --git a/cli/man/generate.sh b/cli/man/generate.sh
index a8a8e8d..e2b4dd9 100755
--- a/cli/man/generate.sh
+++ b/cli/man/generate.sh
@@ -16,6 +16,8 @@ configuration_file=`mktemp`
# pusg - parse usage
# wopt - wait for options
# popt - parse options
+# whts - wait for hosts handling section
+# phts - parse hosts handling section
state="desc"
re_option="^([[:blank:]]+)((-[-[:alpha:]_]+)"
re_option+="(\ [][:alpha:]<>_()[|-]+)*)(\ \ +(.*))?"
@@ -76,7 +78,7 @@ while IFS= read line; do
popt*)
if [[ "$line" =~ ^[[:blank:]]*$ ]]; then
printf "\n"
- break
+ state="whts"
elif [[ "$line" =~ $re_option ]]; then
opt_count=`echo $state | sed 's/^popt\([[:digit:]]\+\)/\1/'`
[ "$opt_count" -gt 0 ] && printf '\n'
@@ -89,6 +91,29 @@ while IFS= read line; do
fi
;;
+ "whts")
+ if [[ "$line" =~ ^[Hh]andling\ [Hh]osts ]]; then
+ printf ".SH HOSTS HANDLING\n"
+ state="phts"
+ fi
+ ;;
+
+ "phts")
+ if [[ "$line" =~ ^$ ]]; then
+ new_paragraph=1
+ elif ! [[ "$line" =~ ^[^[:space:]] ]]; then
+ if [[ ${new_paragraph:-0} = 1 ]]; then
+ printf ".P\n"
+ new_paragraph=0
+ fi
+ printf "$line\n" | sed -e 's/^ \{4\}//' -e 's/\s\+$//' \
+ -e 's/\s*\(--[[:alnum:]-]\+\|<[[:alnum:]_-]\+>\)\s\+/\n.B \1\n/g' \
+ -e 's/\s*\(--[[:alnum:]-]\+\|<[[:alnum:]_-]\+>\)$/\n.B \1/g'
+ else
+ break
+ fi
+ ;;
+
*) break
;;
diff --git a/cli/man/lmi.1 b/cli/man/lmi.1
index d402bf5..d3b771b 100644
--- a/cli/man/lmi.1
+++ b/cli/man/lmi.1
@@ -1,4 +1,4 @@
-.TH lmi 1 "October 2013" "openlmi-scripts 0.2.2" "User Commands"
+.TH lmi 1 "June 2014" "openlmi-scripts 0.9.1.1" "User Commands"
.SH NAME
lmi \- meta-command for managing systems with OpenLMI providers
@@ -65,6 +65,20 @@ Show this text and quit.
.TP
.I --version
Print version of 'lmi' in use and quit.
+.SH HOSTS HANDLING
+If no
+.B --host
+or
+.B --hosts-file
+are given, the "localhost" will be tried. When
+running under root with Pegasus CIMOM, this results in a connection over
+unix socket (no need to supply credentials).
+.P
+Hosts may contain embedded credentials e.g.:
+ http://user:passwd@hostname:5988
+Avoid supplying them on command line though. Always prefer the
+.B --hosts-file
+option.
.SH CONFIGURATION
There is a system-wide configuration file located at
`/etc/openlmi/lmi.conf` and user configuration file searched at `~/.lmirc`.
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : openlmi-tools-lmiwbem
>---------------------------------------------------------------
commit ebd3047ba946ff0238edc874e4069db82184329d
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Jun 23 14:08:15 2014 +0200
introduce WS-MAN support
add various changes needed/related to WS-MAN support.
>---------------------------------------------------------------
Diff suppressed because of size. To see it, use:
git diff --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol ^ebd3047ba946ff0238edc874e4069db82184329d~1 ebd3047ba946ff0238edc874e4069db82184329d