perf: 修改迁移文件

pull/8931/head
ibuler 2022-09-21 13:42:12 +08:00
parent 1b0195cb82
commit 584ce0afe3
2 changed files with 6 additions and 7 deletions

View File

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

View File

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