<s> from __future__ import print_function <EOL> import argparse <EOL> import copy <EOL> import os <EOL> import sys <EOL> import time <EOL> from cinderclient import exceptions <EOL> from cinderclient import utils <EOL> from cinderclient . v1 import availability_zones <EOL> from oslo_utils import strutils <EOL> def _poll_for_status ( poll_fn , obj_id , action , final_ok_states , <EOL> poll_period = <NUM_LIT:5> , show_progress = True ) : <EOL> """<STR_LIT>""" <EOL> def print_progress ( progress ) : <EOL> if show_progress : <EOL> msg = ( '<STR_LIT>' <EOL> % dict ( action = action , progress = progress ) ) <EOL> else : <EOL> msg = '<STR_LIT>' % dict ( action = action ) <EOL> sys . stdout . write ( msg ) <EOL> sys . stdout . flush ( ) <EOL> print ( ) <EOL> while True : <EOL> obj = poll_fn ( obj_id ) <EOL> status = obj . status . lower ( ) <EOL> progress = getattr ( obj , '<STR_LIT>' , None ) or <NUM_LIT:0> <EOL> if status in final_ok_states : <EOL> print_progress ( <NUM_LIT:100> ) <EOL> print ( "<STR_LIT>" ) <EOL> break <EOL> elif status == "<STR_LIT:error>" : <EOL> print ( "<STR_LIT>" % { '<STR_LIT:action>' : action } ) <EOL> break <EOL> else : <EOL> print_progress ( progress ) <EOL> time . sleep ( poll_period ) <EOL> def _find_volume_snapshot ( cs , snapshot ) : <EOL> """<STR_LIT>""" <EOL> return utils . find_resource ( cs . volume_snapshots , snapshot ) <EOL> def _find_backup ( cs , backup ) : <EOL> """<STR_LIT>""" <EOL> return utils . find_resource ( cs . backups , backup ) <EOL> def _find_transfer ( cs , transfer ) : <EOL> """<STR_LIT>""" <EOL> return utils . find_resource ( cs . transfers , transfer ) <EOL> def _find_qos_specs ( cs , qos_specs ) : <EOL> """<STR_LIT>""" <EOL> return utils . find_resource ( cs . qos_specs , qos_specs ) <EOL> def _print_volume ( volume ) : <EOL> utils . print_dict ( volume . _info ) <EOL> def _print_volume_snapshot ( snapshot ) : <EOL> utils . print_dict ( snapshot . _info ) <EOL> def _print_volume_image ( image ) : <EOL> utils . print_dict ( image [ <NUM_LIT:1> ] [ '<STR_LIT>' ] ) <EOL> def _translate_keys ( collection , convert ) : <EOL> for item in collection : <EOL> keys = item . __dict__ <EOL> for from_key , to_key in convert : <EOL> if from_key in keys and to_key not in keys : <EOL> setattr ( item , to_key , item . _info [ from_key ] ) <EOL> def _translate_volume_keys ( collection ) : <EOL> convert = [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> _translate_keys ( collection , convert ) <EOL> def _translate_volume_snapshot_keys ( collection ) : <EOL> convert = [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> _translate_keys ( collection , convert ) <EOL> def _translate_availability_zone_keys ( collection ) : <EOL> convert = [ ( '<STR_LIT>' , '<STR_LIT:name>' ) , ( '<STR_LIT>' , '<STR_LIT:status>' ) ] <EOL> _translate_keys ( collection , convert ) <EOL> def _extract_metadata ( args ) : <EOL> metadata = { } <EOL> for metadatum in args . metadata : <EOL> if '<STR_LIT:=>' in metadatum : <EOL> ( key , value ) = metadatum . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) <EOL> else : <EOL> key = metadatum <EOL> value = None <EOL> metadata [ key ] = value <EOL> return metadata <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:?>' , <EOL> type = int , <EOL> const = <NUM_LIT:1> , <EOL> default = <NUM_LIT:0> , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> nargs = '<STR_LIT:?>' , <EOL> type = int , <EOL> const = <NUM_LIT:1> , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> type = str , <EOL> nargs = '<STR_LIT:*>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> type = str , <EOL> dest = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:?>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_list ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> all_tenants = <NUM_LIT:1> if args . tenant else int ( os . environ . get ( "<STR_LIT>" , args . all_tenants ) ) <EOL> search_opts = { <EOL> '<STR_LIT>' : all_tenants , <EOL> '<STR_LIT>' : args . tenant , <EOL> '<STR_LIT>' : args . display_name , <EOL> '<STR_LIT:status>' : args . status , <EOL> '<STR_LIT>' : _extract_metadata ( args ) if args . metadata else None , <EOL> } <EOL> volumes = cs . volumes . list ( search_opts = search_opts , limit = args . limit ) <EOL> _translate_volume_keys ( volumes ) <EOL> for vol in volumes : <EOL> servers = [ s . get ( '<STR_LIT>' ) for s in vol . attachments ] <EOL> setattr ( vol , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( map ( str , servers ) ) ) <EOL> if all_tenants : <EOL> key_list = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> else : <EOL> key_list = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> utils . print_list ( volumes , key_list ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_show ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> _print_volume ( volume ) <EOL> @ utils . arg ( '<STR_LIT:size>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> type = str , <EOL> nargs = '<STR_LIT:*>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_create ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume_metadata = None <EOL> if args . metadata is not None : <EOL> volume_metadata = _extract_metadata ( args ) <EOL> volume = cs . volumes . create ( args . size , <EOL> args . snapshot_id , <EOL> args . source_volid , <EOL> args . display_name , <EOL> args . display_description , <EOL> args . volume_type , <EOL> availability_zone = args . availability_zone , <EOL> imageRef = args . image_id , <EOL> metadata = volume_metadata ) <EOL> _print_volume ( volume ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , nargs = '<STR_LIT:+>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_delete ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> failure_count = <NUM_LIT:0> <EOL> for volume in args . volume : <EOL> try : <EOL> utils . find_volume ( cs , volume ) . delete ( ) <EOL> print ( "<STR_LIT>" % ( volume ) ) <EOL> except Exception as e : <EOL> failure_count += <NUM_LIT:1> <EOL> print ( "<STR_LIT>" % ( volume , e ) ) <EOL> if failure_count == len ( args . volume ) : <EOL> raise exceptions . CommandError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , nargs = '<STR_LIT:+>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_force_delete ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> failure_count = <NUM_LIT:0> <EOL> for volume in args . volume : <EOL> try : <EOL> utils . find_volume ( cs , volume ) . force_delete ( ) <EOL> except Exception as e : <EOL> failure_count += <NUM_LIT:1> <EOL> print ( "<STR_LIT>" % ( volume , e ) ) <EOL> if failure_count == len ( args . volume ) : <EOL> raise exceptions . CommandError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , nargs = '<STR_LIT:+>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_reset_state ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> failure_flag = False <EOL> for volume in args . volume : <EOL> try : <EOL> utils . find_volume ( cs , volume ) . reset_state ( args . state ) <EOL> except Exception as e : <EOL> failure_flag = True <EOL> msg = "<STR_LIT>" % ( volume , e ) <EOL> print ( msg ) <EOL> if failure_flag : <EOL> msg = "<STR_LIT>" <EOL> raise exceptions . CommandError ( msg ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , nargs = '<STR_LIT:?>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> default = None , help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_rename ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> kwargs = { } <EOL> if args . display_name is not None : <EOL> kwargs [ '<STR_LIT>' ] = args . display_name <EOL> if args . display_description is not None : <EOL> kwargs [ '<STR_LIT>' ] = args . display_description <EOL> if not any ( kwargs ) : <EOL> msg = '<STR_LIT>' <EOL> raise exceptions . ClientException ( code = <NUM_LIT:1> , message = msg ) <EOL> utils . find_volume ( cs , args . volume ) . update ( ** kwargs ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT:action>' , <EOL> metavar = '<STR_LIT>' , <EOL> choices = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:+>' , <EOL> default = [ ] , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_metadata ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> metadata = _extract_metadata ( args ) <EOL> if args . action == '<STR_LIT>' : <EOL> cs . volumes . set_metadata ( volume , metadata ) <EOL> elif args . action == '<STR_LIT>' : <EOL> cs . volumes . delete_metadata ( volume , sorted ( metadata . keys ( ) , <EOL> reverse = True ) ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:?>' , <EOL> type = int , <EOL> const = <NUM_LIT:1> , <EOL> default = <NUM_LIT:0> , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> nargs = '<STR_LIT:?>' , <EOL> type = int , <EOL> const = <NUM_LIT:1> , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_snapshot_list ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> all_tenants = int ( os . environ . get ( "<STR_LIT>" , args . all_tenants ) ) <EOL> search_opts = { <EOL> '<STR_LIT>' : all_tenants , <EOL> '<STR_LIT>' : args . display_name , <EOL> '<STR_LIT:status>' : args . status , <EOL> '<STR_LIT>' : args . volume_id , <EOL> } <EOL> snapshots = cs . volume_snapshots . list ( search_opts = search_opts ) <EOL> _translate_volume_snapshot_keys ( snapshots ) <EOL> utils . print_list ( snapshots , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_snapshot_show ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> snapshot = _find_volume_snapshot ( cs , args . snapshot ) <EOL> _print_volume_snapshot ( snapshot ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = False , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_snapshot_create ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> snapshot = cs . volume_snapshots . create ( volume . id , <EOL> args . force , <EOL> args . display_name , <EOL> args . display_description ) <EOL> _print_volume_snapshot ( snapshot ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , nargs = '<STR_LIT:+>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_snapshot_delete ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> failure_count = <NUM_LIT:0> <EOL> for snapshot in args . snapshot : <EOL> try : <EOL> _find_volume_snapshot ( cs , snapshot ) . delete ( ) <EOL> except Exception as e : <EOL> failure_count += <NUM_LIT:1> <EOL> print ( "<STR_LIT>" % ( snapshot , e ) ) <EOL> if failure_count == len ( args . snapshot ) : <EOL> raise exceptions . CommandError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , nargs = '<STR_LIT:?>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> default = None , help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_snapshot_rename ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> kwargs = { } <EOL> if args . display_name is not None : <EOL> kwargs [ '<STR_LIT>' ] = args . display_name <EOL> if args . display_description is not None : <EOL> kwargs [ '<STR_LIT>' ] = args . display_description <EOL> if not any ( kwargs ) : <EOL> msg = '<STR_LIT>' <EOL> raise exceptions . ClientException ( code = <NUM_LIT:1> , message = msg ) <EOL> _find_volume_snapshot ( cs , args . snapshot ) . update ( ** kwargs ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , nargs = '<STR_LIT:+>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_snapshot_reset_state ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> failure_count = <NUM_LIT:0> <EOL> single = ( len ( args . snapshot ) == <NUM_LIT:1> ) <EOL> for snapshot in args . snapshot : <EOL> try : <EOL> _find_volume_snapshot ( cs , snapshot ) . reset_state ( args . state ) <EOL> except Exception as e : <EOL> failure_count += <NUM_LIT:1> <EOL> msg = "<STR_LIT>" % ( snapshot , e ) <EOL> if not single : <EOL> print ( msg ) <EOL> if failure_count == len ( args . snapshot ) : <EOL> if not single : <EOL> msg = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> raise exceptions . CommandError ( msg ) <EOL> def _print_volume_type_list ( vtypes ) : <EOL> utils . print_list ( vtypes , [ '<STR_LIT>' , '<STR_LIT:Name>' ] ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_type_list ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> vtypes = cs . volume_types . list ( ) <EOL> _print_volume_type_list ( vtypes ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_extra_specs_list ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> vtypes = cs . volume_types . list ( ) <EOL> utils . print_list ( vtypes , [ '<STR_LIT>' , '<STR_LIT:Name>' , '<STR_LIT>' ] ) <EOL> @ utils . arg ( '<STR_LIT:name>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_type_create ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> vtype = cs . volume_types . create ( args . name ) <EOL> _print_volume_type_list ( [ vtype ] ) <EOL> @ utils . arg ( '<STR_LIT:id>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_type_delete ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume_type = _find_volume_type ( cs , args . id ) <EOL> cs . volume_types . delete ( volume_type ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT:action>' , <EOL> metavar = '<STR_LIT>' , <EOL> choices = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:*>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_type_key ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> vtype = _find_volume_type ( cs , args . vtype ) <EOL> if args . metadata is not None : <EOL> keypair = _extract_metadata ( args ) <EOL> if args . action == '<STR_LIT>' : <EOL> vtype . set_keys ( keypair ) <EOL> elif args . action == '<STR_LIT>' : <EOL> vtype . unset_keys ( list ( keypair ) ) <EOL> def do_endpoints ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> catalog = cs . client . service_catalog . catalog <EOL> for e in catalog [ '<STR_LIT>' ] : <EOL> utils . print_dict ( e [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , e [ '<STR_LIT:name>' ] ) <EOL> def do_credentials ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> catalog = cs . client . service_catalog . catalog <EOL> utils . print_dict ( catalog [ '<STR_LIT:user>' ] , "<STR_LIT>" ) <EOL> utils . print_dict ( catalog [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> _quota_resources = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> _quota_infos = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def _quota_show ( quotas ) : <EOL> quota_dict = { } <EOL> for resource in quotas . _info : <EOL> good_name = False <EOL> for name in _quota_resources : <EOL> if resource . startswith ( name ) : <EOL> good_name = True <EOL> if not good_name : <EOL> continue <EOL> quota_dict [ resource ] = getattr ( quotas , resource , None ) <EOL> utils . print_dict ( quota_dict ) <EOL> def _quota_usage_show ( quotas ) : <EOL> quota_list = [ ] <EOL> for resource in quotas . _info . keys ( ) : <EOL> good_name = False <EOL> for name in _quota_resources : <EOL> if resource . startswith ( name ) : <EOL> good_name = True <EOL> if not good_name : <EOL> continue <EOL> quota_info = getattr ( quotas , resource , None ) <EOL> quota_info [ '<STR_LIT>' ] = resource <EOL> quota_info = dict ( ( k . capitalize ( ) , v ) for k , v in quota_info . items ( ) ) <EOL> quota_list . append ( quota_info ) <EOL> utils . print_list ( quota_list , _quota_infos ) <EOL> def _quota_update ( manager , identifier , args ) : <EOL> updates = { } <EOL> for resource in _quota_resources : <EOL> val = getattr ( args , resource , None ) <EOL> if val is not None : <EOL> if args . volume_type : <EOL> resource = resource + '<STR_LIT>' % args . volume_type <EOL> updates [ resource ] = val <EOL> if updates : <EOL> _quota_show ( manager . update ( identifier , ** updates ) ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_quota_show ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> _quota_show ( cs . quotas . get ( args . tenant ) ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_quota_usage ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> _quota_usage_show ( cs . quotas . get ( args . tenant , usage = True ) ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_quota_defaults ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> _quota_show ( cs . quotas . defaults ( args . tenant ) ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_quota_update ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> _quota_update ( cs . quotas , args . tenant , args ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_quota_delete ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> cs . quotas . delete ( args . tenant ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_quota_class_show ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> _quota_show ( cs . quota_classes . get ( args . class_name ) ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_quota_class_update ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> _quota_update ( cs . quota_classes , args . class_name , args ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_absolute_limits ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> limits = cs . limits . get ( ) . absolute <EOL> columns = [ '<STR_LIT:Name>' , '<STR_LIT>' ] <EOL> utils . print_list ( limits , columns ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_rate_limits ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> limits = cs . limits . get ( ) . rate <EOL> columns = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> utils . print_list ( limits , columns ) <EOL> def _find_volume_type ( cs , vtype ) : <EOL> """<STR_LIT>""" <EOL> return utils . find_resource ( cs . volume_types , vtype ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = False , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_upload_to_image ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> _print_volume_image ( volume . upload_to_image ( args . force , <EOL> args . image_name , <EOL> args . container_format , <EOL> args . disk_format ) ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_backup_create ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> backup = cs . backups . create ( volume . id , <EOL> args . container , <EOL> args . display_name , <EOL> args . display_description ) <EOL> info = { "<STR_LIT>" : volume . id } <EOL> info . update ( backup . _info ) <EOL> if '<STR_LIT>' in info : <EOL> info . pop ( '<STR_LIT>' ) <EOL> utils . print_dict ( info ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_backup_show ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> backup = _find_backup ( cs , args . backup ) <EOL> info = dict ( ) <EOL> info . update ( backup . _info ) <EOL> if '<STR_LIT>' in info : <EOL> info . pop ( '<STR_LIT>' ) <EOL> utils . print_dict ( info ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_backup_list ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> backups = cs . backups . list ( ) <EOL> columns = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:Name>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> utils . print_list ( backups , columns ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_backup_delete ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> backup = _find_backup ( cs , args . backup ) <EOL> backup . delete ( ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_backup_restore ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> if args . volume_id : <EOL> volume_id = utils . find_volume ( cs , args . volume_id ) . id <EOL> else : <EOL> volume_id = None <EOL> cs . restores . restore ( args . backup , volume_id ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_transfer_create ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> transfer = cs . transfers . create ( volume . id , <EOL> args . display_name ) <EOL> info = dict ( ) <EOL> info . update ( transfer . _info ) <EOL> if '<STR_LIT>' in info : <EOL> info . pop ( '<STR_LIT>' ) <EOL> utils . print_dict ( info ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_transfer_delete ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> transfer = _find_transfer ( cs , args . transfer ) <EOL> transfer . delete ( ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_transfer_accept ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> transfer = cs . transfers . accept ( args . transfer , args . auth_key ) <EOL> info = dict ( ) <EOL> info . update ( transfer . _info ) <EOL> if '<STR_LIT>' in info : <EOL> info . pop ( '<STR_LIT>' ) <EOL> utils . print_dict ( info ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:?>' , <EOL> type = int , <EOL> const = <NUM_LIT:1> , <EOL> default = <NUM_LIT:0> , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( <EOL> '<STR_LIT>' , <EOL> nargs = '<STR_LIT:?>' , <EOL> type = int , <EOL> const = <NUM_LIT:1> , <EOL> help = argparse . SUPPRESS ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_transfer_list ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> all_tenants = int ( os . environ . get ( "<STR_LIT>" , args . all_tenants ) ) <EOL> search_opts = { <EOL> '<STR_LIT>' : all_tenants , <EOL> } <EOL> transfers = cs . transfers . list ( search_opts = search_opts ) <EOL> columns = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:Name>' ] <EOL> utils . print_list ( transfers , columns ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_transfer_show ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> transfer = _find_transfer ( cs , args . transfer ) <EOL> info = dict ( ) <EOL> info . update ( transfer . _info ) <EOL> if '<STR_LIT>' in info : <EOL> info . pop ( '<STR_LIT>' ) <EOL> utils . print_dict ( info ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_extend ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> cs . volumes . extend ( volume , args . new_size ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , default = None , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_service_list ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> result = cs . services . list ( host = args . host , binary = args . binary ) <EOL> columns = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> if result and hasattr ( result [ <NUM_LIT:0> ] , '<STR_LIT>' ) : <EOL> columns . append ( "<STR_LIT>" ) <EOL> utils . print_list ( result , columns ) <EOL> @ utils . arg ( '<STR_LIT:host>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_service_enable ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> result = cs . services . enable ( args . host , args . binary ) <EOL> columns = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> utils . print_list ( [ result ] , columns ) <EOL> @ utils . arg ( '<STR_LIT:host>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_service_disable ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> columns = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> if args . reason : <EOL> columns . append ( '<STR_LIT>' ) <EOL> result = cs . services . disable_log_reason ( args . host , args . binary , <EOL> args . reason ) <EOL> else : <EOL> result = cs . services . disable ( args . host , args . binary ) <EOL> utils . print_list ( [ result ] , columns ) <EOL> def _treeizeAvailabilityZone ( zone ) : <EOL> """<STR_LIT>""" <EOL> AvailabilityZone = availability_zones . AvailabilityZone <EOL> az = AvailabilityZone ( zone . manager , <EOL> copy . deepcopy ( zone . _info ) , zone . _loaded ) <EOL> result = [ ] <EOL> az . zoneName = zone . zoneName <EOL> az . zoneState = ( '<STR_LIT>' <EOL> if zone . zoneState [ '<STR_LIT>' ] else '<STR_LIT>' ) <EOL> az . _info [ '<STR_LIT>' ] = az . zoneName <EOL> az . _info [ '<STR_LIT>' ] = az . zoneState <EOL> result . append ( az ) <EOL> if getattr ( zone , "<STR_LIT>" , None ) and zone . hosts is not None : <EOL> for ( host , services ) in zone . hosts . items ( ) : <EOL> az = AvailabilityZone ( zone . manager , <EOL> copy . deepcopy ( zone . _info ) , zone . _loaded ) <EOL> az . zoneName = '<STR_LIT>' % host <EOL> az . zoneState = '<STR_LIT>' <EOL> az . _info [ '<STR_LIT>' ] = az . zoneName <EOL> az . _info [ '<STR_LIT>' ] = az . zoneState <EOL> result . append ( az ) <EOL> for ( svc , state ) in services . items ( ) : <EOL> az = AvailabilityZone ( zone . manager , <EOL> copy . deepcopy ( zone . _info ) , zone . _loaded ) <EOL> az . zoneName = '<STR_LIT>' % svc <EOL> az . zoneState = '<STR_LIT>' % ( <EOL> '<STR_LIT>' if state [ '<STR_LIT>' ] else '<STR_LIT>' , <EOL> '<STR_LIT>' if state [ '<STR_LIT>' ] else '<STR_LIT>' , <EOL> state [ '<STR_LIT>' ] ) <EOL> az . _info [ '<STR_LIT>' ] = az . zoneName <EOL> az . _info [ '<STR_LIT>' ] = az . zoneState <EOL> result . append ( az ) <EOL> return result <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_availability_zone_list ( cs , _args ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> availability_zones = cs . availability_zones . list ( ) <EOL> except exceptions . Forbidden as e : <EOL> try : <EOL> availability_zones = cs . availability_zones . list ( detailed = False ) <EOL> except Exception : <EOL> raise e <EOL> result = [ ] <EOL> for zone in availability_zones : <EOL> result += _treeizeAvailabilityZone ( zone ) <EOL> _translate_availability_zone_keys ( result ) <EOL> utils . print_list ( result , [ '<STR_LIT:Name>' , '<STR_LIT>' ] ) <EOL> def _print_volume_encryption_type_list ( encryption_types ) : <EOL> """<STR_LIT>""" <EOL> utils . print_list ( encryption_types , [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_encryption_type_list ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> result = cs . volume_encryption_types . list ( ) <EOL> utils . print_list ( result , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = str , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_encryption_type_show ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume_type = _find_volume_type ( cs , args . volume_type ) <EOL> result = cs . volume_encryption_types . get ( volume_type ) <EOL> if hasattr ( result , '<STR_LIT>' ) : <EOL> _print_volume_encryption_type_list ( [ result ] ) <EOL> else : <EOL> _print_volume_encryption_type_list ( [ ] ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = str , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = str , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = str , <EOL> required = False , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> required = False , <EOL> default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> choices = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> type = str , <EOL> required = False , <EOL> default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_encryption_type_create ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume_type = _find_volume_type ( cs , args . volume_type ) <EOL> body = { <EOL> '<STR_LIT>' : args . provider , <EOL> '<STR_LIT>' : args . cipher , <EOL> '<STR_LIT>' : args . key_size , <EOL> '<STR_LIT>' : args . control_location <EOL> } <EOL> result = cs . volume_encryption_types . create ( volume_type , body ) <EOL> _print_volume_encryption_type_list ( [ result ] ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> type = str , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_encryption_type_delete ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume_type = _find_volume_type ( cs , args . volume_type ) <EOL> cs . volume_encryption_types . delete ( volume_type ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT:host>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> choices = [ '<STR_LIT:True>' , '<STR_LIT:False>' ] , required = False , <EOL> default = False , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_migrate ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> volume . migrate_volume ( args . host , args . force_host_copy ) <EOL> def _print_qos_specs ( qos_specs ) : <EOL> utils . print_dict ( qos_specs . _info ) <EOL> def _print_qos_specs_list ( q_specs ) : <EOL> utils . print_list ( q_specs , [ '<STR_LIT>' , '<STR_LIT:Name>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def _print_qos_specs_and_associations_list ( q_specs ) : <EOL> utils . print_list ( q_specs , [ '<STR_LIT>' , '<STR_LIT:Name>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def _print_associations_list ( associations ) : <EOL> utils . print_list ( associations , [ '<STR_LIT>' , '<STR_LIT:Name>' , '<STR_LIT>' ] ) <EOL> @ utils . arg ( '<STR_LIT:name>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:+>' , <EOL> default = [ ] , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_qos_create ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> keypair = None <EOL> if args . metadata is not None : <EOL> keypair = _extract_metadata ( args ) <EOL> qos_specs = cs . qos_specs . create ( args . name , keypair ) <EOL> _print_qos_specs ( qos_specs ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_qos_list ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> qos_specs = cs . qos_specs . list ( ) <EOL> _print_qos_specs_list ( qos_specs ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_qos_show ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> qos_specs = _find_qos_specs ( cs , args . qos_specs ) <EOL> _print_qos_specs ( qos_specs ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = False , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_qos_delete ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> force = strutils . bool_from_string ( args . force ) <EOL> qos_specs = _find_qos_specs ( cs , args . qos_specs ) <EOL> cs . qos_specs . delete ( qos_specs , force ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_qos_associate ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> cs . qos_specs . associate ( args . qos_specs , args . vol_type_id ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_qos_disassociate ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> cs . qos_specs . disassociate ( args . qos_specs , args . vol_type_id ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_qos_disassociate_all ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> cs . qos_specs . disassociate_all ( args . qos_specs ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT:action>' , <EOL> metavar = '<STR_LIT>' , <EOL> choices = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:+>' , <EOL> default = [ ] , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> def do_qos_key ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> keypair = _extract_metadata ( args ) <EOL> if args . action == '<STR_LIT>' : <EOL> cs . qos_specs . set_keys ( args . qos_specs , keypair ) <EOL> elif args . action == '<STR_LIT>' : <EOL> cs . qos_specs . unset_keys ( args . qos_specs , list ( keypair ) ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_qos_get_association ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> associations = cs . qos_specs . get_associations ( args . qos_specs ) <EOL> _print_associations_list ( associations ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT:action>' , <EOL> metavar = '<STR_LIT>' , <EOL> choices = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:+>' , <EOL> default = [ ] , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_snapshot_metadata ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> snapshot = _find_volume_snapshot ( cs , args . snapshot ) <EOL> metadata = _extract_metadata ( args ) <EOL> if args . action == '<STR_LIT>' : <EOL> metadata = snapshot . set_metadata ( metadata ) <EOL> utils . print_dict ( metadata . _info ) <EOL> elif args . action == '<STR_LIT>' : <EOL> snapshot . delete_metadata ( list ( metadata . keys ( ) ) ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_snapshot_metadata_show ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> snapshot = _find_volume_snapshot ( cs , args . snapshot ) <EOL> utils . print_dict ( snapshot . _info [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_metadata_show ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> utils . print_dict ( volume . _info [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:+>' , <EOL> default = [ ] , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_metadata_update_all ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> metadata = _extract_metadata ( args ) <EOL> metadata = volume . update_all_metadata ( metadata ) <EOL> utils . print_dict ( metadata [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:+>' , <EOL> default = [ ] , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_snapshot_metadata_update_all ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> snapshot = _find_volume_snapshot ( cs , args . snapshot ) <EOL> metadata = _extract_metadata ( args ) <EOL> metadata = snapshot . update_all_metadata ( metadata ) <EOL> utils . print_dict ( metadata ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> choices = [ '<STR_LIT:True>' , '<STR_LIT:true>' , '<STR_LIT:False>' , '<STR_LIT:false>' ] , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_readonly_mode_update ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> cs . volumes . update_readonly_flag ( volume , <EOL> strutils . bool_from_string ( args . read_only ) ) <EOL> @ utils . arg ( '<STR_LIT>' , metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> @ utils . arg ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> choices = [ '<STR_LIT:True>' , '<STR_LIT:true>' , '<STR_LIT:False>' , '<STR_LIT:false>' ] , <EOL> help = '<STR_LIT>' ) <EOL> @ utils . service_type ( '<STR_LIT>' ) <EOL> def do_set_bootable ( cs , args ) : <EOL> """<STR_LIT>""" <EOL> volume = utils . find_volume ( cs , args . volume ) <EOL> cs . volumes . set_bootable ( volume , <EOL> strutils . bool_from_string ( args . bootable ) ) </s>
