def freeze(options, args): rosrs = ROSRS_Session(options["rosrs_uri"], options["rosrs_access_token"]) service_uri = urljoin(options["rosrs_uri"], "../evo/finalize/") body = { 'target': args[2], } body = json.dumps(body) reqheaders = {} (status, reason, headers, data) = response = rosrs.doRequest(uripath=service_uri, method="POST", body=body, ctype="application/json", reqheaders=reqheaders) if "location" in headers: while print_job_status(parse_job(rosrs, headers['location']), options, True): time.sleep(1) print "freeze operation finished successfully" return 0 else: print status print reason print headers print data print "Given URI isn't correct" return -1
def copy_operation(options, args, ro_type): options["rosrs_access_token"] rosrs = ROSRS_Session(options["rosrs_uri"], options["rosrs_access_token"]) service_uri = urljoin(options["rosrs_uri"], "../evo/copy/") body = { 'copyfrom': args[2], 'type': ro_type, 'finalize': ("%s" % options['freeze']).lower() } body = json.dumps(body) reqheaders = {'Slug': args[3]} response = rosrs.doRequest(uripath=service_uri, method="POST", body=body, ctype="application/json", reqheaders=reqheaders) if response[0] != 201: return handle_copy_error(options, rosrs, response, ro_type) if not options["asynchronous"]: return handle_synchronous_copy_operation_with_esc_option( options, rosrs, response, ro_type) if options["asynchronous"]: return handle_asynchronous_copy_operation(options, rosrs, response, ro_type) return 0
def freeze(self, ro_uri): rosrs = ROSRS_Session(ro_test_config.ROSRS_URI, ro_test_config.ROSRS_ACCESS_TOKEN) service_uri = urljoin(ro_test_config.ROSRS_URI, "../evo/finalize/") body = { 'target': ro_uri, } body = json.dumps(body) reqheaders = {} (status, reason, headers, data) = rosrs.doRequest(uripath=service_uri, method="POST", body=body, ctype="application/json", reqheaders=reqheaders) job_location = get_location(headers) status = "RUNNING" while status == "RUNNING": (status, id) = parse_job(rosrs, job_location) return status
def copy_operation(options, args, ro_type): options["rosrs_access_token"] rosrs = ROSRS_Session(options["rosrs_uri"], options["rosrs_access_token"]) service_uri = urljoin(options["rosrs_uri"], "../evo/copy/") body = { 'copyfrom': args[2], 'type': ro_type, 'finalize': ( "%s" % options['freeze']).lower() } body = json.dumps(body) reqheaders = { 'Slug' : args[3] } response = rosrs.doRequest(uripath=service_uri, method="POST", body=body, ctype="application/json", reqheaders=reqheaders) if response[0] != 201: return handle_copy_error(options, rosrs, response, ro_type) if not options["asynchronous"]: return handle_synchronous_copy_operation_with_esc_option(options, rosrs, response, ro_type) if options["asynchronous"]: return handle_asynchronous_copy_operation(options, rosrs, response, ro_type) return 0
def createArchive(self, live_name,sp_name,freeze = True): service_uri = urljoin(ro_test_config.ROSRS_URI, "../evo/copy/") body = { 'copyfrom': live_name, 'target': sp_name, 'type': "ARCHIVE", 'finalize': ( "%s" % freeze).lower() } body = json.dumps(body) reqheaders = { 'token': ro_test_config.ROSRS_ACCESS_TOKEN, 'Slug' : sp_name, } rosrs = ROSRS_Session(ro_test_config.ROSRS_URI, ro_test_config.ROSRS_ACCESS_TOKEN) (status, reason, headers, data) = rosrs.doRequest(uripath=service_uri, method="POST", body=body, ctype="application/json", reqheaders=reqheaders) job_location = get_location(headers) status = "RUNNING" while status == "RUNNING": (status, id) = parse_job(rosrs, job_location) return (status, id)
def remote_status(self, ro_uri): rosrs = ROSRS_Session(ro_test_config.ROSRS_URI, ro_test_config.ROSRS_ACCESS_TOKEN) service_uri = ro_uri (status, reason, headers, data) = rosrs.doRequest(uripath=service_uri, method="POST", body="", ctype="application/json", reqheaders={}) return status, reason, headers, data