<s> """<STR_LIT>""" <EOL> import logging <EOL> import six <EOL> from cliff import command <EOL> from cliff import lister <EOL> from cliff import show <EOL> from openstackclient . common import utils <EOL> from senlinclient . common . i18n import _ <EOL> from senlinclient . common import utils as senlin_utils <EOL> class ClusterPolicyList ( lister . Lister ) : <EOL> """<STR_LIT>""" <EOL> log = logging . getLogger ( __name__ + "<STR_LIT>" ) <EOL> def get_parser ( self , prog_name ) : <EOL> parser = super ( ClusterPolicyList , self ) . get_parser ( prog_name ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> action = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> default = False , <EOL> action = "<STR_LIT:store_true>" , <EOL> help = _ ( '<STR_LIT>' ) <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = _ ( '<STR_LIT>' ) <EOL> ) <EOL> return parser <EOL> def take_action ( self , parsed_args ) : <EOL> self . log . debug ( "<STR_LIT>" , parsed_args ) <EOL> senlin_client = self . app . client_manager . clustering <EOL> columns = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> cluster = senlin_client . get_cluster ( parsed_args . cluster ) <EOL> queries = { <EOL> '<STR_LIT>' : parsed_args . sort , <EOL> } <EOL> if parsed_args . filters : <EOL> queries . update ( senlin_utils . format_parameters ( parsed_args . filters ) ) <EOL> policies = senlin_client . cluster_policies ( cluster . id , ** queries ) <EOL> formatters = { } <EOL> if not parsed_args . full_id : <EOL> formatters = { <EOL> '<STR_LIT>' : lambda x : x [ : <NUM_LIT:8> ] <EOL> } <EOL> return ( <EOL> columns , <EOL> ( utils . get_item_properties ( p , columns , formatters = formatters ) <EOL> for p in policies ) <EOL> ) <EOL> class ClusterPolicyShow ( show . ShowOne ) : <EOL> """<STR_LIT>""" <EOL> log = logging . getLogger ( __name__ + "<STR_LIT>" ) <EOL> def get_parser ( self , prog_name ) : <EOL> parser = super ( ClusterPolicyShow , self ) . get_parser ( prog_name ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> required = True , <EOL> help = _ ( '<STR_LIT>' ) <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = _ ( '<STR_LIT>' ) <EOL> ) <EOL> return parser <EOL> def take_action ( self , parsed_args ) : <EOL> self . log . debug ( "<STR_LIT>" , parsed_args ) <EOL> senlin_client = self . app . client_manager . clustering <EOL> policy = senlin_client . get_cluster_policy ( parsed_args . policy , <EOL> parsed_args . cluster ) <EOL> columns = sorted ( list ( six . iterkeys ( policy ) ) ) <EOL> return columns , utils . get_dict_properties ( policy . to_dict ( ) , columns ) <EOL> class ClusterPolicyUpdate ( command . Command ) : <EOL> """<STR_LIT>""" <EOL> log = logging . getLogger ( __name__ + "<STR_LIT>" ) <EOL> def get_parser ( self , prog_name ) : <EOL> parser = super ( ClusterPolicyUpdate , self ) . get_parser ( prog_name ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> required = True , <EOL> help = _ ( '<STR_LIT>' ) <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> required = True , <EOL> help = _ ( '<STR_LIT>' ) <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = _ ( '<STR_LIT>' ) <EOL> ) <EOL> return parser <EOL> def take_action ( self , parsed_args ) : <EOL> self . log . debug ( "<STR_LIT>" , parsed_args ) <EOL> senlin_client = self . app . client_manager . clustering <EOL> kwargs = { <EOL> '<STR_LIT>' : parsed_args . enabled , <EOL> } <EOL> resp = senlin_client . cluster_update_policy ( parsed_args . cluster , <EOL> parsed_args . policy , <EOL> ** kwargs ) <EOL> print ( '<STR_LIT>' % resp [ '<STR_LIT:action>' ] ) </s>
