From dac9f7486a6f7663a04bdc0b189f47c4357f1b1b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 26 Oct 2020 15:20:13 -0400 Subject: [PATCH] Extend IMM remote media The classical remote media was incomplete and further needed fixes for IPv6 web sessions. Change-Id: Idfa1c06c69c96fdd10fce755fc7d73ebd12ee399 --- pyghmi/ipmi/oem/lenovo/imm.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 489076ff..bd311510 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -127,8 +127,7 @@ class IMMClient(object): srv = self.imm if ':' in srv: srv = '[{0}]'.format(srv) - self.adp_referer = 'https://{0}/designs/imm/index-console.php'.format( - srv) + self.adp_referer = 'https://imm/designs/imm/index-console.php' if ipmicmd.ipmi_session.password: self.username = ipmicmd.ipmi_session.userid.decode('utf-8') self.password = ipmicmd.ipmi_session.password.decode('utf-8') @@ -354,9 +353,9 @@ class IMMClient(object): 'password': self.password, 'SessionTimeout': 60}) headers = {'Connection': 'keep-alive', - 'Origin': 'https://1.2.3.4/', - 'Host': '1.2.3.4', - 'Referer': 'https://1.2.3.4/designs/imm/index.php', + 'Origin': 'https://imm/', + 'Host': 'imm', + 'Referer': 'https://imm/designs/imm/index.php', 'Content-Type': 'application/x-www-form-urlencoded'} wc.request('POST', '/data/login', adata, headers) rsp = wc.getresponse() @@ -372,7 +371,8 @@ class IMMClient(object): else: self.uploadtoken = {} wc.set_header('Referer', self.adp_referer) - wc.set_header('Host', self.imm) + wc.set_header('Host', 'imm') + wc.set_header('Origin', 'https://imm/') return wc @property @@ -482,6 +482,11 @@ class IMMClient(object): for uload in item['images']: if uload['status'] != 0: yield media.Media(uload['filename']) + for attached in item.get('urls', []): + filename = attached['url'] + filename = filename.split('/')[-1] + url = '/'.join(attached['url'].split('/')[:-1]) + yield media.Media(filename, url) def detach_remote_media(self): mnt = self.wc.grab_json_response(