<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 import api <EOL> from openstack_dashboard . dashboards . admin . aggregates import constants <EOL> INDEX_URL = constants . AGGREGATES_INDEX_URL <EOL> class UpdateAggregateForm ( forms . SelfHandlingForm ) : <EOL> name = forms . CharField ( label = _ ( "<STR_LIT:Name>" ) , <EOL> max_length = <NUM_LIT:255> ) <EOL> availability_zone = forms . CharField ( label = _ ( "<STR_LIT>" ) , <EOL> required = False , <EOL> max_length = <NUM_LIT:255> ) <EOL> def handle ( self , request , data ) : <EOL> id = self . initial [ '<STR_LIT:id>' ] <EOL> name = data [ '<STR_LIT:name>' ] <EOL> availability_zone = data [ '<STR_LIT>' ] <EOL> aggregate = { '<STR_LIT:name>' : name } <EOL> if availability_zone : <EOL> aggregate [ '<STR_LIT>' ] = availability_zone <EOL> try : <EOL> api . nova . aggregate_update ( request , id , aggregate ) <EOL> message = ( _ ( '<STR_LIT>' ) <EOL> % data [ '<STR_LIT:name>' ] ) <EOL> messages . success ( request , message ) <EOL> except Exception : <EOL> exceptions . handle ( request , <EOL> _ ( '<STR_LIT>' ) ) <EOL> return True </s>
