Commit a0ed9745 by Kálmán Viktor

dashboard: fix agent errors

parent 8981961e
......@@ -438,10 +438,14 @@ def add_ssh_keys(sender, **kwargs):
userkey = kwargs.get('instance')
instances = Instance.get_objects_with_level(
'user', userkey.user).filter(status='RUNNING')
'user', userkey.user, disregard_superuser=True
).filter(status='RUNNING')
for i in instances:
logger.info('called add_keys(%s, %s)', i, userkey)
try:
i.install_keys(user=userkey.user, keys=[userkey.key])
except Instance.NoAgentError:
logger.info("%s has no agent running", i)
def del_ssh_keys(sender, **kwargs):
......@@ -449,10 +453,14 @@ def del_ssh_keys(sender, **kwargs):
userkey = kwargs.get('instance')
instances = Instance.get_objects_with_level(
'user', userkey.user).filter(status='RUNNING')
'user', userkey.user, disregard_superuser=True
).filter(status='RUNNING')
for i in instances:
logger.info('called del_keys(%s, %s)', i, userkey)
try:
i.remove_keys(user=userkey.user, keys=[userkey.key])
except Instance.NoAgentError:
logger.info("%s has no agent running", i)
post_save.connect(add_ssh_keys, sender=UserKey)
......
......@@ -191,7 +191,8 @@ class EnsureAgentMixin(object):
try:
InstanceActivity.objects.filter(
activity_code="vm.Instance.agent.starting",
started__gt=last_boot_time).latest("started")
started__gt=last_boot_time, instance=self.instance
).latest("started")
except InstanceActivity.DoesNotExist: # no agent since last boot
raise self.instance.NoAgentError(self.instance)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment