| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
from __future__ import (absolute_import, division, print_function) |
| 14 |
|
| 15 |
__metaclass__ = type |
| 16 |
|
| 17 |
DOCUMENTATION = r""" |
| 18 |
--- |
| 19 |
module: idrac_support_assist |
| 20 |
short_description: Run and Export iDRAC SupportAssist collection logs |
| 21 |
version_added: "9.6.0" |
| 22 |
description: |
| 23 |
- This module allows you to run and export SupportAssist collection logs on iDRAC. |
| 24 |
extends_documentation_fragment: |
| 25 |
- dellemc.openmanage.idrac_x_auth_options |
| 26 |
options: |
| 27 |
run: |
| 28 |
description: |
| 29 |
- Run the SupportAssist job based on the different types of logs in the collection on iDRAC. |
| 30 |
type: bool |
| 31 |
default: true |
| 32 |
export: |
| 33 |
description: |
| 34 |
- Exports the SupportAssist collection to the given network share. |
| 35 |
- This operation requires I(share_parameters). |
| 36 |
type: bool |
| 37 |
default: true |
| 38 |
accept_eula: |
| 39 |
description: |
| 40 |
- This parameter accepts the EULA terms and conditions that are required for SupportAssist registration. |
| 41 |
- If EULA terms and conditions are not accepted, then the SupportAssist collection cannot be run or exported. |
| 42 |
type: bool |
| 43 |
filter_data: |
| 44 |
description: |
| 45 |
- This option provides the choice to filter data for privacy. It does not include hostname, MAC address, thermal data, logs, or registry content. |
| 46 |
type: bool |
| 47 |
default: false |
| 48 |
data_collector: |
| 49 |
description: |
| 50 |
- This option provides the choice of data to keep in SupportAssist collection. |
| 51 |
- System Information is available in on the SupportAssist collection by default. |
| 52 |
- C(hardware_data), SupportAssist collection includes data that are related to hardware. |
| 53 |
- C(storage_logs), SupportAssist collection includes logs that are related to storage devices. |
| 54 |
- C(os_app_data), SupportAssist collection includes data that is related to the operating system and applications. |
| 55 |
- C(debug_logs), SupportAssist collection includes logs that are related to debugging. |
| 56 |
- C(telemetry_reports), SupportAssist collection includes reports that are related to telemetry. |
| 57 |
- C(gpu_logs), SupportAssist collection includes logs that are related to GPUs. |
| 58 |
type: list |
| 59 |
elements: str |
| 60 |
choices: [hardware_data, storage_logs, os_app_data, debug_logs, telemetry_reports, gpu_logs] |
| 61 |
job_wait: |
| 62 |
description: |
| 63 |
- This option determines whether to wait for the job completion or not. |
| 64 |
type: bool |
| 65 |
default: true |
| 66 |
job_wait_timeout: |
| 67 |
description: |
| 68 |
- Time in seconds to wait for job completion. |
| 69 |
- This is applicable when I(job_wait) is C(true). |
| 70 |
type: int |
| 71 |
default: 3600 |
| 72 |
share_parameters: |
| 73 |
description: |
| 74 |
- Parameters that are required for the export operation of SupportAssist collection. |
| 75 |
- I(share_parameters) is required when I(export) is C(true). |
| 76 |
type: dict |
| 77 |
suboptions: |
| 78 |
share_type: |
| 79 |
description: |
| 80 |
- Share type of the network share. |
| 81 |
- C(local) uses local path for I(export) operation. |
| 82 |
- C(nfs) uses NFS share for I(export) operation. |
| 83 |
- C(cifs) uses CIFS share for I(export) operation. |
| 84 |
- C(http) uses HTTP share for I(export) operation. |
| 85 |
- C(https) uses HTTPS share for I(export) operation. |
| 86 |
- C(ftp) uses FTP share for I(export) operation. |
| 87 |
type: str |
| 88 |
choices: [local, nfs, cifs, http, https, ftp] |
| 89 |
default: local |
| 90 |
ip_address: |
| 91 |
description: |
| 92 |
- IP address of the network share. |
| 93 |
- I(ip_address) is required when I(share_type) is C(nfs), C(cifs), C(http), or C(https). |
| 94 |
- I(ip_address) is not required when I(share_type) is C(local). |
| 95 |
type: str |
| 96 |
share_name: |
| 97 |
description: |
| 98 |
- Network share path or full local path of the directory for exporting the SupportAssist collection file. |
| 99 |
- The default path will be current directory when I(share_type) is C(local) |
| 100 |
type: str |
| 101 |
workgroup: |
| 102 |
description: |
| 103 |
-(deprecated) Workgroup of the network share. |
| 104 |
- I(workgroup) is applicable only when I(share_type) is C(cifs). |
| 105 |
- The argument is not supported by iDRAC9 and iDRAC10. |
| 106 |
type: str |
| 107 |
username: |
| 108 |
description: |
| 109 |
- Username of the network share. |
| 110 |
- I(username) is required when I(share_type) is C(cifs). |
| 111 |
type: str |
| 112 |
aliases: ['share_username'] |
| 113 |
password: |
| 114 |
description: |
| 115 |
- Password of the network share. |
| 116 |
- I(password) is required when I(share_type) is C(cifs). |
| 117 |
type: str |
| 118 |
aliases: ['share_password'] |
| 119 |
ignore_certificate_warning: |
| 120 |
description: |
| 121 |
- Ignores the certificate warning when connecting to the network share and is only applicable when I(share_type) is C(https). |
| 122 |
- C(on) ignores the certificate warning. |
| 123 |
- C(off) does not ignore the certificate warning. |
| 124 |
type: str |
| 125 |
choices: ["off", "on"] |
| 126 |
default: "off" |
| 127 |
proxy_support: |
| 128 |
description: |
| 129 |
- Specifies if proxy support must be used or not. |
| 130 |
- C(off) does not use proxy settings. |
| 131 |
- C(default_proxy) uses the default proxy settings. |
| 132 |
- C(parameters_proxy) uses the specified proxy settings. I(proxy_server) is required when I(proxy_support) is C(parameters_proxy). |
| 133 |
- I(proxy_support) is only applicable when I(share_type) is C(http) or C(https). |
| 134 |
type: str |
| 135 |
choices: ["off", "default_proxy", "parameters_proxy"] |
| 136 |
default: "off" |
| 137 |
proxy_type: |
| 138 |
description: |
| 139 |
- The proxy type of the proxy server. |
| 140 |
- C(http) to select HTTP proxy. |
| 141 |
- C(socks) to select SOCKS proxy. |
| 142 |
- I(proxy_type) is only applicable when I(share_type) is C(http) or C(https) and when I(proxy_support) is C(parameters_proxy). |
| 143 |
type: str |
| 144 |
choices: [http, socks] |
| 145 |
default: http |
| 146 |
proxy_server: |
| 147 |
description: |
| 148 |
- The IP address of the proxy server. |
| 149 |
- I(proxy_server) is required when I(proxy_support) is C(parameters_proxy). |
| 150 |
- I(proxy_server) is only applicable when I(share_type) is C(http) or C(https) and when I(proxy_support) is C(parameters_proxy). |
| 151 |
type: str |
| 152 |
proxy_port: |
| 153 |
description: |
| 154 |
- The port of the proxy server. |
| 155 |
- I(proxy_port) is only applicable when I(share_type) is C(http) or C(https) and when I(proxy_support) is C(parameters_proxy). |
| 156 |
type: int |
| 157 |
default: 80 |
| 158 |
proxy_username: |
| 159 |
description: |
| 160 |
- The username of the proxy server. |
| 161 |
- I(proxy_username) is only applicable when I(share_type) is C(http) or C(https) and when I(proxy_support) is C(parameters_proxy). |
| 162 |
type: str |
| 163 |
proxy_password: |
| 164 |
description: |
| 165 |
- The password of the proxy server. |
| 166 |
- I(proxy_password) is only applicable when I(share_type) is C(http) or C(https) and when I(proxy_support) is C(parameters_proxy). |
| 167 |
type: str |
| 168 |
resource_id: |
| 169 |
type: str |
| 170 |
description: |
| 171 |
- Id of the resource. |
| 172 |
- If the value for resource ID is not provided, the module picks the first resource ID available from the list of system resources that |
| 173 |
are returned by the iDRAC. |
| 174 |
requirements: |
| 175 |
- "python >= 3.9.6" |
| 176 |
author: |
| 177 |
- "Shivam Sharma(@ShivamSh3)" |
| 178 |
attributes: |
| 179 |
check_mode: |
| 180 |
description: Runs task to validate without performing action on the target machine. |
| 181 |
support: full |
| 182 |
notes: |
| 183 |
- Run this module from a system that has direct access to Dell iDRAC. |
| 184 |
- This module supports only iDRAC9 and above. |
| 185 |
- This module supports IPv4 and IPv6 addresses. |
| 186 |
- C(local) for I(share_type) is applicable only when I(run) and I(export) is C(true). |
| 187 |
- When I(share_type) is C(local) for I(run) and (export) operation, then job_wait is not applicable. |
| 188 |
""" |
| 189 |
|
| 190 |
EXAMPLES = r""" |
| 191 |
--- |
| 192 |
- name: Accept the EULA and run and export the SupportAssist Collection to local path |
| 193 |
dellemc.openmanage.idrac_support_assist: |
| 194 |
idrac_ip: "192.168.0.1" |
| 195 |
idrac_user: "username" |
| 196 |
idrac_password: "password" |
| 197 |
accept_eula: true |
| 198 |
ca_path: "path/to/ca_file" |
| 199 |
data_collector: ["debug_logs", "hardware_data", "os_app_data", "storage_logs"] |
| 200 |
share_parameters: |
| 201 |
share_type: "local" |
| 202 |
share_path: "/opt/local/support_assist_collections/" |
| 203 |
|
| 204 |
- name: Run the SupportAssist Collection with with custom data_to_collect with filter_data |
| 205 |
dellemc.openmanage.idrac_support_assist: |
| 206 |
idrac_ip: "192.168.0.1" |
| 207 |
idrac_user: "username" |
| 208 |
idrac_password: "password" |
| 209 |
ca_path: "path/to/ca_file" |
| 210 |
export: false |
| 211 |
filter_data: true |
| 212 |
data_collector: ["debug_logs", "hardware_data"] |
| 213 |
|
| 214 |
- name: Run and export the SupportAssist Collection to HTTPS share |
| 215 |
dellemc.openmanage.idrac_support_assist: |
| 216 |
idrac_ip: "192.168.0.1" |
| 217 |
idrac_user: "username" |
| 218 |
idrac_password: "password" |
| 219 |
ca_path: "path/to/ca_file" |
| 220 |
data_collector: ["hardware_data"] |
| 221 |
share_parameters: |
| 222 |
share_type: "https" |
| 223 |
ignore_certificate_warning: "on" |
| 224 |
share_name: "/share_path/support_assist_collections" |
| 225 |
ip_address: "192.168.0.2" |
| 226 |
|
| 227 |
- name: Run and export the SupportAssist Collection to NFS share |
| 228 |
dellemc.openmanage.idrac_support_assist: |
| 229 |
idrac_ip: "192.168.0.1" |
| 230 |
idrac_user: "username" |
| 231 |
idrac_password: "password" |
| 232 |
ca_path: "path/to/ca_file" |
| 233 |
data_collector: ["debug_logs"] |
| 234 |
share_parameters: |
| 235 |
share_type: "nfs" |
| 236 |
share_name: "nfsshare/support_assist_collections/" |
| 237 |
ip_address: "192.168.0.3" |
| 238 |
|
| 239 |
- name: Export the last SupportAssist Collection to CIFS share |
| 240 |
dellemc.openmanage.idrac_support_assist: |
| 241 |
idrac_ip: "192.168.0.1" |
| 242 |
idrac_user: "username" |
| 243 |
idrac_password: "password" |
| 244 |
ca_path: "path/to/ca_file" |
| 245 |
run: false |
| 246 |
share_parameters: |
| 247 |
share_type: "nfs" |
| 248 |
share_name: "/cifsshare/support_assist_collections/" |
| 249 |
ip_address: "192.168.0.4" |
| 250 |
|
| 251 |
- name: Export the last SupportAssist Collection to HTTPS share via proxy |
| 252 |
dellemc.openmanage.idrac_support_assist: |
| 253 |
idrac_ip: "192.168.0.1" |
| 254 |
idrac_user: "username" |
| 255 |
idrac_password: "password" |
| 256 |
ca_path: "path/to/ca_file" |
| 257 |
run: false |
| 258 |
share_parameters: |
| 259 |
share_type: "https" |
| 260 |
share_name: "/share_path/support_assist_collections" |
| 261 |
ignore_certificate_warning: "on" |
| 262 |
ip_address: "192.168.0.2" |
| 263 |
proxy_support: parameters_proxy |
| 264 |
proxy_type: http |
| 265 |
proxy_server: "192.168.0.5" |
| 266 |
proxy_port: 1080 |
| 267 |
proxy_username: "proxy_user" |
| 268 |
proxy_password: "proxy_password" |
| 269 |
""" |
| 270 |
|
| 271 |
RETURN = r''' |
| 272 |
--- |
| 273 |
msg: |
| 274 |
type: str |
| 275 |
description: Status of the SupportAssist operation. |
| 276 |
returned: always |
| 277 |
sample: "Successfully ran and exported the SupportAssist collection." |
| 278 |
job_details: |
| 279 |
description: Returns the output for status of the job. |
| 280 |
returned: For run and export operations |
| 281 |
type: dict |
| 282 |
sample: { |
| 283 |
"ActualRunningStartTime": "2024-07-08T01:50:54", |
| 284 |
"ActualRunningStopTime": "2024-07-08T01:56:45", |
| 285 |
"CompletionTime": "2024-07-08T01:56:45", |
| 286 |
"Description": "Job Instance", |
| 287 |
"EndTime": null, |
| 288 |
"Id": "JID_XXXXXXXXXXXX", |
| 289 |
"JobState": "Completed", |
| 290 |
"JobType": "SACollectExportHealthData", |
| 291 |
"Message": "The SupportAssist Collection and Transmission Operation is completed successfully.", |
| 292 |
"MessageArgs": [], |
| 293 |
"[email protected]": 0, |
| 294 |
"MessageId": "SRV088", |
| 295 |
"Name": "SupportAssist Collection", |
| 296 |
"PercentComplete": 100, |
| 297 |
"StartTime": "2024-07-08T01:50:54", |
| 298 |
"TargetSettingsURI": null |
| 299 |
} |
| 300 |
error_info: |
| 301 |
description: Details of the HTTP Error. |
| 302 |
returned: on HTTP error |
| 303 |
type: dict |
| 304 |
sample: { |
| 305 |
"error": { |
| 306 |
"code": "Base.1.12.GeneralError", |
| 307 |
"message": "A general error has occurred. See ExtendedInfo for more information.", |
| 308 |
"@Message.ExtendedInfo": [ |
| 309 |
{ |
| 310 |
"Message": "Unable to start the operation because the SupportAssist End User License Agreement (EULA) is not accepted.", |
| 311 |
"MessageArgs": [], |
| 312 |
"[email protected]": 0, |
| 313 |
"MessageId": "IDRAC.2.8.SRV085", |
| 314 |
"RelatedProperties": [], |
| 315 |
"[email protected]": 0, |
| 316 |
"Resolution": "Accept the SupportAssist End User License Agreement (EULA) by navigating to the SupportAssist page on the iDRAC GUI.", |
| 317 |
"Severity": "Warning" |
| 318 |
} |
| 319 |
] |
| 320 |
} |
| 321 |
} |
| 322 |
''' |
| 323 |
import json |
| 324 |
import os |
| 325 |
from datetime import datetime |
| 326 |
import time |
| 327 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_redfish import iDRACRedfishAPI, IdracAnsibleModule |
| 328 |
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError |
| 329 |
from ansible.module_utils.urls import ConnectionError, SSLValidationError |
| 330 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.utils import ( |
| 331 |
get_dynamic_uri, validate_and_get_first_resource_id_uri, remove_key, idrac_redfish_job_tracking) |
| 332 |
|
| 333 |
MANAGERS_URI = "/redfish/v1/Managers" |
| 334 |
|
| 335 |
OEM = "Oem" |
| 336 |
MANUFACTURER = "Dell" |
| 337 |
JOBS = "Jobs" |
| 338 |
JOBS_EXPAND = "?$expand=*($levels=1)" |
| 339 |
LC_SERVICE = "DellLCService" |
| 340 |
ACTIONS = "Actions" |
| 341 |
ACCEPT_EULA = "#DellLCService.SupportAssistAcceptEULA" |
| 342 |
EULA_STATUS = "#DellLCService.SupportAssistGetEULAStatus" |
| 343 |
EXPORT = "#DellLCService.SupportAssistExportLastCollection" |
| 344 |
RUN = "#DellLCService.SupportAssistCollection" |
| 345 |
TEST_SHARE = "#DellLCService.TestNetworkShare" |
| 346 |
DATA_SELECTOR = "[email protected]" |
| 347 |
ODATA_REGEX = "(.*?)@odata" |
| 348 |
ODATA = "@odata.id" |
| 349 |
MESSAGE_EXTENDED_INFO = "@Message.ExtendedInfo" |
| 350 |
SUCCESS_EXPORT_MSG = "Successfully exported the support assist collections." |
| 351 |
SUCCESS_RUN_MSG = "Successfully ran the support assist collections." |
| 352 |
SUCCESS_RUN_AND_EXPORT_MSG = "Successfully ran and exported the support assist collections." |
| 353 |
RUNNING_RUN_MSG = "Successfully triggered the job to run support assist collections." |
| 354 |
RUNNING_RUN_AND_EXPORT_MSG = "Successfully triggered the job to run and export support assist collections." |
| 355 |
ALREADY_RUN_MSG = "The support assist collections job is already present." |
| 356 |
INVALID_DIRECTORY_MSG = "Provided directory path '{path}' is not valid." |
| 357 |
NO_OPERATION_SKIP_MSG = "The operation is skipped." |
| 358 |
OPERATION_NOT_ALLOWED_MSG = "Export to local is only supported when both run and export is set to true." |
| 359 |
INSUFFICIENT_DIRECTORY_PERMISSION_MSG = "Provided directory path '{path}' is not writable. " \ |
| 360 |
"Please check if the directory has appropriate permissions" |
| 361 |
UNSUPPORTED_FIRMWARE_MSG = "iDRAC firmware version is not supported." |
| 362 |
TIMEOUT_NEGATIVE_OR_ZERO_MSG = "The parameter `job_wait_timeout` value cannot be negative or zero." |
| 363 |
WAIT_TIMEOUT_MSG = "The job is not complete after {0} seconds." |
| 364 |
CHANGES_FOUND_MSG = "Changes found to be applied." |
| 365 |
CHANGES_NOT_FOUND_MSG = "No changes found to be applied." |
| 366 |
ALLOWED_VALUES_MSG = "Enter a valid value from the list of allowable values: {0}" |
| 367 |
NO_VALUE_MSG = "data_collector can't be empty. Enter a valid value." |
| 368 |
NO_FILE = "The support assist collections log does not exist." |
| 369 |
TIME_FORMAT = "%Y%m%d_%H%M%S" |
| 370 |
|
| 371 |
PROXY_SUPPORT = {"off": "Off", "default_proxy": "DefaultProxy", |
| 372 |
"parameters_proxy": "ParametersProxy"} |
| 373 |
STATUS_SUCCESS = [200, 202] |
| 374 |
|
| 375 |
|
| 376 |
class SupportAssist: |
| 377 |
|
| 378 |
def __init__(self, idrac, module): |
| 379 |
self.idrac = idrac |
| 380 |
self.module = module |
| 381 |
self.run_url = None |
| 382 |
self.export_url = None |
| 383 |
self.share_name = None |
| 384 |
|
| 385 |
def execute(self): |
| 386 |
|
| 387 |
pass |
| 388 |
|
| 389 |
def get_payload_details(self): |
| 390 |
payload = {} |
| 391 |
payload["ShareType"] = self.module.params.get( |
| 392 |
'share_parameters').get('share_type').upper() |
| 393 |
payload["IPAddress"] = self.module.params.get( |
| 394 |
'share_parameters').get('ip_address') |
| 395 |
payload["ShareName"] = self.module.params.get( |
| 396 |
'share_parameters').get('share_name') |
| 397 |
payload["UserName"] = self.module.params.get( |
| 398 |
'share_parameters').get('username') |
| 399 |
payload["Password"] = self.module.params.get( |
| 400 |
'share_parameters').get('password') |
| 401 |
payload["IgnoreCertWarning"] = self.module.params.get( |
| 402 |
'share_parameters').get('ignore_certificate_warning').capitalize() |
| 403 |
if self.module.params.get('share_parameters').get('proxy_support') == "parameters_proxy": |
| 404 |
payload["ProxySupport"] = PROXY_SUPPORT[self.module.params.get( |
| 405 |
'share_parameters').get('proxy_support')] |
| 406 |
payload["ProxyType"] = self.module.params.get( |
| 407 |
'share_parameters').get('proxy_type').upper() |
| 408 |
payload["ProxyServer"] = self.module.params.get( |
| 409 |
'share_parameters').get('proxy_server') |
| 410 |
payload["ProxyPort"] = str(self.module.params.get( |
| 411 |
'share_parameters').get('proxy_port')) |
| 412 |
if self.module.params.get('share_parameters').get('proxy_username') and self.module.params.get('share_parameters').get('proxy_password'): |
| 413 |
payload["ProxyUname"] = self.module.params.get( |
| 414 |
'share_parameters').get('proxy_username') |
| 415 |
payload["ProxyPasswd"] = self.module.params.get( |
| 416 |
'share_parameters').get('proxy_password') |
| 417 |
return payload |
| 418 |
|
| 419 |
def test_network_share(self): |
| 420 |
payload = self.get_payload_details() |
| 421 |
payload = {key: value for key, |
| 422 |
value in payload.items() if value is not None} |
| 423 |
if payload.get("ShareType") == "LOCAL": |
| 424 |
path = payload.get("ShareName") |
| 425 |
if not (os.path.exists(path)): |
| 426 |
self.module.exit_json( |
| 427 |
msg=INVALID_DIRECTORY_MSG.format(path=path), failed=True) |
| 428 |
if not os.access(path, os.W_OK): |
| 429 |
self.module.exit_json( |
| 430 |
msg=INSUFFICIENT_DIRECTORY_PERMISSION_MSG.format(path=path), failed=True) |
| 431 |
else: |
| 432 |
try: |
| 433 |
test_url = self.get_test_network_share_url() |
| 434 |
self.idrac.invoke_request(test_url, "POST", data=payload) |
| 435 |
except HTTPError as err: |
| 436 |
filter_err = remove_key( |
| 437 |
json.load(err), regex_pattern=ODATA_REGEX) |
| 438 |
message_details = filter_err.get( |
| 439 |
'error').get(MESSAGE_EXTENDED_INFO)[0] |
| 440 |
message = message_details.get('Message') |
| 441 |
self.module.exit_json( |
| 442 |
msg=message, error_info=filter_err, failed=True) |
| 443 |
|
| 444 |
def get_test_network_share_url(self): |
| 445 |
uri, error_msg = validate_and_get_first_resource_id_uri( |
| 446 |
self.module, self.idrac, MANAGERS_URI) |
| 447 |
if error_msg: |
| 448 |
self.module.exit_json(msg=error_msg, failed=True) |
| 449 |
resp = get_dynamic_uri(self.idrac, uri) |
| 450 |
url = resp.get('Links', {}).get(OEM, {}).get( |
| 451 |
MANUFACTURER, {}).get(LC_SERVICE, {}).get(ODATA, {}) |
| 452 |
action_resp = get_dynamic_uri(self.idrac, url) |
| 453 |
url = action_resp.get(ACTIONS, {}).get( |
| 454 |
TEST_SHARE, {}).get('target', {}) |
| 455 |
return url |
| 456 |
|
| 457 |
|
| 458 |
class AcceptEULA(SupportAssist): |
| 459 |
def __init__(self, idrac, module): |
| 460 |
self.idrac = idrac |
| 461 |
self.module = module |
| 462 |
self.eula_status_url = None |
| 463 |
self.eula_accept_url = None |
| 464 |
|
| 465 |
def execute(self): |
| 466 |
msg = None |
| 467 |
self.__get_eula_status_url() |
| 468 |
if self.module.check_mode: |
| 469 |
self.perform_check_mode() |
| 470 |
self.__get_eula_accept_url() |
| 471 |
eula_status = self.eula_status() |
| 472 |
if eula_status.status_code in STATUS_SUCCESS: |
| 473 |
data = eula_status.json_data.get(MESSAGE_EXTENDED_INFO) |
| 474 |
message_details = data[0] |
| 475 |
msg = message_details.get('Message') |
| 476 |
message_ids = [dict_item['MessageId'] for dict_item in data] |
| 477 |
for string in message_ids: |
| 478 |
if 'SRV074' in string and (self.module.params.get("run") or self.module.params.get("export")): |
| 479 |
return msg |
| 480 |
if self.module.params.get("accept_eula"): |
| 481 |
eula_accept_status = self.accept_eula() |
| 482 |
if eula_accept_status.status_code in STATUS_SUCCESS: |
| 483 |
data = eula_accept_status.json_data.get(MESSAGE_EXTENDED_INFO) |
| 484 |
message_details = data[0] |
| 485 |
message_id = message_details.get('MessageId') |
| 486 |
msg = message_details.get('Message') |
| 487 |
if 'SRV074' in message_id: |
| 488 |
return msg |
| 489 |
|
| 490 |
def __get_eula_status_url(self): |
| 491 |
uri, error_msg = validate_and_get_first_resource_id_uri( |
| 492 |
self.module, self.idrac, MANAGERS_URI) |
| 493 |
if error_msg: |
| 494 |
self.module.exit_json(msg=error_msg, failed=True) |
| 495 |
resp = get_dynamic_uri(self.idrac, uri) |
| 496 |
url = resp.get('Links', {}).get(OEM, {}).get( |
| 497 |
MANUFACTURER, {}).get(LC_SERVICE, {}).get(ODATA, {}) |
| 498 |
if url: |
| 499 |
action_resp = get_dynamic_uri(self.idrac, url) |
| 500 |
eula_status_url = action_resp.get(ACTIONS, {}).get( |
| 501 |
EULA_STATUS, {}).get('target', {}) |
| 502 |
self.eula_status_url = eula_status_url |
| 503 |
else: |
| 504 |
self.module.exit_json(msg=UNSUPPORTED_FIRMWARE_MSG, failed=True) |
| 505 |
|
| 506 |
def __get_eula_accept_url(self): |
| 507 |
uri, error_msg = validate_and_get_first_resource_id_uri( |
| 508 |
self.module, self.idrac, MANAGERS_URI) |
| 509 |
if error_msg: |
| 510 |
self.module.exit_json(msg=error_msg, failed=True) |
| 511 |
resp = get_dynamic_uri(self.idrac, uri) |
| 512 |
url = resp.get('Links', {}).get(OEM, {}).get( |
| 513 |
MANUFACTURER, {}).get(LC_SERVICE, {}).get(ODATA, {}) |
| 514 |
if url: |
| 515 |
action_resp = get_dynamic_uri(self.idrac, url) |
| 516 |
eula_accept_url = action_resp.get(ACTIONS, {}).get( |
| 517 |
ACCEPT_EULA, {}).get('target', {}) |
| 518 |
self.eula_accept_url = eula_accept_url |
| 519 |
else: |
| 520 |
self.module.exit_json(msg=UNSUPPORTED_FIRMWARE_MSG, failed=True) |
| 521 |
|
| 522 |
def eula_status(self): |
| 523 |
eula_status = self.idrac.invoke_request( |
| 524 |
self.eula_status_url, "POST", data="{}", dump=False) |
| 525 |
return eula_status |
| 526 |
|
| 527 |
def accept_eula(self): |
| 528 |
eula_accept_status = self.idrac.invoke_request( |
| 529 |
self.eula_accept_url, "POST", data="{}", dump=False) |
| 530 |
return eula_accept_status |
| 531 |
|
| 532 |
def perform_check_mode(self): |
| 533 |
eula_status = self.eula_status() |
| 534 |
if eula_status.status_code in STATUS_SUCCESS: |
| 535 |
data = eula_status.json_data.get(MESSAGE_EXTENDED_INFO) |
| 536 |
message_ids = [dict_item['MessageId'] for dict_item in data] |
| 537 |
|
| 538 |
actions = { |
| 539 |
'SRV104': { |
| 540 |
True: (CHANGES_FOUND_MSG, True), |
| 541 |
False: (CHANGES_NOT_FOUND_MSG, False), |
| 542 |
None: (CHANGES_NOT_FOUND_MSG, False) |
| 543 |
}, |
| 544 |
'SRV074': { |
| 545 |
True: (CHANGES_NOT_FOUND_MSG, False), |
| 546 |
False: (CHANGES_FOUND_MSG, True), |
| 547 |
None: (CHANGES_FOUND_MSG, True) |
| 548 |
} |
| 549 |
} |
| 550 |
|
| 551 |
for string in message_ids: |
| 552 |
for key, value in actions.items(): |
| 553 |
if key in string: |
| 554 |
msg, changed = value[self.module.params.get( |
| 555 |
"accept_eula")] |
| 556 |
self.module.exit_json(msg=msg, changed=changed) |
| 557 |
|
| 558 |
|
| 559 |
class RunSupportAssist(SupportAssist): |
| 560 |
|
| 561 |
def execute(self): |
| 562 |
msg, job_details = None, None |
| 563 |
if self.module.params.get('export'): |
| 564 |
self.test_network_share() |
| 565 |
self.__get_run_support_assist_url() |
| 566 |
self.check_support_assist_jobs() |
| 567 |
self.__validate_job_timeout() |
| 568 |
run_support_assist_status = self.__run_support_assist() |
| 569 |
job_status = self.__perform_job_wait(run_support_assist_status) |
| 570 |
status = run_support_assist_status.status_code |
| 571 |
if status in STATUS_SUCCESS and job_status.get('JobState') in ["Completed", "CompletedWithErrors"]: |
| 572 |
msg = SUCCESS_RUN_MSG |
| 573 |
if self.module.params.get('run') and self.module.params.get('export'): |
| 574 |
msg = SUCCESS_RUN_AND_EXPORT_MSG |
| 575 |
job_details = job_status |
| 576 |
if status in STATUS_SUCCESS and job_status.get('JobState') in ["Scheduled", "Scheduling", "Running", "New"]: |
| 577 |
msg = RUNNING_RUN_MSG |
| 578 |
if self.module.params.get('run') and self.module.params.get('export'): |
| 579 |
msg = RUNNING_RUN_AND_EXPORT_MSG |
| 580 |
job_details = job_status |
| 581 |
return msg, job_details |
| 582 |
|
| 583 |
def __run_support_assist(self): |
| 584 |
data_selector = { |
| 585 |
"hardware_data": "HWData", |
| 586 |
"storage_logs": "TTYLogs", |
| 587 |
"os_app_data": "OSAppData", |
| 588 |
"debug_logs": "DebugLogs", |
| 589 |
"telemetry_reports": "TelemetryReports", |
| 590 |
"gpu_logs": "GPULogs" |
| 591 |
} |
| 592 |
payload = {} |
| 593 |
data_selected = self.module.params.get('data_collector') |
| 594 |
if data_selected == []: |
| 595 |
self.module.exit_json(msg=NO_VALUE_MSG, skipped=True) |
| 596 |
data = [data_selector.get(item, item) for item in data_selected] |
| 597 |
self.__validate_input(data, data_selector) |
| 598 |
payload["DataSelectorArrayIn"] = data |
| 599 |
if self.module.params.get('filter_data'): |
| 600 |
payload["Filter"] = "Yes" |
| 601 |
if self.module.params.get('export'): |
| 602 |
share_payload_obj = ExportSupportAssist(self.idrac, self.module) |
| 603 |
share_payload = share_payload_obj.execute() |
| 604 |
payload.update(share_payload) |
| 605 |
payload = {k: v for k, v in payload.items() if v is not None} |
| 606 |
run_support_assist_status = self.idrac.invoke_request( |
| 607 |
self.run_url, "POST", data=payload) |
| 608 |
return run_support_assist_status |
| 609 |
|
| 610 |
def __validate_input(self, data_selected, data_selector): |
| 611 |
uri, error_msg = validate_and_get_first_resource_id_uri( |
| 612 |
self.module, self.idrac, MANAGERS_URI) |
| 613 |
if error_msg: |
| 614 |
self.module.exit_json(msg=error_msg, failed=True) |
| 615 |
resp = get_dynamic_uri(self.idrac, uri) |
| 616 |
url = resp.get('Links', {}).get(OEM, {}).get( |
| 617 |
MANUFACTURER, {}).get(LC_SERVICE, {}).get(ODATA, {}) |
| 618 |
allowable_values_response = self.idrac.invoke_request(url, "GET") |
| 619 |
allowable_values = allowable_values_response.json_data[ACTIONS][RUN][DATA_SELECTOR] |
| 620 |
invalid_values = [ |
| 621 |
item for item in data_selected if item not in allowable_values] |
| 622 |
if invalid_values: |
| 623 |
allowed_keys = [ |
| 624 |
key for key, value in data_selector.items() if value not in invalid_values] |
| 625 |
allowed_values = [ |
| 626 |
key for key, value in data_selector.items() if key in allowed_keys] |
| 627 |
self.module.exit_json(msg=ALLOWED_VALUES_MSG.format( |
| 628 |
allowed_values), skipped=True) |
| 629 |
|
| 630 |
def __get_run_support_assist_url(self): |
| 631 |
uri, error_msg = validate_and_get_first_resource_id_uri( |
| 632 |
self.module, self.idrac, MANAGERS_URI) |
| 633 |
if error_msg: |
| 634 |
self.module.exit_json(msg=error_msg, failed=True) |
| 635 |
resp = get_dynamic_uri(self.idrac, uri) |
| 636 |
url = resp.get('Links', {}).get(OEM, {}).get( |
| 637 |
MANUFACTURER, {}).get(LC_SERVICE, {}).get(ODATA, {}) |
| 638 |
if url: |
| 639 |
action_resp = get_dynamic_uri(self.idrac, url) |
| 640 |
run_url = action_resp.get(ACTIONS, {}).get( |
| 641 |
RUN, {}).get('target', {}) |
| 642 |
self.run_url = run_url |
| 643 |
else: |
| 644 |
self.module.exit_json(msg=UNSUPPORTED_FIRMWARE_MSG, failed=True) |
| 645 |
|
| 646 |
def __validate_job_timeout(self): |
| 647 |
if self.module.params.get("job_wait") and self.module.params.get("job_wait_timeout") <= 0: |
| 648 |
self.module.exit_json( |
| 649 |
msg=TIMEOUT_NEGATIVE_OR_ZERO_MSG, failed=True) |
| 650 |
|
| 651 |
def __perform_job_wait(self, run_support_assist_status): |
| 652 |
job_details = {} |
| 653 |
job_wait = self.module.params.get('job_wait') |
| 654 |
share_params = self.module.params.get('share_parameters') or {} |
| 655 |
local_share = share_params.get('share_type') or False |
| 656 |
timeout_of_job_wait = self.module.params.get('job_wait_timeout') |
| 657 |
job_tracking_uri = run_support_assist_status.headers.get("Location") |
| 658 |
if job_tracking_uri: |
| 659 |
job_id = job_tracking_uri.split("/")[-1] |
| 660 |
res_uri = validate_and_get_first_resource_id_uri( |
| 661 |
self.module, self.idrac, MANAGERS_URI) |
| 662 |
job_uri = f"{res_uri[0]}/{OEM}/{MANUFACTURER}/{JOBS}/{job_id}" |
| 663 |
if job_wait or local_share == 'local': |
| 664 |
failed_job, message, job_details, time_to_wait = idrac_redfish_job_tracking(self.idrac, job_uri, |
| 665 |
max_job_wait_sec=timeout_of_job_wait, |
| 666 |
sleep_interval_secs=1) |
| 667 |
job_details = remove_key(job_details, regex_pattern=ODATA_REGEX) |
| 668 |
if int(time_to_wait) >= int(timeout_of_job_wait): |
| 669 |
self.module.exit_json(msg=WAIT_TIMEOUT_MSG.format( |
| 670 |
timeout_of_job_wait), changed=True, job_status=job_details) |
| 671 |
if failed_job: |
| 672 |
self.module.exit_json( |
| 673 |
msg=job_details.get("Message"), job_status=job_details, failed=True) |
| 674 |
else: |
| 675 |
job_response = self.idrac.invoke_request(job_uri, 'GET') |
| 676 |
job_details = job_response.json_data |
| 677 |
job_details = remove_key(job_details, regex_pattern=ODATA_REGEX) |
| 678 |
self.file_download(job_tracking_uri, local_share) |
| 679 |
return job_details |
| 680 |
|
| 681 |
def file_download(self, job_tracking_uri, local_share): |
| 682 |
if job_tracking_uri and local_share == 'local': |
| 683 |
file_path = self.module.params.get( |
| 684 |
'share_parameters').get('share_name') |
| 685 |
now = datetime.now() |
| 686 |
hostname = self.module.params.get('idrac_ip') |
| 687 |
hostname = self.expand_ipv6(hostname) |
| 688 |
hostname = hostname.replace(":", ".") |
| 689 |
sa_file_name = f"{hostname}_{now.strftime(TIME_FORMAT)}.zip" |
| 690 |
file_name = (os.path.join(file_path, sa_file_name)) |
| 691 |
time.sleep(10) |
| 692 |
file_dict = self.idrac.invoke_request(job_tracking_uri, "GET", |
| 693 |
api_timeout=200) |
| 694 |
time.sleep(10) |
| 695 |
file_dnld = self.idrac.invoke_request(file_dict.headers.get( |
| 696 |
"Location"), "GET", |
| 697 |
headers={"Content-Type": "application/x-tar"}, |
| 698 |
api_timeout=200) |
| 699 |
if file_dnld.status_code == 200: |
| 700 |
with open(file_name, "wb") as file: |
| 701 |
file.write(file_dnld.body) |
| 702 |
|
| 703 |
def expand_ipv6(self, ip): |
| 704 |
sections = ip.split(':') |
| 705 |
num_sections = len(sections) |
| 706 |
double_colon_index = sections.index('') if '' in sections else -1 |
| 707 |
if double_colon_index != -1: |
| 708 |
missing_sections = 8 - num_sections + 1 |
| 709 |
sections[double_colon_index:double_colon_index + 1] = ['0000'] * missing_sections |
| 710 |
sections = [section.zfill(4) for section in sections] |
| 711 |
expanded_ip = ':'.join(sections) |
| 712 |
return expanded_ip |
| 713 |
|
| 714 |
def check_support_assist_jobs(self): |
| 715 |
res_uri = validate_and_get_first_resource_id_uri( |
| 716 |
self.module, self.idrac, MANAGERS_URI) |
| 717 |
job_uri = f"{res_uri[0]}/{OEM}/{MANUFACTURER}/{JOBS}{JOBS_EXPAND}" |
| 718 |
job_resp = self.idrac.invoke_request(job_uri, "GET") |
| 719 |
job_list = job_resp.json_data.get('Members', []) |
| 720 |
job_id = "" |
| 721 |
for jb in job_list: |
| 722 |
if (jb.get("JobType") == "SACollectHealthData" or jb.get("JobType") == |
| 723 |
"SACollectExportHealthData") and jb.get("JobState") in ["Scheduled", "Running", "Starting", "New"]: |
| 724 |
job_id = jb['Id'] |
| 725 |
job_dict = remove_key(jb, regex_pattern=ODATA_REGEX) |
| 726 |
break |
| 727 |
if self.module.check_mode and job_id: |
| 728 |
self.module.exit_json(msg=ALREADY_RUN_MSG, |
| 729 |
job_details=job_dict, skipped=True) |
| 730 |
if self.module.check_mode and not job_id: |
| 731 |
eula_status_obj = AcceptEULA(self.idrac, self.module) |
| 732 |
eula_status_obj.execute() |
| 733 |
if job_id: |
| 734 |
self.module.exit_json(msg=ALREADY_RUN_MSG, |
| 735 |
job_details=job_dict, skipped=True) |
| 736 |
|
| 737 |
|
| 738 |
class ExportSupportAssist(SupportAssist): |
| 739 |
|
| 740 |
def execute(self): |
| 741 |
self.test_network_share() |
| 742 |
RunSupportAssist.check_support_assist_jobs(self) |
| 743 |
self.__get_export_support_assist_url() |
| 744 |
if self.module.check_mode: |
| 745 |
self.perform_check_mode() |
| 746 |
job_status = {} |
| 747 |
share_type = self.module.params.get( |
| 748 |
'share_parameters').get('share_type') |
| 749 |
share_type_methods = { |
| 750 |
"local": self.__export_support_assist_local, |
| 751 |
"http": self.__export_support_assist_remote_shares, |
| 752 |
"https": self.__export_support_assist_remote_shares, |
| 753 |
"cifs": self.__export_support_assist_remote_shares, |
| 754 |
"nfs": self.__export_support_assist_nfs, |
| 755 |
"ftp": self.__export_support_assist_remote_shares |
| 756 |
} |
| 757 |
payload = share_type_methods[share_type]() |
| 758 |
if share_type == "local": |
| 759 |
if self.module.params.get('run') and self.module.params.get('export'): |
| 760 |
return payload |
| 761 |
else: |
| 762 |
self.module.exit_json( |
| 763 |
msg=OPERATION_NOT_ALLOWED_MSG, skipped=True) |
| 764 |
if self.module.params.get('run'): |
| 765 |
return payload |
| 766 |
export_support_assist_status = self.__export_support_assist(payload) |
| 767 |
job_status = self.get_job_status(export_support_assist_status) |
| 768 |
status = export_support_assist_status.status_code |
| 769 |
if status in STATUS_SUCCESS: |
| 770 |
msg = SUCCESS_EXPORT_MSG |
| 771 |
job_details = job_status |
| 772 |
return msg, job_details |
| 773 |
|
| 774 |
def __export_support_assist_local(self): |
| 775 |
payload = {} |
| 776 |
payload["ShareType"] = "Local" |
| 777 |
return payload |
| 778 |
|
| 779 |
def __export_support_assist_remote_shares(self): |
| 780 |
payload = self.get_payload_details() |
| 781 |
return payload |
| 782 |
|
| 783 |
def __export_support_assist_nfs(self): |
| 784 |
payload = self.get_payload_details() |
| 785 |
del payload["UserName"], payload["Password"] |
| 786 |
return payload |
| 787 |
|
| 788 |
def __get_export_support_assist_url(self): |
| 789 |
uri, error_msg = validate_and_get_first_resource_id_uri( |
| 790 |
self.module, self.idrac, MANAGERS_URI) |
| 791 |
if error_msg: |
| 792 |
self.module.exit_json(msg=error_msg, failed=True) |
| 793 |
resp = get_dynamic_uri(self.idrac, uri) |
| 794 |
url = resp.get('Links', {}).get(OEM, {}).get( |
| 795 |
MANUFACTURER, {}).get(LC_SERVICE, {}).get(ODATA, {}) |
| 796 |
if url: |
| 797 |
action_resp = get_dynamic_uri(self.idrac, url) |
| 798 |
export_url = action_resp.get(ACTIONS, {}).get( |
| 799 |
EXPORT, {}).get('target', {}) |
| 800 |
self.export_url = export_url |
| 801 |
else: |
| 802 |
self.module.exit_json(msg=UNSUPPORTED_FIRMWARE_MSG, failed=True) |
| 803 |
|
| 804 |
def __export_support_assist(self, payload): |
| 805 |
if self.module.params.get('run') or self.module.params.get('share_parameters').get('share_type') == "local": |
| 806 |
return payload |
| 807 |
export_support_assist_status = self.idrac.invoke_request( |
| 808 |
self.export_url, "POST", data=payload) |
| 809 |
return export_support_assist_status |
| 810 |
|
| 811 |
def get_job_status(self, export_support_assist_status): |
| 812 |
res_uri = validate_and_get_first_resource_id_uri( |
| 813 |
self.module, self.idrac, MANAGERS_URI) |
| 814 |
job_tracking_uri = export_support_assist_status.headers.get("Location") |
| 815 |
job_id = job_tracking_uri.split("/")[-1] |
| 816 |
job_uri = f"{res_uri[0]}/{OEM}/{MANUFACTURER}/{JOBS}/{job_id}" |
| 817 |
job_failed, msg, job_dict, wait_time = idrac_redfish_job_tracking( |
| 818 |
self.idrac, job_uri) |
| 819 |
job_dict = remove_key(job_dict, regex_pattern=ODATA_REGEX) |
| 820 |
if job_failed: |
| 821 |
self.module.exit_json(msg=job_dict.get( |
| 822 |
'Message'), failed=True, job_details=job_dict) |
| 823 |
return job_dict |
| 824 |
|
| 825 |
|
| 826 |
class SupportAssistType: |
| 827 |
_support_assist_classes = { |
| 828 |
"accept_eula": AcceptEULA, |
| 829 |
"run": RunSupportAssist, |
| 830 |
"export": ExportSupportAssist |
| 831 |
} |
| 832 |
|
| 833 |
@staticmethod |
| 834 |
def support_assist_operation(idrac, module): |
| 835 |
class_type = None |
| 836 |
if module.params.get("run"): |
| 837 |
class_type = "run" |
| 838 |
elif module.params.get("export"): |
| 839 |
class_type = "export" |
| 840 |
if class_type: |
| 841 |
support_assist_class = SupportAssistType._support_assist_classes.get( |
| 842 |
class_type) |
| 843 |
return support_assist_class(idrac, module) |
| 844 |
else: |
| 845 |
if not module.params.get("accept_eula"): |
| 846 |
module.exit_json(msg=NO_OPERATION_SKIP_MSG, skipped=True) |
| 847 |
|
| 848 |
|
| 849 |
def main(): |
| 850 |
specs = get_argument_spec() |
| 851 |
|
| 852 |
module = IdracAnsibleModule( |
| 853 |
argument_spec=specs, |
| 854 |
required_one_of=[["run", "export"]], |
| 855 |
required_if=[ |
| 856 |
["run", True, ("data_collector",)], |
| 857 |
["export", True, ("share_parameters",)] |
| 858 |
], |
| 859 |
supports_check_mode=True |
| 860 |
) |
| 861 |
|
| 862 |
msg = None |
| 863 |
try: |
| 864 |
with iDRACRedfishAPI(module.params) as idrac: |
| 865 |
if module.params.get("accept_eula"): |
| 866 |
accept_eula_obj = AcceptEULA(idrac, module) |
| 867 |
msg = accept_eula_obj.execute() |
| 868 |
support_assist_obj = SupportAssistType.support_assist_operation( |
| 869 |
idrac, module) |
| 870 |
if support_assist_obj is None: |
| 871 |
module.exit_json(msg=msg, changed=True) |
| 872 |
msg, job_status = support_assist_obj.execute() |
| 873 |
module.exit_json(msg=msg, changed=True, job_details=job_status) |
| 874 |
except HTTPError as err: |
| 875 |
filter_err = remove_key(json.load(err), regex_pattern=ODATA_REGEX) |
| 876 |
message_details = filter_err.get('error').get(MESSAGE_EXTENDED_INFO)[0] |
| 877 |
message_id = message_details.get('MessageId') |
| 878 |
if 'SRV095' in message_id: |
| 879 |
module.exit_json(msg=message_details.get('Message'), skipped=True) |
| 880 |
if 'SRV085' in message_id: |
| 881 |
module.exit_json(msg=message_details.get('Message'), skipped=True) |
| 882 |
if 'LIC501' in message_id: |
| 883 |
module.exit_json(msg=message_details.get('Message'), skipped=True) |
| 884 |
if 'SRV113' in message_id: |
| 885 |
module.exit_json(msg=message_details.get('Message'), skipped=True) |
| 886 |
module.exit_json(msg=str(err), error_info=filter_err, failed=True) |
| 887 |
except URLError as err: |
| 888 |
module.exit_json(msg=str(err), unreachable=True) |
| 889 |
except (OSError, ValueError, SSLValidationError, ConnectionError, TypeError) as e: |
| 890 |
module.exit_json(msg=str(e), failed=True) |
| 891 |
|
| 892 |
|
| 893 |
def get_argument_spec(): |
| 894 |
""" |
| 895 |
Function to generate the argument specification for the IdracAnsibleModule. |
| 896 |
It returns a dictionary containing the argument specification for the module. |
| 897 |
|
| 898 |
The argument specification is a dictionary that contains the following keys: |
| 899 |
- run: a boolean that defaults to True |
| 900 |
- export: a boolean that defaults to True |
| 901 |
- accept_eula: a boolean |
| 902 |
- filter_data: a boolean that defaults to False |
| 903 |
- data_collector: a list of strings with choices including hardware_data, storage_logs, os_app_data, debug_logs, telemetry_reports, gpu_logs |
| 904 |
- job_wait: a boolean that defaults to True |
| 905 |
- job_wait_timeout: an integer that defaults to 3600 |
| 906 |
- share_parameters: a dictionary with options including |
| 907 |
- share_type: a string with default 'local' and choices ['local', 'nfs', 'cifs', 'http', 'https', 'ftp'] |
| 908 |
- proxy_type: a string with default 'http' and choices ['http', 'socks'] |
| 909 |
- username: |
| 910 |
description: User name for accessing the share, required when share_type is 'cifs' |
| 911 |
type: str |
| 912 |
aliases: ['share_username'] |
| 913 |
- password: |
| 914 |
description: Password for accessing the share, required when share_type is 'cifs', will not be logged |
| 915 |
type: str |
| 916 |
aliases: ['share_password'] |
| 917 |
- proxy_support: |
| 918 |
description: Proxy support, a string with default 'off' and choices ['off', 'default_proxy', 'parameters_proxy'] |
| 919 |
- proxy_port: |
| 920 |
description: Proxy port, an integer with default 80 |
| 921 |
- proxy_server: |
| 922 |
description: Proxy server address, a string |
| 923 |
- proxy_username: |
| 924 |
description: User name for the proxy server, a string |
| 925 |
- proxy_password: |
| 926 |
description: Password for the proxy server, a string, will not be logged |
| 927 |
- workgroup: |
| 928 |
description: Workgroup for accessing the share, a string |
| 929 |
- ignore_certificate_warning: |
| 930 |
description: Ignores the certificate warning when connecting to the share, a string with default 'off' and choices ['off', 'on'] |
| 931 |
- share_name: |
| 932 |
description: Share path or name, a string |
| 933 |
- ip_address: |
| 934 |
description: IP address of the share, a string |
| 935 |
- resource_id: a string |
| 936 |
|
| 937 |
""" |
| 938 |
return { |
| 939 |
"run": {"type": 'bool', "default": True}, |
| 940 |
"export": {"type": 'bool', "default": True}, |
| 941 |
"accept_eula": {"type": 'bool'}, |
| 942 |
"filter_data": {"type": 'bool', "default": False}, |
| 943 |
"data_collector": { |
| 944 |
"type": 'list', |
| 945 |
"elements": 'str', |
| 946 |
"choices": ['hardware_data', 'storage_logs', 'os_app_data', 'debug_logs', 'telemetry_reports', 'gpu_logs'] |
| 947 |
}, |
| 948 |
"job_wait": {"type": 'bool', "default": True}, |
| 949 |
"job_wait_timeout": {"type": 'int', "default": 3600}, |
| 950 |
"share_parameters": { |
| 951 |
"type": 'dict', |
| 952 |
"options": { |
| 953 |
"share_type": { |
| 954 |
"type": 'str', |
| 955 |
"default": 'local', |
| 956 |
"choices": ['local', 'nfs', 'cifs', 'http', 'https', 'ftp'] |
| 957 |
}, |
| 958 |
"proxy_type": { |
| 959 |
"type": 'str', |
| 960 |
"default": 'http', |
| 961 |
"choices": ['http', 'socks'] |
| 962 |
}, |
| 963 |
"username": { |
| 964 |
"type": 'str', |
| 965 |
"aliases": ['share_username'], |
| 966 |
'required_if': [('share_type', 'cifs', True)] |
| 967 |
}, |
| 968 |
"password": { |
| 969 |
"type": 'str', |
| 970 |
"no_log": True, |
| 971 |
"aliases": ['share_password'], |
| 972 |
'required_if': [('share_type', 'cifs', True)] |
| 973 |
}, |
| 974 |
"proxy_port": {"type": 'int', "default": 80}, |
| 975 |
"proxy_server": {"type": 'str'}, |
| 976 |
"proxy_username": {"type": 'str'}, |
| 977 |
"proxy_password": {"type": 'str', "no_log": True}, |
| 978 |
"workgroup": {"type": 'str'}, |
| 979 |
"proxy_support": { |
| 980 |
"type": 'str', |
| 981 |
"default": "off", |
| 982 |
"choices": ["off", "default_proxy", "parameters_proxy"] |
| 983 |
}, |
| 984 |
"ignore_certificate_warning": { |
| 985 |
"type": 'str', |
| 986 |
"default": "off", |
| 987 |
"choices": ["off", "on"] |
| 988 |
}, |
| 989 |
"share_name": {"type": 'str'}, |
| 990 |
"ip_address": {"type": 'str'}, |
| 991 |
}, |
| 992 |
"required_together": [ |
| 993 |
("username", "password"), |
| 994 |
("proxy_username", "proxy_password") |
| 995 |
], |
| 996 |
"required_if": [ |
| 997 |
["share_type", "local", ["share_name"]], |
| 998 |
["share_type", "nfs", ["ip_address", "share_name"]], |
| 999 |
["share_type", "cifs", ["ip_address", |
| 1000 |
"share_name", "username", "password"]], |
| 1001 |
["share_type", "http", ["ip_address", "share_name"]], |
| 1002 |
["share_type", "https", ["ip_address", "share_name"]], |
| 1003 |
["proxy_support", "parameters_proxy", ["proxy_server"]] |
| 1004 |
], |
| 1005 |
}, |
| 1006 |
"resource_id": {"type": 'str'} |
| 1007 |
} |
| 1008 |
|
| 1009 |
|
| 1010 |
if __name__ == '__main__': |
| 1011 |
main() |