def list_base_tasks(self, eid): cfg = config_service.get_config_by_key(eid) if not cfg: # init base tasks logger.info("Enterprise id: {}; initialize basic tasks information".format(eid)) data = self.init_base_task() # TODO: handle error config_service.add_config_without_reload(key=eid, default_value=json.dumps(data), type="json") else: data = json.loads(cfg) need_update = False for item in data: if not item["status"]: ctx = BaseTaskStatusContext(eid, item["key"]) status = ctx.confirm_status() if status: logger.info("Enterprise id: {0}; Task: {1}; Original status: False; " "update status.".format(eid, item["key"])) item["status"] = status need_update = True if need_update: # TODO: handle error config_service.update_config(eid, json.dumps(data)) return data
def update_region_config(self): region_json_data = self.generate_region_config() if not config_service.get_config_by_key("REGION_SERVICE_API"): config_service.add_config("REGION_SERVICE_API", region_json_data, 'json', "数据中心配置") else: config_service.update_config("REGION_SERVICE_API", region_json_data)
def get(self, request, *args, **kwargs): """ 登录页面获取云帮Logo、标题、github、gitlab配置信息(不要Authorization头) --- """ try: # 判断是否已经初始化权限默认数据,没有则初始化 status = role_perm_repo.initialize_permission_settings() code = 200 data = dict() logo = config_service.get_image() host_name = request.get_host() build_absolute_uri = request.build_absolute_uri() scheme = "http" if build_absolute_uri.startswith("https"): scheme = "https" data["logo"] = "{0}".format(str(logo)) # 判断是否为公有云 if settings.MODULES.get('SSO_LOGIN'): data["url"] = "https://sso.goodrain.com/#/login/" data["is_public"] = True else: data["url"] = "{0}://{1}/index#/user/login".format(scheme, request.get_host()) data["is_public"] = False title = config_service.get_config_by_key("TITLE") if not title: config = config_service.add_config("TITLE", "好雨云帮", "string", "云帮title") title = config.value data["title"] = title if settings.MODULES.get('SSO_LOGIN'): data["is_user_register"] = True else: users = user_repo.get_all_users() if users: data["is_user_register"] = True else: data["is_user_register"] = False github_config = config_service.get_github_config() data["github_config"] = github_config gitlab_config = config_service.get_gitlab_config() data["gitlab_config"] = gitlab_config result = general_message(code, "query success", "Logo获取成功", bean=data, initialize_info=status) return Response(result, status=code) except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result)
def get(self, request, *args, **kwargs): """ 获取当前云帮Title --- """ data = dict() try: code = 200 title = config_service.get_config_by_key("TITLE") if not title: config = config_service.add_config("TITLE", "好雨云帮", "string", "云帮title") title = config.value data["title"] = title result = general_message(code, "success", "云帮标题获取成功", bean=data) except Exception as e: code = 500 result = error_message(e.message) logger.exception(e) return Response(result, status=code)
def get(self, request, *args, **kwargs): """ 获取当前云帮Title --- """ bean = {} try: title = config_service.get_config_by_key("TITLE") if not title: config = config_service.add_config("TITLE", "好雨云帮", "string", "云帮title") title = config.value bean["title"] = title code = "0000" msg = "success" msg_show = "查询成功" result = generate_result(code, msg, msg_show, bean) except Exception as e: result = generate_error_result() logger.exception(e) return Response(result)
def get(self, request, *args, **kwargs): """ 登录页面获取云帮Logo、标题、github、gitlab配置信息(不要Authorization头) --- """ try: # 判断是否已经初始化权限默认数据,没有则初始化 status = role_perm_repo.initialize_permission_settings() code = 200 data = dict() logo = config_service.get_image() build_absolute_uri = request.build_absolute_uri() scheme = "http" if build_absolute_uri.startswith("https"): scheme = "https" data["logo"] = "{0}".format(str(logo)) # 判断是否为公有云 if settings.MODULES.get('SSO_LOGIN'): data["url"] = os.getenv( "SSO_BASE_URL", "https://sso.goodrain.com") + "/#/login/" data["is_public"] = True else: data["url"] = "{0}://{1}/index#/user/login".format( scheme, request.get_host()) data["is_public"] = False title = config_service.get_config_by_key("TITLE") if not title: config = config_service.add_config("TITLE", "好雨云帮", "string", "云帮title") title = config.value data["title"] = title if settings.MODULES.get('SSO_LOGIN'): data["is_user_register"] = True else: users = user_repo.get_all_users() if users: data["is_user_register"] = True else: data["is_user_register"] = False is_regist = config_service.get_config_by_key("REGISTER_STATUS") if not is_regist: is_regist = config_service.add_config( key="REGISTER_STATUS", default_value="yes", type="string", desc="开启/关闭注册").value if is_regist == "yes": data["is_regist"] = True else: data["is_regist"] = False # if register_config[0].value != "yes": # data["is_regist"] = False # else: # data["is_regist"] = True github_config = config_service.get_github_config() data["github_config"] = github_config gitlab_config = config_service.get_gitlab_config() data["gitlab_config"] = gitlab_config data["eid"] = None enterprise = enterprise_repo.get_enterprise_first() if enterprise: data["eid"] = enterprise.enterprise_id data["enterprise_name"] = enterprise.enterprise_alias data["version"] = os.getenv("RELEASE_DESC", "public-cloud") result = general_message( code, "query success", "Logo获取成功", bean=data, initialize_info=status) return Response(result, status=code) except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result)