<s> from django . utils . translation import ugettext_lazy as _ <EOL> from horizon import exceptions <EOL> from horizon import forms <EOL> from horizon import messages <EOL> from openstack_dashboard . api import cinder <EOL> class CreateVolumeType ( forms . SelfHandlingForm ) : <EOL> name = forms . CharField ( max_length = <NUM_LIT:255> , label = _ ( "<STR_LIT:Name>" ) ) <EOL> def handle ( self , request , data ) : <EOL> try : <EOL> volume_type = cinder . volume_type_create ( request , <EOL> data [ '<STR_LIT:name>' ] ) <EOL> messages . success ( request , _ ( '<STR_LIT>' ) <EOL> % data [ '<STR_LIT:name>' ] ) <EOL> return volume_type <EOL> except Exception : <EOL> exceptions . handle ( request , <EOL> _ ( '<STR_LIT>' ) ) <EOL> return False <EOL> class UpdateStatus ( forms . SelfHandlingForm ) : <EOL> status = forms . ChoiceField ( label = _ ( "<STR_LIT>" ) ) <EOL> def __init__ ( self , request , * args , ** kwargs ) : <EOL> super ( forms . SelfHandlingForm , self ) . __init__ ( request , * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT:status>' ] . choices = ( <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT:error>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ) <EOL> def handle ( self , request , data ) : <EOL> for choice in self . fields [ '<STR_LIT:status>' ] . choices : <EOL> if choice [ <NUM_LIT:0> ] == data [ '<STR_LIT:status>' ] : <EOL> new_status = choice [ <NUM_LIT:1> ] <EOL> break <EOL> else : <EOL> new_status = data [ '<STR_LIT:status>' ] <EOL> try : <EOL> cinder . volume_reset_state ( request , <EOL> self . initial [ '<STR_LIT>' ] , <EOL> data [ '<STR_LIT:status>' ] ) <EOL> messages . success ( request , <EOL> _ ( '<STR_LIT>' ) % <EOL> new_status ) <EOL> return True <EOL> except Exception : <EOL> exceptions . handle ( request , <EOL> _ ( '<STR_LIT>' ) % <EOL> new_status ) <EOL> return False <EOL> class CreateQosSpec ( forms . SelfHandlingForm ) : <EOL> name = forms . CharField ( max_length = <NUM_LIT:255> , label = _ ( "<STR_LIT:Name>" ) ) <EOL> consumer = forms . ChoiceField ( label = _ ( "<STR_LIT>" ) , <EOL> choices = cinder . CONSUMER_CHOICES ) <EOL> def handle ( self , request , data ) : <EOL> try : <EOL> qos_spec = cinder . qos_spec_create ( request , <EOL> data [ '<STR_LIT:name>' ] , <EOL> { '<STR_LIT>' : data [ '<STR_LIT>' ] } ) <EOL> messages . success ( request , <EOL> _ ( '<STR_LIT>' ) <EOL> % data [ '<STR_LIT:name>' ] ) <EOL> return qos_spec <EOL> except Exception : <EOL> exceptions . handle ( request , <EOL> _ ( '<STR_LIT>' ) ) <EOL> return False </s>
