Esempio n. 1
0
from www.tenantservice.baseservice import TenantUsedResource, CodeRepositoriesService, BaseTenantService, \
    ServicePluginResource
from www.utils.crypt import make_uuid
from www.utils.status_translate import get_status_info_map
from django.conf import settings


tenantUsedResource = TenantUsedResource()
logger = logging.getLogger("default")
region_api = RegionInvokeApi()
codeRepositoriesService = CodeRepositoriesService()
baseService = BaseTenantService()
servicePluginResource = ServicePluginResource()
gitHubClient = GitHubApi()
port_service = AppPortService()
probe_service = ProbeService()


class AppService(object):
    def check_service_cname(self, tenant, service_cname, region):
        if not service_cname:
            return False, u"应用名称不能为空"
        if len(service_cname) > 20:
            return False, u"应用名称最多支持20个字符"
        r = re.compile(u'^[a-zA-Z0-9_\\-\\.\u4e00-\u9fa5]+$')
        if not r.match(service_cname.decode("utf-8")):
            return False, u"应用名称只支持中英文下划线和中划线和点(.)"
        service = service_repo.get_service_by_region_tenant_and_name(tenant.tenant_id, service_cname, region)
        if service:
            return False, u"当前团队下已存在相同名称应用"
        return True, u"success"
Esempio n. 2
0
from console.constants import ServicePortConstants
from console.exception.main import AbortRequest
from console.repositories.app import service_repo
from console.repositories.app_config import domain_repo
from console.repositories.app_config import port_repo
from console.repositories.app_config import tcp_domain
from console.repositories.probe_repo import probe_repo
from console.repositories.region_repo import region_repo
from console.services.app_config.env_service import AppEnvVarService
from console.services.app_config.probe_service import ProbeService
from console.services.region_services import region_services
from www.apiclient.regionapi import RegionInvokeApi
from www.apiclient.regionapibaseclient import RegionApiBaseHttpClient
from www.utils.crypt import make_uuid

pros = ProbeService()
region_api = RegionInvokeApi()
env_var_service = AppEnvVarService()
logger = logging.getLogger("default")


class AppPortService(object):
    def check_port(self, service, container_port):
        port = port_repo.get_service_port_by_port(service.tenant_id, service.service_id, container_port)
        if port:
            return 400, u"端口{0}已存在".format(container_port)
        if not (1 <= container_port <= 65535):
            return 412, u"端口必须为1到65535的整数"
        return 200, "success"

    def check_port_alias(self, port_alias):