55import SoftLayer
66from SoftLayer .CLI import environment
77from SoftLayer .CLI import exceptions
8+ from SoftLayer .CLI import helpers
9+ from SoftLayer import utils
810
911
1012CONTEXT_SETTINGS = {'token_normalize_func' : lambda x : x .upper ()}
1416@click .argument ('volume_id' )
1517@click .option ('--snapshot-schedule' , '-s' ,
1618 help = 'Snapshot schedule to use for replication, '
17- '(INTERVAL | HOURLY | DAILY | WEEKLY)' ,
19+ '(HOURLY | DAILY | WEEKLY)' ,
1820 required = True ,
19- type = click .Choice (['INTERVAL' , ' HOURLY' , 'DAILY' , 'WEEKLY' ]))
21+ type = click .Choice (['HOURLY' , 'DAILY' , 'WEEKLY' ]))
2022@click .option ('--location' , '-l' ,
2123 help = 'Short name of the data center for the replicant '
2224 '(e.g.: dal09)' ,
4042def cli (env , volume_id , snapshot_schedule , location , tier , os_type ):
4143 """Order a block storage replica volume."""
4244 block_manager = SoftLayer .BlockStorageManager (env .client )
45+ block_volume_id = helpers .resolve_id (block_manager .resolve_ids , volume_id , 'Block Volume' )
4346
4447 if tier is not None :
4548 tier = float (tier )
4649
4750 try :
4851 order = block_manager .order_replicant_volume (
49- volume_id ,
52+ block_volume_id ,
5053 snapshot_schedule = snapshot_schedule ,
5154 location = location ,
5255 tier = tier ,
@@ -57,9 +60,9 @@ def cli(env, volume_id, snapshot_schedule, location, tier, os_type):
5760
5861 if 'placedOrder' in order .keys ():
5962 click .echo ("Order #{0} placed successfully!" .format (
60- order [ 'placedOrder' ][ 'id' ] ))
61- for item in order [ 'placedOrder' ][ 'items' ] :
62- click .echo (" > %s" % item [ 'description' ] )
63+ utils . lookup ( order , 'placedOrder' , 'id' ) ))
64+ for item in utils . lookup ( order , 'placedOrder' , 'items' ) :
65+ click .echo (" > %s" % item . get ( 'description' ) )
6366 else :
6467 click .echo ("Order could not be placed! Please verify your options " +
6568 "and try again." )
0 commit comments