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
978b1340
authored
Feb 13, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: add batch options to InstanceAdmin
parent
2b501ced
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletions
+22
-1
one/admin.py
+22
-1
No files found.
one/admin.py
View file @
978b1340
...
@@ -47,8 +47,27 @@ update_state.short_description = _('Update status')
...
@@ -47,8 +47,27 @@ update_state.short_description = _('Update status')
def
submit_vm
(
modeladmin
,
request
,
queryset
):
def
submit_vm
(
modeladmin
,
request
,
queryset
):
for
i
in
queryset
.
all
():
for
i
in
queryset
.
all
():
i
.
submit
(
request
.
user
)
i
.
submit
(
request
.
user
)
i
.
update_state
()
submit_vm
.
short_description
=
_
(
'Submit VM'
)
submit_vm
.
short_description
=
_
(
'Submit VM'
)
def
delete_vm
(
modeladmin
,
request
,
queryset
):
for
i
in
queryset
.
exclude
(
state
=
'DONE'
)
.
all
():
i
.
one_delete
()
i
.
update_state
()
delete_vm
.
short_description
=
_
(
'Delete VM'
)
def
suspend_vm
(
modeladmin
,
request
,
queryset
):
for
i
in
queryset
.
filter
(
state
=
'ACTIVE'
)
.
all
():
i
.
stop
()
i
.
update_state
()
suspend_vm
.
short_description
=
_
(
'Suspend VM'
)
def
resume_vm
(
modeladmin
,
request
,
queryset
):
for
i
in
queryset
.
filter
(
state__in
=
(
'STOPPED'
,
'SUSPENDED'
))
.
all
():
i
.
resume
()
i
.
update_state
()
resume_vm
.
short_description
=
_
(
'Resume VM'
)
class
TemplateAdmin
(
contrib
.
admin
.
ModelAdmin
):
class
TemplateAdmin
(
contrib
.
admin
.
ModelAdmin
):
model
=
models
.
Template
model
=
models
.
Template
...
@@ -57,10 +76,12 @@ class TemplateAdmin(contrib.admin.ModelAdmin):
...
@@ -57,10 +76,12 @@ class TemplateAdmin(contrib.admin.ModelAdmin):
class
InstanceAdmin
(
contrib
.
admin
.
ModelAdmin
):
class
InstanceAdmin
(
contrib
.
admin
.
ModelAdmin
):
model
=
models
.
Instance
model
=
models
.
Instance
actions
=
[
update_state
,
submit_vm
]
actions
=
[
update_state
,
submit_vm
,
delete_vm
,
suspend_vm
,
resume_vm
]
list_display
=
(
'id'
,
'name'
,
owner_person
,
'state'
)
list_display
=
(
'id'
,
'name'
,
owner_person
,
'state'
)
readonly_fields
=
(
'ip'
,
'active_since'
,
'pw'
,
'template'
)
readonly_fields
=
(
'ip'
,
'active_since'
,
'pw'
,
'template'
)
list_filter
=
(
'owner'
,
'template'
,
'state'
)
list_filter
=
(
'owner'
,
'template'
,
'state'
)
def
queryset
(
self
,
request
):
return
super
(
InstanceAdmin
,
self
)
.
queryset
(
request
)
class
DiskAdmin
(
contrib
.
admin
.
ModelAdmin
):
class
DiskAdmin
(
contrib
.
admin
.
ModelAdmin
):
model
=
models
.
Disk
model
=
models
.
Disk
...
...
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