Skip to content

Commit 5f00cca

Browse files
committed
add /api/v1/SetBootFromVirtualMedia
1 parent 55b659c commit 5f00cca

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

src/web-ui/app.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import requests
66
from requests.auth import HTTPBasicAuth
77
from types import SimpleNamespace
8+
import json
89

910
app = APIFlask(__name__)
1011
app.config.update(TESTING=True, SECRET_KEY=os.getenv("SECRET_KEY"))
@@ -33,7 +34,7 @@ def api_response(req):
3334
)
3435

3536

36-
def api_call(path=None, method=None, payload=None):
37+
def api_call(path=None, method=None, payload=None, raw_payload=False):
3738
assert method is not None
3839
url = f"https://{session.get('IDRAC_HOST')}/redfish/v1/{path}"
3940
authHeaders = HTTPBasicAuth(
@@ -48,13 +49,22 @@ def api_call(path=None, method=None, payload=None):
4849
verify=False,
4950
)
5051
elif method == "POST":
51-
req = requests.post(
52-
url,
53-
auth=authHeaders,
54-
verify=False,
55-
json=payload,
56-
headers={"Content-Type": "application/json"},
57-
)
52+
if raw_payload:
53+
req = requests.post(
54+
url,
55+
auth=authHeaders,
56+
verify=False,
57+
data=payload,
58+
headers={"Content-Type": "application/json"},
59+
)
60+
else:
61+
req = requests.post(
62+
url,
63+
auth=authHeaders,
64+
verify=False,
65+
json=payload,
66+
headers={"Content-Type": "application/json"},
67+
)
5868

5969
return req
6070

@@ -298,6 +308,23 @@ def UnmountISO():
298308
return api_response(req)
299309

300310

311+
@app.route("/api/v1/SetBootFromVirtualMedia", methods=["POST"])
312+
def SetBootFromVirtualMedia():
313+
payload = {
314+
"ShareParameters": {"Target": "ALL"},
315+
"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
316+
}
317+
318+
req = api_call(
319+
path="Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemConfiguration", # noqa: E501
320+
method="POST",
321+
payload=json.dumps(payload),
322+
raw_payload=True,
323+
)
324+
325+
return api_response(req)
326+
327+
301328
@app.route("/api/v1/GetOnetimeBootValue", methods=["POST"])
302329
def get_current_onetime_boot_order():
303330
return execute_redfish_command("GetOnetimeBootValue")

0 commit comments

Comments
 (0)