more agent prep
This commit is contained in:
parent
2928beb6e5
commit
ffe3240b27
|
@ -84,6 +84,31 @@ class Agent(BaseAuditModel):
|
|||
|
||||
return CoreSettings.objects.first().default_time_zone
|
||||
|
||||
@property
|
||||
def arch(self):
|
||||
if self.operating_system is not None:
|
||||
if "64bit" in self.operating_system:
|
||||
return "64"
|
||||
elif "32bit" in self.operating_system:
|
||||
return "32"
|
||||
return "64"
|
||||
|
||||
@property
|
||||
def winagent_dl(self):
|
||||
return settings.DL_64 if self.arch == "64" else settings.DL_32
|
||||
|
||||
@property
|
||||
def winsalt_dl(self):
|
||||
return settings.SALT_64 if self.arch == "64" else settings.SALT_32
|
||||
|
||||
@property
|
||||
def win_inno_exe(self):
|
||||
return (
|
||||
f"winagent-v{settings.LATEST_AGENT_VER}.exe"
|
||||
if self.arch == "64"
|
||||
else f"winagent-v{settings.LATEST_AGENT_VER}-x86.exe"
|
||||
)
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
offline = dt.datetime.now(dt.timezone.utc) - dt.timedelta(minutes=6)
|
||||
|
|
|
@ -29,28 +29,13 @@ def send_agent_update_task(pks, version):
|
|||
for chunk in chunks:
|
||||
for pk in chunk:
|
||||
agent = Agent.objects.get(pk=pk)
|
||||
if agent.operating_system is not None:
|
||||
if "64bit" in agent.operating_system:
|
||||
arch = "64"
|
||||
elif "32bit" in agent.operating_system:
|
||||
arch = "32"
|
||||
else:
|
||||
arch = "64"
|
||||
|
||||
url = settings.DL_64 if arch == "64" else settings.DL_32
|
||||
inno = (
|
||||
f"winagent-v{version}.exe"
|
||||
if arch == "64"
|
||||
else f"winagent-v{version}-x86.exe"
|
||||
)
|
||||
|
||||
r = agent.salt_api_async(
|
||||
func="win_agent.do_agent_update_v2",
|
||||
kwargs={
|
||||
"inno": inno,
|
||||
"url": url,
|
||||
},
|
||||
)
|
||||
r = agent.salt_api_async(
|
||||
func="win_agent.do_agent_update_v2",
|
||||
kwargs={
|
||||
"inno": agent.win_inno_exe,
|
||||
"url": agent.winagent_dl,
|
||||
},
|
||||
)
|
||||
sleep(10)
|
||||
|
||||
|
||||
|
@ -72,28 +57,13 @@ def auto_self_agent_update_task():
|
|||
for chunk in chunks:
|
||||
for pk in chunk:
|
||||
agent = Agent.objects.get(pk=pk)
|
||||
if agent.operating_system is not None:
|
||||
if "64bit" in agent.operating_system:
|
||||
arch = "64"
|
||||
elif "32bit" in agent.operating_system:
|
||||
arch = "32"
|
||||
else:
|
||||
arch = "64"
|
||||
|
||||
url = settings.DL_64 if arch == "64" else settings.DL_32
|
||||
inno = (
|
||||
f"winagent-v{settings.LATEST_AGENT_VER}.exe"
|
||||
if arch == "64"
|
||||
else f"winagent-v{settings.LATEST_AGENT_VER}-x86.exe"
|
||||
)
|
||||
|
||||
r = agent.salt_api_async(
|
||||
func="win_agent.do_agent_update_v2",
|
||||
kwargs={
|
||||
"inno": inno,
|
||||
"url": url,
|
||||
},
|
||||
)
|
||||
r = agent.salt_api_async(
|
||||
func="win_agent.do_agent_update_v2",
|
||||
kwargs={
|
||||
"inno": agent.win_inno_exe,
|
||||
"url": agent.winagent_dl,
|
||||
},
|
||||
)
|
||||
sleep(10)
|
||||
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ class SaltMinion(APIView):
|
|||
"latestVer": settings.LATEST_SALT_VER,
|
||||
"currentVer": agent.salt_ver,
|
||||
"salt_id": agent.salt_id,
|
||||
"downloadURL": "changeme", # TODO
|
||||
"downloadURL": agent.winsalt_dl,
|
||||
}
|
||||
return Response(ret)
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ LATEST_AGENT_VER = "0.11.2"
|
|||
DL_64 = f"https://github.com/wh1te909/winagent/releases/download/v{LATEST_AGENT_VER}/winagent-v{LATEST_AGENT_VER}.exe"
|
||||
DL_32 = f"https://github.com/wh1te909/winagent/releases/download/v{LATEST_AGENT_VER}/winagent-v{LATEST_AGENT_VER}-x86.exe"
|
||||
|
||||
SALT_64 = f"https://github.com/wh1te909/salt/releases/download/{LATEST_SALT_VER}/salt-minion-setup.exe"
|
||||
SALT_32 = f"https://github.com/wh1te909/salt/releases/download/{LATEST_SALT_VER}/salt-minion-setup-x86.exe"
|
||||
|
||||
try:
|
||||
from .local_settings import *
|
||||
except ImportError:
|
||||
|
|
Loading…
Reference in New Issue