Skip to content

Commit 0143b8a

Browse files
committed
CMCI Feedback Support
- Added support for cmci feedback include BAS feedback errors - Added new integration test with BAS installation error to cover feedback support - Updated names on integration tests - Updated cmci_variables template and all int tests to explicitly use secure/ non-secure ports - Removed copyright statements from ignore.txt files: Can't have a # on the first line of those files
1 parent 793f4bd commit 0143b8a

File tree

32 files changed

+2315
-133
lines changed

32 files changed

+2315
-133
lines changed

plugins/module_utils/cmci.py

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
COMPLEX_FILTER = 'complex_filter'
4545
SCHEME = 'scheme'
4646
INSECURE = 'insecure'
47+
FEEDBACK = 'feedback'
4748
TIMEOUT = 'timeout'
48-
4949
GET_PARAMETERS = 'get_parameters'
5050

5151

@@ -152,6 +152,33 @@ def is_alphanumeric(value):
152152
return re.match('^([A-Za-z0-9]{1,100})$', value, flags=0)
153153

154154

155+
def read_node(node):
156+
result = [
157+
OrderedDict(
158+
# Copy feedback from result, stripping @ from attributes
159+
# Feedback nodes can contain error types with further information
160+
[(k[1:], v) if k[0] == '@'
161+
else read_error_detail(k, v)
162+
for k, v in n.items()]
163+
) for n in node
164+
]
165+
return result
166+
167+
168+
def read_error_detail(key, value):
169+
# Xmltodict parses inner error types as Dicts when there is only one item in it even though it may well be a list
170+
# if multiple results were returned. If we find a dict here, wrap it in a list so we can account for only one result or many
171+
# being returned
172+
if not isinstance(value, list):
173+
value = [value]
174+
return key, \
175+
[
176+
OrderedDict(
177+
[(k[1:], v) for k, v in error.items()]
178+
) for error in value
179+
]
180+
181+
155182
class AnsibleCMCIModule(object):
156183

157184
def __init__(self, method):
@@ -364,12 +391,13 @@ def handle_response(self, response_dict): # type: (Dict) -> None
364391
records_node = response_node['records']
365392
resource_type = self._p[TYPE].lower()
366393
if resource_type in records_node:
367-
records = records_node[resource_type]
368-
# Copy records in result, stripping @ from attributes
369-
self.result['records'] = [
370-
{k[1:]: v for k, v in record.items()}
371-
for record in records
372-
]
394+
self.result['records'] = read_node(records_node[resource_type])
395+
396+
if 'errors' in response_node:
397+
errors_node = response_node['errors']
398+
if FEEDBACK in errors_node:
399+
feedback = errors_node[FEEDBACK]
400+
self.result[FEEDBACK] = read_node(feedback)
373401

374402
# Non-OK CPSM responses fail the module
375403
if cpsm_response_code != 1024:
@@ -534,7 +562,10 @@ def _do_request(self): # type: () -> Dict
534562
process_namespaces=True,
535563
namespaces=namespaces,
536564
# Make sure we always return a list for the resource node
537-
force_list=(self._p.get(TYPE).lower(),)
565+
force_list=(
566+
self._p.get(TYPE).lower(),
567+
FEEDBACK
568+
)
538569
)
539570

540571
return r
@@ -674,7 +705,7 @@ def _get_complex_filter(self, i, path):
674705
if not is_alphanumeric(attribute):
675706
self._fail(
676707
"Filter attribute with value {0} was not valid. Valid characters are A-Z a-z 0-9."
677-
.format(attribute)
708+
.format(attribute)
678709
)
679710

680711
value = escape_quotes(value)
@@ -685,7 +716,6 @@ def _get_complex_filter(self, i, path):
685716
else:
686717
return attribute + operator + '\'' + value + '\''
687718

688-
689719
def _convert_filter_operator(self, operator, path):
690720
if operator in ['<', 'LT']:
691721
return '<'

plugins/modules/cmci_action.py

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,239 @@
244244
description: The URL used for the request.
245245
returned: success
246246
type: str
247+
feedback:
248+
description: Diagnostic data from FEEDBACK records associated with the request
249+
returned: cmci error
250+
type: list
251+
elements: dict
252+
contains:
253+
action:
254+
description: The name of the action that has failed.
255+
returned: cmci error
256+
type: str
257+
attribute1:
258+
description: The name of one of up to six attributes associated with the error.
259+
returned: cmci error
260+
type: str
261+
attribute2:
262+
description: The name of one of up to six attributes associated with the error.
263+
returned: cmci error
264+
type: str
265+
attribute3:
266+
description: The name of one of up to six attributes associated with the error.
267+
returned: cmci error
268+
type: str
269+
attribute4:
270+
description: The name of one of up to six attributes associated with the error.
271+
returned: cmci error
272+
type: str
273+
attribute5:
274+
description: The name of one of up to six attributes associated with the error.
275+
returned: cmci error
276+
type: str
277+
attribute6:
278+
description: The name of one of up to six attributes associated with the error.
279+
returned: cmci error
280+
type: str
281+
eibfn:
282+
description: The function code associated with the request.
283+
returned: cmci error
284+
type: str
285+
eibfn_alt:
286+
description: The name of the function associated with the request.
287+
returned: cmci error
288+
type: str
289+
errorcode:
290+
description: The CICSPlex® SM error code associated with the resource.
291+
returned: cmci error
292+
type: str
293+
eyu_cicsname:
294+
description: The name of the CICS region or CICSplex associated with the error.
295+
returned: cmci error
296+
type: str
297+
keydata:
298+
description: A string of data that identifies the instance of a resource associated with the error.
299+
returned: cmci error
300+
type: str
301+
resp:
302+
description: The CICS RESP code or the CICSPlex SM API EYUDA response code as a numeric value.
303+
returned: cmci error
304+
type: str
305+
resp2:
306+
description: The CICS RESP2 code or the CICSPlex SM API EYUDA reason code as a numeric value.
307+
returned: cmci error
308+
type: str
309+
resp_alt:
310+
description: >
311+
The text equivalent for the resp value. For example, the text equivalent of a resp value of 16 is INVREQ.
312+
returned: cmci error
313+
type: str
314+
installerror:
315+
description: >
316+
Contains diagnostic data from a BINSTERR record associated with a CICS® management client interface PUT install request.
317+
returned: cmci error
318+
type: list
319+
elements: dict
320+
contains:
321+
eibfn:
322+
description: The function code associated with the request.
323+
returned: cmci error
324+
type: str
325+
eyu_cicsname:
326+
description: The name of the CICS region or CICSplex associated with the installation error.
327+
returned: cmci error
328+
type: str
329+
cresp1:
330+
description: The CICS RESP code or the CICSPlex® SM API EYUDA response code as a numeric value.
331+
returned: cmci error
332+
type: str
333+
cresp2:
334+
description: The CICS RESP2 code or the CICSPlex SM API EYUDA reason code as a numeric value.
335+
returned: cmci error
336+
type: str
337+
errorcode:
338+
description: The CICSPlex SM error code associated with the resource.
339+
returned: cmci error
340+
type: str
341+
ressname:
342+
description: The name of the resource associated with the error.
343+
returned: cmci error
344+
type: str
345+
resver:
346+
description: The version number of the resource associated with the error.
347+
returned: cmci error
348+
type: str
349+
inconsistentscope:
350+
description: >
351+
Contains diagnostic data from a BINCONSC record associated with a CICS® management client interface PUT request.
352+
returned: cmci error
353+
type: list
354+
elements: dict
355+
contains:
356+
eibfn:
357+
description: The function code associated with the request.
358+
returned: cmci error
359+
type: str
360+
eyu_cicsname:
361+
description: The name of the CICS region or CICSplex associated with the installation error.
362+
returned: cmci error
363+
type: str
364+
erroroperation:
365+
description: A numeric value that identifies the operation being performed when the error occurred.
366+
returned: cmci error
367+
type: str
368+
errorcode:
369+
description: The CICSPlex® SM error code associated with the resource.
370+
returned: cmci error
371+
type: str
372+
targetassignment:
373+
description: The assignment for the target scope.
374+
returned: cmci error
375+
type: str
376+
targetdescription:
377+
description: The resource description for the target scope.
378+
returned: cmci error
379+
type: str
380+
relatedassignment:
381+
description: The resource assignment for the related scope.
382+
returned: cmci error
383+
type: str
384+
relateddescription:
385+
description: The resource description for the related scope.
386+
returned: cmci error
387+
type: str
388+
relatedscope:
389+
description: The name of the related scope.
390+
returned: cmci error
391+
type: str
392+
inconsistentset:
393+
description: >
394+
Contains diagnostic data from a BINCONRS record associated with a CICS® management client interface PUT request.
395+
returned: cmci error
396+
type: list
397+
elements: dict
398+
contains:
399+
candidatename:
400+
description: The name of the candidate resource.
401+
returned: cmci error
402+
type: str
403+
candidateversion:
404+
description: The version number of the candidate resource.
405+
returned: cmci error
406+
type: str
407+
candidategroup:
408+
description: The resource group of the candidate resource.
409+
returned: cmci error
410+
type: str
411+
candidateassignment:
412+
description: The assignment of the candidate resource.
413+
returned: cmci error
414+
type: str
415+
candidatedescription:
416+
description: The description of the candidate resource.
417+
returned: cmci error
418+
type: str
419+
candidateusage:
420+
description: The assignment usage of the candidate resource.
421+
returned: cmci error
422+
type: str
423+
candidatesystemgroup:
424+
description: The system group of the candidate resource.
425+
returned: cmci error
426+
type: str
427+
candidatetype:
428+
description: The system type of the candidate resource.
429+
returned: cmci error
430+
type: str
431+
candidateoverride:
432+
description: The assignment override of the candidate resource.
433+
returned: cmci error
434+
type: str
435+
eyu_cicsname:
436+
description: The name of the CICS region associated with the installation error.
437+
returned: cmci error
438+
type: str
439+
erroroperation:
440+
description: >
441+
A numeric value that identifies that the operation being performed when the error occurred
442+
returned: cmci error
443+
type: str
444+
existingname:
445+
description: The name of the existing resource.
446+
returned: cmci error
447+
type: str
448+
existingversion:
449+
description: The version number of the existing resource.
450+
returned: cmci error
451+
type: str
452+
existinggroup:
453+
description: The resource group of the existing resource.
454+
returned: cmci error
455+
type: str
456+
existingassignment:
457+
description: The assignment of the existing resource.
458+
returned: cmci error
459+
type: str
460+
existingdescription:
461+
description: The description of the existing resource.
462+
returned: cmci error
463+
type: str
464+
existingusage:
465+
description: The assignment usage of the existing resource.
466+
returned: cmci error
467+
type: str
468+
existingsystemgroup:
469+
description: The system group of the existing resource.
470+
returned: cmci error
471+
type: str
472+
existingtype:
473+
description: The system type of the existing resource.
474+
returned: cmci error
475+
type: str
476+
existingoverride:
477+
description: The assignment override of the existing resource.
478+
returned: cmci error
479+
type: str
247480
"""
248481

249482

0 commit comments

Comments
 (0)