Exemple #1
0
 def __init_docker_image_app(self, region):
     """
     初始化docker image创建的应用默认数据,未存入数据库
     """
     tenant_service = TenantServiceInfo()
     tenant_service.service_region = region
     tenant_service.service_key = "0000"
     tenant_service.desc = "docker run application"
     tenant_service.category = "app_publish"
     # tenant_service.image = "goodrain.me/runner"
     # tenant_service.cmd = "start web"
     tenant_service.setting = ""
     tenant_service.extend_method = "stateless"
     tenant_service.env = ","
     tenant_service.min_node = 1
     tenant_service.min_memory = 128
     tenant_service.min_cpu = baseService.calculate_service_cpu(region, 128)
     tenant_service.inner_port = 0
     tenant_service.version = "latest"
     tenant_service.namespace = "goodrain"
     tenant_service.update_version = 1
     tenant_service.port_type = "multi_outer"
     tenant_service.create_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
     tenant_service.deploy_version = ""
     tenant_service.git_project_id = 0
     tenant_service.service_type = "application"
     tenant_service.total_memory = 128
     tenant_service.volume_mount_path = ""
     tenant_service.host_path = ""
     tenant_service.code_from = "image_manual"
     tenant_service.language = "docker-image"
     tenant_service.create_status = "creating"
     return tenant_service
 def __init_compose_service(self, tenant, user, service_cname, image,
                            region):
     """
     初始化docker compose创建的组件默认数据
     """
     tenant_service = TenantServiceInfo()
     tenant_service.tenant_id = tenant.tenant_id
     tenant_service.service_id = make_uuid()
     tenant_service.service_cname = service_cname
     tenant_service.service_alias = "gr" + tenant_service.service_id[-6:]
     tenant_service.creater = user.pk
     tenant_service.image = image
     tenant_service.service_region = region
     tenant_service.service_key = "0000"
     tenant_service.desc = "docker compose application"
     tenant_service.category = "app_publish"
     tenant_service.setting = ""
     tenant_service.extend_method = ComponentType.stateless_multiple.value
     tenant_service.env = ","
     tenant_service.min_node = 1
     tenant_service.min_memory = 128
     tenant_service.min_cpu = baseService.calculate_service_cpu(region, 128)
     tenant_service.inner_port = 0
     tenant_service.version = "latest"
     tenant_service.namespace = "goodrain"
     tenant_service.update_version = 1
     tenant_service.port_type = "multi_outer"
     tenant_service.create_time = datetime.datetime.now().strftime(
         '%Y-%m-%d %H:%M:%S')
     tenant_service.deploy_version = ""
     tenant_service.git_project_id = 0
     tenant_service.service_type = "application"
     tenant_service.total_memory = 128
     tenant_service.volume_mount_path = ""
     tenant_service.host_path = "/grdata/tenant/" + tenant.tenant_id + "/service/" + tenant_service.service_id
     tenant_service.code_from = "image_manual"
     tenant_service.language = "docker-compose"
     tenant_service.service_source = AppConstants.DOCKER_COMPOSE
     tenant_service.create_status = "checked"
     return tenant_service