#NEWLINE# def handle( self , request , context ) : #NEWLINE# #INDENT# aggregate_id = context [ 'id' ] #NEWLINE# aggregate = api . nova . aggregate_get ( request , aggregate_id ) #NEWLINE# current_aggregate_hosts = set ( aggregate . hosts ) #NEWLINE# context_hosts_aggregate = set ( context [ 'hosts_aggregate' ] ) #NEWLINE# removed_hosts = ( current_aggregate_hosts - context_hosts_aggregate ) #NEWLINE# added_hosts = ( context_hosts_aggregate - current_aggregate_hosts ) #NEWLINE# try : #NEWLINE# #INDENT# for host in removed_hosts : #NEWLINE# #INDENT# api . nova . remove_host_from_aggregate ( request , aggregate_id , host ) #NEWLINE# #UNINDENT# for host in added_hosts : #NEWLINE# #INDENT# api . nova . add_host_to_aggregate ( request , aggregate_id , host ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# exceptions . handle ( request , _ ( 'Error when adding or removing hosts.' ) ) #NEWLINE# return False #NEWLINE# #UNINDENT# return True