Skip to content

Commit 7bfc12c

Browse files
authored
Merge pull request #603 from dikobra4/main
Added requesttimeout and requestattempts arguments
2 parents 573695a + 512f625 commit 7bfc12c

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ At a minimum, the `ip`, `username`, and `password` options must be modified.
7979
### [Validator]
8080

8181
| Variable | CLI Argument | Type | Definition |
82-
| :--- | :--- | :--- | :--- |
82+
| :--- | :--- |:--------| :--- |
8383
| `payload` | `--payload` | string | The mode to validate payloads ('Tree', 'Single', 'SingleFile', or 'TreeFile') followed by resource/filepath; see below. |
8484
| `logdir` | `--logdir` | string | The directory for generated report files; default: 'logs'. |
8585
| `oemcheck` | `--nooemcheck` | boolean | Whether to check OEM items on service; 'True' or 'False'. |
@@ -88,6 +88,8 @@ At a minimum, the `ip`, `username`, and `password` options must be modified.
8888
| `schema_directory` | `--schema_directory` | string | Directory for local schema files. |
8989
| `mockup` | `--mockup` | string | Directory tree for local mockup files. This option enables insertion of local mockup resources to replace missing, incomplete, or incorrect implementations retrieved from the service that may hinder full validation coverage. |
9090
| `collectionlimit` | `--collectionlimit` | string | Sets a limit to links gathered from collections by type (schema name).<br/>Example 1: `ComputerSystem 20` limits ComputerSystemCollection to 20 links.<br/>Example 2: `ComputerSystem 20 LogEntry 10` limits ComputerSystemCollection to 20 links and LogEntryCollection to 10 links. |
91+
| `requesttimeout` | `--requesttimeout` | integer | Timeout in seconds for HTTP request waiting for response. |
92+
| `requestattempts` | `--requestattempts` | integer | Number of attempts after failed HTTP requests. |
9193

9294
### Payload Option
9395

redfish_service_validator/RedfishServiceValidator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def validate(argslist=None, configfile=None):
8080
argget.add_argument('--schema_directory', type=str, default='./SchemaFiles/metadata', help='Directory for local schema files')
8181
argget.add_argument('--mockup', type=str, default='', help='Enables insertion of local mockup resources to replace missing, incomplete, or incorrect implementations retrieved from the service that may hinder full validation coverage')
8282
argget.add_argument('--collectionlimit', type=str, default=['LogEntry', '20'], help='apply a limit to collections (format: RESOURCE1 COUNT1 RESOURCE2 COUNT2...)', nargs='+')
83+
argget.add_argument('--requesttimeout', type=int, default=10, help='Timeout in seconds for HTTP requests waiting for response')
84+
argget.add_argument('--requestattempts', type=int, default=10, help='Number of attempts after failed HTTP requests')
8385

8486
# parse...
8587
args = argget.parse_args(argslist)

redfish_service_validator/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
config_struct = {
1313
'Tool': ['verbose'],
1414
'Host': ['ip', 'username', 'password', 'description', 'forceauth', 'authtype', 'token', 'ext_http_proxy', 'ext_https_proxy', 'serv_http_proxy', 'serv_https_proxy'],
15-
'Validator': ['payload', 'logdir', 'oemcheck', 'debugging', 'schema_directory', 'uricheck', 'mockup', 'collectionlimit']
15+
'Validator': ['payload', 'logdir', 'oemcheck', 'debugging', 'schema_directory', 'uricheck', 'mockup', 'collectionlimit', 'requesttimeout', 'requestattempts']
1616
}
1717

1818
config_options = [x for name in config_struct for x in config_struct[name]]
@@ -53,6 +53,8 @@ def convert_config_to_args(args, config):
5353
elif my_config[section][option] not in ['', None]:
5454
if option.lower() == 'payload' or option.lower() == 'collectionlimit':
5555
setattr(args, option, my_config[section][option].split(' '))
56+
elif option.lower() in ['requesttimeout', 'requestattempts']:
57+
setattr(args, option, int(my_config[section][option]))
5658
else:
5759
setattr(args, option, my_config[section][option])
5860
if option.lower() in ['password', 'token']:

redfish_service_validator/traverse.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def __init__(self, config):
4747
self.config['usessl'] = urlparse(self.config['configuri']).scheme in ['https']
4848
self.config['certificatecheck'] = False
4949
self.config['certificatebundle'] = None
50-
self.config['timeout'] = 10
5150

5251
# NOTE: this is a validator limitation. maybe move this to its own config
5352
if self.config['collectionlimit']:
@@ -75,7 +74,7 @@ def __init__(self, config):
7574
self.ext_proxies = {}
7675
if self.config['ext_http_proxy'] != '': self.ext_proxies['http'] = self.config['ext_http_proxy']
7776
if self.config['ext_https_proxy'] != '': self.ext_proxies['https'] = self.config['ext_https_proxy']
78-
self.context = rf.redfish_client(base_url=rhost, username=user, password=passwd, timeout=self.config['timeout'], proxies=proxies)
77+
self.context = rf.redfish_client(base_url=rhost, username=user, password=passwd, timeout=self.config['requesttimeout'], max_retry=self.config['requestattempts'], proxies=proxies)
7978
self.context.login( auth = self.config['authtype'].lower() )
8079

8180
# Go through $metadata and download any additional schema files needed
@@ -135,7 +134,7 @@ def callResourceURI(self, link_uri):
135134
config = self.config
136135
# proxies = self.proxies
137136
ConfigIP, UseSSL, AuthType, ChkCert, ChkCertBundle, timeout, Token = config['configuri'], config['usessl'], config['authtype'], \
138-
config['certificatecheck'], config['certificatebundle'], config['timeout'], config['token']
137+
config['certificatecheck'], config['certificatebundle'], config['requesttimeout'], config['token']
139138

140139
scheme, netloc, path, params, query, fragment = urlparse(link_uri)
141140
inService = scheme == '' and netloc == ''

0 commit comments

Comments
 (0)