<s> import logging <EOL> from django . core . urlresolvers import reverse <EOL> from django import shortcuts <EOL> from django . utils import html <EOL> from django . utils . text import normalize_newlines <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from django . views . decorators . debug import sensitive_variables <EOL> from horizon import exceptions <EOL> from horizon import forms <EOL> from horizon . utils import validators <EOL> from horizon import workflows <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . dashboards . project . instances import utils as instance_utils <EOL> from openstack_dashboard . dashboards . project . instances . workflows import create_instance as workflows_create_instance <EOL> from gbpui import client <EOL> from gbpui import fields <EOL> LOG = logging . getLogger ( __name__ ) <EOL> POLICY_RULE_SET_URL = "<STR_LIT>" <EOL> ADD_EXTERNAL_CONNECTIVITY = "<STR_LIT>" <EOL> class SelectPolicyRuleSetAction ( workflows . Action ) : <EOL> provided_policy_rule_set = fields . DynamicMultiChoiceField ( <EOL> label = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> add_item_link = POLICY_RULE_SET_URL , <EOL> required = False ) <EOL> consumed_policy_rule_set = fields . DynamicMultiChoiceField ( <EOL> label = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> add_item_link = POLICY_RULE_SET_URL , <EOL> required = False ) <EOL> class Meta ( object ) : <EOL> name = _ ( "<STR_LIT>" ) <EOL> help_text = _ ( "<STR_LIT>" ) <EOL> def _policy_rule_set_list ( self , request ) : <EOL> policy_rule_sets = client . policy_rule_set_list ( request , <EOL> tenant_id = request . user . tenant_id ) <EOL> for c in policy_rule_sets : <EOL> c . set_id_as_name_if_empty ( ) <EOL> policy_rule_sets = sorted ( policy_rule_sets , <EOL> key = lambda rule : rule . name ) <EOL> return [ ( c . id , c . name ) for c in policy_rule_sets ] <EOL> def populate_provided_policy_rule_set_choices ( self , request , context ) : <EOL> policy_rule_set_list = [ ] <EOL> try : <EOL> rsets = self . _policy_rule_set_list ( request ) <EOL> if len ( rsets ) == <NUM_LIT:0> : <EOL> rsets . extend ( [ ( '<STR_LIT:None>' , '<STR_LIT>' ) ] ) <EOL> policy_rule_set_list = rsets <EOL> except Exception as e : <EOL> policy_rule_set_list = [ ] <EOL> msg = _ ( '<STR_LIT>' ) % ( str ( e ) ) <EOL> exceptions . handle ( request , msg ) <EOL> return policy_rule_set_list <EOL> def populate_consumed_policy_rule_set_choices ( self , request , context ) : <EOL> policy_rule_set_list = [ ] <EOL> try : <EOL> policy_rule_set_list = [ ( '<STR_LIT:None>' , '<STR_LIT>' ) ] <EOL> policy_rule_set_list = self . _policy_rule_set_list ( request ) <EOL> except Exception as e : <EOL> msg = _ ( '<STR_LIT>' ) % ( str ( e ) ) <EOL> exceptions . handle ( request , msg ) <EOL> return policy_rule_set_list <EOL> class SelectL2policyAction ( workflows . Action ) : <EOL> l2policy_id = forms . ChoiceField ( <EOL> label = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) ) <EOL> network_service_policy_id = forms . ChoiceField ( <EOL> label = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> required = False ) <EOL> class Meta ( object ) : <EOL> name = _ ( "<STR_LIT>" ) <EOL> help_text = _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def populate_l2policy_id_choices ( self , request , context ) : <EOL> policies = [ ] <EOL> try : <EOL> policies = client . l2policy_list ( request , <EOL> tenant_id = request . user . tenant_id ) <EOL> for p in policies : <EOL> p . set_id_as_name_if_empty ( ) <EOL> policies = sorted ( policies , key = lambda rule : rule . name ) <EOL> policies = [ ( p . id , p . name + "<STR_LIT::>" + p . id ) for p in policies ] <EOL> policies . insert ( <NUM_LIT:0> , ( '<STR_LIT:default>' , '<STR_LIT>' ) ) <EOL> except Exception as e : <EOL> exceptions . handle ( request , <EOL> _ ( "<STR_LIT>" ) <EOL> % { '<STR_LIT:error>' : str ( e ) } ) <EOL> return policies <EOL> def populate_network_service_policy_id_choices ( self , request , context ) : <EOL> policies = [ ] <EOL> try : <EOL> policies = client . networkservicepolicy_list ( request , <EOL> tenant_id = request . user . tenant_id ) <EOL> for p in policies : <EOL> p . set_id_as_name_if_empty ( ) <EOL> policies = [ ( p . id , p . name + "<STR_LIT::>" + p . id ) for p in policies ] <EOL> policies . insert ( <NUM_LIT:0> , ( '<STR_LIT:None>' , '<STR_LIT>' ) ) <EOL> except Exception as e : <EOL> msg = _ ( "<STR_LIT>" ) % ( str ( e ) ) <EOL> exceptions . handle ( request , msg ) <EOL> return policies <EOL> class SelectL2policyStep ( workflows . Step ) : <EOL> action_class = SelectL2policyAction <EOL> name = _ ( "<STR_LIT>" ) <EOL> contributes = ( "<STR_LIT>" , "<STR_LIT>" , ) <EOL> def contribute ( self , data , context ) : <EOL> if data [ '<STR_LIT>' ] != '<STR_LIT:default>' : <EOL> context [ '<STR_LIT>' ] = data [ '<STR_LIT>' ] <EOL> if data [ '<STR_LIT>' ] != '<STR_LIT:None>' : <EOL> context [ '<STR_LIT>' ] = data [ '<STR_LIT>' ] <EOL> return context <EOL> class SelectPolicyRuleSetStep ( workflows . Step ) : <EOL> action_class = SelectPolicyRuleSetAction <EOL> name = _ ( "<STR_LIT>" ) <EOL> contributes = ( "<STR_LIT>" , "<STR_LIT>" , ) <EOL> def contribute ( self , data , context ) : <EOL> if data : <EOL> policy_rule_sets = self . workflow . request . POST . getlist ( <EOL> "<STR_LIT>" ) <EOL> if policy_rule_sets : <EOL> policy_rule_set_dict = { } <EOL> for policy_rule_set in policy_rule_sets : <EOL> if policy_rule_set != '<STR_LIT:None>' : <EOL> policy_rule_set_dict [ policy_rule_set ] = None <EOL> context [ '<STR_LIT>' ] = policy_rule_set_dict <EOL> policy_rule_sets = self . workflow . request . POST . getlist ( <EOL> "<STR_LIT>" ) <EOL> if policy_rule_sets : <EOL> policy_rule_set_dict = { } <EOL> for policy_rule_set in policy_rule_sets : <EOL> if policy_rule_set != '<STR_LIT:None>' : <EOL> policy_rule_set_dict [ policy_rule_set ] = None <EOL> context [ '<STR_LIT>' ] = policy_rule_set_dict <EOL> return context <EOL> class AddPTGAction ( workflows . Action ) : <EOL> name = forms . CharField ( max_length = <NUM_LIT> , <EOL> label = _ ( "<STR_LIT:Name>" ) ) <EOL> description = forms . CharField ( max_length = <NUM_LIT> , <EOL> label = _ ( "<STR_LIT>" ) , <EOL> required = False ) <EOL> shared = forms . BooleanField ( label = _ ( "<STR_LIT>" ) , <EOL> initial = False , required = False ) <EOL> def __init__ ( self , request , * args , ** kwargs ) : <EOL> super ( AddPTGAction , self ) . __init__ ( request , * args , ** kwargs ) <EOL> class Meta ( object ) : <EOL> name = _ ( "<STR_LIT>" ) <EOL> help_text = _ ( "<STR_LIT>" ) <EOL> class AddPTGStep ( workflows . Step ) : <EOL> action_class = AddPTGAction <EOL> contributes = ( "<STR_LIT:name>" , "<STR_LIT:description>" , "<STR_LIT>" ) <EOL> def contribute ( self , data , context ) : <EOL> context = super ( AddPTGStep , self ) . contribute ( data , context ) <EOL> return context <EOL> class AddPTG ( workflows . Workflow ) : <EOL> slug = "<STR_LIT>" <EOL> name = _ ( "<STR_LIT>" ) <EOL> finalize_button_name = _ ( "<STR_LIT>" ) <EOL> success_message = _ ( '<STR_LIT>' ) <EOL> failure_message = _ ( '<STR_LIT>' ) <EOL> success_url = "<STR_LIT>" <EOL> default_steps = ( AddPTGStep , <EOL> SelectPolicyRuleSetStep , <EOL> SelectL2policyStep , ) <EOL> wizard = True <EOL> def format_status_message ( self , message ) : <EOL> return message % self . context . get ( '<STR_LIT:name>' ) <EOL> def handle ( self , request , context ) : <EOL> try : <EOL> if context . get ( '<STR_LIT:name>' ) : <EOL> context [ '<STR_LIT:name>' ] = html . escape ( context [ '<STR_LIT:name>' ] ) <EOL> if context . get ( '<STR_LIT:description>' ) : <EOL> context [ '<STR_LIT:description>' ] = html . escape ( context [ '<STR_LIT:description>' ] ) <EOL> group = client . policy_target_create ( request , ** context ) <EOL> return group <EOL> except Exception as e : <EOL> msg = self . format_status_message ( self . failure_message ) + str ( e ) <EOL> exceptions . handle ( request , msg ) <EOL> return False <EOL> class ExternalConnectivityAction ( workflows . Action ) : <EOL> external_segments = fields . DynamicMultiChoiceField ( <EOL> label = _ ( "<STR_LIT>" ) , <EOL> required = True , <EOL> add_item_link = ADD_EXTERNAL_CONNECTIVITY , <EOL> help_text = _ ( "<STR_LIT>" ) ) <EOL> class Meta ( object ) : <EOL> name = _ ( "<STR_LIT>" ) <EOL> help_text = _ ( <EOL> "<STR_LIT>" ) <EOL> def populate_external_segments_choices ( self , request , context ) : <EOL> external_connectivities = [ ] <EOL> try : <EOL> external_connectivities = client . externalconnectivity_list ( <EOL> request , tenant_id = request . user . tenant_id ) <EOL> for p in external_connectivities : <EOL> p . set_id_as_name_if_empty ( ) <EOL> ext_conn_list = sorted ( external_connectivities , <EOL> key = lambda segment : segment . name ) <EOL> ext_conn_list = [ ( p . id , p . name + "<STR_LIT::>" + p . id ) for p in ext_conn_list ] <EOL> except Exception as e : <EOL> exceptions . handle ( request , <EOL> _ ( "<STR_LIT>" ) <EOL> % { '<STR_LIT:error>' : str ( e ) } ) <EOL> return ext_conn_list <EOL> class ExternalConnectivityStep ( workflows . Step ) : <EOL> action_class = ExternalConnectivityAction <EOL> name = _ ( "<STR_LIT>" ) <EOL> contributes = ( "<STR_LIT>" , ) <EOL> def contribute ( self , data , context ) : <EOL> context [ '<STR_LIT>' ] = data . get ( '<STR_LIT>' , [ ] ) <EOL> return context <EOL> class ExtAddPTGAction ( workflows . Action ) : <EOL> name = forms . CharField ( max_length = <NUM_LIT> , <EOL> label = _ ( "<STR_LIT:Name>" ) ) <EOL> description = forms . CharField ( max_length = <NUM_LIT> , <EOL> label = _ ( "<STR_LIT>" ) , <EOL> required = False ) <EOL> shared = forms . BooleanField ( label = _ ( "<STR_LIT>" ) , <EOL> initial = False , required = False ) <EOL> def __init__ ( self , request , * args , ** kwargs ) : <EOL> super ( ExtAddPTGAction , self ) . __init__ ( request , * args , ** kwargs ) <EOL> class Meta ( object ) : <EOL> name = _ ( "<STR_LIT>" ) <EOL> help_text = _ ( "<STR_LIT>" ) <EOL> class ExtAddPTGStep ( workflows . Step ) : <EOL> action_class = ExtAddPTGAction <EOL> contributes = ( "<STR_LIT:name>" , "<STR_LIT:description>" , "<STR_LIT>" ) <EOL> def contribute ( self , data , context ) : <EOL> context = super ( ExtAddPTGStep , self ) . contribute ( data , context ) <EOL> return context <EOL> class AddExternalPTG ( workflows . Workflow ) : <EOL> slug = "<STR_LIT>" <EOL> name = _ ( "<STR_LIT>" ) <EOL> finalize_button_name = _ ( "<STR_LIT>" ) <EOL> success_message = _ ( '<STR_LIT>' ) <EOL> failure_message = _ ( '<STR_LIT>' ) <EOL> success_url = "<STR_LIT>" <EOL> default_steps = ( ExtAddPTGStep , <EOL> SelectPolicyRuleSetStep , <EOL> ExternalConnectivityStep , ) <EOL> wizard = True <EOL> def format_status_message ( self , message ) : <EOL> return message % self . context . get ( '<STR_LIT:name>' ) <EOL> def handle ( self , request , context ) : <EOL> try : <EOL> if context . get ( '<STR_LIT:name>' ) : <EOL> context [ '<STR_LIT:name>' ] = html . escape ( context [ '<STR_LIT:name>' ] ) <EOL> if context . get ( '<STR_LIT:description>' ) : <EOL> context [ '<STR_LIT:description>' ] = html . escape ( context [ '<STR_LIT:description>' ] ) <EOL> group = client . ext_policy_target_create ( request , ** context ) <EOL> return group <EOL> except Exception as e : <EOL> msg = self . format_status_message ( self . failure_message ) + str ( e ) <EOL> exceptions . handle ( request , msg ) <EOL> return False <EOL> KEYPAIR_IMPORT_URL = "<STR_LIT>" <EOL> class SetAccessControlsAction ( workflows . Action ) : <EOL> keypair = forms . DynamicChoiceField ( label = _ ( "<STR_LIT>" ) , <EOL> required = False , <EOL> help_text = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> add_item_link = KEYPAIR_IMPORT_URL ) <EOL> admin_pass = forms . RegexField ( <EOL> label = _ ( "<STR_LIT>" ) , <EOL> required = False , <EOL> widget = forms . PasswordInput ( render_value = False ) , <EOL> regex = validators . password_validator ( ) , <EOL> error_messages = { '<STR_LIT>' : validators . password_validator_msg ( ) } ) <EOL> confirm_admin_pass = forms . CharField ( <EOL> label = _ ( "<STR_LIT>" ) , <EOL> required = False , <EOL> widget = forms . PasswordInput ( render_value = False ) ) <EOL> class Meta ( object ) : <EOL> name = _ ( "<STR_LIT>" ) <EOL> help_text = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def __init__ ( self , request , * args , ** kwargs ) : <EOL> super ( SetAccessControlsAction , self ) . __init__ ( request , * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] . choices = instance_utils . keypair_field_data ( <EOL> request , True ) <EOL> if not api . nova . can_set_server_password ( ) : <EOL> del self . fields [ '<STR_LIT>' ] <EOL> del self . fields [ '<STR_LIT>' ] <EOL> def clean ( self ) : <EOL> '''<STR_LIT>''' <EOL> cleaned_data = super ( SetAccessControlsAction , self ) . clean ( ) <EOL> if '<STR_LIT>' in cleaned_data : <EOL> if cleaned_data [ '<STR_LIT>' ] != cleaned_data . get ( <EOL> '<STR_LIT>' , None ) : <EOL> raise forms . ValidationError ( _ ( '<STR_LIT>' ) ) <EOL> return cleaned_data <EOL> class SetAccessControls ( workflows . Step ) : <EOL> action_class = SetAccessControlsAction <EOL> depends_on = ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> contributes = ( "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> def contribute ( self , data , context ) : <EOL> if data : <EOL> post = self . workflow . request . POST <EOL> context [ '<STR_LIT>' ] = post . getlist ( "<STR_LIT>" ) <EOL> context [ '<STR_LIT>' ] = data . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> context [ '<STR_LIT>' ] = data . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> context [ '<STR_LIT>' ] = data . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> return context <EOL> class SetGroupAction ( workflows . Action ) : <EOL> network = forms . MultipleChoiceField ( label = _ ( "<STR_LIT>" ) , <EOL> widget = forms . CheckboxSelectMultiple ( ) , <EOL> error_messages = { <EOL> '<STR_LIT>' : _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) } , <EOL> help_text = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> widget = forms . HiddenInput ( ) <EOL> def __init__ ( self , request , * args , ** kwargs ) : <EOL> super ( SetGroupAction , self ) . __init__ ( request , * args , ** kwargs ) <EOL> policy_targetid = self . request . path . split ( "<STR_LIT:/>" ) [ - <NUM_LIT:2> ] <EOL> self . fields [ '<STR_LIT>' ] . initial = [ policy_targetid ] <EOL> class Meta ( object ) : <EOL> name = _ ( "<STR_LIT>" ) <EOL> help_text = _ ( "<STR_LIT>" ) <EOL> def populate_network_choices ( self , request , context ) : <EOL> try : <EOL> pt_list = [ ] <EOL> pts = client . policy_target_list ( request , <EOL> tenant_id = request . user . tenant_id ) <EOL> for pt in pts : <EOL> pt . set_id_as_name_if_empty ( ) <EOL> pt_list . append ( ( pt . id , pt . name ) ) <EOL> return sorted ( pt_list , key = lambda obj : obj [ <NUM_LIT:1> ] ) <EOL> except Exception : <EOL> msg = _ ( "<STR_LIT>" ) <EOL> LOG . error ( msg ) <EOL> exceptions . handle ( request , msg , redirect = shortcuts . redirect ) <EOL> class SetGroup ( workflows . Step ) : <EOL> action_class = SetGroupAction <EOL> template_name = "<STR_LIT>" <EOL> contributes = ( "<STR_LIT>" , ) <EOL> def contribute ( self , data , context ) : <EOL> if data : <EOL> groups = self . workflow . request . POST . getlist ( "<STR_LIT>" ) <EOL> groups = [ n for n in groups if n != '<STR_LIT>' ] <EOL> if groups : <EOL> context [ '<STR_LIT>' ] = groups <EOL> return context <EOL> class LaunchInstance ( workflows . Workflow ) : <EOL> slug = "<STR_LIT>" <EOL> name = _ ( "<STR_LIT>" ) <EOL> finalize_button_name = _ ( "<STR_LIT>" ) <EOL> success_message = _ ( '<STR_LIT>' ) <EOL> multipart = True <EOL> default_steps = ( workflows_create_instance . SelectProjectUser , <EOL> workflows_create_instance . SetInstanceDetails , <EOL> SetAccessControls , <EOL> SetGroup , <EOL> workflows_create_instance . PostCreationStep , <EOL> workflows_create_instance . SetAdvanced ) <EOL> def format_status_message ( self , message ) : <EOL> count = self . context . get ( '<STR_LIT:count>' , <NUM_LIT:1> ) <EOL> if int ( count ) > <NUM_LIT:1> : <EOL> return message % { "<STR_LIT:count>" : _ ( "<STR_LIT>" ) % count } <EOL> else : <EOL> return message % { "<STR_LIT:count>" : _ ( "<STR_LIT>" ) } <EOL> def get_success_url ( self ) : <EOL> policy_targetid = self . request . path . split ( "<STR_LIT:/>" ) [ - <NUM_LIT:2> ] <EOL> u = "<STR_LIT>" <EOL> success_url = reverse ( u , kwargs = { '<STR_LIT>' : policy_targetid } ) <EOL> return success_url <EOL> @ sensitive_variables ( '<STR_LIT>' ) <EOL> def handle ( self , request , context ) : <EOL> custom_script = context . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> dev_mapping_1 = None <EOL> dev_mapping_2 = None <EOL> image_id = '<STR_LIT>' <EOL> source_type = context . get ( '<STR_LIT>' , None ) <EOL> if source_type in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> image_id = context [ '<STR_LIT>' ] <EOL> elif source_type in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> try : <EOL> if api . nova . extension_supported ( "<STR_LIT>" , <EOL> request ) : <EOL> volume_source_id = context [ '<STR_LIT>' ] . split ( '<STR_LIT::>' ) [ <NUM_LIT:0> ] <EOL> device_name = context . get ( '<STR_LIT>' , '<STR_LIT>' ) . strip ( ) or None <EOL> dev_source_type_mapping = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> dev_mapping_2 = [ <EOL> { '<STR_LIT>' : device_name , <EOL> '<STR_LIT>' : dev_source_type_mapping [ source_type ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> int ( bool ( context [ '<STR_LIT>' ] ) ) , <EOL> '<STR_LIT>' : volume_source_id , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : context [ '<STR_LIT>' ] <EOL> } <EOL> ] <EOL> else : <EOL> dev_mapping_1 = { context [ '<STR_LIT>' ] : '<STR_LIT>' % <EOL> ( context [ '<STR_LIT>' ] , <EOL> int ( bool ( context [ '<STR_LIT>' ] ) ) ) <EOL> } <EOL> except Exception : <EOL> msg = _ ( '<STR_LIT>' ) <EOL> exceptions . handle ( request , msg ) <EOL> elif source_type == '<STR_LIT>' : <EOL> device_name = context . get ( '<STR_LIT>' , '<STR_LIT>' ) . strip ( ) or None <EOL> dev_mapping_2 = [ <EOL> { '<STR_LIT>' : device_name , <EOL> '<STR_LIT>' : '<STR_LIT:image>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <EOL> int ( bool ( context [ '<STR_LIT>' ] ) ) , <EOL> '<STR_LIT>' : context [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : context [ '<STR_LIT>' ] <EOL> } <EOL> ] <EOL> avail_zone = context . get ( '<STR_LIT>' , None ) <EOL> try : <EOL> instance_count = int ( context [ '<STR_LIT:count>' ] ) <EOL> count = <NUM_LIT:1> <EOL> while count <= instance_count : <EOL> if instance_count == <NUM_LIT:1> : <EOL> instance_name = context [ '<STR_LIT:name>' ] <EOL> else : <EOL> instance_name = context [ '<STR_LIT:name>' ] + str ( count ) <EOL> nics = [ ] <EOL> for ptg_id in context [ '<STR_LIT>' ] : <EOL> ep = client . pt_create ( <EOL> request , policy_target_group_id = ptg_id , <EOL> name = instance_name [ : <NUM_LIT> ] + "<STR_LIT>" ) <EOL> nics . append ( { '<STR_LIT>' : ep . port_id } ) <EOL> api . nova . server_create ( request , <EOL> instance_name , <EOL> image_id , <EOL> context [ '<STR_LIT>' ] , <EOL> context [ '<STR_LIT>' ] , <EOL> normalize_newlines ( custom_script ) , <EOL> security_groups = None , <EOL> block_device_mapping = dev_mapping_1 , <EOL> block_device_mapping_v2 = dev_mapping_2 , <EOL> nics = nics , <EOL> availability_zone = avail_zone , <EOL> instance_count = <NUM_LIT:1> , <EOL> admin_pass = context [ '<STR_LIT>' ] , <EOL> disk_config = context . get ( '<STR_LIT>' ) , <EOL> config_drive = context . get ( '<STR_LIT>' ) ) <EOL> count += <NUM_LIT:1> <EOL> return True <EOL> except Exception : <EOL> error = _ ( "<STR_LIT>" ) <EOL> msg = error % { '<STR_LIT:count>' : count , '<STR_LIT:name>' : instance_name } <EOL> LOG . error ( msg ) <EOL> u = "<STR_LIT>" <EOL> policy_target_id = self . request . path . split ( "<STR_LIT:/>" ) [ - <NUM_LIT:2> ] <EOL> redirect = reverse ( u , kwargs = { '<STR_LIT>' : <EOL> policy_target_id } ) <EOL> exceptions . handle ( request , msg , redirect = redirect ) <EOL> return False </s>
