渠道、区服信息新增是否为跨服字段,项目配置调整

This commit is contained in:
chenzuoqing 2021-12-02 16:54:48 +08:00
parent 81088c85e9
commit 20215d4aae
4 changed files with 25 additions and 6 deletions

10
settings/common.py Normal file
View File

@ -0,0 +1,10 @@
# API static token 允许请求的静态token
X_TOKEN_SET = (
"51ab21fa323a11eca1af000c2993d583", #
)
# 跨服spid集合
CROSS_SPID_SET = (
"000", "111", "222", "333", "444"
)

View File

@ -13,11 +13,6 @@ MONGODB_SETTINGS = {
'host': 'mongodb://admin:111111@10.2.2.10:27017/ops_api?authSource=admin',
}
# API static token 允许请求的静态token
X_TOKEN_SET = (
"51ab21fa323a11eca1af000c2993d583", #
)
LOGGING = {
'version': 1,
'disable_existing_loggers': True,

View File

@ -44,6 +44,7 @@ ChannelFields = {
"project": fields.Nested(ProjectSimpleField),
"name": fields.String,
"spid": fields.String,
"is_cross": fields.Boolean,
"version": fields.Nested(VersionFields),
"repository": fields.String,
"branch": fields.String,
@ -79,6 +80,7 @@ AgentServerFields = {
"num": fields.Integer,
"spid": fields.String,
"agent": fields.String,
"is_cross": fields.Boolean,
# "channel_id": fields.String,
"project": fields.String,
"public_ip": fields.String,

View File

@ -1,6 +1,7 @@
import mongoengine as mongo
from common.document import DocumentBase
from settings import common
from common.document import DocumentBase
from common.validator import isalnum
from asset.models import Host
@ -58,6 +59,11 @@ class Channel(DocumentBase):
created = mongo.DateTimeField()
@property
def is_cross(self):
"""渠道 spid 在 CROSS_SPID_SET表示跨服"""
return self.spid in common.CROSS_SPID_SET
class Server(DocumentBase):
"""服务"""
@ -128,3 +134,9 @@ class Server(DocumentBase):
if self.host:
return self.host.id
return ""
@property
def is_cross(self):
if self.channel:
return self.channel.is_cross
return False