diff --git a/imcsdk/apis/server/bios.py b/imcsdk/apis/server/bios.py index f2a1b9b1..74b93afa 100644 --- a/imcsdk/apis/server/bios.py +++ b/imcsdk/apis/server/bios.py @@ -22,6 +22,7 @@ from imcsdk.mometa.lsboot.LsbootDevPrecision import LsbootDevPrecision from imcsdk.imcexception import ImcOperationError from imcsdk.apis.utils import _is_valid_arg +import imcsdk.imcgenutils as imcgenutils log = logging.getLogger('imc') @@ -137,7 +138,7 @@ def _is_boot_order_policy(dn): def _get_device_type(policy_type, in_device): if policy_type == "boot-order-policy": - for device_type, device_props in policy_device_dict.iteritems(): + for device_type, device_props in imcgenutils.iteritems(policy_device_dict): if device_props["class_id"] == in_device._class_id and \ device_props["access"] == in_device.access: return device_type @@ -200,7 +201,7 @@ def _add_boot_device(handle, parent_dn, boot_device): (boot_device["device-type"], boot_device["name"])) device.order = boot_device["order"] - device_props = {key: value for key, value in boot_device.iteritems() if key not in ["order", "device-type", "name"]} + device_props = {key: value for key, value in imcgenutils.iteritems(boot_device) if key not in ["order", "device-type", "name"]} device.set_prop_multiple(**device_props) if hasattr(device, "state"): device.state = "enabled" @@ -288,7 +289,7 @@ def boot_precision_configured_get(handle, server_id=1): class_to_name_dict = { value["class_id"]: key for key, - value in precision_device_dict.items()} + value in imcgenutils.iteritems(precision_device_dict)} server_dn = get_server_dn(handle, server_id) pmo = LsbootDevPrecision(parent_mo_or_dn=server_dn) diff --git a/imcsdk/apis/server/inventory.py b/imcsdk/apis/server/inventory.py index 8979475e..d18081d9 100644 --- a/imcsdk/apis/server/inventory.py +++ b/imcsdk/apis/server/inventory.py @@ -216,7 +216,7 @@ def _get_inventory_csv(inventory, file_name, spec=inventory_spec): if file_name is None: raise ImcOperationError("Inventory collection", "file_name is a required parameter") - f = csv.writer(open(file_name, "wb")) + f = csv.writer(open(file_name, "w")) x = inventory for comp in spec: @@ -291,7 +291,7 @@ def _get_inventory_html(inventory, file_name, spec=inventory_spec): if file_name is None: raise ImcOperationError("Inventory collection", "file_name is a required parameter") - f = open(file_name, "wb") + f = open(file_name, "w") html = "" html += "\n" diff --git a/imcsdk/apis/server/remotepresence.py b/imcsdk/apis/server/remotepresence.py index a478911a..cd74bb2a 100644 --- a/imcsdk/apis/server/remotepresence.py +++ b/imcsdk/apis/server/remotepresence.py @@ -17,8 +17,14 @@ """ import os import time -import urlparse import re + +try: + from urllib.parse import urlsplit +except ImportError: + from urlparse import urlsplit + + from imcsdk.mometa.comm.CommKvm import CommKvm from imcsdk.mometa.comm.CommVMedia import CommVMedia from imcsdk.mometa.comm.CommVMediaMap import CommVMediaMap @@ -274,9 +280,9 @@ def vmedia_mount_iso_uri(handle, uri, user_id=None, password=None, mount_options = "noauto" # Set the Map based on the protocol - if urlparse.urlsplit(uri).scheme == 'http': + if urlsplit(uri).scheme == 'http': mount_protocol = "www" - elif urlparse.urlsplit(uri).scheme == 'https': + elif urlsplit(uri).scheme == 'https': mount_protocol = "www" elif CIFS_URI_PATTERN.match(uri): mount_protocol = "cifs" @@ -285,7 +291,7 @@ def vmedia_mount_iso_uri(handle, uri, user_id=None, password=None, else: # Raise ValueError and bail raise ValueError("Unsupported protocol: " + - urlparse.urlsplit(uri).scheme) + urlsplit(uri).scheme) # Convert no user/pass to blank strings if not user_id: diff --git a/imcsdk/imccoreutils.py b/imcsdk/imccoreutils.py index 6e9e1908..86b05fbb 100644 --- a/imcsdk/imccoreutils.py +++ b/imcsdk/imccoreutils.py @@ -27,7 +27,7 @@ from . imcmeta import MO_CLASS_ID, METHOD_CLASS_ID, OTHER_TYPE_CLASS_ID, \ MO_CLASS_META from .imcexception import ImcOperationError, ImcValidationException -from imccoremeta import MoPropertyMeta +from .imccoremeta import MoPropertyMeta log = logging.getLogger('imc') diff --git a/imcsdk/imchandle.py b/imcsdk/imchandle.py index f293d08c..7afbb563 100644 --- a/imcsdk/imchandle.py +++ b/imcsdk/imchandle.py @@ -394,7 +394,7 @@ def add_mo(self, mo, modify_present=True, timeout=None): obj = handle.add_mo(mo) """ - from imccoreutils import validate_mo_version + from .imccoreutils import validate_mo_version validate_mo_version(self, mo) @@ -425,7 +425,7 @@ def set_mo(self, mo, timeout=None): obj = handle.set_mo(mo) """ - from imccoreutils import validate_mo_version + from .imccoreutils import validate_mo_version validate_mo_version(self, mo) @@ -448,6 +448,10 @@ def remove_mo(self, mo, timeout=None): obj = handle.remove_mo(mo) """ + from .imccoreutils import validate_mo_version + + validate_mo_version(self, mo) + mo.status = "deleted" if mo.parent_mo: mo.parent_mo.child_remove(mo)