eva-shell 0.2.20__tar.gz → 0.2.22__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {eva-shell-0.2.20 → eva-shell-0.2.22}/PKG-INFO +1 -1
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva4_shell/__init__.py +1 -1
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva4_shell/ap.py +203 -20
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva4_shell/cli.py +239 -3
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva4_shell/client.py +1 -1
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva4_shell/compl.py +5 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva_shell.egg-info/PKG-INFO +1 -1
- {eva-shell-0.2.20 → eva-shell-0.2.22}/setup.py +1 -1
- {eva-shell-0.2.20 → eva-shell-0.2.22}/LICENSE +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/README.md +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/bin/eva +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva4_shell/charts.py +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva4_shell/sharedobj.py +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva4_shell/shell.py +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva4_shell/tools.py +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva_shell.egg-info/SOURCES.txt +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva_shell.egg-info/dependency_links.txt +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva_shell.egg-info/requires.txt +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/eva_shell.egg-info/top_level.txt +0 -0
- {eva-shell-0.2.20 → eva-shell-0.2.22}/setup.cfg +0 -0
|
@@ -17,7 +17,24 @@ from .compl import ComplOIDtp, ComplSvcRpcMethod, ComplSvcRpcParams, ComplEdit
|
|
|
17
17
|
from .client import call_rpc, DEFAULT_DB_SERVICE, DEFAULT_REPL_SERVICE
|
|
18
18
|
from .client import DEFAULT_ACL_SERVICE, DEFAULT_AUTH_SERVICE
|
|
19
19
|
from .client import DEFAULT_KIOSK_SERVICE, DEFAULT_GENERATOR_SERVICE
|
|
20
|
-
from .client import DEFAULT_ACCOUNTING_SERVICE
|
|
20
|
+
from .client import DEFAULT_ACCOUNTING_SERVICE, DEFAULT_ALARM_SERVICE
|
|
21
|
+
|
|
22
|
+
ALARM_OP_CODES = [
|
|
23
|
+
'TT', 'TL', 'LL', 'SS', 'SD', 'OS', 'CC', 'AA', 'US', 'RD', 'IS'
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
ALARM_OP_SOURCE_KINDS = ['U', 'R', 'P']
|
|
27
|
+
|
|
28
|
+
ALARM_CURRENT_CODES = [
|
|
29
|
+
'TT',
|
|
30
|
+
'TL',
|
|
31
|
+
'LL',
|
|
32
|
+
'SS',
|
|
33
|
+
'SD',
|
|
34
|
+
'OS',
|
|
35
|
+
'CC',
|
|
36
|
+
'AA',
|
|
37
|
+
]
|
|
21
38
|
|
|
22
39
|
DEFAULT_RPC_ERROR_MESSAGE = {
|
|
23
40
|
-32700: 'parse error',
|
|
@@ -233,6 +250,160 @@ def append_accounting_cli(root_sp):
|
|
|
233
250
|
p.add_argument('--err', metavar='ERR')
|
|
234
251
|
|
|
235
252
|
|
|
253
|
+
def append_alarm_cli(root_sp):
|
|
254
|
+
ap = root_sp.add_parser('alarm', help='alarm commands')
|
|
255
|
+
sp = ap.add_subparsers(dest='_subc', help='sub command')
|
|
256
|
+
|
|
257
|
+
p = sp.add_parser('summary', help='alarm summary')
|
|
258
|
+
p.add_argument('-a',
|
|
259
|
+
'--alarm-svc',
|
|
260
|
+
help=f'Alarm service (default: {DEFAULT_ALARM_SERVICE})',
|
|
261
|
+
default=DEFAULT_ALARM_SERVICE).completer = ComplSvc('alarm')
|
|
262
|
+
|
|
263
|
+
p = sp.add_parser('state', help='alarm state')
|
|
264
|
+
p.add_argument('--node', metavar='NODE', help='filter by node')
|
|
265
|
+
p.add_argument('--group', metavar='GROUP', help='filter by group')
|
|
266
|
+
p.add_argument('--level', metavar='LEVEL', help='filter by level')
|
|
267
|
+
p.add_argument('--id', metavar='ID', help='filter by ID')
|
|
268
|
+
p.add_argument('--current',
|
|
269
|
+
choices=ALARM_CURRENT_CODES,
|
|
270
|
+
metavar='CURRENT',
|
|
271
|
+
help='filter by current status')
|
|
272
|
+
p.add_argument('--active', action='store_true', help='active only')
|
|
273
|
+
p.add_argument('--inactive', action='store_true', help='inactive only')
|
|
274
|
+
p.add_argument('--user', help='view user subscriptions')
|
|
275
|
+
p.add_argument('-a',
|
|
276
|
+
'--alarm-svc',
|
|
277
|
+
help=f'Alarm service (default: {DEFAULT_ALARM_SERVICE})',
|
|
278
|
+
default=DEFAULT_ALARM_SERVICE).completer = ComplSvc('alarm')
|
|
279
|
+
|
|
280
|
+
p = sp.add_parser('history', help='alarm history')
|
|
281
|
+
p.add_argument('-y', '--full', action='store_true')
|
|
282
|
+
p.add_argument('-s', '--time-start', metavar='TIME', help='start time')
|
|
283
|
+
p.add_argument('-e', '--time-end', metavar='TIME', help='end time')
|
|
284
|
+
p.add_argument('-z',
|
|
285
|
+
'--time-zone',
|
|
286
|
+
metavar='ZONE',
|
|
287
|
+
help='time zone (pytz, e.g. UTC or Europe/Prague)')
|
|
288
|
+
p.add_argument('--node', metavar='NODE').completer = ComplNode()
|
|
289
|
+
p.add_argument('--level-min', metavar='LEVEL', type=int)
|
|
290
|
+
p.add_argument('--level-max', metavar='LEVEL', type=int)
|
|
291
|
+
p.add_argument('--group', metavar='GROUP')
|
|
292
|
+
p.add_argument('--id', metavar='ID')
|
|
293
|
+
p.add_argument('--ack', action='store_true')
|
|
294
|
+
p.add_argument('--no-ack', action='store_true')
|
|
295
|
+
p.add_argument('--latch', action='store_true')
|
|
296
|
+
p.add_argument('--no-latch', action='store_true')
|
|
297
|
+
p.add_argument('--oos', action='store_true')
|
|
298
|
+
p.add_argument('--no-oos', action='store_true')
|
|
299
|
+
p.add_argument('--sbd', action='store_true')
|
|
300
|
+
p.add_argument('--no-sbd', action='store_true')
|
|
301
|
+
p.add_argument('--shelv', action='store_true')
|
|
302
|
+
p.add_argument('--no-shelv', action='store_true')
|
|
303
|
+
p.add_argument('--trig', action='store_true')
|
|
304
|
+
p.add_argument('--no-trig', action='store_true')
|
|
305
|
+
p.add_argument('--lo', choices=ALARM_OP_CODES, help='last operation')
|
|
306
|
+
p.add_argument('--losk',
|
|
307
|
+
choices=ALARM_OP_SOURCE_KINDS,
|
|
308
|
+
help='last operation source kind')
|
|
309
|
+
p.add_argument('--los', help='last operation source')
|
|
310
|
+
|
|
311
|
+
p.add_argument('-a',
|
|
312
|
+
'--alarm-svc',
|
|
313
|
+
help=f'Alarm service (default: {DEFAULT_ALARM_SERVICE})',
|
|
314
|
+
default=DEFAULT_ALARM_SERVICE).completer = ComplSvc('alarm')
|
|
315
|
+
|
|
316
|
+
p = sp.add_parser('list', help='list managed alarms')
|
|
317
|
+
p.add_argument('--group', metavar='GROUP', help='filter by group')
|
|
318
|
+
p.add_argument('--level', metavar='LEVEL', help='filter by level')
|
|
319
|
+
p.add_argument('--id', metavar='ID', help='filter by ID')
|
|
320
|
+
p.add_argument('-a',
|
|
321
|
+
'--alarm-svc',
|
|
322
|
+
help=f'Alarm service (default: {DEFAULT_ALARM_SERVICE})',
|
|
323
|
+
default=DEFAULT_ALARM_SERVICE).completer = ComplSvc('alarm')
|
|
324
|
+
|
|
325
|
+
p = sp.add_parser('edit', help='edit a managed alarm')
|
|
326
|
+
p.add_argument('i', metavar='OID').completer = ComplOIDtp('lvar')
|
|
327
|
+
p.add_argument('-a',
|
|
328
|
+
'--alarm-svc',
|
|
329
|
+
help=f'Alarm service (default: {DEFAULT_ALARM_SERVICE})',
|
|
330
|
+
default=DEFAULT_ALARM_SERVICE).completer = ComplSvc('alarm')
|
|
331
|
+
|
|
332
|
+
p = sp.add_parser('create', help='create a new managed alarm')
|
|
333
|
+
p.add_argument('level', type=int, metavar='LEVEL')
|
|
334
|
+
p.add_argument('full_id', metavar='GROUP/ID')
|
|
335
|
+
p.add_argument('-a',
|
|
336
|
+
'--alarm-svc',
|
|
337
|
+
help=f'Alarm service (default: {DEFAULT_ALARM_SERVICE})',
|
|
338
|
+
default=DEFAULT_ALARM_SERVICE).completer = ComplSvc('alarm')
|
|
339
|
+
|
|
340
|
+
p = sp.add_parser('destroy', help='destroy a managed alarm')
|
|
341
|
+
p.add_argument('i', metavar='OID').completer = ComplOIDtp('lvar')
|
|
342
|
+
p.add_argument('-a',
|
|
343
|
+
'--alarm-svc',
|
|
344
|
+
help=f'Alarm service (default: {DEFAULT_ALARM_SERVICE})',
|
|
345
|
+
default=DEFAULT_ALARM_SERVICE).completer = ComplSvc('alarm')
|
|
346
|
+
|
|
347
|
+
p = sp.add_parser('acknowledge', help='acknowledge alarm')
|
|
348
|
+
p.add_argument('i', metavar='OID').completer = ComplOIDtp('lvar')
|
|
349
|
+
p.add_argument(
|
|
350
|
+
'-w',
|
|
351
|
+
'--wait',
|
|
352
|
+
metavar='SEC',
|
|
353
|
+
type=float,
|
|
354
|
+
help='wait max seconds until the action is completed (default: timeout)'
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
p = sp.add_parser('shelve', help='shelve alarm')
|
|
358
|
+
p.add_argument('i', metavar='OID').completer = ComplOIDtp('lvar')
|
|
359
|
+
p.add_argument(
|
|
360
|
+
'-w',
|
|
361
|
+
'--wait',
|
|
362
|
+
metavar='SEC',
|
|
363
|
+
type=float,
|
|
364
|
+
help='wait max seconds until the action is completed (default: timeout)'
|
|
365
|
+
)
|
|
366
|
+
|
|
367
|
+
p = sp.add_parser('unshelve', help='unshelve alarm')
|
|
368
|
+
p.add_argument('i', metavar='OID').completer = ComplOIDtp('lvar')
|
|
369
|
+
p.add_argument(
|
|
370
|
+
'-w',
|
|
371
|
+
'--wait',
|
|
372
|
+
metavar='SEC',
|
|
373
|
+
type=float,
|
|
374
|
+
help='wait max seconds until the action is completed (default: timeout)'
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
p = sp.add_parser('deploy',
|
|
378
|
+
help='deploy managed alarm(s) from a deployment file')
|
|
379
|
+
p.add_argument('-f', '--file', metavar='FILE',
|
|
380
|
+
help='deployment file').completer = ComplDeployFile()
|
|
381
|
+
p.add_argument('-a',
|
|
382
|
+
'--alarm-svc',
|
|
383
|
+
help=f'Alarm service (default: {DEFAULT_ALARM_SERVICE})',
|
|
384
|
+
default=DEFAULT_ALARM_SERVICE).completer = ComplSvc('alarm')
|
|
385
|
+
|
|
386
|
+
p = sp.add_parser('undeploy',
|
|
387
|
+
help='undeploy managed alarm(s) using a deployment file')
|
|
388
|
+
p.add_argument('-f', '--file', metavar='FILE',
|
|
389
|
+
help='deployment file').completer = ComplDeployFile()
|
|
390
|
+
p.add_argument('-a',
|
|
391
|
+
'--alarm-svc',
|
|
392
|
+
help=f'Alarm service (default: {DEFAULT_ALARM_SERVICE})',
|
|
393
|
+
default=DEFAULT_ALARM_SERVICE).completer = ComplSvc('alarm')
|
|
394
|
+
|
|
395
|
+
p = sp.add_parser('export', help='export managed alarms')
|
|
396
|
+
p.add_argument('--group', metavar='GROUP', help='filter by group')
|
|
397
|
+
p.add_argument('--level', metavar='LEVEL', help='filter by level')
|
|
398
|
+
p.add_argument('--id', metavar='ID', help='filter by ID')
|
|
399
|
+
p.add_argument('-o', '--output', metavar='FILE',
|
|
400
|
+
help='output file').completer = ComplDeployFile()
|
|
401
|
+
p.add_argument('-a',
|
|
402
|
+
'--alarm-svc',
|
|
403
|
+
help=f'Alarm service (default: {DEFAULT_ALARM_SERVICE})',
|
|
404
|
+
default=DEFAULT_ALARM_SERVICE).completer = ComplSvc('alarm')
|
|
405
|
+
|
|
406
|
+
|
|
236
407
|
def append_dobj_cli(root_sp):
|
|
237
408
|
ap = root_sp.add_parser('dobj', help='data object commands')
|
|
238
409
|
sp = ap.add_subparsers(dest='_subc', help='sub command')
|
|
@@ -941,6 +1112,9 @@ def append_cloud_cli(root_sp):
|
|
|
941
1112
|
p.add_argument('--test',
|
|
942
1113
|
action='store_true',
|
|
943
1114
|
help=f'test deployment config and exit')
|
|
1115
|
+
p.add_argument('--verbose-extra',
|
|
1116
|
+
action='store_true',
|
|
1117
|
+
help=f'output extra bus call parameters and results')
|
|
944
1118
|
|
|
945
1119
|
p = sp.add_parser('undeploy', help='cloud undeploy')
|
|
946
1120
|
p.add_argument('file', metavar='FILE',
|
|
@@ -957,6 +1131,9 @@ def append_cloud_cli(root_sp):
|
|
|
957
1131
|
p.add_argument('--test',
|
|
958
1132
|
action='store_true',
|
|
959
1133
|
help=f'test deployment config and exit')
|
|
1134
|
+
p.add_argument('--verbose-extra',
|
|
1135
|
+
action='store_true',
|
|
1136
|
+
help=f'output extra bus call parameters and results')
|
|
960
1137
|
|
|
961
1138
|
p = sp.add_parser('update', help='update cloud nodes')
|
|
962
1139
|
p.add_argument('nodes',
|
|
@@ -1370,22 +1547,27 @@ def init_ap():
|
|
|
1370
1547
|
|
|
1371
1548
|
ap.sections = {
|
|
1372
1549
|
'action': [],
|
|
1550
|
+
'acl': [],
|
|
1373
1551
|
'accounting': [],
|
|
1552
|
+
'alarm': [],
|
|
1374
1553
|
'broker': [],
|
|
1554
|
+
'cloud': [],
|
|
1375
1555
|
'item': [],
|
|
1376
|
-
'
|
|
1556
|
+
'dobj': [],
|
|
1557
|
+
'generator': [],
|
|
1558
|
+
'key': [],
|
|
1559
|
+
'kiosk': [],
|
|
1377
1560
|
'log': [],
|
|
1378
|
-
'
|
|
1561
|
+
'lvar': [],
|
|
1562
|
+
'mirror': [],
|
|
1563
|
+
'node': [],
|
|
1379
1564
|
'server': [],
|
|
1565
|
+
'spoint': [],
|
|
1566
|
+
'system': [],
|
|
1380
1567
|
'registry': [],
|
|
1381
|
-
'
|
|
1382
|
-
'cloud': [],
|
|
1383
|
-
'venv': [],
|
|
1384
|
-
'acl': [],
|
|
1385
|
-
'key': [],
|
|
1568
|
+
'svc': [],
|
|
1386
1569
|
'user': [],
|
|
1387
|
-
'
|
|
1388
|
-
'mirror': []
|
|
1570
|
+
'venv': [],
|
|
1389
1571
|
}
|
|
1390
1572
|
|
|
1391
1573
|
ap.add_argument('-D',
|
|
@@ -1404,28 +1586,29 @@ def init_ap():
|
|
|
1404
1586
|
append_action_cli(sp)
|
|
1405
1587
|
append_acl_cli(sp)
|
|
1406
1588
|
append_accounting_cli(sp)
|
|
1589
|
+
append_alarm_cli(sp)
|
|
1407
1590
|
append_broker_cli(sp)
|
|
1591
|
+
append_cloud_cli(sp)
|
|
1408
1592
|
append_item_cli(sp)
|
|
1409
1593
|
append_dobj_cli(sp)
|
|
1594
|
+
append_generator_cli(sp)
|
|
1410
1595
|
append_key_cli(sp)
|
|
1411
|
-
|
|
1596
|
+
append_kiosk_cli(sp)
|
|
1412
1597
|
append_log_cli(sp)
|
|
1598
|
+
append_lvar_cli(sp)
|
|
1599
|
+
if is_local_shell():
|
|
1600
|
+
append_mirror_cli(sp)
|
|
1413
1601
|
append_node_cli(sp)
|
|
1602
|
+
if is_local_shell():
|
|
1603
|
+
append_server_cli(sp)
|
|
1414
1604
|
append_spoint_cli(sp)
|
|
1415
1605
|
if is_local_shell():
|
|
1416
|
-
|
|
1606
|
+
append_system_cli(sp)
|
|
1417
1607
|
if is_local_shell():
|
|
1418
|
-
|
|
1608
|
+
append_registry_cli(sp)
|
|
1419
1609
|
append_user_cli(sp)
|
|
1420
1610
|
if is_local_shell():
|
|
1421
1611
|
append_venv_cli(sp)
|
|
1422
|
-
append_cloud_cli(sp)
|
|
1423
|
-
append_generator_cli(sp)
|
|
1424
|
-
if is_local_shell():
|
|
1425
|
-
append_system_cli(sp)
|
|
1426
|
-
if is_local_shell():
|
|
1427
|
-
append_mirror_cli(sp)
|
|
1428
|
-
append_kiosk_cli(sp)
|
|
1429
1612
|
|
|
1430
1613
|
sp.add_parser('save', help='save scheduled states (if instant-save is off)')
|
|
1431
1614
|
append_svc_cli(sp)
|
|
@@ -109,7 +109,7 @@ class CLI:
|
|
|
109
109
|
def server_status(self):
|
|
110
110
|
eva_control_c('status')
|
|
111
111
|
|
|
112
|
-
def cloud_deploy(self, file, config_var, config, test):
|
|
112
|
+
def cloud_deploy(self, file, config_var, config, test, verbose_extra):
|
|
113
113
|
args = ''
|
|
114
114
|
if current_command.debug:
|
|
115
115
|
args += ' --verbose '
|
|
@@ -122,9 +122,11 @@ class CLI:
|
|
|
122
122
|
args += f' --config "{config}"'
|
|
123
123
|
if test:
|
|
124
124
|
args += ' --test'
|
|
125
|
+
if verbose_extra:
|
|
126
|
+
args += ' --verbose-extra'
|
|
125
127
|
exec_cmd('eva-cloud-manager', args)
|
|
126
128
|
|
|
127
|
-
def cloud_undeploy(self, file, config_var, config, test):
|
|
129
|
+
def cloud_undeploy(self, file, config_var, config, test, verbose_extra):
|
|
128
130
|
args = ''
|
|
129
131
|
if current_command.debug:
|
|
130
132
|
args += ' --verbose '
|
|
@@ -137,6 +139,8 @@ class CLI:
|
|
|
137
139
|
args += f' --config "{config}"'
|
|
138
140
|
if test:
|
|
139
141
|
args += ' --test'
|
|
142
|
+
if verbose_extra:
|
|
143
|
+
args += ' --verbose-extra'
|
|
140
144
|
exec_cmd('eva-cloud-manager', args)
|
|
141
145
|
|
|
142
146
|
def cloud_update(self, nodes, check_timeout, all, info_only, yes):
|
|
@@ -785,7 +789,28 @@ class CLI:
|
|
|
785
789
|
else:
|
|
786
790
|
print_action_result(result)
|
|
787
791
|
|
|
788
|
-
def
|
|
792
|
+
def alarm_shelve(self, i, wait=None):
|
|
793
|
+
self.alarm_control_command(i, 'SS', wait=wait)
|
|
794
|
+
|
|
795
|
+
def alarm_unshelve(self, i, wait=None):
|
|
796
|
+
self.alarm_control_command(i, 'US', wait=wait)
|
|
797
|
+
|
|
798
|
+
def alarm_acknowledge(self, i, wait=None):
|
|
799
|
+
self.alarm_control_command(i, 'AA', wait=wait)
|
|
800
|
+
|
|
801
|
+
def alarm_control_command(self, i, cmd, wait=None):
|
|
802
|
+
if wait is None:
|
|
803
|
+
wait = current_command.timeout
|
|
804
|
+
try:
|
|
805
|
+
lmacro_oid = 'lmacro:' + i.rsplit('/', maxsplit=3)[0].split(
|
|
806
|
+
':', maxsplit=1)[-1] + '/control'
|
|
807
|
+
except:
|
|
808
|
+
raise RuntimeError('invalid alarm OID')
|
|
809
|
+
self.action_run(lmacro_oid, [],
|
|
810
|
+
[f'i={i}', f'cmd={cmd}', 'sk=U', 'src=console'],
|
|
811
|
+
wait=wait)
|
|
812
|
+
|
|
813
|
+
def action_run(self, i, arg, kwarg, priority=None, wait=None):
|
|
789
814
|
params = dict(i=i, wait=wait)
|
|
790
815
|
if priority is not None:
|
|
791
816
|
params['priority'] = int(priority)
|
|
@@ -1834,3 +1859,214 @@ class CLI:
|
|
|
1834
1859
|
def generator_source_destroy(self, i, generator_svc):
|
|
1835
1860
|
call_rpc('source.destroy', dict(i=i), target=generator_svc)
|
|
1836
1861
|
ok()
|
|
1862
|
+
|
|
1863
|
+
def alarm_create(self, level, full_id, alarm_svc):
|
|
1864
|
+
if '/' not in full_id:
|
|
1865
|
+
raise ValueError('alarm full ID must contain GROUP/ID')
|
|
1866
|
+
group, id = full_id.rsplit('/', 1)
|
|
1867
|
+
call_rpc('alarm.deploy',
|
|
1868
|
+
dict(alarms=[dict(level=level, group=group, id=id)]),
|
|
1869
|
+
target=alarm_svc)
|
|
1870
|
+
ok()
|
|
1871
|
+
|
|
1872
|
+
def alarm_deploy(self, alarm_svc, file=None):
|
|
1873
|
+
import yaml
|
|
1874
|
+
alarms = yaml.safe_load(read_file(file).decode()).pop('alarms')
|
|
1875
|
+
call_rpc('alarm.deploy', dict(alarms=alarms), target=alarm_svc)
|
|
1876
|
+
print(f'{len(alarms)} alarm(s) deployed')
|
|
1877
|
+
print()
|
|
1878
|
+
|
|
1879
|
+
def alarm_undeploy(self, alarm_svc, file=None):
|
|
1880
|
+
import yaml
|
|
1881
|
+
alarms = yaml.safe_load(read_file(file).decode()).pop('alarms')
|
|
1882
|
+
call_rpc('alarm.undeploy', dict(alarms=alarms), target=alarm_svc)
|
|
1883
|
+
print(f'{len(alarms)} alarm(s) undeployed')
|
|
1884
|
+
print()
|
|
1885
|
+
|
|
1886
|
+
def alarm_list(self, alarm_svc, level=None, group=None, id=None):
|
|
1887
|
+
flt = {}
|
|
1888
|
+
if level:
|
|
1889
|
+
flt['level'] = level
|
|
1890
|
+
if group:
|
|
1891
|
+
flt['group'] = group
|
|
1892
|
+
if id:
|
|
1893
|
+
flt['id'] = id
|
|
1894
|
+
data = call_rpc('alarm.list', flt, target=alarm_svc)
|
|
1895
|
+
print_result(data, cols=['oid', 'level', 'group', 'id'])
|
|
1896
|
+
|
|
1897
|
+
def alarm_state(self,
|
|
1898
|
+
alarm_svc,
|
|
1899
|
+
node=None,
|
|
1900
|
+
level=None,
|
|
1901
|
+
group=None,
|
|
1902
|
+
id=None,
|
|
1903
|
+
current=None,
|
|
1904
|
+
active=None,
|
|
1905
|
+
inactive=None,
|
|
1906
|
+
user=None):
|
|
1907
|
+
flt = {}
|
|
1908
|
+
if node:
|
|
1909
|
+
flt['node'] = node
|
|
1910
|
+
if level is not None:
|
|
1911
|
+
flt['level'] = level
|
|
1912
|
+
if group:
|
|
1913
|
+
flt['group'] = group
|
|
1914
|
+
if id:
|
|
1915
|
+
flt['id'] = id
|
|
1916
|
+
if current:
|
|
1917
|
+
flt['current'] = current
|
|
1918
|
+
if active:
|
|
1919
|
+
flt['active'] = True
|
|
1920
|
+
if inactive:
|
|
1921
|
+
flt['active'] = False
|
|
1922
|
+
if user:
|
|
1923
|
+
flt['u'] = user
|
|
1924
|
+
data = call_rpc('alarm.state', flt, target=alarm_svc)
|
|
1925
|
+
if current_command.json:
|
|
1926
|
+
print_result(data)
|
|
1927
|
+
else:
|
|
1928
|
+
cols = ['oid', 'node', 'level', 'group', 'id', 'current']
|
|
1929
|
+
if user:
|
|
1930
|
+
cols += ['subscriptions']
|
|
1931
|
+
for d in data:
|
|
1932
|
+
d['subscriptions'] = ''
|
|
1933
|
+
if d['subscribed_email']:
|
|
1934
|
+
d['subscriptions'] += 'M:' + ','.join(
|
|
1935
|
+
d['subscribed_email'])
|
|
1936
|
+
print_result(data, cols=cols)
|
|
1937
|
+
|
|
1938
|
+
def alarm_summary(self, alarm_svc):
|
|
1939
|
+
data = call_rpc('alarm.summary', target=alarm_svc)
|
|
1940
|
+
if current_command.json:
|
|
1941
|
+
print_result(data)
|
|
1942
|
+
else:
|
|
1943
|
+
res = []
|
|
1944
|
+
for node, active in data['active_by_node'].items():
|
|
1945
|
+
res.append({'node': node, 'active': active})
|
|
1946
|
+
res.sort(key=lambda x: x['node'])
|
|
1947
|
+
print_result(res)
|
|
1948
|
+
print('total active:', data['active'])
|
|
1949
|
+
|
|
1950
|
+
def alarm_destroy(self, i, alarm_svc):
|
|
1951
|
+
call_rpc('alarm.destroy', dict(i=i), target=alarm_svc)
|
|
1952
|
+
ok()
|
|
1953
|
+
|
|
1954
|
+
def alarm_edit(self, i, alarm_svc):
|
|
1955
|
+
|
|
1956
|
+
def deploy_edited_alarm(cfg, i, alarm_svc):
|
|
1957
|
+
call_rpc('alarm.deploy', dict(alarms=[cfg]), target=alarm_svc)
|
|
1958
|
+
print(f'alarms re-deployed: {i}')
|
|
1959
|
+
print()
|
|
1960
|
+
|
|
1961
|
+
config = call_rpc('alarm.get_config', dict(i=i), target=alarm_svc)
|
|
1962
|
+
edit_config(config,
|
|
1963
|
+
f'alarm|{i}|config',
|
|
1964
|
+
deploy_fn=partial(deploy_edited_alarm,
|
|
1965
|
+
i=i,
|
|
1966
|
+
alarm_svc=alarm_svc))
|
|
1967
|
+
|
|
1968
|
+
def alarm_export(self,
|
|
1969
|
+
alarm_svc,
|
|
1970
|
+
level=None,
|
|
1971
|
+
group=None,
|
|
1972
|
+
id=None,
|
|
1973
|
+
output=None):
|
|
1974
|
+
c = 0
|
|
1975
|
+
configs = []
|
|
1976
|
+
flt = {}
|
|
1977
|
+
if level:
|
|
1978
|
+
flt['level'] = level
|
|
1979
|
+
if group:
|
|
1980
|
+
flt['group'] = group
|
|
1981
|
+
if id:
|
|
1982
|
+
flt['id'] = id
|
|
1983
|
+
for alarm in call_rpc('alarm.list', flt, target=alarm_svc):
|
|
1984
|
+
config = call_rpc('alarm.get_config',
|
|
1985
|
+
dict(i=alarm['oid']),
|
|
1986
|
+
target=alarm_svc)
|
|
1987
|
+
configs.append(config)
|
|
1988
|
+
c += 1
|
|
1989
|
+
result = dict(alarms=configs)
|
|
1990
|
+
if current_command.json:
|
|
1991
|
+
print_result(result)
|
|
1992
|
+
else:
|
|
1993
|
+
import yaml
|
|
1994
|
+
dump = yaml.dump(result, default_flow_style=False)
|
|
1995
|
+
if output is None:
|
|
1996
|
+
print(dump)
|
|
1997
|
+
else:
|
|
1998
|
+
write_file(output, dump)
|
|
1999
|
+
print(f'{c} alarm(s) exported')
|
|
2000
|
+
print()
|
|
2001
|
+
|
|
2002
|
+
def alarm_history(self, alarm_svc, time_start, time_end, time_zone, node,
|
|
2003
|
+
level_min, level_max, group, id, ack, no_ack, latch,
|
|
2004
|
+
no_latch, oos, no_oos, sbd, no_sbd, shelv, no_shelv, trig,
|
|
2005
|
+
no_trig, lo, losk, los, full):
|
|
2006
|
+
payload = {}
|
|
2007
|
+
if time_start is not None:
|
|
2008
|
+
payload['t_start'] = time_start
|
|
2009
|
+
if time_end is not None:
|
|
2010
|
+
payload['t_end'] = time_end
|
|
2011
|
+
if node is not None:
|
|
2012
|
+
payload['node'] = node
|
|
2013
|
+
if level_min is not None:
|
|
2014
|
+
payload['level_min'] = level_min
|
|
2015
|
+
if level_max is not None:
|
|
2016
|
+
payload['level_max'] = level_max
|
|
2017
|
+
if group is not None:
|
|
2018
|
+
payload['group'] = group
|
|
2019
|
+
if id is not None:
|
|
2020
|
+
payload['id'] = id
|
|
2021
|
+
if ack:
|
|
2022
|
+
payload['ack'] = True
|
|
2023
|
+
if no_ack:
|
|
2024
|
+
payload['ack'] = False
|
|
2025
|
+
if latch:
|
|
2026
|
+
payload['latch'] = True
|
|
2027
|
+
if no_latch:
|
|
2028
|
+
payload['latch'] = False
|
|
2029
|
+
if oos:
|
|
2030
|
+
payload['oos'] = True
|
|
2031
|
+
if no_oos:
|
|
2032
|
+
payload['oos'] = False
|
|
2033
|
+
if sbd:
|
|
2034
|
+
payload['sbd'] = True
|
|
2035
|
+
if no_sbd:
|
|
2036
|
+
payload['sbd'] = False
|
|
2037
|
+
if shelv:
|
|
2038
|
+
payload['shelv'] = True
|
|
2039
|
+
if no_shelv:
|
|
2040
|
+
payload['shelv'] = False
|
|
2041
|
+
if trig:
|
|
2042
|
+
payload['trig'] = True
|
|
2043
|
+
if no_trig:
|
|
2044
|
+
payload['trig'] = False
|
|
2045
|
+
if lo:
|
|
2046
|
+
payload['lo'] = lo
|
|
2047
|
+
if losk:
|
|
2048
|
+
payload['losk'] = losk
|
|
2049
|
+
if los:
|
|
2050
|
+
payload['los'] = los
|
|
2051
|
+
data = call_rpc('alarm.history', payload, target=alarm_svc)
|
|
2052
|
+
cols = [
|
|
2053
|
+
't|n=time|f=time_sec{}'.format(
|
|
2054
|
+
f':{time_zone}' if time_zone else ''),
|
|
2055
|
+
'alarm_node|n=node',
|
|
2056
|
+
'alarm_level|n=lvl',
|
|
2057
|
+
'alarm_group|n=group',
|
|
2058
|
+
'alarm_id|n=id',
|
|
2059
|
+
'lo',
|
|
2060
|
+
'losk',
|
|
2061
|
+
'los',
|
|
2062
|
+
]
|
|
2063
|
+
if full:
|
|
2064
|
+
cols += [
|
|
2065
|
+
'ack',
|
|
2066
|
+
'latch',
|
|
2067
|
+
'oos',
|
|
2068
|
+
'sbd',
|
|
2069
|
+
'shelv',
|
|
2070
|
+
'trig',
|
|
2071
|
+
]
|
|
2072
|
+
print_result(data, cols=cols)
|
|
@@ -17,7 +17,7 @@ DEFAULT_AUTH_SERVICE = 'eva.aaa.localauth'
|
|
|
17
17
|
DEFAULT_KIOSK_SERVICE = 'eva.kioskman.default'
|
|
18
18
|
DEFAULT_GENERATOR_SERVICE = 'eva.generator.default'
|
|
19
19
|
DEFAULT_ACCOUNTING_SERVICE = 'eva.aaa.accounting'
|
|
20
|
-
|
|
20
|
+
DEFAULT_ALARM_SERVICE = 'eva.alarm.default'
|
|
21
21
|
|
|
22
22
|
def print_trace_msg(msg):
|
|
23
23
|
level = msg['l']
|
|
@@ -59,6 +59,7 @@ class ComplSvc:
|
|
|
59
59
|
if self.prefix is None or i.startswith(self.prefix):
|
|
60
60
|
yield i
|
|
61
61
|
|
|
62
|
+
|
|
62
63
|
class ComplDobj:
|
|
63
64
|
|
|
64
65
|
def __init__(self):
|
|
@@ -70,6 +71,7 @@ class ComplDobj:
|
|
|
70
71
|
if self.prefix is None or i.startswith(self.prefix):
|
|
71
72
|
yield i
|
|
72
73
|
|
|
74
|
+
|
|
73
75
|
class ComplSvcRpcMethod:
|
|
74
76
|
|
|
75
77
|
def __call__(self, prefix, parsed_args=None, **kwargs):
|
|
@@ -127,6 +129,9 @@ class ComplDeployFile:
|
|
|
127
129
|
else:
|
|
128
130
|
prefix = expand_user(prefix)
|
|
129
131
|
masks = [f'{prefix}*.yml', f'{prefix}*.yaml', f'{prefix}*.json']
|
|
132
|
+
if '.' in prefix:
|
|
133
|
+
p = prefix.rsplit('.', 1)[0]
|
|
134
|
+
masks += [f'{p}*.yml', f'{p}*.yaml', f'{p}*.json']
|
|
130
135
|
for mask in masks:
|
|
131
136
|
for f in glob.glob(mask):
|
|
132
137
|
yield contract_user(f)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|