Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
139b8230
authored
Jul 23, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added readable_name params
parent
ac493847
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
12 deletions
+48
-12
circle/vm/operations.py
+48
-12
No files found.
circle/vm/operations.py
View file @
139b8230
...
...
@@ -24,6 +24,8 @@ from django.core.exceptions import PermissionDenied
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
sizefield.utils
import
filesizeformat
from
celery.exceptions
import
TimeLimitExceeded
from
common.models
import
create_readable
...
...
@@ -107,7 +109,10 @@ class AddInterfaceOperation(InstanceOperation):
managed
=
managed
,
owner
=
user
,
vlan
=
vlan
)
if
self
.
instance
.
is_running
:
with
activity
.
sub_activity
(
'attach_network'
):
with
activity
.
sub_activity
(
'attach_network'
,
readable_name
=
ugettext_noop
(
"attach network"
)
):
self
.
instance
.
attach_network
(
net
)
net
.
deploy
()
...
...
@@ -149,14 +154,21 @@ class CreateDiskOperation(InstanceOperation):
self
.
instance
.
disks
.
add
(
disk
)
if
self
.
instance
.
is_running
:
with
activity
.
sub_activity
(
'deploying_disk'
):
with
activity
.
sub_activity
(
'deploying_disk'
,
readable_name
=
ugettext_noop
(
"deploying disk"
)
):
disk
.
deploy
()
with
activity
.
sub_activity
(
'attach_disk'
):
with
activity
.
sub_activity
(
'attach_disk'
,
readable_name
=
ugettext_noop
(
"attach disk"
)
):
self
.
instance
.
attach_disk
(
disk
)
def
get_activity_name
(
self
,
kwargs
):
return
create_readable
(
ugettext_noop
(
"create
%(size)
s disk"
),
size
=
kwargs
[
'size'
])
return
create_readable
(
ugettext_noop
(
"create disk
%(name)
s (
%(size)
s)"
),
size
=
filesizeformat
(
kwargs
[
'size'
]),
name
=
kwargs
[
'name'
])
register_operation
(
CreateDiskOperation
)
...
...
@@ -193,7 +205,10 @@ class DownloadDiskOperation(InstanceOperation):
# TODO iso (cd) hot-plug is not supported by kvm/guests
if
self
.
instance
.
is_running
and
disk
.
type
not
in
[
"iso"
]:
with
activity
.
sub_activity
(
'attach_disk'
):
with
activity
.
sub_activity
(
'attach_disk'
,
readable_name
=
ugettext_noop
(
"attach disk"
)
):
self
.
instance
.
attach_disk
(
disk
)
register_operation
(
DownloadDiskOperation
)
...
...
@@ -398,13 +413,20 @@ class RemoveInterfaceOperation(InstanceOperation):
def
_operation
(
self
,
activity
,
user
,
system
,
interface
):
if
self
.
instance
.
is_running
:
with
activity
.
sub_activity
(
'detach_network'
):
with
activity
.
sub_activity
(
'detach_network'
,
readable_name
=
ugettext_noop
(
"detach network"
)
):
self
.
instance
.
detach_network
(
interface
)
interface
.
shutdown
()
interface
.
destroy
()
interface
.
delete
()
def
get_activity_name
(
self
,
kwargs
):
return
create_readable
(
ugettext_noop
(
"remove
%(vlan)
s interface"
),
vlan
=
kwargs
[
'vlan'
])
register_operation
(
RemoveInterfaceOperation
)
...
...
@@ -423,10 +445,20 @@ class RemoveDiskOperation(InstanceOperation):
def
_operation
(
self
,
activity
,
user
,
system
,
disk
):
if
self
.
instance
.
is_running
and
disk
.
type
not
in
[
"iso"
]:
with
activity
.
sub_activity
(
'detach_disk'
):
with
activity
.
sub_activity
(
'detach_disk'
,
readable_name
=
ugettext_noop
(
'detach disk'
)
):
self
.
instance
.
detach_disk
(
disk
)
return
self
.
instance
.
disks
.
remove
(
disk
)
with
activity
.
sub_activity
(
'destroy_disk'
,
readable_name
=
ugettext_noop
(
'destroy disk'
)
):
return
self
.
instance
.
disks
.
remove
(
disk
)
def
get_activity_name
(
self
,
kwargs
):
return
create_readable
(
ugettext_noop
(
'remove disk
%(name)
s'
),
name
=
kwargs
[
"disk"
]
.
name
)
register_operation
(
RemoveDiskOperation
)
...
...
@@ -523,9 +555,13 @@ class SaveAsTemplateOperation(InstanceOperation):
return
disk
self
.
disks
=
[]
with
activity
.
sub_activity
(
'saving_disks'
,
readable_name
=
ugettext_noop
(
"save disks"
)):
for
disk
in
self
.
instance
.
disks
.
all
():
for
disk
in
self
.
instance
.
disks
.
all
():
with
activity
.
sub_activity
(
'saving_disk'
,
readable_name
=
create_readable
(
ugettext_noop
(
"saving disk
%(name)
s"
),
name
=
disk
.
name
)
):
self
.
disks
.
append
(
__try_save_disk
(
disk
))
for
disk
in
self
.
disks
:
...
...
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