Skip to content

Commit

Permalink
python3 compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Swapnil Wagh <waghswapnil@gmail.com>
  • Loading branch information
waghswapnil committed May 9, 2017
1 parent 187ca49 commit 2e098ae
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
7 changes: 4 additions & 3 deletions imcsdk/apis/server/bios.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions imcsdk/apis/server/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 += "<html>\n"
Expand Down
14 changes: 10 additions & 4 deletions imcsdk/apis/server/remotepresence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion imcsdk/imccoreutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
8 changes: 6 additions & 2 deletions imcsdk/imchandle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit 2e098ae

Please sign in to comment.