From a1fe180e040d6751e0892b570f12fc587dfa12b3 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 12 Dec 2019 10:01:05 -0500 Subject: [PATCH] urlencode was not properly imported for py2/py3 This function move was not accomodated everywhere. Change-Id: I31839b84e750b0fc25a379db640193366a14c8c4 --- pyghmi/ipmi/oem/lenovo/handler.py | 7 +++++-- pyghmi/ipmi/oem/lenovo/imm.py | 17 ++++++++++------- pyghmi/ipmi/oem/lenovo/nextscale.py | 7 +++++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index 7ea9e285..63de168f 100755 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -17,7 +17,10 @@ import base64 import binascii import traceback -import urllib +try: + from urllib import urlencode +except ImportError: + from urllib.parse import urlencode import pyghmi.constants as pygconst import pyghmi.exceptions as pygexc @@ -739,7 +742,7 @@ class OEMHandler(generic.OEMHandler): conn = wc.SecureHTTPConnection(bmc, 443, verifycallback=self.ipmicmd.certverify) conn.connect() - params = urllib.urlencode({ + params = urlencode({ 'WEBVAR_USERNAME': username, 'WEBVAR_PASSWORD': password }) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index cab1e62d..d6376eff 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -37,7 +37,10 @@ import random import re import socket import struct -import urllib +try: + from urllib import urlencode +except ImportError: + from urllib.parse import urlencode import weakref @@ -319,10 +322,10 @@ class IMMClient(object): if se.errno != errno.ECONNREFUSED: raise return None - adata = urllib.urlencode({'user': self.username, - 'password': self.password, - 'SessionTimeout': 60 - }) + adata = urlencode({'user': self.username, + 'password': self.password, + 'SessionTimeout': 60 + }) headers = {'Connection': 'keep-alive', 'Referer': 'https://{0}/designs/imm/index.php'.format( self.imm), @@ -425,7 +428,7 @@ class IMMClient(object): def attach_remote_media(self, url, user, password): url = url.replace(':', '\:') - params = urllib.urlencode({ + params = urlencode({ 'RP_VmAllocateMountUrl({0},{1},1,,)'.format( self.username, url): '' }) @@ -464,7 +467,7 @@ class IMMClient(object): uload['slotId'])) for url in removeurls: url = url.replace(':', '\:') - params = urllib.urlencode({ + params = urlencode({ 'RP_VmAllocateUnMountUrl({0},{1},0,)'.format( self.username, url): ''}) result = self.wc.grab_json_response('/data?set', params, diff --git a/pyghmi/ipmi/oem/lenovo/nextscale.py b/pyghmi/ipmi/oem/lenovo/nextscale.py index 2660e9e0..9fa557ca 100644 --- a/pyghmi/ipmi/oem/lenovo/nextscale.py +++ b/pyghmi/ipmi/oem/lenovo/nextscale.py @@ -20,7 +20,10 @@ import pyghmi.ipmi.private.session as ipmisession import pyghmi.ipmi.sdr as sdr import pyghmi.util.webclient as webclient import struct -import urllib +try: + from urllib import urlencode +except ImportError: + from urllib.parse import urlencode import weakref from xml.etree.ElementTree import fromstring import zipfile @@ -386,7 +389,7 @@ class SMMClient(object): cv = self.ipmicmd.certverify wc = webclient.SecureHTTPConnection(self.smm, 443, verifycallback=cv) wc.connect() - loginform = urllib.urlencode({'user': self.username, + loginform = urlencode({'user': self.username, 'password': self.password}) wc.request('POST', '/data/login', loginform) rsp = wc.getresponse()