#NEWLINE# @ shared_task #NEWLINE# def backup_create( backup_uuid ) : #NEWLINE# #INDENT# backup = Backup . objects . get ( uuid = backup_uuid ) #NEWLINE# logger . debug ( 'About to perform backup for instance: %s' , backup . instance ) #NEWLINE# event_logger . openstack_backup . info ( 'Backup for {resource_name} has been scheduled.' , event_type = 'resource_backup_creation_scheduled' , event_context = { #NEWLINE# #INDENT# 'resource' : backup . instance , #NEWLINE# #UNINDENT# } ) #NEWLINE# try : #NEWLINE# #INDENT# backend = backup . get_backend ( ) #NEWLINE# backup . metadata = backend . create ( ) #NEWLINE# backup . save ( ) #NEWLINE# #UNINDENT# except BackupError : #NEWLINE# #INDENT# logger . exception ( 'Failed to perform backup for instance: %s' , backup . instance ) #NEWLINE# schedule = backup . backup_schedule #NEWLINE# if schedule : #NEWLINE# #INDENT# schedule . is_active = False #NEWLINE# schedule . save ( ) #NEWLINE# event_logger . openstack_backup . info ( 'Backup schedule for {resource_name} has been deactivated.' , event_type = 'resource_backup_schedule_deactivated' , event_context = { #NEWLINE# #INDENT# 'resource' : backup . instance , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# event_logger . openstack_backup . error ( 'Backup creation for {resource_name} has failed.' , event_type = 'resource_backup_creation_failed' , event_context = { #NEWLINE# #INDENT# 'resource' : backup . instance , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . info ( 'Successfully performed backup for instance: %s' , backup . instance ) #NEWLINE# event_logger . openstack_backup . info ( 'Backup for {resource_name} has been created.' , event_type = 'resource_backup_creation_succeeded' , event_context = { #NEWLINE# #INDENT# 'resource' : backup . instance , #NEWLINE# #UNINDENT# } )