Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
29574622
authored
Apr 27, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-copy-keys' into 'master'
Add InstallKeysOperation
✅
See merge request !323
parents
151c90c6
bf92aeee
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
8 deletions
+46
-8
circle/common/operations.py
+1
-1
circle/dashboard/models.py
+2
-7
circle/dashboard/templates/dashboard/vm-detail/home.html
+10
-0
circle/dashboard/views/vm.py
+4
-0
circle/vm/operations.py
+29
-0
No files found.
circle/common/operations.py
View file @
29574622
...
@@ -76,7 +76,7 @@ class Operation(object):
...
@@ -76,7 +76,7 @@ class Operation(object):
user
=
auxargs
.
pop
(
'user'
)
user
=
auxargs
.
pop
(
'user'
)
parent_activity
=
auxargs
.
pop
(
'parent_activity'
)
parent_activity
=
auxargs
.
pop
(
'parent_activity'
)
if
parent_activity
and
user
is
None
and
not
skip_auth_check
:
if
parent_activity
and
user
is
None
and
not
skip_auth_check
:
user
=
parent_activity
.
user
user
=
allargs
[
'user'
]
=
parent_activity
.
user
if
user
is
None
:
# parent was a system call
if
user
is
None
:
# parent was a system call
skip_auth_check
=
True
skip_auth_check
=
True
...
...
circle/dashboard/models.py
View file @
29574622
...
@@ -46,7 +46,6 @@ from model_utils import Choices
...
@@ -46,7 +46,6 @@ from model_utils import Choices
from
acl.models
import
AclBase
from
acl.models
import
AclBase
from
common.models
import
HumanReadableObject
,
create_readable
,
Encoder
from
common.models
import
HumanReadableObject
,
create_readable
,
Encoder
from
vm.tasks.agent_tasks
import
add_keys
,
del_keys
from
vm.models.instance
import
ACCESS_METHODS
from
vm.models.instance
import
ACCESS_METHODS
from
.store_api
import
Store
,
NoStoreException
,
NotOkException
,
Timeout
from
.store_api
import
Store
,
NoStoreException
,
NotOkException
,
Timeout
...
@@ -429,9 +428,7 @@ def add_ssh_keys(sender, **kwargs):
...
@@ -429,9 +428,7 @@ def add_ssh_keys(sender, **kwargs):
'user'
,
userkey
.
user
)
.
filter
(
status
=
'RUNNING'
)
'user'
,
userkey
.
user
)
.
filter
(
status
=
'RUNNING'
)
for
i
in
instances
:
for
i
in
instances
:
logger
.
info
(
'called add_keys(
%
s,
%
s)'
,
i
,
userkey
)
logger
.
info
(
'called add_keys(
%
s,
%
s)'
,
i
,
userkey
)
queue
=
i
.
get_remote_queue_name
(
"agent"
)
i
.
install_keys
(
user
=
userkey
.
user
,
keys
=
[
userkey
.
key
])
add_keys
.
apply_async
(
args
=
(
i
.
vm_name
,
[
userkey
.
key
]),
queue
=
queue
)
def
del_ssh_keys
(
sender
,
**
kwargs
):
def
del_ssh_keys
(
sender
,
**
kwargs
):
...
@@ -442,9 +439,7 @@ def del_ssh_keys(sender, **kwargs):
...
@@ -442,9 +439,7 @@ def del_ssh_keys(sender, **kwargs):
'user'
,
userkey
.
user
)
.
filter
(
status
=
'RUNNING'
)
'user'
,
userkey
.
user
)
.
filter
(
status
=
'RUNNING'
)
for
i
in
instances
:
for
i
in
instances
:
logger
.
info
(
'called del_keys(
%
s,
%
s)'
,
i
,
userkey
)
logger
.
info
(
'called del_keys(
%
s,
%
s)'
,
i
,
userkey
)
queue
=
i
.
get_remote_queue_name
(
"agent"
)
i
.
remove_keys
(
user
=
userkey
.
user
,
keys
=
[
userkey
.
key
])
del_keys
.
apply_async
(
args
=
(
i
.
vm_name
,
[
userkey
.
key
]),
queue
=
queue
)
post_save
.
connect
(
add_ssh_keys
,
sender
=
UserKey
)
post_save
.
connect
(
add_ssh_keys
,
sender
=
UserKey
)
...
...
circle/dashboard/templates/dashboard/vm-detail/home.html
View file @
29574622
...
@@ -157,6 +157,16 @@
...
@@ -157,6 +157,16 @@
</a>
</a>
</div>
</div>
{% endif %}
{% endif %}
{% if op.install_keys %}
<strong>
{% trans "SSH keys" %}
</strong>
<div
class=
"operation-wrapper"
>
<a
href=
"{{ op.install_keys.get_url }}"
class=
"btn btn-info btn-xs operation"
{%
if
op
.
install_keys
.
disabled
%}
disabled
{%
endif
%}
>
<i
class=
"fa fa-{{op.install_keys.icon}}"
></i>
{{ op.install_keys.name }}
</a>
</div>
{% endif %}
</div>
</div>
<div
class=
"col-md-8"
>
<div
class=
"col-md-8"
>
{% if graphite_enabled %}
{% if graphite_enabled %}
...
...
circle/dashboard/views/vm.py
View file @
29574622
...
@@ -776,6 +776,10 @@ vm_ops = OrderedDict([
...
@@ -776,6 +776,10 @@ vm_ops = OrderedDict([
op
=
'mount_store'
,
icon
=
'briefcase'
,
effect
=
'info'
,
op
=
'mount_store'
,
icon
=
'briefcase'
,
effect
=
'info'
,
show_in_toolbar
=
False
,
show_in_toolbar
=
False
,
)),
)),
(
'install_keys'
,
VmOperationView
.
factory
(
op
=
'install_keys'
,
icon
=
'key'
,
effect
=
'info'
,
show_in_toolbar
=
False
,
)),
])
])
...
...
circle/vm/operations.py
View file @
29574622
...
@@ -1390,6 +1390,34 @@ class PasswordResetOperation(RemoteAgentOperation):
...
@@ -1390,6 +1390,34 @@ class PasswordResetOperation(RemoteAgentOperation):
@register_operation
@register_operation
class
InstallKeysOperation
(
RemoteAgentOperation
):
id
=
'install_keys'
name
=
_
(
"install SSH keys"
)
acl_level
=
"user"
task
=
agent_tasks
.
add_keys
required_perms
=
()
def
_get_remote_args
(
self
,
user
,
keys
=
None
,
**
kwargs
):
if
keys
is
None
:
keys
=
list
(
user
.
userkey_set
.
values_list
(
'key'
,
flat
=
True
))
return
(
super
(
InstallKeysOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
[
keys
])
@register_operation
class
RemoveKeysOperation
(
RemoteAgentOperation
):
id
=
'remove_keys'
name
=
_
(
"remove SSH keys"
)
acl_level
=
"user"
task
=
agent_tasks
.
del_keys
required_perms
=
()
def
_get_remote_args
(
self
,
user
,
keys
,
**
kwargs
):
return
(
super
(
RemoveKeysOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
[
keys
])
@register_operation
class
AgentStartedOperation
(
InstanceOperation
):
class
AgentStartedOperation
(
InstanceOperation
):
id
=
'agent_started'
id
=
'agent_started'
name
=
_
(
"agent"
)
name
=
_
(
"agent"
)
...
@@ -1462,6 +1490,7 @@ class AgentStartedOperation(InstanceOperation):
...
@@ -1462,6 +1490,7 @@ class AgentStartedOperation(InstanceOperation):
self
.
instance
.
_cleanup
(
parent_activity
=
activity
)
self
.
instance
.
_cleanup
(
parent_activity
=
activity
)
self
.
instance
.
password_reset
(
self
.
instance
.
password_reset
(
parent_activity
=
activity
,
password
=
self
.
instance
.
pw
)
parent_activity
=
activity
,
password
=
self
.
instance
.
pw
)
self
.
instance
.
install_keys
(
parent_activity
=
activity
)
self
.
instance
.
_set_time
(
parent_activity
=
activity
)
self
.
instance
.
_set_time
(
parent_activity
=
activity
)
self
.
instance
.
_set_hostname
(
parent_activity
=
activity
)
self
.
instance
.
_set_hostname
(
parent_activity
=
activity
)
...
...
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