mirror of https://github.com/jumpserver/jumpserver
fix asset add batch bug
parent
89901fa7fb
commit
cf59ebf1aa
|
@ -278,14 +278,13 @@ def excel_to_db(excel_file):
|
||||||
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
|
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
table = data.sheets()[0]
|
table = data.sheets()[0]
|
||||||
rows = table.nrows
|
rows = table.nrows
|
||||||
group_instance = []
|
|
||||||
for row_num in range(1, rows):
|
for row_num in range(1, rows):
|
||||||
row = table.row_values(row_num)
|
row = table.row_values(row_num)
|
||||||
if row:
|
if row:
|
||||||
|
group_instance = []
|
||||||
ip, port, hostname, use_default_auth, username, password, group = row
|
ip, port, hostname, use_default_auth, username, password, group = row
|
||||||
if get_object(Asset, hostname=hostname):
|
if get_object(Asset, hostname=hostname):
|
||||||
continue
|
continue
|
||||||
|
@ -306,7 +305,6 @@ def excel_to_db(excel_file):
|
||||||
if group:
|
if group:
|
||||||
group_instance.append(group)
|
group_instance.append(group)
|
||||||
if group_instance:
|
if group_instance:
|
||||||
print group_instance
|
|
||||||
asset.group = group_instance
|
asset.group = group_instance
|
||||||
asset.save()
|
asset.save()
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue