@@ -29,12 +29,33 @@ def lbaas_table(this_lb):
2929 table .align ['value' ] = 'l'
3030 table .add_row (['Id' , this_lb .get ('id' )])
3131 table .add_row (['UUI' , this_lb .get ('uuid' )])
32+ table .add_row (['Name' , this_lb .get ('name' )])
3233 table .add_row (['Address' , this_lb .get ('address' )])
34+ table .add_row (['Type' , SoftLayer .LoadBalancerManager .TYPE .get (this_lb .get ('type' ))])
3335 table .add_row (['Location' , utils .lookup (this_lb , 'datacenter' , 'longName' )])
3436 table .add_row (['Description' , this_lb .get ('description' )])
35- table .add_row (['Name' , this_lb .get ('name' )])
3637 table .add_row (['Status' , "{} / {}" .format (this_lb .get ('provisioningStatus' ), this_lb .get ('operatingStatus' ))])
3738
39+ listener_table , pools = get_listener_table (this_lb )
40+ table .add_row (['Protocols' , listener_table ])
41+
42+ member_table = get_member_table (this_lb , pools )
43+ table .add_row (['Members' , member_table ])
44+
45+ hp_table = get_hp_table (this_lb )
46+ table .add_row (['Health Checks' , hp_table ])
47+
48+ l7pool_table = get_l7pool_table (this_lb )
49+ table .add_row (['L7 Pools' , l7pool_table ])
50+
51+ ssl_table = get_ssl_table (this_lb )
52+ table .add_row (['Ciphers' , ssl_table ])
53+
54+ return table
55+
56+
57+ def get_hp_table (this_lb ):
58+ """Generates a table from a list of LBaaS devices"""
3859 # https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_HealthMonitor/
3960 hp_table = formatting .Table (['UUID' , 'Interval' , 'Retries' , 'Type' , 'Timeout' , 'Modify' , 'Active' ])
4061 for health in this_lb .get ('healthMonitors' , []):
@@ -47,44 +68,17 @@ def lbaas_table(this_lb):
4768 utils .clean_time (health .get ('modifyDate' )),
4869 health .get ('provisioningStatus' )
4970 ])
50- table . add_row ([ 'Checks' , hp_table ])
71+ return hp_table
5172
52- # https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_L7Pool/
53- l7_table = formatting .Table (['Id' , 'UUID' , 'Balancer' , 'Name' , 'Protocol' , 'Modify' , 'Active' ])
54- for layer7 in this_lb .get ('l7Pools' , []):
55- l7_table .add_row ([
56- layer7 .get ('id' ),
57- layer7 .get ('uuid' ),
58- layer7 .get ('loadBalancingAlgorithm' ),
59- layer7 .get ('name' ),
60- layer7 .get ('protocol' ),
61- utils .clean_time (layer7 .get ('modifyDate' )),
62- layer7 .get ('provisioningStatus' )
63- ])
64- table .add_row (['L7 Pools' , l7_table ])
65-
66- pools = {}
67- # https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_Listener/
68- listener_table = formatting .Table (['UUID' , 'Max Connection' , 'Mapping' , 'Balancer' , 'Modify' , 'Active' ])
69- for listener in this_lb .get ('listeners' , []):
70- pool = listener .get ('defaultPool' )
71- priv_map = "{}:{}" .format (pool ['protocol' ], pool ['protocolPort' ])
72- pools [pool ['uuid' ]] = priv_map
73- mapping = "{}:{} -> {}" .format (listener .get ('protocol' ), listener .get ('protocolPort' ), priv_map )
74- listener_table .add_row ([
75- listener .get ('uuid' ),
76- listener .get ('connectionLimit' , 'None' ),
77- mapping ,
78- pool .get ('loadBalancingAlgorithm' , 'None' ),
79- utils .clean_time (listener .get ('modifyDate' )),
80- listener .get ('provisioningStatus' )
81- ])
82- table .add_row (['Pools' , listener_table ])
8373
74+ def get_member_table (this_lb , pools ):
75+ """Generates a members table from a list of LBaaS devices"""
8476 # https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_Member/
8577 member_col = ['UUID' , 'Address' , 'Weight' , 'Modify' , 'Active' ]
78+ counter = 0
8679 for uuid in pools .values ():
87- member_col .append (uuid )
80+ member_col .append (f'P{ counter } -> { uuid } ' )
81+ counter += 1
8882 member_table = formatting .Table (member_col )
8983 for member in this_lb .get ('members' , []):
9084 row = [
@@ -97,14 +91,54 @@ def lbaas_table(this_lb):
9791 for uuid in pools :
9892 row .append (get_member_hp (this_lb .get ('health' ), member .get ('uuid' ), uuid ))
9993 member_table .add_row (row )
100- table .add_row (['Members' , member_table ])
94+ return member_table
95+
10196
97+ def get_ssl_table (this_lb ):
98+ """Generates a ssl table from a list of LBaaS devices"""
10299 # https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_SSLCipher/
103100 ssl_table = formatting .Table (['Id' , 'Name' ])
104101 for ssl in this_lb .get ('sslCiphers' , []):
105102 ssl_table .add_row ([ssl .get ('id' ), ssl .get ('name' )])
106- table .add_row (['Ciphers' , ssl_table ])
107- return table
103+ return ssl_table
104+
105+
106+ def get_listener_table (this_lb ):
107+ """Generates a protocols table from a list of LBaaS devices"""
108+ pools = {}
109+ # https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_Listener/
110+ listener_table = formatting .Table (['UUID' , 'Max Connection' , 'Mapping' , 'Balancer' , 'Modify' , 'Active' ])
111+ for listener in this_lb .get ('listeners' , []):
112+ pool = listener .get ('defaultPool' )
113+ priv_map = "{}:{}" .format (pool ['protocol' ], pool ['protocolPort' ])
114+ pools [pool ['uuid' ]] = priv_map
115+ mapping = "{}:{} -> {}" .format (listener .get ('protocol' ), listener .get ('protocolPort' ), priv_map )
116+ listener_table .add_row ([
117+ listener .get ('uuid' ),
118+ listener .get ('connectionLimit' , 'None' ),
119+ mapping ,
120+ pool .get ('loadBalancingAlgorithm' , 'None' ),
121+ utils .clean_time (listener .get ('modifyDate' )),
122+ listener .get ('provisioningStatus' )
123+ ])
124+ return listener_table , pools
125+
126+
127+ def get_l7pool_table (this_lb ):
128+ """Generates a l7Pools table from a list of LBaaS devices"""
129+ # https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_L7Pool/
130+ l7_table = formatting .Table (['Id' , 'UUID' , 'Balancer' , 'Name' , 'Protocol' , 'Modify' , 'Active' ])
131+ for layer7 in this_lb .get ('l7Pools' , []):
132+ l7_table .add_row ([
133+ layer7 .get ('id' ),
134+ layer7 .get ('uuid' ),
135+ layer7 .get ('loadBalancingAlgorithm' ),
136+ layer7 .get ('name' ),
137+ layer7 .get ('protocol' ),
138+ utils .clean_time (layer7 .get ('modifyDate' )),
139+ layer7 .get ('provisioningStatus' )
140+ ])
141+ return l7_table
108142
109143
110144def get_member_hp (checks , member_uuid , pool_uuid ):
0 commit comments