Esempio n. 1
0
 def update_env_by_attr_name(self, tenant, service, attr_name, name,
                             attr_value):
     attr_name = attr_name.strip()
     attr_value = attr_value.strip()
     env = env_var_repo.get_service_env_by_attr_name(
         tenant.tenant_id, service.service_id, attr_name)
     if not env:
         return 404, "环境变量不存在", None
     if not env.is_change:
         return 409, "环境变量不允许被修改", None
     update_params = {"name": name, "attr_value": attr_value}
     if service.create_status == "complete":
         body = {
             "env_name": attr_name,
             "env_value": attr_value,
             "scope": env.scope
         }
         region_api.update_service_env(service.service_region,
                                       tenant.tenant_name,
                                       service.service_alias, body)
     env_var_repo.update_env_var(tenant.tenant_id, service.service_id,
                                 attr_name, **update_params)
     env.name = name
     env.attr_value = attr_value
     return 200, "success", env
Esempio n. 2
0
 def update_env_by_env_id(self,
                          tenant,
                          service,
                          env_id,
                          name,
                          attr_value,
                          user_name=''):
     env_id = env_id.strip()
     attr_value = attr_value.strip()
     env = env_var_repo.get_env_by_ids_and_env_id(tenant.tenant_id,
                                                  service.service_id,
                                                  env_id)
     if not env:
         return 404, "环境变量不存在", None
     update_params = {"name": name, "attr_value": attr_value}
     if service.create_status == "complete":
         body = {
             "env_name": env.attr_name,
             "env_value": attr_value,
             "scope": env.scope,
             "operator": user_name
         }
         region_api.update_service_env(service.service_region,
                                       tenant.tenant_name,
                                       service.service_alias, body)
     env_var_repo.update_env_var(tenant.tenant_id, service.service_id,
                                 env.attr_name, **update_params)
     env.name = name
     env.attr_value = attr_value
     return 200, "success", env