30
30
- "Demetrios Dimatos (@ddimatos)"
31
31
- "Ivan Moreno (@rexemin)"
32
32
- "Rich Parker (@richp405)"
33
+ - "Fernando Flores (@fernandofloresg)"
33
34
34
35
options:
35
36
system:
41
42
- A trailing asterisk, (*) wildcard is supported.
42
43
type: str
43
44
required: false
44
- message_id :
45
+ msg_id :
45
46
description:
46
47
- Return outstanding messages requiring operator action awaiting a
47
48
reply for a particular message identifier.
50
51
- A trailing asterisk, (*) wildcard is supported.
51
52
type: str
52
53
required: false
54
+ aliases: [ message_id ]
53
55
job_name:
54
56
description:
55
57
- Return outstanding messages requiring operator action awaiting a reply
59
61
- A trailing asterisk, (*) wildcard is supported.
60
62
type: str
61
63
required: false
62
- message_filter :
64
+ msg_filter :
63
65
description:
64
66
- Return outstanding messages requiring operator action awaiting a
65
67
reply that match a regular expression (regex) filter.
66
68
- If the message filter is not specified, all outstanding messages
67
69
are returned regardless of their content.
68
70
type: dict
69
71
required: false
72
+ aliases: [ message_filter ]
70
73
suboptions:
71
74
filter:
72
75
description:
73
76
- Specifies the substring or regex to match to the outstanding messages,
74
- see I(use_regex ).
77
+ see I(literal ).
75
78
- All special characters in a filter string that are not a regex are escaped.
76
79
- Valid Python regular expressions are supported. See L(the official
77
80
documentation,https://docs.python.org/library/re.html) for more information.
80
83
newline."
81
84
required: True
82
85
type: str
83
- use_regex :
86
+ literal :
84
87
description:
85
88
- Indicates that the value for I(filter) is a regex or a string to match.
86
- - If False, the module assumes that I(filter) is not a regex and
87
- matches the I(filter) substring on the outstanding messages.
88
- - If True, the module creates a regex from the I(filter) string and
89
+ - If False, the module creates a regex from the I(filter) string and
89
90
matches it to the outstanding messages.
91
+ - If True, the module assumes that I(filter) is not a regex and
92
+ matches the I(filter) substring on the outstanding messages.
90
93
required: False
91
94
type: bool
92
- default: False
95
+ default: True
93
96
seealso:
94
97
- module: zos_operator
95
98
116
119
117
120
- name: Display all outstanding messages whose message id begin with dsi*
118
121
zos_operator_action_query:
119
- message_id : dsi*
122
+ msg_id : dsi*
120
123
121
124
- name: Display all outstanding messages that have the text IMS READY in them
122
125
zos_operator_action_query:
123
- message_filter :
126
+ msg_filter :
124
127
filter: IMS READY
125
128
126
129
- name: Display all outstanding messages where the job name begins with 'mq',
127
130
message ID begins with 'dsi', on system 'mv29' and which contain the
128
131
pattern 'IMS'
129
132
zos_operator_action_query:
130
133
job_name: mq*
131
- message_id : dsi*
134
+ msg_id : dsi*
132
135
system: mv29
133
- message_filter :
136
+ msg_filter :
134
137
filter: ^.*IMS.*$
135
- use_regex : true
138
+ literal : true
136
139
"""
137
140
138
141
RETURN = r"""
147
150
count:
148
151
description:
149
152
The total number of outstanding messages.
150
- returned: on success
153
+ returned: always
151
154
type: int
152
155
sample: 12
153
156
actions:
154
157
description:
155
158
The list of the outstanding messages.
156
- returned: success
159
+ returned: always
157
160
type: list
158
161
elements: dict
159
162
contains:
183
186
returned: on success
184
187
type: str
185
188
sample: STC01537
186
- message_text :
189
+ msg_txt :
187
190
description:
188
191
Content of the outstanding message requiring operator
189
- action awaiting a reply. If I(message_filter ) is set,
190
- I(message_text ) will be filtered accordingly.
192
+ action awaiting a reply. If I(msg_filter ) is set,
193
+ I(msg_txt ) will be filtered accordingly.
191
194
returned: success
192
195
type: str
193
196
sample: "*399 HWSC0000I *IMS CONNECT READY* IM5HCONN"
198
201
returned: success
199
202
type: str
200
203
sample: IM5HCONN
201
- message_id :
204
+ msg_id :
202
205
description:
203
206
Message identifier for outstanding message requiring operator
204
207
action awaiting a reply.
212
215
"type": 'R',
213
216
"system": 'MV27',
214
217
"job_id": 'STC01537',
215
- "message_text ": '*399 HWSC0000I *IMS CONNECT READY* IM5HCONN',
218
+ "msg_txt ": '*399 HWSC0000I *IMS CONNECT READY* IM5HCONN',
216
219
"job_name": 'IM5HCONN',
217
- "message_id ": 'HWSC0000I'
220
+ "msg_id ": 'HWSC0000I'
218
221
},
219
222
{
220
223
"number": '002',
221
224
"type": 'R',
222
225
"system": 'MV27',
223
226
"job_id": 'STC01533',
224
- "message_text ": '*400 DFS3139I IMS INITIALIZED, AUTOMATIC RESTART PROCEEDING IM5H',
227
+ "msg_txt ": '*400 DFS3139I IMS INITIALIZED, AUTOMATIC RESTART PROCEEDING IM5H',
225
228
"job_name": 'IM5HCTRL',
226
- "message_id ": 'DFS3139I'
229
+ "msg_id ": 'DFS3139I'
227
230
}
228
231
]
229
232
"""
@@ -260,19 +263,20 @@ def run_module():
260
263
"""
261
264
module_args = dict (
262
265
system = dict (type = "str" , required = False ),
263
- message_id = dict (type = "str" , required = False ),
266
+ msg_id = dict (type = "str" , required = False , aliases = [ 'message_id' ] ),
264
267
job_name = dict (type = "str" , required = False ),
265
- message_filter = dict (
268
+ msg_filter = dict (
266
269
type = "dict" ,
267
270
required = False ,
271
+ aliases = ['message_filter' ],
268
272
options = dict (
269
273
filter = dict (type = "str" , required = True ),
270
- use_regex = dict (default = False , type = "bool" , required = False )
274
+ literal = dict (default = True , type = "bool" , required = False )
271
275
)
272
276
)
273
277
)
274
278
275
- result = dict (changed = False )
279
+ result = dict (changed = False , count = 0 , actions = [] )
276
280
module = AnsibleModule (argument_spec = module_args , supports_check_mode = False )
277
281
requests = []
278
282
try :
@@ -321,7 +325,7 @@ def run_module():
321
325
cmd = "d r,a,jn" ,
322
326
)
323
327
324
- merged_list = create_merge_list (cmd_result_a .message , cmd_result_b .message , new_params ['message_filter ' ])
328
+ merged_list = create_merge_list (cmd_result_a .message , cmd_result_b .message , new_params ['msg_filter ' ])
325
329
requests = find_required_request (merged_list , new_params )
326
330
if requests :
327
331
result ["count" ] = len (requests )
@@ -351,9 +355,9 @@ def parse_params(params):
351
355
"""
352
356
arg_defs = dict (
353
357
system = dict (arg_type = system_type , required = False ),
354
- message_id = dict (arg_type = message_id_type , required = False ),
358
+ msg_id = dict (arg_type = msg_id_type , required = False ),
355
359
job_name = dict (arg_type = job_name_type , required = False ),
356
- message_filter = dict (arg_type = message_filter_type , required = False )
360
+ msg_filter = dict (arg_type = msg_filter_type , required = False )
357
361
)
358
362
parser = BetterArgParser (arg_defs )
359
363
new_params = parser .parse_args (params )
@@ -380,7 +384,7 @@ def system_type(arg_val, params):
380
384
return arg_val .upper ()
381
385
382
386
383
- def message_id_type (arg_val , params ):
387
+ def msg_id_type (arg_val , params ):
384
388
"""Message id type.
385
389
386
390
Parameters
@@ -420,7 +424,7 @@ def job_name_type(arg_val, params):
420
424
return arg_val .upper ()
421
425
422
426
423
- def message_filter_type (arg_val , params ):
427
+ def msg_filter_type (arg_val , params ):
424
428
"""Message filter type.
425
429
426
430
Parameters
@@ -442,12 +446,12 @@ def message_filter_type(arg_val, params):
442
446
"""
443
447
try :
444
448
filter_text = arg_val .get ("filter" )
445
- use_regex = arg_val .get ("use_regex " )
449
+ literal = arg_val .get ("literal " )
446
450
447
- if use_regex :
448
- raw_arg_val = r'{0}' .format (filter_text )
449
- else :
451
+ if literal :
450
452
raw_arg_val = r'^.*{0}.*$' .format (re .escape (filter_text ))
453
+ else :
454
+ raw_arg_val = r'{0}' .format (filter_text )
451
455
452
456
re .compile (raw_arg_val )
453
457
except re .error :
@@ -503,7 +507,7 @@ def find_required_request(merged_list, params):
503
507
return requests
504
508
505
509
506
- def create_merge_list (message_a , message_b , message_filter ):
510
+ def create_merge_list (msg_a , msg_b , msg_filter ):
507
511
"""Merge the return lists that execute both 'd r,a,s' and 'd r,a,jn'.
508
512
For example, if we have:
509
513
'd r,a,s' response like: "742 R MV28 JOB57578 &742 ARC0055A REPLY 'GO' OR 'CANCEL'"
@@ -512,20 +516,20 @@ def create_merge_list(message_a, message_b, message_filter):
512
516
513
517
Parameters
514
518
----------
515
- message_a : str
519
+ msg_a : str
516
520
Result coming from command 'd r,a,s'.
517
- message_b : str
521
+ msg_b : str
518
522
Result coming from command 'd r,a,jn'.
519
- message_filter : str
523
+ msg_filter : str
520
524
Message filter.
521
525
522
526
Returns
523
527
-------
524
528
Union
525
- Merge of the result of message_a and the result of message_b .
529
+ Merge of the result of msg_a and the result of msg_b .
526
530
"""
527
- list_a = parse_result_a (message_a , message_filter )
528
- list_b = parse_result_b (message_b , message_filter )
531
+ list_a = parse_result_a (msg_a , msg_filter )
532
+ list_b = parse_result_b (msg_b , msg_filter )
529
533
merged_list = merge_list (list_a , list_b )
530
534
return merged_list
531
535
@@ -546,15 +550,15 @@ def filter_requests(merged_list, params):
546
550
Filtered list.
547
551
"""
548
552
system = params .get ("system" )
549
- message_id = params .get ("message_id " )
553
+ msg_id = params .get ("msg_id " )
550
554
job_name = params .get ("job_name" )
551
555
newlist = merged_list
552
556
if system :
553
557
newlist = handle_conditions (newlist , "system" , system )
554
558
if job_name :
555
559
newlist = handle_conditions (newlist , "job_name" , job_name )
556
- if message_id :
557
- newlist = handle_conditions (newlist , "message_id " , message_id )
560
+ if msg_id :
561
+ newlist = handle_conditions (newlist , "msg_id " , msg_id )
558
562
return newlist
559
563
560
564
@@ -619,26 +623,26 @@ def execute_command(operator_cmd, timeout_s=1, *args, **kwargs):
619
623
return OperatorQueryResult (rc , stdout , stderr )
620
624
621
625
622
- def match_raw_message (msg , message_filter ):
626
+ def match_raw_message (msg , msg_filter ):
623
627
"""Match raw message.
624
628
625
629
Parameters
626
630
----------
627
631
msg : str
628
632
Message to match.
629
- message_filter : str
633
+ msg_filter : str
630
634
Filter for the message.
631
635
632
636
Return
633
637
------
634
638
bool
635
639
If the pattern matches msg.
636
640
"""
637
- pattern = re .compile (message_filter , re .DOTALL )
641
+ pattern = re .compile (msg_filter , re .DOTALL )
638
642
return pattern .match (msg )
639
643
640
644
641
- def parse_result_a (result , message_filter ):
645
+ def parse_result_a (result , msg_filter ):
642
646
"""parsing the result that coming from command 'd r,a,s',
643
647
there are usually two formats:
644
648
- line with job_id: 810 R MV2D JOB58389 &810 ARC0055A REPLY 'GO' OR 'CANCEL'
@@ -649,7 +653,7 @@ def parse_result_a(result, message_filter):
649
653
----------
650
654
result : str
651
655
Result coming from command 'd r,a,s'.
652
- message_filter : str
656
+ msg_filter : str
653
657
Message filter.
654
658
655
659
Returns
@@ -668,7 +672,7 @@ def parse_result_a(result, message_filter):
668
672
)
669
673
for match in match_iter :
670
674
# If there was a filter specified, we skip messages that do not match it.
671
- if message_filter is not None and not match_raw_message (match .string , message_filter ):
675
+ if msg_filter is not None and not match_raw_message (match .string , msg_filter ):
672
676
continue
673
677
674
678
dict_temp = {
@@ -679,13 +683,13 @@ def parse_result_a(result, message_filter):
679
683
if match .group (4 ) != "" :
680
684
dict_temp ["job_id" ] = match .group (4 )
681
685
if match .group (5 ) != "" :
682
- dict_temp ["message_text " ] = match .group (5 ).strip ()
686
+ dict_temp ["msg_txt " ] = match .group (5 ).strip ()
683
687
list .append (dict_temp )
684
688
685
689
return list
686
690
687
691
688
- def parse_result_b (result , message_filter ):
692
+ def parse_result_b (result , msg_filter ):
689
693
"""Parse the result that comes from command 'd r,a,jn', the main purpose
690
694
to use this command is to get the job_name and message id, which is not
691
695
included in 'd r,a,s'
@@ -694,7 +698,7 @@ def parse_result_b(result, message_filter):
694
698
----------
695
699
result : str
696
700
Result coming from command 'd r,a,jn'.
697
- message_filter : str
701
+ msg_filter : str
698
702
Message filter.
699
703
700
704
Returns
@@ -714,13 +718,13 @@ def parse_result_b(result, message_filter):
714
718
715
719
for match in match_iter :
716
720
# If there was a filter specified, we skip messages that do not match it.
717
- if message_filter is not None and not match_raw_message (match .string , message_filter ):
721
+ if msg_filter is not None and not match_raw_message (match .string , msg_filter ):
718
722
continue
719
723
720
724
dict_temp = {
721
725
"number" : match .group (1 ),
722
726
"job_name" : match .group (2 ),
723
- "message_id " : match .group (3 ),
727
+ "msg_id " : match .group (3 ),
724
728
}
725
729
726
730
# Sometimes 'job_name' will be null because the operator action is a
0 commit comments