-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
745 lines (612 loc) · 21.5 KB
/
Copy pathapp.py
File metadata and controls
745 lines (612 loc) · 21.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
import os
import subprocess
from flask import jsonify, render_template, request, session
from apiflask import APIFlask
import requests
from requests.auth import HTTPBasicAuth
import json
from time import sleep
import platform
from settings import settings
from tenacity import retry, wait_exponential, before_log, stop_after_attempt
import logging
import sys
import time
from functools import wraps
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
log = logging.getLogger(__name__)
app = APIFlask(__name__)
app.config.update(TESTING=True, SECRET_KEY=os.getenv("SECRET_KEY"))
IDRAC_HOST = None # noqa: F841
IDRAC_USERNAME = None # noqa: F841
IDRAC_PASSWORD = None # noqa: F841
HOST_HEALTHCHECK_POLL_IP = None
DEFAULT_HTTP_REQ_TIMEOUT = settings.get("DEFAULT_HTTP_REQ_TIMEOUT", 20)
IDRAC_HTTP_REQ_TIMEOUT = settings.get("IDRAC_HTTP_REQ_TIMEOUT", 15)
IDRAC_SLEEP_AFTER_RESET_REQUEST_REQ = settings.get(
"IDRAC_SLEEP_AFTER_RESET_REQUEST_REQ", 3
)
playwright_working_dir = os.getenv(
"PLAYWRIGHT_WORKING_DIR", "../playwright-boostrap/"
) # noqa: E501
PWDEBUG = os.getenv("PWDEBUG", False)
playwright_headed = "--headed" if "PWDEBUG" in os.environ else ""
IDRAC_SCRIPTS_BASE_PATH = os.getenv(
"IDRAC_SCRIPTS_BASE_PATH", "./iDRAC-Redfish-Scripting/Redfish Python/"
)
HOST_HEALTHCHECK_POLL_IP = settings.get("HOST_HEALTHCHECK_POLL_IP")
session_requests = requests.Session()
session_requests.verify = False
def countdown(seconds):
log.info(f"Sleeping for {seconds} seconds")
for remaining in range(seconds, 0, -1):
sys.stdout.write(f"\rTime left: {remaining} seconds")
sys.stdout.flush()
time.sleep(1)
# Clear the line after countdown ends
sys.stdout.write("\rCountdown finished!\n")
def ConnectToVPN():
"""
Attempt to connect to VPN
Assumptions:
- Any existing VPN connection will be torn down
- Credentials for VPN will be fetched using secret(s)
required to fetch them
- VPN tunnel (wireguard) will be started
"""
log.info(
"Tear down any existing VPN connection "
"(assumes wg-quick is used for WireGuard"
)
subprocess.run(["wg-quick", "down", "wg0"], check=False)
log.info("Download the psonoci tool")
subprocess.run(
[
"curl",
"https://get.psono.com/psono/psono-ci/x86_64-linux/psonoci",
"--output",
"./psonoci",
],
check=True,
)
log.info("Mark psonoci as executable")
subprocess.run(["chmod", "+x", "./psonoci"], check=True)
# Fetch credentials using the psonoci tool
PSONO_CI_VPN_SECRET_NOTE_ID = settings.get(
"PSONO_CI_VPN_SECRET_NOTE_ID"
) # noqa: E501
try:
os.environ["PSONO_CI_API_KEY_ID"] = settings.get(
"PSONO_CI_API_KEY_ID"
) # noqa: E501
os.environ["PSONO_CI_API_SECRET_KEY_HEX"] = settings.get(
"PSONO_CI_API_SECRET_KEY_HEX"
)
os.environ["PSONO_CI_SERVER_URL"] = settings.get(
"PSONO_CI_SERVER_URL"
) # noqa: E501
result = subprocess.run(
[
"./psonoci",
"secret",
"get",
PSONO_CI_VPN_SECRET_NOTE_ID,
"notes",
], # noqa: E501
check=True,
capture_output=True,
text=True,
env=os.environ,
)
log.info(result)
except Exception as e:
log.error(e)
vpn_config = result.stdout.strip()
log.debug("Write the VPN configuration to /etc/wireguard/wg0.conf")
with open("/etc/wireguard/wg0.conf", "w") as vpn_file:
vpn_file.write(vpn_config)
try:
log.debug("Start the VPN tunnel")
sleep(3)
subprocess.run(["wg-quick", "up", "wg0"], check=False)
print("VPN connected successfully.")
except subprocess.CalledProcessError as e:
print(f"An error occurred while executing a command: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
def recover_from_error_vpn_not_active(retry_state):
"""Attempt to recover from error VPN
not active.
"""
log.debug(retry_state)
ConnectToVPN()
@retry(
wait=wait_exponential(multiplier=1, min=5, max=10),
before=before_log(log, logging.DEBUG),
stop=stop_after_attempt(4),
retry_error_callback=recover_from_error_vpn_not_active,
)
def vpn_must_be_up(f):
"""
Checks for a route to the IDRAC_HOST
The/a valid VPN connection
must be up for the majority of the server
bootstrap process to work.
If the VPN is *up*, then the IDRAC_HOST
will be reachable (there will be a route to
that host/IP).
If the VPN is *down* then the IDRAC_HOST will
likely be 'no route to host'.
"""
@wraps(f)
def wrapper(*args, **kwds):
log.info("Calling wrapper vpn_must_be_up")
try:
url = f"https://{settings.get('IDRAC_HOST')}/start.html"
log.info(f"Contacting: {url}")
requests.get(url, verify=False, timeout=DEFAULT_HTTP_REQ_TIMEOUT)
except Exception as e:
log.error(f"Verify VPN connection is up & functioning. {e}")
log.debug("Attempting reconnect of VPN")
ConnectToVPN()
return f(*args, **kwds)
return wrapper
def api_response(req):
try:
resp = req.json()
except Exception:
resp = req.text
return (
jsonify({"resp": resp, "status_code": req.status_code}),
req.status_code,
)
def api_call(
path=None, method=None, payload=None, raw_payload=False, timeout=60
): # noqa: E501
assert method is not None
if "redfish" not in path and "http" not in path:
url = f"https://{settings.get('IDRAC_HOST')}/redfish/v1/{path}"
if "redfish" in path:
url = f"https://{settings.get('IDRAC_HOST')}/{path}"
authHeaders = HTTPBasicAuth(
settings.get("IDRAC_USERNAME"), settings.get("IDRAC_PASSWORD")
) # noqa: E501
# Making the request
if method == "GET":
req = requests.get(
url,
auth=authHeaders,
verify=False,
timeout=timeout, # noqa: E501
)
elif method == "POST":
if raw_payload:
req = requests.post(
url,
auth=authHeaders,
verify=False,
data=payload,
headers={"Content-Type": "application/json"},
timeout=DEFAULT_HTTP_REQ_TIMEOUT,
)
else:
req = requests.post(
url,
auth=authHeaders,
verify=False,
json=payload,
headers={"Content-Type": "application/json"},
)
elif method == "PATCH":
req = requests.patch(
url,
auth=authHeaders,
verify=False,
json=payload,
headers={"Content-Type": "application/json"},
)
return req
@app.before_request
def load_idrac_settings():
"""
Load settings in following order of presidence:
- environment variable
- session variable (from url GET paramenter)
- default fallback
"""
settings = ["IDRAC_HOST", "IDRAC_USERNAME", "IDRAC_PASSWORD"]
for setting in settings:
# Default setting to None (meaning unset)
exec(f"{setting}=None")
# Check if setting is set in environment variable
if os.getenv(setting, None):
exec(f"{setting}='{os.getenv(setting)}'")
# Check if setting is set in url get parameter
if request.args.get(setting, None):
session[setting] = request.args.get(setting)
exec(f"{setting}='{request.args.get(setting)}'")
@app.context_processor
def inject_settings():
return dict(IDRAC_HOST=settings.get("IDRAC_HOST"))
@app.route("/")
def index():
load_idrac_settings()
return render_template("index.html")
@app.route("/wipefs")
def wipefs():
"""Wipe the entire server"""
# Power off server
# Mount & Boot into fedora live CD (there must be a better way...)
# SSH into server
# Run 'wip-all-disks.sh'
# See https://github.com/KarmaComputing/server-bootstrap/blob/d9faddb3138d4ddb733dd9890d35a7c1296cdee7/src/playbooks/scripts/wipe-all-disks.sh#L1 # noqa: E501
return {"message": "Server has been wiped"}
def PollPingHostOSOnline(
ip=HOST_HEALTHCHECK_POLL_IP, interval=1, max_attempts=35
): # noqa: E501
""" "
Keep polling max_attempts until host os responds
"""
def ping(ip):
"""
Ping the IP address to check for a response.
Returns True if the IP is reachable, False otherwise.
"""
# Determine the ping command based on the operating system
ping_command = (
"ping -c 1 " + ip
if platform.system().lower() != "windows"
else "ping -n 1 " + ip
)
# Execute the ping command and check the response
response = os.system(ping_command)
return response == 0 # Return True if ping was successful
print(f"Polling IP address {ip}...")
attempt = 0
while attempt < max_attempts:
if ping(ip):
print(f"IP address {ip} is now reachable.")
return True
attempt += 1
print(
f"Attempt {attempt}/{max_attempts}: "
f"No response from {ip}. "
f"Retrying in {interval} seconds..."
)
sleep(interval)
print(
f"Reached maximum attempts ({max_attempts}). "
"IP address {ip} is not reachable."
)
return False
def justKeepRedeploying(max_repeated_deploys=-1, delayBetweenRedeploy=180):
print("Starting justKeepRedeploying")
execute_redfish_command("Bootstrap")
deploy_count = 0
while deploy_count < max_repeated_deploys or max_repeated_deploys == -1:
print(f"Deployment #{deploy_count + 1}")
countdown(delayBetweenRedeploy)
execute_redfish_command("Bootstrap")
deploy_count += 1
if max_repeated_deploys != -1 and deploy_count >= max_repeated_deploys:
break
print("Deployment loop finished")
def execute_redfish_command(action, redfish_uri=None):
if action == "Bootstrap":
VerifyVPNAccess()
VerifyiDRACAccess()
ForceOff()
sleepSecconds = 15
countdown(sleepSecconds)
# iDRACSetVirtualTerminalHTML5()
UnmountISO()
MountISO()
SetBootFromVirtualMedia()
GetPowerState()
sleepSecconds = 10
countdown(sleepSecconds)
PowerOn()
# Setup host disks
# Run install
# HealthCheckBootedHost
return PollPingHostOSOnline()
if action == "ForceRestart":
payload = {"ResetType": "ForceRestart"}
req = api_call(
path="Systems/System.Embedded.1/Actions/ComputerSystem.Reset",
method="POST",
payload=payload,
)
return api_response(req)
if action == "GetOnetimeBootValue":
req = api_call(path="Systems/System.Embedded.1", method="GET")
return api_response(req)
if action == "ChangeBiosBootOrderREDFISH":
command = f"python {IDRAC_SCRIPTS_BASE_PATH}ChangeBiosBootOrderREDFISH.py -ip {IDRAC_HOST} -u {IDRAC_USERNAME} -p {IDRAC_PASSWORD} --get" # noqa: E501
result = subprocess.run(command, capture_output=True, shell=True)
if action == "RawRequest":
req = api_call(
path=redfish_uri,
method="GET",
)
return req
else:
command = f"python {IDRAC_SCRIPTS_BASE_PATH}GetSetPowerStateREDFISH.py -ip {IDRAC_HOST} -u {IDRAC_USERNAME} -p {IDRAC_PASSWORD} --set {action}" # noqa: E501
result = subprocess.run(command, capture_output=True, shell=True)
return (
jsonify(
{
"output": result.stdout.decode("utf-8"),
"error": result.stderr.decode("utf-8"),
}
),
result.returncode,
)
@app.route("/api/v1/Bootstrap", methods=["POST"])
def bootstrap():
return execute_redfish_command("Bootstrap")
@vpn_must_be_up
def VerifyVPNAccess():
pass
# NOTE "max" does not think what you may think it
# means - you probably want "stop_after_attempt"
# See:
# https://tenacity.readthedocs.io/en/latest/index.html?highlight=max_attempts
@retry(
wait=wait_exponential(multiplier=1, min=4, max=20),
before=before_log(log, logging.DEBUG),
stop=stop_after_attempt(20),
)
@vpn_must_be_up
def VerifyiDRACAccess():
try:
req = api_call(
path="Systems/", method="GET", timeout=IDRAC_HTTP_REQ_TIMEOUT
) # noqa: E501
if req.status_code == 200:
log.info(f"iDRACAccess is OK. Got status code {req.status_code}")
if req.status_code == 401:
msg = f"VerifyiDRACAccess returned 401 {req.text}"
log.error(msg)
raise Exception(msg)
except requests.exceptions.ConnectionError as e:
log.error(f"Connection error occurred: {e}")
raise
except requests.exceptions.RequestException as e:
log.error(f"An HTTP error occurred: {e}")
raise
return req
@app.route("/api/v1/VerifyiDRACAccess", methods=["POST"])
def route_VerifyiDRACAccess():
req = VerifyiDRACAccess()
return api_response(req)
def ResetiDRAC():
"""
Soft reset the iDRAC.
Since Dell iDRACs can easily get into a 'bad' state
the iDRAC reset often overcomes these bad states.
For example, mounting virual media, even after unmounting
media and terminating sessions can leave the iDRAC is a
'operations busy' state with no way to mount new media.
Dell documents this behaviour as:
"Sometimes, iDRAC may become unresponsive due to various reasons."
https://www.dell.com/support/kbdoc/en-uk/000126703/how-to-reset-the-internal-dell-remote-access-controller-idrac-on-a-poweredge-server
See also Rigor: https://oxide.computer/principles
"""
print("ResetiDRAC")
data = {"ResetType": "GracefulRestart"}
req = api_call(
path="Managers/iDRAC.Embedded.1/Actions/Manager.Reset/",
method="POST", # noqa: E501
payload=data,
)
msg = (
f"Sleeping {IDRAC_SLEEP_AFTER_RESET_REQUEST_REQ} "
"secconds to give iDRAC time to commence the reset "
"without sleeping, subsequent iDRAC api request may appear to "
"succeed before the iDRAC actually starts performing it's reset, "
"causing confusing.\n"
"Note this sleep has nothing to do with verifying the iDRAC has "
"completed it's reset. For that, calls to VerifyiDRACAccess may be "
"made."
)
log.info(msg)
sleep(IDRAC_SLEEP_AFTER_RESET_REQUEST_REQ)
return req
@app.route("/api/v1/ResetiDRAC", methods=["POST"])
def route_ResetiDRAC():
req = ResetiDRAC()
return req
def iDRACSetVirtualTerminalHTML5():
command = (
f"IDRAC_HOST=http://{IDRAC_HOST} IDRAC_USERNAME={IDRAC_USERNAME} "
f"IDRAC_PASSWORD={IDRAC_PASSWORD} npx playwright test scripts/iDRAC-set-virtual-terminal-html5.spec.ts " # noqa: E501
f" {playwright_headed}"
)
result = subprocess.run(
command,
cwd=playwright_working_dir,
env=os.environ,
capture_output=True,
shell=True,
) # noqa: E501
return (
jsonify(
{
"output": result.stdout.decode("utf-8"),
"error": result.stderr.decode("utf-8"),
}
),
result.returncode,
)
@app.route("/api/v1/iDRACSetVirtualTerminalHTML5", methods=["POST"])
def route_iDRACSetVirtualTerminalHTML5():
resp = iDRACSetVirtualTerminalHTML5()
return resp
def PowerOn():
print("PowerOn")
print("Ensuring PowerState is 'Off' before attempting power On")
req = GetPowerState()
power_state = req.json()["PowerState"]
if power_state != "Off":
print(f"PowerState is currently {power_state}")
Exception(
"PowerState is not 'Off' "
f"(it's {power_state}). Refusing to Power on" # noqa: E501
)
data = {"ResetType": "On"}
req = api_call(
path="Systems/System.Embedded.1/Actions/ComputerSystem.Reset",
method="POST", # noqa: E501
payload=data,
)
return req
@app.route("/api/v1/PowerOn", methods=["POST"])
def route_PowerOn():
req = PowerOn()
return api_response(req)
def PowerOff():
print("Power OFF (GracefulShutdown)")
data = {"ResetType": "GracefulShutdown"}
req = api_call(
path="Systems/System.Embedded.1/Actions/ComputerSystem.Reset",
method="POST", # noqa: E501
payload=data,
)
return req
def ForceOff():
print("ForceOff")
req = GetPowerState()
power_state = req.json()["PowerState"]
if power_state != "On":
print(f"PowerState is currently {power_state}")
Exception(f"PowerState is {power_state}. Refusing to Power off")
data = {"ResetType": "ForceOff"}
req = api_call(
path="Systems/System.Embedded.1/Actions/ComputerSystem.Reset",
method="POST", # noqa: E501
payload=data,
)
return req
@app.route("/api/v1/ForceOff", methods=["POST"])
@app.route("/api/v1/PowerOff", methods=["POST"])
def route_ForceOff():
req = ForceOff()
return api_response(req)
@app.route("/api/v1/ForceRestart", methods=["POST"])
def force_restart():
return execute_redfish_command("ForceRestart")
@app.route("/api/v1/GracefulShutdown", methods=["POST"])
def set_power_graceful_shutdown():
return execute_redfish_command("GracefulShutdown")
@vpn_must_be_up
def GetPowerState():
print("GetPowerState")
req = api_call(path="Systems/System.Embedded.1", method="GET")
req.raise_for_status()
if req.status_code == 200:
power_state = req.json().get("PowerState")
print(f"PowerState is {power_state}")
return req
@app.route("/api/v1/GetPowerState", methods=["POST"])
def route_GetPowerState():
req = GetPowerState()
return api_response(req)
@app.route("/api/v1/ChangeBiosBootOrderREDFISH", methods=["POST"])
def get_bios_boot_order():
return execute_redfish_command("ChangeBiosBootOrderREDFISH")
@vpn_must_be_up
def MountISO():
print("MountISO")
data = {"Image": "http://138.201.59.208/sites/default/files/ipxe.iso"}
req = api_call(
path="Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.InsertMedia", # noqa: E501
method="POST", # noqa: E501
payload=data,
)
if req.status_code == "500":
try:
message = req.json()["error"]["@Message.ExtendedInfo"][0][
"Message"
] # noqa: E501
if (
message
== "The Virtual Media image server is already connected." # noqa: E501
): # noqa: E501
print("The Virtual Media image server is already connected.")
else:
log.error(f"req.status_code: {req.status_code}")
log.error(
"Performing ResetiDRAC to attempt VirtualMedia state fix"
) # noqa: E501
ResetiDRAC()
VerifyiDRACAccess()
except Exception as e:
print(e)
elif req.status_code == 204:
print("http 204 No Content successful - (ISO mounted)")
return req
@app.route("/api/v1/MountISO", methods=["POST"])
def route_MountISO():
req = MountISO()
return api_response(req)
@vpn_must_be_up
def UnmountISO():
print(UnmountISO)
req = api_call(
path="Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.EjectMedia", # noqa: E501
method="POST",
payload={},
)
return req
@app.route("/api/v1/UnmountISO", methods=["POST"])
def route_UnmountISO():
req = UnmountISO()
return api_response(req)
@vpn_must_be_up
def EnableHostWatchdogTimer():
req = api_call(
path="/redfish/v1/Systems/System.Embedded.1", # noqa: E501
method="PATCH",
payload={"HostWatchdogTimer": {"FunctionEnabled": True}},
)
return req
@app.route("/api/v1/EnableHostWatchdogTimer", methods=["POST"])
def route_EnableHostWatchdogTimer():
req = EnableHostWatchdogTimer()
return api_response(req)
@vpn_must_be_up
def SetBootFromVirtualMedia():
payload = {
"ShareParameters": {"Target": "ALL"},
"ImportBuffer": '<SystemConfiguration><Component FQDD="iDRAC.Embedded.1"><Attribute Name="ServerBoot.1#BootOnce">Enabled</Attribute><Attribute Name="ServerBoot.1#FirstBootDevice">VCD-DVD</Attribute></Component></SystemConfiguration>', # noqa: E501
}
req = api_call(
path="Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemConfiguration", # noqa: E501
method="POST",
payload=json.dumps(payload),
raw_payload=True,
)
if req.status_code == 202:
print("HTTP 202 Accepted - Boot device set/setting to VirtualMedia")
return req
@app.route("/api/v1/SetBootFromVirtualMedia", methods=["POST"])
def route_SetBootFromVirtualMedia():
req = SetBootFromVirtualMedia()
return api_response(req)
@app.route("/api/v1/GetOnetimeBootValue", methods=["POST"])
def get_current_onetime_boot_order():
return execute_redfish_command("GetOnetimeBootValue")
@vpn_must_be_up
def RawRequest(redfish_uri: str):
"""
Pass any valid Redfish api url and the response is returned
e.g.
https://192.168.1.1/redfish/v1/Systems/System.Embedded.1?$select=BootProgress/LastState
"""
return execute_redfish_command("RawRequest", redfish_uri=redfish_uri)
@app.route("/api/v1/RawRequest", methods=["POST"])
def route_RawRequest():
redfish_uri = request.json.get("data")
req = RawRequest(redfish_uri)
return api_response(req)