Debian Codegraph @

ansible_collections/dellemc/openmanage/plugins/module_utils/omevv_utils/omevv_firmware_utils.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3 # Dell OpenManage Ansible Modules
4 # Version 9.10.0
5 # Copyright (C) 2024-2025 Dell Inc. or its subsidiaries. All Rights Reserved.
6
7 # Redistribution and use in source and binary forms, with or without modification,
8 # are permitted provided that the following conditions are met:
9
10 # * Redistributions of source code must retain the above copyright notice,
11 # this list of conditions and the following disclaimer.
12
13 # * Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #
27
28
29 from __future__ import (absolute_import, division, print_function)
30 import time
31
32 __metaclass__ = type
33
34 INVALID_REPO_PROFILE_MSG = "Invalid repository profile: {repository_profile}. Please provide a valid profile."
35 NO_REPO_PROFILE_MSG = "No repository profiles found."
36 INVALID_CLUSTER_NAMES_MSG = "Invalid cluster names: {cluster_names}. Please provide valid cluster(s)."
37 NO_CLUSTERS_FOUND_MSG = "No clusters found."
38 PROFILE_URI = "/RepositoryProfiles"
39 RESYNC_UMP_URI = "/RepositoryProfiles/ResyncRepository"
40 TEST_CONNECTION_URI = "/RepositoryProfiles/TestConnection"
41 TEST_CONNECTION_HISTORY = "/TestConnectionJobs/{job_id}/ExecutionHistories"
42 BASELINE_PROFILE_URI = "/Consoles/{vcenter_uuid}/BaselineProfiles"
43 TEST_CONNECTION_URI = "/RepositoryProfiles/TestConnection"
44 CLUSTER_URI = "/Consoles/{vcenter_uuid}/Clusters"
45 CLUSTER_IDS_URI = "/Consoles/{vcenter_uuid}/Groups/getGroupsForClusters"
46 DRIFT_URI = "/Consoles/{vcenter_uuid}/UpdateJobs"
47 FIRMARE_UPDATE_URI = "/Consoles/{vcenter_uuid}/Groups/{cluster_group_id}/Update"
48 FIRMWARE_UPDATE_JOB_TRACK_URI = "/Consoles/{vcenter_uuid}/UpdateJobs/{job_id}"
49 TRIGGER_UPDATE_CHECK_URI = "/Consoles/{vcenter_uuid}/CanTriggerUpdate"
50 FIRMWARE_UPDATE_JOB_NAME_CHECK_URI = "/Consoles/{vcenter_uuid}/UpdateJobs?jobtype=FWUpdate"
51
52
53 class OMEVVFirmwareProfile:
54 def __init__(self, omevv):
55 self.omevv = omevv
56
57 def get_firmware_repository_profile(self, profile_name=None):
58 """
59 Retrieves the firmware repository profile information.
60
61 Args:
62 profile_name (str, optional): The name of the profile to search for. Defaults to None.
63
64 Returns:
65 list: The list of firmware repository profile information.
66 """
67 resp = self.omevv.invoke_request('GET', PROFILE_URI)
68 profile_info = []
69 if resp.success:
70 profile_info = resp.json_data
71 if profile_name:
72 profile_info = self.search_profile_name(
73 profile_info, profile_name)
74 return profile_info
75
76 def get_all_repository_profiles(self):
77 """
78 Retrieves the firmware repository profile information.
79
80 Returns:
81 list: The list of all firmware repository profile information.
82 """
83 resp = self.omevv.invoke_request('GET', PROFILE_URI)
84
85 return resp
86
87 def get_create_payload_details(self, name, catalog_path, description, protocol_type, share_username, share_password, share_domain):
88 """
89 Returns a dictionary containing the payload details for creating a firmware repository profile.
90
91 Args:
92 name (str): The name of the firmware repository profile.
93 catalog_path (str): The path to the firmware catalog.
94 description (str, optional): The description of the firmware repository profile.
95 protocol_type (str): The protocol type of the firmware repository profile.
96 share_username (str): The username for the share credential.
97 share_password (str): The password for the share credential.
98 share_domain (str): The domain for the share credential.
99
100 Returns:
101 dict: A dictionary containing the payload details for creating a firmware repository profile.
102 """
103 payload = {}
104 payload["profileName"] = name
105 payload["protocolType"] = protocol_type
106 payload["sharePath"] = catalog_path
107 if description is not None:
108 payload["description"] = description
109 payload["profileType"] = "Firmware"
110 payload["shareCredential"] = {
111 "username": share_username,
112 "password": share_password,
113 "domain": share_domain
114 }
115 return payload
116
117 def get_modify_payload_details(self, name, catalog_path, description, share_username, share_password, share_domain):
118 """
119 Returns a dictionary containing the payload details for modifying a firmware repository profile.
120
121 Args:
122 name (str): The name of the firmware repository profile.
123 catalog_path (str): The path to the firmware catalog.
124 description (str, optional): The description of the firmware repository profile.
125 share_username (str): The username for the share credential.
126 share_password (str): The password for the share credential.
127 share_domain (str): The domain for the share credential.
128
129 Returns:
130 dict: A dictionary containing the payload details for modifying a firmware repository profile.
131 """
132 payload = {}
133 payload["profileName"] = name
134 payload["sharePath"] = catalog_path
135 if description is not None:
136 payload["description"] = description
137 payload["shareCredential"] = {
138 "username": share_username,
139 "password": share_password,
140 "domain": share_domain
141 }
142 return payload
143
144 def form_conn_payload(self, protocol_type, catalog_path, share_username, share_password, share_domain):
145 """
146 Returns a dictionary containing the payload details for testing the connection to a firmware repository.
147
148 Args:
149 protocol_type (str): The protocol type of the firmware repository.
150 catalog_path (str): The path to the firmware catalog.
151 share_username (str): The username for the share credential.
152 share_password (str): The password for the share credential.
153 share_domain (str): The domain for the share credential.
154
155 Returns:
156 dict: A dictionary containing the payload details for testing the connection to a firmware repository.
157 """
158 payload = {}
159 payload["protocolType"] = protocol_type
160 payload["catalogPath"] = catalog_path
161 payload["shareCredential"] = {
162 "username": share_username if share_username is not None else "",
163 "password": share_password if share_password is not None else "",
164 "domain": share_domain if share_domain is not None else ""
165 }
166 payload["checkCertificate"] = False
167 return payload
168
169 def search_profile_name(self, data, profile_name):
170 """
171 Searches for a profile with the given name in the provided data.
172
173 Args:
174 data (list): A list of dictionaries representing profiles.
175 profile_name (str): The name of the profile to search for.
176
177 Returns:
178 dict: The dictionary representing the profile if found, or an empty dictionary if not found.
179 """
180 for d in data:
181 if d.get('profileName') == profile_name:
182 return d
183 return {}
184
185 def test_connection(self, protocol_type, catalog_path, share_username, share_password, share_domain):
186 """
187 Tests the connection to the vCenter server.
188
189 """
190 payload = self.form_conn_payload(
191 protocol_type, catalog_path, share_username, share_password, share_domain)
192 resp = self.omevv.invoke_request("POST", TEST_CONNECTION_URI, payload)
193 if resp.success:
194 # Waiting here because response comes as empty at first call
195 time.sleep(5)
196 job_id = resp.json_data
197 resp_history = self.omevv.invoke_request(
198 "GET", TEST_CONNECTION_HISTORY.format(job_id=job_id))
199 while resp_history.json_data[0]["statusSummary"] != "SUCCESSFUL" and resp_history.json_data[0]["statusSummary"] != "FAILED":
200 time.sleep(3)
201 resp_history = self.omevv.invoke_request(
202 "GET", TEST_CONNECTION_HISTORY.format(job_id=job_id))
203 if resp_history.json_data[0]["statusSummary"] == "SUCCESSFUL":
204 return True
205 else:
206 return False
207
208 def get_firmware_repository_profile_by_id(self, profile_id):
209 """
210 Retrieves all firmware repository profile Information.
211
212 """
213 resp = self.omevv.invoke_request(
214 "GET", PROFILE_URI + "/" + str(profile_id))
215 return resp
216
217 def create_firmware_repository_profile(self, name, catalog_path,
218 description, protocol_type,
219 share_username, share_password,
220 share_domain):
221 """
222 Creates a firmware repository profile.
223
224 Args:
225 name (str): The name of the firmware repository profile.
226 catalog_path (str): The path to the firmware catalog.
227 description (str, optional): The description of the firmware repository profile.
228 protocol_type (str): The protocol type of the firmware repository profile.
229 share_username (str): The username for the share credential.
230 share_password (str): The password for the share credential.
231 share_domain (str): The domain for the share credential.
232
233 Returns:
234 tuple: A tuple containing the response and an error message.
235
236 Raises:
237 None.
238
239 """
240 err_msg = None
241 required_params = [name, catalog_path, protocol_type]
242 missing_params = [param for param in required_params if param is None]
243 if missing_params:
244 err_msg = "Required parameters such as: " + \
245 ", ".join(missing_params)
246
247 payload = self.get_create_payload_details(name, catalog_path,
248 description, protocol_type,
249 share_username, share_password,
250 share_domain)
251 resp = self.omevv.invoke_request("POST", PROFILE_URI, payload)
252 return resp, err_msg
253
254 def modify_firmware_repository_profile(self, profile_id, name, catalog_path,
255 description,
256 share_username, share_password,
257 share_domain):
258 """
259 Modifies a firmware repository profile.
260
261 Args:
262 profile_id (int): The ID of the firmware repository profile.
263 name (str): The new name of the firmware repository profile.
264 catalog_path (str): The new path to the firmware catalog.
265 description (str, optional): The new description of the firmware repository profile.
266 share_username (str): The new username for the share credential.
267 share_password (str): The new password for the share credential.
268 share_domain (str): The new domain for the share credential.
269
270 Returns:
271 tuple: A tuple containing the response and an error message.
272
273 Raises:
274 None.
275
276 """
277 err_msg = None
278 required_params = [name, catalog_path]
279 missing_params = [param for param in required_params if param is None]
280 if missing_params:
281 err_msg = "Required parameters such as: " + \
282 ", ".join(missing_params)
283
284 payload = self.get_modify_payload_details(name, catalog_path,
285 description,
286 share_username, share_password,
287 share_domain)
288 resp = self.omevv.invoke_request(
289 "PUT", PROFILE_URI + "/" + str(profile_id), payload)
290 return resp, err_msg
291
292 def delete_firmware_repository_profile(self, profile_id):
293 """
294 Deletes a firmware repository profile.
295
296 """
297 resp = self.omevv.invoke_request(
298 "DELETE", PROFILE_URI + "/" + str(profile_id))
299 return resp
300
301 def resync_repository_profiles_from_ump(self):
302 """
303 Resyncs the repository profiles from UMP.
304
305 """
306 resp = self.omevv.invoke_request("POST", RESYNC_UMP_URI, {})
307 return resp
308
309
310 class OMEVVBaselineProfile:
311 def __init__(self, omevv):
312 self.omevv = omevv
313 self.omevv_profile_obj = OMEVVFirmwareProfile(self.omevv)
314
315 def validate_repository_profile(self, repository_profile):
316 """
317 Validates the repository profile against available repository profiles.
318
319 Args:
320 repository_profile (str): The repository profile name to validate.
321
322 Returns:
323 tuple: A tuple containing a success flag (bool) and an error message (str).
324 """
325 available_repo_profiles = self.omevv_profile_obj.get_all_repository_profiles()
326
327 if not available_repo_profiles:
328 return False, NO_REPO_PROFILE_MSG
329
330 available_repo_profile_names = [profile.get(
331 'profileName') for profile in available_repo_profiles.json_data]
332
333 if repository_profile not in available_repo_profile_names:
334 return False, INVALID_REPO_PROFILE_MSG.format(repository_profile=repository_profile)
335
336 return True, ""
337
338 def validate_cluster_names(self, cluster_names, vcenter_uuid):
339 """
340 Validates the provided cluster names against the available clusters.
341
342 Args:
343 cluster_names (list): List of cluster names to validate.
344 vcenter_uuid (str): The UUID of the vCenter for cluster lookup.
345
346 Returns:
347 tuple: A tuple containing a success flag (bool) and an error message (str).
348 """
349 # Check if cluster_names is None or empty
350 if not cluster_names:
351 return False, INVALID_CLUSTER_NAMES_MSG.format(cluster_names="")
352
353 # Fetch all available clusters
354 available_clusters = self.get_all_clusters(vcenter_uuid)
355
356 if not available_clusters:
357 return False, NO_CLUSTERS_FOUND_MSG
358
359 available_cluster_names = [
360 cluster.get('name') for cluster in available_clusters if cluster.get('name') is not None
361 ]
362 invalid_clusters = [
363 cluster for cluster in cluster_names if cluster not in available_cluster_names]
364
365 if invalid_clusters:
366 error_message = INVALID_CLUSTER_NAMES_MSG.format(
367 cluster_names=', '.join(invalid_clusters))
368 return False, error_message
369
370 return True, ""
371
372 def get_all_clusters(self, vcenter_uuid):
373 """
374 Retrieves the cluster information.
375
376 Args:
377 vcenter_uuid: UUID of the vCenter.
378
379 Returns:
380 list: The list of all cluster information.
381 """
382 clusters_resp = self.omevv.invoke_request(
383 'GET', CLUSTER_URI.format(vcenter_uuid=vcenter_uuid))
384
385 # If the response is a list (as per the error), return it directly
386 if isinstance(clusters_resp, list):
387 return clusters_resp
388
389 # If the response has a json_data attribute, return json_data
390 return clusters_resp.json_data if hasattr(clusters_resp, 'json_data') else []
391
392 def get_cluster_id(self, cluster_names, vcenter_uuid):
393 """
394 Fetch cluster IDs for the given cluster names.
395
396 Args:
397 vcenter_uuid (str): UUID of the vCenter.
398 cluster_names (list): List of cluster names to fetch IDs for.
399
400 Returns:
401 list: A list of cluster IDs.
402 """
403 clusters = self.get_all_clusters(vcenter_uuid=vcenter_uuid)
404
405 # Map cluster name to entity ID (clustId)
406 cluster_ids = [c['entityId']
407 for c in clusters if c['name'] in cluster_names]
408
409 return cluster_ids
410
411 def get_group_ids_for_clusters(self, vcenter_uuid, cluster_names):
412 """
413 Fetch group IDs for the given clusters.
414
415 Args:
416 vcenter_uuid: UUID of the vCenter.
417 cluster_names: List of cluster names to fetch group IDs for.
418
419 Returns:
420 list: A list of group IDs.
421 """
422 clusters = self.get_all_clusters(vcenter_uuid=vcenter_uuid)
423
424 # Map cluster name to entity ID (clustId)
425 cluster_ids = [c['entityId']
426 for c in clusters if c['name'] in cluster_names]
427
428 # Fetch group IDs for the identified cluster IDs
429 group_ids = []
430 if cluster_ids:
431 payload = {"clustIds": cluster_ids}
432 group_resp = self.omevv.invoke_request(
433 'POST', CLUSTER_IDS_URI.format(vcenter_uuid=vcenter_uuid), payload)
434 group_ids = [g['groupId'] for g in group_resp.json_data] if hasattr(
435 group_resp, 'json_data') and group_resp.success else []
436
437 return group_ids
438
439 def get_repo_id_by_name(self, repository_profile):
440 repo_profile_info = self.omevv_profile_obj.get_firmware_repository_profile(
441 profile_name=repository_profile
442 )
443
444 firmware_repo_id = None
445 if repo_profile_info:
446 firmware_repo_id = repo_profile_info.get("id")
447 return firmware_repo_id
448
449 def get_baseline_profiles(self, vcenter_uuid):
450 """
451 Retrieves the list of baseline profiles associated with a given vCenter.
452
453 Args:
454 vcenter_uuid (str): The UUID of the vCenter server.
455
456 Returns:
457 list: A list of baseline profiles.
458
459 Raises:
460 None
461 """
462 response = self.omevv.invoke_request(
463 'GET', BASELINE_PROFILE_URI.format(vcenter_uuid=vcenter_uuid))
464 if response.success:
465 return response.json_data
466
467 return []
468
469 def get_baseline_profile_by_id(self, profile_id, vcenter_uuid):
470 """
471 Retrieves all baseline profile Information.
472
473 """
474 resp = self.omevv.invoke_request(
475 "GET", BASELINE_PROFILE_URI.format(vcenter_uuid=vcenter_uuid) + "/" + str(profile_id))
476 return resp.json_data
477
478 def get_baseline_profile_by_name(self, profile_name, vcenter_uuid):
479 """
480 Retrieves all baseline profile information and checks for a profile with the given name.
481
482 Args:
483 profile_name (str): The name of the profile to search for.
484 vcenter_uuid (str): The UUID of the vCenter to retrieve profiles from.
485
486 Returns:
487 dict: The dictionary representing the profile if found, or an empty dictionary if not found.
488 """
489 profiles = self.get_baseline_profiles(vcenter_uuid)
490
491 for profile in profiles:
492 if profile.get('name') == profile_name:
493 return profile
494
495 return {}
496
497 def create_job_schedule(self, days, time):
498 """
499 Creates a job schedule based on provided days and time.
500
501 Args:
502 days (list): List of days selected for the job schedule.
503 time (str): The time to be set for the job schedule.
504
505 Returns:
506 dict: A dictionary representing the job schedule.
507 """
508 if days and time:
509 days_selected = set(days)
510
511 if "all" in days_selected:
512 return {
513 "monday": True,
514 "tuesday": True,
515 "wednesday": True,
516 "thursday": True,
517 "friday": True,
518 "saturday": True,
519 "sunday": True,
520 "time": time
521 }
522 else:
523 return {
524 "monday": "monday" in days_selected,
525 "tuesday": "tuesday" in days_selected,
526 "wednesday": "wednesday" in days_selected,
527 "thursday": "thursday" in days_selected,
528 "friday": "friday" in days_selected,
529 "saturday": "saturday" in days_selected,
530 "sunday": "sunday" in days_selected,
531 "time": time
532 }
533 return None
534
535 def get_current_job_schedule(self, profile_id, vcenter_uuid):
536 """
537 Retrieves the current job schedule for a baseline profile.
538
539 Args:
540 profile_id (str): The ID of the profile for which to retrieve the schedule.
541 vcenter_uuid (str): The UUID of the vCenter.
542
543 Returns:
544 dict: Job schedule details if available.
545 """
546 resp = self.omevv.invoke_request(
547 "GET", DRIFT_URI.format(
548 vcenter_uuid=vcenter_uuid) + "/" + str(profile_id)
549 )
550 return resp.json_data
551
552 def get_add_remove_group_ids(self, existing_profile, vcenter_uuid, cluster_names):
553 """Determine groups to add or remove based on the cluster names"""
554 current_group_ids = {group['omevv_groupID']
555 for group in existing_profile.get('clusterGroups', [])}
556
557 new_group_ids = set(self.get_group_ids_for_clusters(
558 vcenter_uuid=vcenter_uuid,
559 cluster_names=cluster_names
560 ))
561
562 # Determine the groups that need to be added or removed
563 add_group_ids = list(new_group_ids - current_group_ids)
564 remove_group_ids = list(current_group_ids - new_group_ids)
565
566 return add_group_ids, remove_group_ids
567
568 def create_baseline_profile(self, name, firmware_repo_id, group_ids, job_schedule, vcenter_uuid, description=None):
569 """
570 Creates a baseline profile.
571
572 Args:
573 name (str): The name of the baseline profile.
574 firmware_repo_id (str): The ID of the firmware repository to associate with the baseline profile.
575 group_ids (list): List of group IDs (clusters) associated with the baseline profile.
576 job_schedule (dict): A dictionary specifying the job schedule details, including selected days and time.
577 vcenter_uuid (str): The UUID of the vCenter instance.
578 description (str, optional): A description of the baseline profile.
579
580 Returns:
581 tuple: A tuple containing the response and an error message.
582
583 Raises:
584 None.
585 """
586 err_msg = None
587 required_params = [name, firmware_repo_id, group_ids, job_schedule]
588 missing_params = [param_name for param_name, param in zip(
589 ["name", "firmware_repo_id", "group_ids", "job_schedule"], required_params) if param is None]
590
591 if missing_params:
592 err_msg = "Required parameters missing: " + \
593 ", ".join(missing_params)
594 return None, err_msg
595
596 payload = {
597 "name": name,
598 "firmwareRepoId": firmware_repo_id,
599 "groupIds": group_ids,
600 "jobSchedule": job_schedule
601 }
602 if description is not None:
603 payload["description"] = description
604
605 resp = self.omevv.invoke_request(
606 "POST", BASELINE_PROFILE_URI.format(vcenter_uuid=vcenter_uuid), payload)
607 return resp, err_msg
608
609 def modify_baseline_profile(self, add_group_ids, remove_group_ids, profile_id, vcenter_uuid, firmware_repo_id=None, job_schedule=None, description=None):
610 """
611 Modifies an existing baseline profile.
612
613 Args:
614 profile_id (str): The ID of the baseline profile to modify.
615 vcenter_uuid (str): The UUID of the vCenter environment.
616 payload (dict): A dictionary containing the fields to modify in the baseline profile.
617
618 Returns:
619 tuple: A tuple containing the response and an error message.
620
621 Raises:
622 None.
623 """
624 err_msg = None
625
626 # Check if the required parameters are provided
627 if profile_id is None or vcenter_uuid is None:
628 err_msg = "Required parameters: profile_id or vcenter_uuid are missing."
629 return None, err_msg
630
631 # Construct the payload for the PATCH request
632 payload = {
633 "addgroupIds": add_group_ids if add_group_ids is not None else [],
634 "removeGroupIds": remove_group_ids if remove_group_ids is not None else []
635 }
636
637 # Add the optional parameters if provided
638 if firmware_repo_id is not None:
639 payload["firmwareRepoId"] = firmware_repo_id
640 if job_schedule is not None:
641 payload["jobSchedule"] = job_schedule
642 if description is not None:
643 payload["description"] = description
644
645 # Construct the URL for the PATCH request
646 url = BASELINE_PROFILE_URI.format(
647 vcenter_uuid=vcenter_uuid) + f"/{profile_id}"
648
649 # Send the PATCH request using the appropriate method (e.g., self.omevv.invoke_request)
650 resp = self.omevv.invoke_request("PATCH", url, payload)
651
652 return resp, err_msg
653
654 def delete_baseline_profile(self, profile_id, vcenter_uuid):
655 """
656 Deletes a baseline profile.
657
658 """
659 resp = self.omevv.invoke_request(
660 "DELETE", BASELINE_PROFILE_URI.format(vcenter_uuid=vcenter_uuid) + "/" + str(profile_id))
661 return resp
662
663
664 class OMEVVFirmwareUpdate:
665 def __init__(self, omevv):
666 self.omevv = omevv
667
668 def update_cluster(self, vcenter_uuid, cluster_group_id, **kwargs):
669 """
670 Sample input of kwargs
671 **kwargs = {
672 "jobName": "Sample JobName",
673 "jobDescription": "Sample description",
674 "schedule": {
675 "runNow": false,
676 "dateTime": "2024-09-10T20:50:00Z"
677 },
678 "firmware": {
679 "enterMaintenanceModetimeout": 60,
680 "drsCheck": true,
681 "evacuateVMs": true,
682 "exitMaintenanceMode": true,
683 "rebootOptions": "SAFEREBOOT",
684 "enterMaintenanceModeOption": null,
685 "maintenanceModeCountCheck": true,
686 "checkvSANHealth": true,
687 "resetIDrac": true,
688 "deleteJobsQueue": true,
689 "targets": [
690 {
691 "firmwarecomponents": [
692 "DCIM:INSTALLED#802__Diagnostics.Embedded.1:LC.Embedded.1"
693 ],
694 "id": 1002
695 }
696 ]
697 }
698 }
699 """
700 err_msg = None
701 uri = FIRMARE_UPDATE_URI.format(vcenter_uuid=vcenter_uuid, cluster_group_id=cluster_group_id)
702 resp = self.omevv.invoke_request("POST", uri, data=kwargs)
703 return resp, err_msg
704
705 def firmware_update_job_track(self, vcenter_uuid, job_id):
706 err_msg = None
707 resp = self.omevv.invoke_request("GET",
708 FIRMWARE_UPDATE_JOB_TRACK_URI.format(vcenter_uuid=vcenter_uuid, job_id=job_id))
709 return resp.json_data, err_msg
710
711 def check_existing_update_job(self, vcenter_uuid, cluster_group_id):
712 uri = TRIGGER_UPDATE_CHECK_URI.format(vcenter_uuid=vcenter_uuid)
713 resp = self.omevv.invoke_request("POST", uri, cluster_group_id)
714 return resp.json_data
715
716 def check_existing_job_name(self, vcenter_uuid, job_name):
717 uri = FIRMWARE_UPDATE_JOB_NAME_CHECK_URI.format(vcenter_uuid=vcenter_uuid)
718 resp = self.omevv.invoke_request("GET", uri)
719 jobs = resp.json_data
720 for job in jobs:
721 if job['jobName'] == job_name:
722 return True
723 return False