#NEWLINE# @ staticmethod #NEWLINE# def _create_container_job( conn , container , headers = None , policy_source = None ) : #NEWLINE# #INDENT# '\n        Create a container using the given connection\n\n        :param conn: The swift connection used for requests.\n        :param container: The container name to create.\n        :param headers: An optional dict of headers for the\n                        put_container request.\n        :param policy_source: An optional name of a container whose policy we\n                              should duplicate.\n        :return: A dict containing the results of the operation.\n        ' #NEWLINE# res = { #NEWLINE# #INDENT# 'action' : 'create_container' , #NEWLINE# 'container' : container , #NEWLINE# 'headers' : headers , #NEWLINE# #UNINDENT# } #NEWLINE# create_response = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# if ( policy_source is not None ) : #NEWLINE# #INDENT# _meta = conn . head_container ( policy_source ) #NEWLINE# if ( 'x-storage-policy' in _meta ) : #NEWLINE# #INDENT# policy_header = { #NEWLINE# #INDENT# POLICY : _meta . get ( 'x-storage-policy' ) , #NEWLINE# #UNINDENT# } #NEWLINE# if ( headers is None ) : #NEWLINE# #INDENT# headers = policy_header #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# headers . update ( policy_header ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# conn . put_container ( container , headers , response_dict = create_response ) #NEWLINE# res . update ( { #NEWLINE# #INDENT# 'success' : True , #NEWLINE# 'response_dict' : create_response , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except Exception as err : #NEWLINE# #INDENT# ( traceback , err_time ) = report_traceback ( ) #NEWLINE# logger . exception ( err ) #NEWLINE# res . update ( { #NEWLINE# #INDENT# 'success' : False , #NEWLINE# 'error' : err , #NEWLINE# 'traceback' : traceback , #NEWLINE# 'error_timestamp' : err_time , #NEWLINE# 'response_dict' : create_response , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return res