#NEWLINE# def associate_address( self , req , id , body ) : #NEWLINE# #INDENT# ' /zadr-vsa/{vsa_id}/associate_address\n        auto or manually associate an IP to VSA\n        ' #NEWLINE# context = req . environ [ 'nova.context' ] #NEWLINE# if ( body is None ) : #NEWLINE# #INDENT# ip = 'auto' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ip = body . get ( 'ipAddress' , 'auto' ) #NEWLINE# #UNINDENT# LOG . audit ( _ ( 'Associate address %(ip)s to VSA %(id)s' ) , locals ( ) , context = context ) #NEWLINE# try : #NEWLINE# #INDENT# instances = self . _get_instances_by_vsa_id ( context , id ) #NEWLINE# if ( ( instances is None ) or ( len ( instances ) == 0 ) ) : #NEWLINE# #INDENT# return faults . Fault ( exc . HTTPNotFound ( ) ) #NEWLINE# #UNINDENT# for instance in instances : #NEWLINE# #INDENT# self . network_api . allocate_for_instance ( context , instance , vpn = False ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# except exception . NotFound : #NEWLINE# #INDENT# return faults . Fault ( exc . HTTPNotFound ( ) )