[cura-tools] master: lmi: fixed connection setup (6b4d4db)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 6b4d4dba0b400018abd45744dd66694354afdc91
Author: Michal Minar <miminar(a)redhat.com>
Date: Mon Dec 8 15:18:00 2014 +0100
lmi: fixed connection setup
LMIConnection no longer has a connection argument. This caused commands
modifying connection timeout to fail.
>---------------------------------------------------------------
cli/lmi/scripts/common/command/session.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/scripts/common/command/session.py b/cli/lmi/scripts/common/command/session.py
index cbbf9fa..7714bc2 100644
--- a/cli/lmi/scripts/common/command/session.py
+++ b/cli/lmi/scripts/common/command/session.py
@@ -193,9 +193,10 @@ class LmiSessionCommand(LmiEndPointCommand):
namespace = self.cim_namespace()
timeout = self.connection_timeout()
if timeout is not None:
- if hasattr(connection.connection, "timeout"):
+ conn = getattr(connection, "connection", connection)
+ if hasattr(conn, "timeout"):
LOG().debug("Set connection timeout to %d seconds.", timeout)
- connection.timeout = timeout * 1000
+ conn.timeout = timeout * 1000
else:
LOG().debug("Could not set connection timeout.")
if namespace is not None:
9 years, 4 months
[cura-tools] master: bump release version to 0.10.3 (b791831)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit b791831ebf54e93709786152185b6f85e6f13b56
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Dec 8 14:25:33 2014 +0100
bump release version to 0.10.3
>---------------------------------------------------------------
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 e951d1a..14b6dcb 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.10.2"
+__version__ = "0.10.3"
diff --git a/cli/man/lmi.1 b/cli/man/lmi.1
index 1ee7a63..799a1db 100644
--- a/cli/man/lmi.1
+++ b/cli/man/lmi.1
@@ -1,4 +1,4 @@
-.TH lmi 1 "October 2014" "openlmi-scripts 1.0.0" "User Commands"
+.TH lmi 1 "December 2014" "openlmi-scripts 0.10.3" "User Commands"
.SH NAME
lmi \- meta-command for managing systems with OpenLMI providers
9 years, 4 months
[cura-tools] master: make wsman support optional (df4399b)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit df4399b3103c01550487f9651b50f7e92ce27921
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Dec 2 11:17:35 2014 +0100
make wsman support optional
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 21 +++++++++++++++------
cli/lmi/shell/LMIWSMANClient.py | 17 ++++++++++++++++-
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 197cc12..4108549 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -167,10 +167,16 @@ def connect(uri, username="", password="", interactive=False, use_cache=True,
sys.stdout.write("\n")
return None
- connection = LMIConnection(
- uri, username, password, interactive=interactive,
- use_cache=use_cache, key_file=key_file, cert_file=cert_file,
- verify_server_cert=verify_server_cert)
+ try:
+ # Try to create a LMIConnection. We may fail to construct such object,
+ # if WSMAN isn't supported (package pywsman not available).
+ connection = LMIConnection(
+ uri, username, password, interactive=interactive,
+ use_cache=use_cache, key_file=key_file, cert_file=cert_file,
+ verify_server_cert=verify_server_cert)
+ except Exception as e:
+ lmi_raise_or_dump_exception(e)
+ return
# Verify the connection
rval, _, errorstr = connection.connect()
@@ -241,8 +247,11 @@ class LMIConnection(object):
"""
Disconnects and frees :py:class:`.LMICIMXMLClient` object.
"""
- self._client.disconnect()
- del self._client
+ try:
+ self._client.disconnect()
+ del self._client
+ except AttributeError:
+ pass
def __repr__(self):
"""
diff --git a/cli/lmi/shell/LMIWSMANClient.py b/cli/lmi/shell/LMIWSMANClient.py
index cfa794c..056253a 100644
--- a/cli/lmi/shell/LMIWSMANClient.py
+++ b/cli/lmi/shell/LMIWSMANClient.py
@@ -13,7 +13,11 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-import pywsman
+try:
+ import pywsman
+ HAVE_PYWSMAN = True
+except ImportError:
+ HAVE_PYWSMAN = False
import types
from lmi.shell.compat import *
@@ -22,8 +26,11 @@ from lmi.shell.LMIDecorators import lmi_wrap_cim_exceptions
from lmi.shell.LMIDecorators import lmi_wrap_cim_exceptions_rval
from lmi.shell.LMIExceptions import CIMError
+from lmi.shell.LMIExceptions import ConnectionError
from lmi.shell.LMIExceptions import LMINotSupported
+from lmi.shell.LMIShellLogger import lmi_get_logger
+
from lmi.shell.LMIReturnValue import LMIReturnValue
from lmi.shell.LMIUtil import lmi_instance_to_path
@@ -47,6 +54,8 @@ SCHEMES = {
"DCIM": "http://schemas.dell.com/wbem/wscim/1/cim-schema/2"
}
+logger = lmi_get_logger()
+
class LMIWSMANClient(object):
"""
@@ -76,6 +85,12 @@ class LMIWSMANClient(object):
def __init__(self, uri, username="", password="", interactive=False,
verify_server_cert=True, key_file=None, cert_file=None):
+ if not HAVE_PYWSMAN:
+ logger.error("WSMAN not supported")
+ raise ConnectionError(
+ wbem.CIM_ERR_NOT_SUPPORTED,
+ "WSMAN not supported")
+
if not uri.startswith("http://") and \
not uri.startswith("https://"):
uri = "https://" + uri
9 years, 4 months