1010
1111@click .command ()
1212@click .argument ('unique_id' )
13- @click .option ('--last_days ' ,
14- default = 30 ,
15- help = 'cdn overview last days less than 90 days, because it is the maximum e.g 7, 15, 30, 60, 89 ' )
13+ @click .option ('--history ' ,
14+ default = 30 , type = click . IntRange ( 1 , 89 ),
15+ help = 'Bandwidth, Hits, Ratio counted over history number of days ago. 89 is the maximum. ' )
1616@environment .pass_env
17- def cli (env , unique_id , last_days ):
17+ def cli (env , unique_id , history ):
1818 """Detail a CDN Account."""
1919
2020 manager = SoftLayer .CDNManager (env .client )
2121
2222 cdn_mapping = manager .get_cdn (unique_id )
23- cdn_metrics = manager .get_usage_metrics (unique_id , days = last_days )
23+ cdn_metrics = manager .get_usage_metrics (unique_id , history = history )
2424
2525 # usage metrics
26- total_bandwidth = str ( cdn_metrics ['totals' ][0 ]) + " GB"
27- total_hits = str ( cdn_metrics ['totals' ][1 ])
28- hit_radio = str ( cdn_metrics ['totals' ][2 ]) + " %"
26+ total_bandwidth = "%s GB" % cdn_metrics ['totals' ][0 ]
27+ total_hits = cdn_metrics ['totals' ][1 ]
28+ hit_ratio = "%s %%" % cdn_metrics ['totals' ][2 ]
2929
3030 table = formatting .KeyValueTable (['name' , 'value' ])
3131 table .align ['name' ] = 'r'
@@ -41,6 +41,6 @@ def cli(env, unique_id, last_days):
4141 table .add_row (['status' , cdn_mapping ['status' ]])
4242 table .add_row (['total_bandwidth' , total_bandwidth ])
4343 table .add_row (['total_hits' , total_hits ])
44- table .add_row (['hit_radio' , hit_radio ])
44+ table .add_row (['hit_radio' , hit_ratio ])
4545
4646 env .fout (table )
0 commit comments