Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3ef0bd43
authored
Jun 23, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add ssh key tasks
parent
9306e681
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
circle/dashboard/models.py
+34
-0
circle/vm/tasks/agent_tasks.py
+15
-0
No files found.
circle/dashboard/models.py
View file @
3ef0bd43
...
@@ -29,9 +29,11 @@ from django.db.models import (
...
@@ -29,9 +29,11 @@ from django.db.models import (
Model
,
ForeignKey
,
OneToOneField
,
CharField
,
IntegerField
,
TextField
,
Model
,
ForeignKey
,
OneToOneField
,
CharField
,
IntegerField
,
TextField
,
DateTimeField
,
permalink
,
BooleanField
DateTimeField
,
permalink
,
BooleanField
)
)
from
django.db.models.signals
import
post_save
,
pre_delete
from
django.template.loader
import
render_to_string
from
django.template.loader
import
render_to_string
from
django.templatetags.static
import
static
from
django.templatetags.static
import
static
from
django.utils.translation
import
ugettext_lazy
as
_
,
override
,
ugettext
from
django.utils.translation
import
ugettext_lazy
as
_
,
override
,
ugettext
from
django_sshkey.models
import
UserKey
from
model_utils.models
import
TimeStampedModel
from
model_utils.models
import
TimeStampedModel
from
model_utils.fields
import
StatusField
from
model_utils.fields
import
StatusField
...
@@ -39,6 +41,8 @@ from model_utils import Choices
...
@@ -39,6 +41,8 @@ from model_utils import Choices
from
acl.models
import
AclBase
from
acl.models
import
AclBase
from
vm.tasks.agent_tasks
import
add_keys
,
del_keys
logger
=
getLogger
(
__name__
)
logger
=
getLogger
(
__name__
)
...
@@ -224,3 +228,33 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
...
@@ -224,3 +228,33 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
else
:
else
:
logger
.
debug
(
"Do not register save_org_id to djangosaml2 pre_user_save"
)
logger
.
debug
(
"Do not register save_org_id to djangosaml2 pre_user_save"
)
def
add_ssh_keys
(
sender
,
**
kwargs
):
from
vm.models
import
Instance
userkey
=
kwargs
.
get
(
'instance'
)
instances
=
Instance
.
get_objects_with_level
(
'user'
,
userkey
.
user
)
.
filter
(
status
=
'RUNNING'
)
for
i
in
instances
:
logger
.
info
(
'called add_keys(
%
s,
%
s)'
,
i
,
userkey
)
queue
=
i
.
get_remote_queue_name
(
"agent"
)
add_keys
.
apply_async
(
args
=
(
i
.
vm_name
,
[
userkey
.
key
]),
queue
=
queue
)
def
del_ssh_keys
(
sender
,
**
kwargs
):
from
vm.models
import
Instance
userkey
=
kwargs
.
get
(
'instance'
)
instances
=
Instance
.
get_objects_with_level
(
'user'
,
userkey
.
user
)
.
filter
(
status
=
'RUNNING'
)
for
i
in
instances
:
logger
.
info
(
'called del_keys(
%
s,
%
s)'
,
i
,
userkey
)
queue
=
i
.
get_remote_queue_name
(
"agent"
)
del_keys
.
apply_async
(
args
=
(
i
.
vm_name
,
[
userkey
.
key
]),
queue
=
queue
)
post_save
.
connect
(
add_ssh_keys
,
sender
=
UserKey
)
pre_delete
.
connect
(
del_ssh_keys
,
sender
=
UserKey
)
circle/vm/tasks/agent_tasks.py
View file @
3ef0bd43
...
@@ -56,3 +56,18 @@ def start_access_server(vm):
...
@@ -56,3 +56,18 @@ def start_access_server(vm):
@celery.task
(
name
=
'agent.update'
)
@celery.task
(
name
=
'agent.update'
)
def
update
(
vm
,
data
):
def
update
(
vm
,
data
):
pass
pass
@celery.task
(
name
=
'agent.add_keys'
)
def
add_keys
(
vm
,
keys
):
pass
@celery.task
(
name
=
'agent.del_keys'
)
def
del_keys
(
vm
,
keys
):
pass
@celery.task
(
name
=
'agent.get_keys'
)
def
get_keys
(
vm
):
pass
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment