def deploy_openstack(): if not __check_razor_env(): return make_response("Razor setting fail, please set Razor according to the instruction.", 400) req_data = json.loads(request.data) logger.info("Receive request data: %s" % req_data) deployment_spec = req_data["deployment_spec"] try: mac_table = csv_parser(deployment_spec) logger.info("mac_table: %s" % json.dumps(mac_table)) except Exception as e: logger.error(e) return make_response("Parse deployment file fail!", 400) task_id = "os-i-%s" % uuid.uuid1() deployment_parameters = { 'tor_netmask': str(req_data['tor_netmask']), 'tor_gateway': str(req_data['tor_gateway']), 'tor_dns': str(req_data['tor_dns']), 'controller_ip': str(req_data['controller_ip']), 'admin_password': str(req_data['admin_password']), 'admin_email': str(req_data['admin_email']), 'monitor_server_ip': str(req_data['monitor_server_ip']), 'ntp_server': str(req_data['ntp_server']), 'api_network': str(req_data['api_network']), 'external_network': str(req_data['external_network']), 'management_network': str(req_data['management_network']), 'data_network': str(req_data['data_network']) } do_deploy_args = { 'task_id': task_id, 'deployment_id': str(req_data['deployment_id']), 'mac_table': mac_table, 'deployment_parameters': deployment_parameters } threading.Thread(target = __do_deploy, kwargs = do_deploy_args).start() return json.dumps({'task_id': task_id})
def scaleup_openstack(deployment_id): if not __check_razor_env(): return make_response("Razor setting fail, please set Razor according to the instruction.", 400) req_data = json.loads(request.data) deployment_spec = req_data["deployment_spec"] try: mac_table = csv_parser(deployment_spec) logger.info("mac_table: %s" % json.dumps(mac_table)) except Exception as e: logger.error(e) return make_response("Parse deployment file fail!", 400) task_id = "os-e-%s" % uuid.uuid1() do_scaleup_args = {'task_id': task_id, 'deployment_id': deployment_id, 'mac_table': mac_table} threading.Thread(target = __do_scaleup, kwargs = do_scaleup_args).start() return json.dumps({'task_id': task_id})
def mock_deploy_openstack(): req_data = json.loads(request.data) logger.info(req_data) mac_table = None deployment_spec = req_data["deployment_spec"] if deployment_spec is not None: try: mac_table = csv_parser(deployment_spec) logger.info("mac_table: %s" % json.dumps(mac_table)) except Exception as e: logger.error(e) return make_response("Parse deployment file fail!", 400) else: return make_response("No deployment file found!", 400) task_id = uuid.uuid1() openstack_uuid = "openstack-deployment-%s" % task_id res = {} res["deployment_id"] = openstack_uuid return json.dumps(res)