同步信息时机器对象保存项目名称到tags
This commit is contained in:
parent
1b6eb7147b
commit
b2e7e18f8a
|
@ -111,8 +111,13 @@ class ServerSyncView(CreateMixin):
|
|||
|
||||
try:
|
||||
if not host:
|
||||
hostObj, _ = Host.get_or_create(
|
||||
public_ip=ip, defaults=dict(public_ip=ip, created=datetime.datetime.now()))
|
||||
proj = self.project.fullname()
|
||||
hostObj, created = Host.get_or_create(
|
||||
public_ip=ip, defaults=dict(public_ip=ip, tags=[proj], created=datetime.datetime.now()))
|
||||
# 项目写入机器的tags
|
||||
if not created and proj not in hostObj.tags:
|
||||
hostObj.tags.append(proj)
|
||||
hostObj.save()
|
||||
host = hostObj.id
|
||||
hosts[ip] = hostObj.id
|
||||
if not channel:
|
||||
|
|
Loading…
Reference in New Issue