Skip to content

Commit

Permalink
Merge pull request #496 from DMTF/xml-gets
Browse files Browse the repository at this point in the history
Corrected out-of-service requests for xml files
  • Loading branch information
mraineri authored Jul 15, 2022
2 parents e6748c5 + 8a9d86a commit 042f534
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion common/traverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os

import redfish as rf
import requests
import common.catalog as catalog
from common.helper import navigateJsonFragment, splitVersionString
from common.metadata import Metadata
Expand Down Expand Up @@ -55,6 +56,11 @@ def __init__(self, config):
proxies = {}
if self.config['serv_http_proxy'] != '': proxies['http'] = self.config['serv_http_proxy']
if self.config['serv_https_proxy'] != '': proxies['https'] = self.config['serv_https_proxy']
self.ext_proxies=None
if self.config['ext_http_proxy'] != '' or self.config['ext_https_proxy'] != '':
self.ext_proxies = {}
if self.config['ext_http_proxy'] != '': self.ext_proxies['http'] = self.config['ext_http_proxy']
if self.config['ext_https_proxy'] != '': self.ext_proxies['https'] = self.config['ext_https_proxy']
self.context = rf.redfish_client(base_url=rhost, username=user, password=passwd, timeout=self.config['timeout'], proxies=proxies)
self.context.login( auth = self.config['authtype'].lower() )

Expand Down Expand Up @@ -158,7 +164,11 @@ def callResourceURI(self, URILink):
try:
startTick = datetime.now()
mockup_file_path = os.path.join(config['mockup'], URLDest.replace('/redfish/v1/', '', 1).strip('/'), 'index.json')
if config['mockup'] != '' and os.path.isfile(mockup_file_path):
if not inService:
req = requests.get(URLDest, proxies=self.ext_proxies)
content = req.json if not isXML else req.text
response = rf.rest.v1.StaticRestResponse(Status=req.status_code, Headers={x:req.headers[x] for x in req.headers}, Content=req.text)
elif config['mockup'] != '' and os.path.isfile(mockup_file_path):
content = {}
with open(mockup_file_path) as mockup_file:
content = json.load(mockup_file)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
redfish>=3.1.5
requests
beautifulsoup4>=4.6.0
lxml

0 comments on commit 042f534

Please sign in to comment.