Agent tasks sent is updated when command is sent
This commit is contained in:
parent
fc22980f85
commit
39e26ac5e2
11
cli/cli.py
11
cli/cli.py
@ -178,6 +178,8 @@ def send_command(search_str: str, command: str) -> None:
|
|||||||
Task.create(agent_ip = agent.ip, task = command, completed = False)
|
Task.create(agent_ip = agent.ip, task = command, completed = False)
|
||||||
commands_sent += 1
|
commands_sent += 1
|
||||||
|
|
||||||
|
Agent.update(tasks_sent = agent.tasks_sent + 1).where(Agent.ip == agent.ip).execute()
|
||||||
|
|
||||||
print(f'Sent the command to {Colors.YELLOW}{commands_sent}{Colors.RESET} agents')
|
print(f'Sent the command to {Colors.YELLOW}{commands_sent}{Colors.RESET} agents')
|
||||||
|
|
||||||
def add_tag(ip_pattern: str, tag: str) -> None:
|
def add_tag(ip_pattern: str, tag: str) -> None:
|
||||||
@ -187,11 +189,12 @@ def add_tag(ip_pattern: str, tag: str) -> None:
|
|||||||
if ip_match(agent.ip, ip_pattern):
|
if ip_match(agent.ip, ip_pattern):
|
||||||
current_tags = agent.tags
|
current_tags = agent.tags
|
||||||
|
|
||||||
if tag in current_tags[0].split(','):
|
if len(current_tags) != 0:
|
||||||
print(f'{Colors.YELLOW}{agent.ip}{Colors.RESET} already has the tag {Colors.YELLOW}{tag}{Colors.RESET}.')
|
if tag in current_tags[0].split(','):
|
||||||
return
|
print(f'{Colors.YELLOW}{agent.ip}{Colors.RESET} already has the tag {Colors.YELLOW}{tag}{Colors.RESET}.')
|
||||||
|
return
|
||||||
|
|
||||||
if current_tags[0] == '':
|
if len(current_tags) == 0:
|
||||||
Agent.update(tags=str(tag)).where(Agent.ip == agent.ip).execute()
|
Agent.update(tags=str(tag)).where(Agent.ip == agent.ip).execute()
|
||||||
else:
|
else:
|
||||||
Agent.update(tags=Agent.tags.concat(',' + str(tag))).where(Agent.ip == agent.ip).execute()
|
Agent.update(tags=Agent.tags.concat(',' + str(tag))).where(Agent.ip == agent.ip).execute()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user