/
showoci_output.py
executable file
·1731 lines (1338 loc) · 68 KB
/
showoci_output.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##########################################################################
# Copyright(c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
# showoci_output.py
#
# @author: Adi Zohar
#
# Supports Python 2.7 and above, Python 3 recommended
#
# coding: utf-8
##########################################################################
# This file has ShowOCIOutput class and ShowOCISummary class
# it accept data as JSON format and print nice output
##########################################################################
from __future__ import print_function
class ShowOCIOutput(object):
##########################################################################
# spaces for align
##########################################################################
tabs = ' ' * 4
taba = '--> '
tabs2 = tabs + tabs
############################################
# Init
############################################
def __init__(self):
pass
##########################################################################
# Print header centered
##########################################################################
def print_header(self, name, category):
options = {0: 90, 1: 60, 2: 30, 3: 75}
chars = int(options[category])
print("")
print('#' * chars)
print("#" + name.center(chars - 2, " ") + "#")
print('#' * chars)
##########################################################################
# print_oci_main
##########################################################################
def print_data(self, data, print_version=False):
try:
has_data = False
for d in data:
if 'type' in d:
if d['type'] == "showoci":
if print_version:
self.print_showoci_config(d['data'])
elif d['type'] == "identity":
self.__print_identity_main(d['data'])
has_data = True
elif d['type'] == "budgets":
self.__print_budgets_main(d['data'])
has_data = True
elif d['type'] == "announcement":
self.__print_announcement_main(d['data'])
has_data = True
elif d['type'] == "region":
self.__print_region_data(d['region'], d['data'])
has_data = True
else:
print("Error Unknown Type in JSON file...")
# if no data - print message
if not has_data:
print("")
print("*** Data not found, please check your execution flags ***")
except Exception as e:
raise Exception("Error in self.__print_main: " + str(e.args))
##########################################################################
# Print showoci data
##########################################################################
def print_showoci_config(self, data):
try:
self.print_header(data['program'], 1)
if data['use_instance_principals']:
print("Authentication : Instance Principals")
else:
print("Authentication : Config File")
print("Config File : " + data['config_file'])
print("Config Profile : " + data['config_profile'])
print("Version : " + data['version'])
print("Date/Time : " + data['datetime'])
print("Comand Line : " + data['cmdline'])
print("OCI SDK Ver : " + data['oci_sdk_version'])
if 'proxy' in data:
print("Proxy : " + data['proxy'])
if 'joutfile' in data:
print("JSON Out : " + data['joutfile'])
print("")
except Exception as e:
raise Exception("Error in print_showoci_config: " + str(e.args))
##########################################################################
# print print error
##########################################################################
def __print_error(self, msg, e):
classname = type(self).__name__
if isinstance(e, KeyError):
print("\nError in " + classname + ":" + msg + ": KeyError " + str(e.args))
else:
print("\nError in " + classname + ":" + msg + ": " + str(e))
##########################################################################
# Print Tenancy
##########################################################################
def __print_identity_tenancy(self, tenancy):
try:
self.print_header("Tenancy", 0)
print("Name : " + tenancy['name'])
print("Tenant Id : " + tenancy['id'])
print("Home Region : " + tenancy['home_region_key'])
print("Subs Region : " + tenancy['subscribe_regions'])
print("")
except Exception as e:
self.__print_error("__print_identity_tenancy", e)
##########################################################################
# Print Identity Users
##########################################################################
def __print_identity_users(self, users):
try:
self.print_header("Users", 2)
for user in users:
print(self.taba + user['name'])
print(self.tabs + "Groups : " + user['groups'])
print("")
except Exception as e:
self.__print_error("__print_identity_users", e)
##########################################################################
# Print Identity Groups
##########################################################################
def __print_identity_groups(self, groups):
try:
self.print_header("Groups", 2)
for group in groups:
print(self.taba + group['name'].ljust(18, " ") + " : " + group['users'])
except Exception as e:
self.__print_error("__print_identity_groups", e)
##########################################################################
# Print Identity Policies
##########################################################################
def __print_identity_policies(self, policies_data):
try:
if not policies_data:
return
self.print_header("Policies", 2)
for c in policies_data:
policies = c['policies']
if not policies:
continue
print("\n" + c['compartment_path'] + ":")
for policy in policies:
print("")
print(self.taba + policy['name'] + ":")
print(self.tabs + "\n ".join(policy['statements']))
except Exception as e:
self.__print_error("__print_identity_policies", e)
##########################################################################
# Print Identity Providers
##########################################################################
def __print_identity_providers(self, identity_providers):
try:
if not identity_providers:
return
self.print_header("identity providers", 2)
for ip in identity_providers:
print(self.taba + ip['name'])
print(self.tabs + "Desc : " + ip['description'])
print(self.tabs + "Type : " + ip['product_type'])
print(self.tabs + "Protocol : " + ip['protocol'])
print(self.tabs + "Redirect : " + ip['redirect_url'])
print(self.tabs + "Metadata : " + ip['metadata_url'])
for ig in ip['group_map']:
print(self.tabs + "Group Map : " + ig)
print("")
print("")
except Exception as e:
self.__print_error("__print_identity_providers", e)
##########################################################################
# Print Dynamic Groups
##########################################################################
def __print_identity_dynamic_groups(self, dynamic_groups):
try:
if not dynamic_groups:
return
self.print_header("Dynamic Groups", 2)
for dg in dynamic_groups:
print(self.taba + dg['name'])
print(self.tabs + "Desc :" + dg['description'])
print(self.tabs + "Rules :" + dg['matching_rule'])
print("")
except Exception as e:
self.__print_error("__print_identity_dynamic_groups", e)
##########################################################################
# Print Cost Tracking Tags
##########################################################################
def __print_identity_cost_tracking_tags(self, tags):
try:
if not tags:
return
self.print_header("Cost Tracking Tags", 2)
for tag in tags:
print(self.taba + tag['tag_namespace_name'] + "." + tag['name'])
print(self.tabs + "Desc :" + tag['description'])
print(self.tabs + "Created :" + tag['time_created'][0:16])
print("")
except Exception as e:
self.__print_error("__print_identity_cost_tracking_tags", e)
##########################################################################
# Identity Module
##########################################################################
def __print_identity_main(self, data):
try:
if 'tenancy' in data:
self.__print_identity_tenancy(data['tenancy'])
if 'users' in data:
self.__print_identity_users(data['users'])
if 'groups' in data:
self.__print_identity_groups(data['groups'])
if 'dynamic_groups' in data:
self.__print_identity_dynamic_groups(data['dynamic_groups'])
if 'policies' in data:
self.__print_identity_policies(data['policies'])
if 'providers' in data:
self.__print_identity_providers(data['providers'])
if 'cost_tracking_tags' in data:
self.__print_identity_cost_tracking_tags(data['cost_tracking_tags'])
except Exception as e:
self.__print_error("__print_identity_data", e)
##########################################################################
# return compartment name
##########################################################################
def __print_core_network_vcn_compartment(self, vcn_compartment, data_compartment):
if vcn_compartment == data_compartment:
return ""
val = " (Compartment=" + data_compartment + ")"
return val
##########################################################################
# Print Network VCN Local Peering
##########################################################################
def __print_core_network_vcn_subnet(self, subnets, vcn_compartment):
try:
for subnet in subnets:
print("")
print(self.tabs + "Subnet " + subnet['subnet'] + self.__print_core_network_vcn_compartment(vcn_compartment, subnet['compartment']))
print(self.tabs + self.tabs + "Name : " + subnet['name'])
print(self.tabs + self.tabs + "DNS : " + subnet['dns'])
print(self.tabs + self.tabs + "DHCP : " + subnet['dhcp_options'])
print(self.tabs + self.tabs + "Route : " + subnet['route'])
for s in subnet['security_list']:
print(self.tabs + self.tabs + "Sec List: " + s)
except Exception as e:
self.__print_error("__print_core_network_vcn_subnet", e)
##########################################################################
# get DHCP options for DHCP_ID
##########################################################################
def __print_core_network_vcn_dhcp_options(self, dhcp_options, vcn_compartment):
try:
for dhcp in dhcp_options:
print("")
print(self.tabs + "DHCP Options: " + dhcp['name'] + self.__print_core_network_vcn_compartment(vcn_compartment, dhcp['compartment']))
for opt in dhcp['opt']:
print(self.tabs + self.tabs + opt)
except Exception as e:
self.__print_error("__print_core_network_vcn_dhcp_options", e)
##########################################################################
# Print Network vcn security list
##########################################################################
def __print_core_network_vcn_security_lists(self, sec_lists, vcn_compartment):
try:
if not sec_lists:
return
for sl in sec_lists:
print("")
print(self.tabs + "Sec List : " + str(sl['name']) + self.__print_core_network_vcn_compartment(vcn_compartment, sl['compartment']))
if len(sl['sec_rules']) == 0:
print(self.tabs + " : Empty.")
for slr in sl['sec_rules']:
print(self.tabs + self.tabs + slr['desc'])
except Exception as e:
self.__print_error("__print_core_network_vcn_security_lists", e)
########################################################################
# Print Network vcn Route Tables
##########################################################################
def __print_core_network_vcn_route_tables(self, route_tables, vcn_compartment):
try:
if not route_tables:
return
for rt in route_tables:
print("")
print(self.tabs + "Route Table : " + rt['name'] + self.__print_core_network_vcn_compartment(vcn_compartment, rt['compartment']))
if 'route_rules' not in rt:
print(self.tabs + self.tabs + "Route : Empty.")
return
if len(rt['route_rules']) == 0:
print(self.tabs + self.tabs + "Route : Empty.")
return
for rl in rt['route_rules']:
print(self.tabs + self.tabs + "Route : " + str(rl['desc']))
except Exception as e:
self.__print_error("__print_core_network_vcn_route_tables", e)
##########################################################################
# print network vcn
##########################################################################
def __print_core_network_vcn(self, vcns):
try:
if len(vcns) == 0:
return
self.print_header("VCNs", 2)
for vcn in vcns:
print(self.taba + "VCN " + vcn['name'])
vcn_compartment = vcn['compartment']
if 'igw' in vcn['data']:
for igwloop in vcn['data']['igw']:
print(self.tabs + "Internet GW : " + igwloop['name'] + self.__print_core_network_vcn_compartment(vcn_compartment, igwloop['compartment']))
if 'sgw' in vcn['data']:
for sgwloop in vcn['data']['sgw']:
print(self.tabs + "Service GW : " + sgwloop['name'] + " - " + sgwloop['services'] + self.__print_core_network_vcn_compartment(vcn_compartment, sgwloop['compartment']))
if 'nat' in vcn['data']:
for natloop in vcn['data']['nat']:
print(self.tabs + "NAT GW : " + natloop['name'] + self.__print_core_network_vcn_compartment(vcn_compartment, natloop['compartment']))
if 'drg_attached' in vcn['data']:
for drgloop in vcn['data']['drg_attached']:
print(self.tabs + "DRG Attached: " + drgloop['name'] + self.__print_core_network_vcn_compartment(vcn_compartment, drgloop['compartment']))
if 'local_peering' in vcn['data']:
for lpeer in vcn['data']['local_peering']:
print(self.tabs + "Local Peer : " + lpeer['name'] + self.__print_core_network_vcn_compartment(vcn_compartment, lpeer['compartment']))
if 'subnets' in vcn['data']:
self.__print_core_network_vcn_subnet(vcn['data']['subnets'], vcn_compartment)
if 'security_lists' in vcn['data']:
self.__print_core_network_vcn_security_lists(vcn['data']['security_lists'], vcn_compartment)
if 'route_tables' in vcn['data']:
self.__print_core_network_vcn_route_tables(vcn['data']['route_tables'], vcn_compartment)
if 'dhcp_options' in vcn['data']:
self.__print_core_network_vcn_dhcp_options(vcn['data']['dhcp_options'], vcn_compartment)
print("")
except BaseException as e:
self.__print_error("__print_core_network_vcn", e)
##########################################################################
# print network drg
##########################################################################
def __print_core_network_drg(self, drgs):
try:
if len(drgs) == 0:
return
self.print_header("DRGs", 2)
for drg in drgs:
print(self.taba + "DRG " + drg)
except Exception as e:
self.__print_error("__print_core_network_vcn", e)
##########################################################################
# print network remote peering
##########################################################################
def __print_core_network_remote_peering(self, rpcs):
try:
if len(rpcs) == 0:
return
self.print_header("Remote Peering", 2)
for rpc in rpcs:
print(self.tabs + "RPC Name : " + rpc['name'])
print(self.tabs + " DRG : " + rpc['drg'])
# if peer has name if not id
if rpc['peer_rfc_name']:
print(self.tabs + " Peer : " + rpc['peer_rfc_name'] + " - " + rpc['peer_region_name'])
else:
print(self.tabs + " PeerId : " + rpc['peer_id'])
print(self.tabs + " Region : " + rpc['peer_region_name'])
print(self.tabs + " Status : " + rpc['peering_status'])
if rpc['is_cross_tenancy_peering'] == "True":
print(self.tabs + " Tenant: Cross Tenant: " + rpc['peer_tenancy_id'])
except Exception as e:
self.__print_error("__print_core_network_vcn", e)
##########################################################################
# print network cpe
##########################################################################
def __print_core_network_cpe(self, cpes):
try:
if len(cpes) == 0:
return
self.print_header("CPEs", 2)
for cpe in cpes:
print(self.taba + "CPE " + cpe)
except Exception as e:
self.__print_error("__print_core_network_cpe", e)
##########################################################################
# print network ipsec
##########################################################################
def __print_core_network_ipsec(self, ipsecs):
try:
if len(ipsecs) == 0:
return
self.print_header("IPSec", 2)
for ips in ipsecs:
print(self.taba + "IPSEC : " + ips['name'])
print(self.tabs + "DRG : " + ips['drg'])
print(self.tabs + "CPE : " + ips['cpe'])
# get tunnel status
for t in ips['tunnels']:
print(self.tabs + "Tunnel : " + t['display_name'].ljust(12) + " - " + t['status'] + ", " + t['routing'] + ", VPN: " + t['vpn_ip'] + ", CPE: " + t['cpe_ip'] + ", " + t['status_date'])
if t['bgp_info']:
print(self.tabs + " : " + t['bgp_info'])
if ips['routes']:
print(self.tabs + "Routes : " + "\n Static : ".join(ips['routes']))
print("")
except Exception as e:
self.__print_error("__print_core_network_ipsec", e)
##########################################################################
# print virtual cirtuicts
##########################################################################
def __print_core_network_virtual_circuit(self, virtual_circuit):
try:
if len(virtual_circuit) == 0:
return
self.print_header("Virtual Circuits (FC)", 2)
for vc in virtual_circuit:
print(self.taba + "VC : " + vc['name'] + " - " + vc['bandwidth_shape_name'] + " - " + vc['lifecycle_state'])
print(self.tabs + "DRG : " + vc['drg'])
print(self.tabs + "BGP : " + vc['bgp_management'] + " - " + vc['bgp_session_state'] + " - Cust ASN:" + vc['customer_bgp_asn'] + " - Ora ASN:" + vc['oracle_bgp_asn'])
print(self.tabs + "PROVIDER: " + vc['provider_name'] + " - " + vc['provider_service_name'] + " - " + vc['provider_state'] + " - " + vc['service_type'])
# get tunnel status
for t in vc['cross_connect_mappings']:
print(self.tabs + "CCMAP : Cust : " + str(t['customer_bgp_peering_ip']) + " - Ora : " + str(t['oracle_bgp_peering_ip']) + " - VLAN " + str(t['vlan']))
print("")
except Exception as e:
self.__print_error("__print_core_network_virtual_circuit", e)
##########################################################################
# print network Main
##########################################################################
def __print_core_network_main(self, data):
try:
if 'vcn' in data:
self.__print_core_network_vcn(data['vcn'])
if 'drg' in data:
self.__print_core_network_drg(data['drg'])
if 'cpe' in data:
self.__print_core_network_cpe(data['cpe'])
if 'ipsec' in data:
self.__print_core_network_ipsec(data['ipsec'])
if 'remote_peering' in data:
self.__print_core_network_remote_peering(data['remote_peering'])
if 'virtual_circuit' in data:
self.__print_core_network_virtual_circuit(data['virtual_circuit'])
except Exception as e:
self.__print_error("__print_core_network", e)
##########################################################################
# print load balancer backedset
##########################################################################
def __print_load_balancer_backendset(self, backendset):
try:
for bs in backendset:
print("")
if 'backend_set' in bs:
print(self.tabs + "backendSet : " + bs['backend_set'])
if 'status' in bs:
print(self.tabs + self.tabs + "Status : " + bs['status'])
# list of backends
if 'backends' in bs:
for backend in bs['backends']:
print(self.tabs + self.tabs + "Backend: " + backend)
if 'health_check' in bs:
for health in bs['health_check']:
print(self.tabs + self.tabs + "H.Chk : " + health)
if 'session_persistence' in bs:
if bs['session_persistence']:
print(self.tabs + self.tabs + "Cookie : " + bs['session_persistence'])
if 'ssl_cert' in bs:
if bs['ssl_cert']:
print(self.tabs + self.tabs + "Cert : " + bs['ssl_cert'])
except Exception as e:
self.__print_error("__print_load_balancer_backendset", e)
##########################################################################
# print load balancer config
##########################################################################
def __print_load_balancer_details(self, load_balance_obj):
try:
lb = load_balance_obj
print(self.taba + "Name : " + lb['name'])
print(self.tabs + "Status : " + lb['status'])
# subnets
if 'subnets' in lb:
for subnet in lb['subnets']:
print(self.tabs + "Subnet : " + subnet)
# ip_addresses
if 'ips' in lb:
for ip in lb['ips']:
print(self.tabs + "IP : " + ip)
# listeners
if 'listeners' in lb:
if not lb['listeners']:
print(self.tabs + "Listener : None")
for listener in lb['listeners']:
print(self.tabs + "Listener : " + listener)
# Path route set - need to test - TBD
if 'path_route' in lb:
for prs in lb['path_route']:
print(self.tabs + "Path Route : " + prs['name'])
if 'path_routes' in prs:
for p in prs['path_routes']:
print(self.tabs + " : Backend: " + str(p['backend_set_name']) + ', Path: ' + p['path'])
# Hostnames
if 'hostnames' in lb:
for hostname in lb['hostnames']:
print(self.tabs + "Hostname : " + hostname)
except Exception as e:
self.__print_error("__print_load_balancer_details", e)
##########################################################################
# Load Balancer
##########################################################################
def __print_load_balancer_main(self, load_balancers):
try:
if len(load_balancers) == 0:
return
self.print_header("Load Balancers", 2)
for load_balance_obj in load_balancers:
if 'details' in load_balance_obj:
self.__print_load_balancer_details(load_balance_obj['details'])
if 'backendset' in load_balance_obj:
self.__print_load_balancer_backendset(load_balance_obj['backendset'])
print("")
except Exception as e:
self.__print_error("__print_load_balancer_main", e)
##########################################################################
# print file systems mount targets
##########################################################################
def __print_file_storage_mount_target(self, mount_targets):
try:
for mt in mount_targets:
print(self.tabs + "Mount : " + mt['mount'])
for ip in mt['private_ip_ids']:
print(self.tabs + "Mount IP : " + ip)
except Exception as e:
self.__print_error("__print_file_storage_mount_target", e)
##########################################################################
# print file systems exports
##########################################################################
def __print_file_storage_exports(self, exports):
try:
for export in exports:
if 'path' in export:
print(self.tabs + "Export : " + export['path'])
if 'exportset' in export:
print(self.tabs + "ExportSet : " + export['exportset'])
# Mount Target
self.__print_file_storage_mount_target(export['mount_target'])
except Exception as e:
self.__print_error("__print_file_storage_exports", e)
##########################################################################
# File System
##########################################################################
def __print_file_storage_main(self, file_systems):
try:
if len(file_systems) == 0:
return
self.print_header("File Storage", 2)
# print details
for fs in file_systems:
if 'filesystem' in fs:
print(self.taba + fs['filesystem'])
self.__print_file_storage_exports(fs['exports'])
# snapshots
if 'snapshots' in fs:
for snap in fs['snapshots']:
print(self.tabs + "Snap : " + snap)
print("")
except Exception as e:
self.__print_error("__print_file_storage_main", e)
##########################################################################
# print database db system
##########################################################################
def __print_database_db_system_details(self, dbs):
try:
print(self.taba + dbs['name'])
print(self.tabs + "AD : " + dbs['availability_domain'])
if 'cpu_core_count' in dbs:
print(self.tabs + "Cores : " + str(dbs['cpu_core_count']))
if 'node_count' in dbs:
if dbs['node_count']:
print(self.tabs + "Nodes : " + str(dbs['node_count']))
if 'version' in dbs:
print(self.tabs + "Version : " + dbs['version'])
if 'host' in dbs:
print(self.tabs + "Host : " + dbs['host'])
if 'domain' in dbs:
if dbs['domain']:
print(self.tabs + "Domain : " + dbs['domain'])
if 'cluster_name' in dbs:
if dbs['cluster_name']:
print(self.tabs + "Cluster : " + dbs['cluster_name'])
if 'data' in dbs:
if dbs['data']:
print(self.tabs + "Data : " + dbs['data'])
if 'data_subnet' in dbs:
print(self.tabs + "DataSub : " + dbs['data_subnet'])
if 'backup_subnet' in dbs:
if dbs['backup_subnet']:
print(self.tabs + "BackSub : " + dbs['backup_subnet'])
if 'scan_dns' in dbs:
if dbs['scan_dns']:
print(self.tabs + "Scan DNS: " + dbs['scan_dns'])
if 'scan_ips' in dbs:
for ip in dbs['scan_ips']:
print(self.tabs + "Scan Ips: " + ip)
if 'vip_ips' in dbs:
for ip in dbs['vip_ips']:
print(self.tabs + "VIP Ips : " + ip)
if 'listener_port' in dbs:
print(self.tabs + "Port : " + dbs['listener_port'])
if 'patches' in dbs:
for p in dbs['patches']:
print(self.tabs + "Patches : " + p)
print(self.tabs + " : " + '-' * 90)
except Exception as e:
self.__print_error("__print_database_db_system_details", e)
##########################################################################
# database db systems
##########################################################################
def __print_database_db_system(self, list_db_systems):
try:
for dbs in list_db_systems:
print("")
# db systems
self.__print_database_db_system_details(dbs)
# db nodes
for db_node in dbs['db_nodes']:
print(self.tabs + db_node)
# db homes
for db_home in dbs['db_homes']:
print(self.tabs + "Home : " + db_home['home'])
# patches
for p in db_home['patches']:
print(self.tabs + self.tabs + " PT : " + p)
# databases
for db in db_home['databases']:
print(self.tabs + self.tabs + " DB : " + db['name'])
# print data guard
for dg in db['dataguard']:
print(self.tabs + self.tabs + " " + dg['name'])
# print backups
for backup in db['backups']:
print(self.tabs + self.tabs + " " + backup['name'] + " - " + backup['time'] + " - " + backup['size'])
except Exception as e:
self.__print_error("__print_database_db_system", e)
##########################################################################
# print database db system
##########################################################################
def __print_database_db_autonomous(self, dbs):
try:
for db in dbs:
print(self.taba + db['name'])
if 'cpu_core_count' in db:
print(self.tabs + "Cores : " + str(db['cpu_core_count']))
if 'data_storage_size_in_tbs' in db:
print(self.tabs + "Size TB : " + str(db['data_storage_size_in_tbs']))
if 'db_name' in db:
print(self.tabs + "DB Name : " + db['db_name'])
if 'time_created' in db:
print(self.tabs + "Created : " + db['time_created'])
if 'whitelisted_ips' in db:
print(self.tabs + "Allowed IPs : " + db['whitelisted_ips'])
# print backups
if db['backups']:
for backup in db['backups']:
print(self.tabs + self.tabs + " " + backup['name'] + " - " + backup['time'])
print("")
except Exception as e:
self.__print_error("__print_database_db_autonomous", e)
##########################################################################
# database
##########################################################################
def __print_database_main(self, list_databases):
try:
if len(list_databases) == 0:
return
if 'db_system' in list_databases:
self.print_header("databases DB Systems", 2)
self.__print_database_db_system(list_databases['db_system'])
print("")
if 'autonomous' in list_databases:
self.print_header("Autonomous databases", 2)
self.__print_database_db_autonomous(list_databases['autonomous'])
print("")
except Exception as e:
self.__print_error("__print_database_main", e)
##########################################################################
# object storage
##########################################################################
def __print_object_storage_main(self, objects):
try:
if len(objects) == 0:
return
self.print_header("Object Storage", 2)
for obj in objects:
print(self.taba + obj['desc'])
except Exception as e:
self.__print_error("__print_object_storage_main", e)
##########################################################################
# Email
##########################################################################
def __print_email_main(self, emails):
try:
if 'senders' not in emails and 'supp_list' not in emails:
return
self.print_header("EMails", 2)
if 'senders' in emails:
print(self.taba + "Approved Senders:")
for val in emails['senders']:
print(self.tabs + str(val))
print("")
if 'supp_list' in emails:
print(self.taba + "Suppression List:")
for val in emails['supp_list']:
print(self.tabs + str(val))
except Exception as e:
self.__print_error("__print_email_main", e)
##########################################################################
# Streams
##########################################################################
def __print_streams_main(self, streams):
try:
if not streams:
return
self.print_header("Streams", 2)
for ct in streams:
print(self.taba + ct['name'] + ", partitions (" + ct['partitions'] + "), Created: " + ct['time_created'][0:16])
print(self.tabs + "URL : " + str(ct['messages_endpoint']))
print("")
except Exception as e:
self.__print_error("__print_streams_main", e)
##########################################################################
# Budgets
##########################################################################
def __print_budgets_main(self, budgets):
try:
if not budgets:
return
self.print_header("Budgets", 2)
for budget in budgets:
print(self.taba + budget['display_name'] + " for Compartment: " + budget['compartment_name'] + " (" + budget['reset_period'] + ")")
print(self.tabs + "Costs : Spent: " + budget['actual_spend'] + ", Forcasted: " + budget['forecasted_spend'], ", Time Computed: " + budget['time_spend_computed'][0:16])
print(self.tabs + "Created : " + budget['time_created'][0:16] + ", Total Alert Rules: " + budget['alert_rule_count'])
print("")
except Exception as e:
self.__print_error("__print_budgets_main", e)
##########################################################################
# Announcement
##########################################################################
def __print_announcement_main(self, announcements):
try:
if not announcements:
return
self.print_header("Announcements", 2)
for ann in announcements:
print(self.taba + ann['summary'][0:100] + " (" + ann['reference_ticket_number'] + ") - " + ann['announcement_type'] + ", " + ann['time_one_value'][0:16])
print(self.tabs + "Regions : " + ann['affected_regions'])
print(self.tabs + "Services : " + ann['services'])
print("")
except Exception as e:
self.__print_error("__print_announcement_main", e)
##########################################################################
# Monitoring
##########################################################################
def __print_monitoring_main(self, alarms):
try:
if not alarms:
return
self.print_header("Monitoring - Alarms", 2)
for alarm in alarms:
print(self.taba + alarm['display_name'] + " (" + alarm['namespace'] + "), Enabled = " + str(alarm['is_enabled']) + ", Severity = " + alarm['severity'])
print(self.tabs + "Query : " + alarm['query'])
for dest in alarm['destinations_names']:
print(self.tabs + "Topic : " + dest)
print("")
except Exception as e:
self.__print_error("__print_monitoring_main", e)
##########################################################################
# Notifications
##########################################################################
def __print_notifications_main(self, topics):
try:
if not topics:
return
self.print_header("Notifications - Topics", 2)
for topic in topics: