[Update] 修改Inverntoy,增加更多属性

This commit is contained in:
ibuler
2018-03-28 19:37:29 +08:00
parent c5af4d47eb
commit d32f070b5c
3 changed files with 93 additions and 45 deletions

View File

@@ -96,7 +96,7 @@ class Asset(models.Model):
return False, warning
def is_unixlike(self):
if self.platform not in ("Windows", "Other"):
if self.platform not in ("Windows",):
return True
else:
return False
@@ -132,6 +132,15 @@ class Asset(models.Model):
info["gateways"] = [d.id for d in self.domain.gateway_set.all()]
return info
def get_auth_info(self):
if self.admin_user:
return {
'username': self.admin_user.username,
'password': self.admin_user.password,
'private_key': self.admin_user.private_key_file,
'become': self.admin_user.become_info,
}
def _to_secret_json(self):
"""
Ansible use it create inventory, First using asset user,
@@ -175,4 +184,3 @@ class Asset(models.Model):
except IntegrityError:
print('Error continue')
continue