def start(self): """This is the archive method. Uses archive (TAR) feature to compress files and then upload the TAR Ball to a specified container. """ report.reporter(msg='Toggling CDN on Container %s.' % ARGS.get('container')) # Package up the Payload payload = http.prep_payload(auth=self.auth, container=ARGS.get('container', basic.rand_string()), source=None, args=ARGS) report.reporter(msg='PAYLOAD\t: "%s"' % payload, log=True, lvl='debug', prt=False) # Set the actions class up self.go = actions.CloudActions(payload=payload) with multi.spinner(): if ARGS.get('purge'): for obj in ARGS.get('purge'): # Perform the purge self.go.container_cdn_command(url=payload['cnet'], container=payload['c_name'], sfile=obj) else: self.go.container_cdn_command(url=payload['cnet'], container=payload['c_name'])
def start(self): """This is the upload method. Uses file_upload is to simply upload all files and folders to a specified container. """ # Index Local Files for Upload with multi.spinner(): f_indexed = methods.get_local_files() if ARGS.get('pattern_match'): f_indexed = basic.match_filter( idx_list=f_indexed, pattern=ARGS['pattern_match'] ) num_files = len(f_indexed) # Get The rate of concurrency concurrency = multi.set_concurrency(args=ARGS, file_count=num_files) # Package up the Payload payload = multi.manager_dict( http.prep_payload( auth=self.auth, container=ARGS.get('container', basic.rand_string()), source=basic.get_local_source(), args=ARGS ) ) LOG.info('MESSAGE\t: "%s" Files have been found.', num_files) LOG.debug('PAYLOAD\t: "%s"', payload) # Set the actions class up self.go = actions.CloudActions(payload=payload) kwargs = {'url': payload['url'], 'container': payload['c_name']} # get that the container exists if not create it. self.go.container_create(**kwargs) kwargs['source'] = payload['source'] kwargs['cf_job'] = getattr(self.go, 'object_putter') multi.job_processer( num_jobs=num_files, objects=f_indexed, job_action=multi.doerator, concur=concurrency, kwargs=kwargs ) if ARGS.get('delete_remote') is True: self.remote_delete(payload=payload, f_indexed=f_indexed)
def start(self): """This is the archive method. Uses archive (TAR) feature to compress files and then upload the TAR Ball to a specified container. """ # Index Local Files for Upload f_indexed = methods.get_local_files() if ARGS.get('pattern_match'): f_indexed = basic.match_filter( idx_list=f_indexed, pattern=ARGS['pattern_match'] ) num_files = len(f_indexed) report.reporter(msg='MESSAGE: "%s" Files have been found.' % num_files) # Package up the Payload payload = http.prep_payload( auth=self.auth, container=ARGS.get('container', basic.rand_string()), source=None, args=ARGS ) report.reporter( msg='PAYLOAD\t: "%s"' % payload, log=True, lvl='debug', prt=False ) # Set the actions class up self.go = actions.CloudActions(payload=payload) self.go.container_create( url=payload['url'], container=payload['c_name'] ) self.action = getattr(self.go, 'object_putter') with multi.spinner(): # Compression Job wfile = methods.compress_files(file_list=f_indexed) source, name = os.path.split(wfile) report.reporter(msg='MESSAGE: "%s" is being uploaded.' % name) # Perform the upload self.action(url=payload['url'], container=payload['c_name'], source=source, u_file=wfile) # Remove the archive unless instructed not too. if ARGS.get('no_cleanup') is None: basic.remove_file(wfile)
def start(self): """This is the upload method. Uses file_upload is to simply upload all files and folders to a specified container. """ # Index Local Files for Upload f_indexed = methods.get_local_files() if ARGS.get('pattern_match'): f_indexed = basic.match_filter( idx_list=f_indexed, pattern=ARGS['pattern_match'] ) num_files = len(f_indexed) # Get The rate of concurrency concurrency = multi.set_concurrency(args=ARGS, file_count=num_files) # Package up the Payload payload = multi.manager_dict( http.prep_payload( auth=self.auth, container=ARGS.get('container', basic.rand_string()), source=basic.get_local_source(), args=ARGS ) ) LOG.info('MESSAGE\t: "%s" Files have been found.', num_files) LOG.debug('PAYLOAD\t: "%s"', payload) # Set the actions class up self.go = actions.CloudActions(payload=payload) kwargs = {'url': payload['url'], 'container': payload['c_name']} # get that the container exists if not create it. self.go.container_create(**kwargs) kwargs['source'] = payload['source'] kwargs['cf_job'] = getattr(self.go, 'object_putter') multi.job_processer( num_jobs=num_files, objects=f_indexed, job_action=multi.doerator, concur=concurrency, kwargs=kwargs ) if ARGS.get('delete_remote') is True: self.remote_delete(payload=payload, f_indexed=f_indexed)
def start(self): """This is the archive method. Uses archive (TAR) feature to compress files and then upload the TAR Ball to a specified container. """ # Index Local Files for Upload f_indexed = methods.get_local_files() if ARGS.get('pattern_match'): f_indexed = basic.match_filter(idx_list=f_indexed, pattern=ARGS['pattern_match']) num_files = len(f_indexed) report.reporter(msg='MESSAGE: "%s" Files have been found.' % num_files) # Package up the Payload payload = http.prep_payload(auth=self.auth, container=ARGS.get('container', basic.rand_string()), source=None, args=ARGS) report.reporter( msg='PAYLOAD : [ %s ]' % payload, prt=False, lvl='debug', ) # Set the actions class up self.go = actions.CloudActions(payload=payload) self.go.container_create(url=payload['url'], container=payload['c_name']) self.action = getattr(self.go, 'object_putter') with multi.spinner(): # Compression Job wfile = methods.compress_files(file_list=f_indexed) source, name = os.path.split(wfile) report.reporter(msg='MESSAGE: "%s" is being uploaded.' % name) # Perform the upload self.action(url=payload['url'], container=payload['c_name'], source=source, u_file=wfile) # Remove the archive unless instructed not too. if ARGS.get('no_cleanup') is None: basic.remove_file(wfile)
def start(self): """This is the upload method. Uses file_upload is to simply upload all files and folders to a specified container. """ f_indexed = self._index_local_files() num_files = len(f_indexed) # Get The rate of concurrency concurrency = multi.set_concurrency(args=ARGS, file_count=num_files) # Package up the Payload payload = multi.manager_dict( http.prep_payload( auth=self.auth, container=ARGS.get('container', basic.rand_string()), source=basic.get_local_source(), args=ARGS ) ) report.reporter(msg='MESSAGE : "%s" Files found.' % num_files) report.reporter( msg='PAYLOAD : [ %s ]' % payload, prt=False, lvl='debug' ) # Set the actions class up self.go = actions.CloudActions(payload=payload) kwargs = {'url': payload['url'], 'container': payload['c_name']} # get that the container exists if not create it. self.go.container_create(**kwargs) kwargs['source'] = payload['source'] kwargs['cf_job'] = getattr(self.go, 'object_putter') multi.job_processer( num_jobs=num_files, objects=f_indexed, job_action=multi.doerator, concur=concurrency, kwargs=kwargs ) if ARGS.get('delete_remote') is True: self.remote_delete(payload=payload)
def start(self): """This is the archive method. Uses archive (TAR) feature to compress files and then upload the TAR Ball to a specified container. """ report.reporter( msg='Toggling CDN on Container %s.' % ARGS.get('container') ) # Package up the Payload payload = http.prep_payload( auth=self.auth, container=ARGS.get('container', basic.rand_string()), source=None, args=ARGS ) report.reporter( msg='PAYLOAD\t: "%s"' % payload, log=True, lvl='debug', prt=False ) # Set the actions class up self.go = actions.CloudActions(payload=payload) with multi.spinner(): if ARGS.get('purge'): for obj in ARGS.get('purge'): # Perform the purge self.go.container_cdn_command(url=payload['cnet'], container=payload['c_name'], sfile=obj) else: self.go.container_cdn_command(url=payload['cnet'], container=payload['c_name'])
def test_rand_string(self): return_str1 = basic_utils.rand_string() return_str2 = basic_utils.rand_string() self.assertIsInstance(return_str1, str) self.assertIsInstance(return_str2, str) self.assertNotEqual(return_str1, return_str2)