perf: 修改迁移文件

pull/8931/head
ibuler 2 years ago
parent 1b0195cb82
commit 584ce0afe3

@ -55,7 +55,7 @@ def migrate_database_to_asset(apps, *args):
attrs.update(_attrs)
db = db_model(
id=app.id, hostname=app.name, ip=attrs['host'],
id=app.id, hostname=app.name, address=attrs['host'],
protocols='{}/{}'.format(app.type, attrs['port']),
db_name=attrs['database'] or '',
platform=platforms_map[app.type],
@ -82,11 +82,10 @@ def migrate_cloud_to_asset(apps, *args):
attrs = app.attrs
print("Create cloud: {}".format(app.name))
cloud = cloud_model(
id=app.id, hostname=app.name, ip='',
protocols='',
platform=platform,
id=app.id, hostname=app.name,
address=attrs.get('cluster', ''),
protocols='', platform=platform,
org_id=app.org_id,
url=attrs.get('cluster', '')
)
try:

@ -36,13 +36,13 @@ def write_content_to_excel(response, header=None, login_logs=None, fields=None):
def write_login_log(*args, **kwargs):
from audits.models import UserLoginLog
ip = kwargs.get('address') or ''
ip = kwargs.get('ip') or ''
if not (ip and validate_ip(ip)):
ip = ip[:15]
city = DEFAULT_CITY
else:
city = get_ip_city(ip) or DEFAULT_CITY
kwargs.update({'address': ip, 'city': city})
kwargs.update({'ip': ip, 'city': city})
UserLoginLog.objects.create(**kwargs)

Loading…
Cancel
Save