Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
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
62dd4060
authored
Feb 11, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webui: Fixed template running instance number
parent
150644d6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
10 deletions
+14
-10
one/models.py
+3
-1
one/templates/box-templatelist.html
+2
-2
one/views.py
+9
-7
No files found.
one/models.py
View file @
62dd4060
...
...
@@ -283,6 +283,8 @@ class Template(models.Model):
help_text
=
(
_
(
'Name of operating system in format like "
%
s".'
)
%
"Ubuntu 12.04 LTS Desktop amd64"
))
def
running_instances
(
self
):
return
self
.
instance_set
.
exclude
(
state
=
'DONE'
)
.
count
()
def
os_type
(
self
):
if
self
.
access_type
==
'rdp'
:
return
"win"
...
...
@@ -294,7 +296,7 @@ class Template(models.Model):
@transaction.commit_on_success
def
safe_delete
(
self
):
if
not
self
.
instance_set
.
exists
():
if
not
self
.
instance_set
.
ex
clude
(
state
=
'DONE'
)
.
ex
ists
():
self
.
delete
()
return
True
else
:
...
...
one/templates/box-templatelist.html
View file @
62dd4060
...
...
@@ -25,7 +25,7 @@
</span></li>
<li
class=
"description"
>
{% trans "Description" %}:
<span
class=
"value"
>
{{t.description}}
</span><div
class=
"clear"
></div></li>
<li
class=
"date"
>
{% trans "Created at" %}:
<span
class=
"value"
>
{{t.created_at}} ({{t.owner.get_profile}})
</span><div
class=
"clear"
></div></li>
<li
class=
"count"
>
{% trans "Running instances" %}:
<span
class=
"value"
>
{{
t.instance_set.count
}}
</span></li>
<li
class=
"count"
>
{% trans "Running instances" %}:
<span
class=
"value"
>
{{
t.running_instances
}}
</span></li>
</ul>
</div>
</li>
...
...
@@ -72,7 +72,7 @@
</span></li>
<li
class=
"description"
>
{% trans "Description" %}:
<span
class=
"value"
>
{{t.description}}
</span><div
class=
"clear"
></div></li>
<li
class=
"date"
>
{% trans "Created at" %}:
<span
class=
"value"
>
{{t.created_at}} ({{t.owner.get_profile}})
</span><div
class=
"clear"
></div></li>
<li
class=
"count"
>
{% trans "Running instances" %}:
<span
class=
"value"
>
{{t.
instance_set.count
}}
</span></li>
<li
class=
"count"
>
{% trans "Running instances" %}:
<span
class=
"value"
>
{{t.
running_instances
}}
</span></li>
</ul>
</div>
</li>
...
...
one/views.py
View file @
62dd4060
...
...
@@ -89,15 +89,17 @@ def ajax_template_delete(request):
except
:
return
HttpResponse
(
unicode
(
_
(
"Invalid template ID."
)),
status
=
404
)
template
=
get_object_or_404
(
Template
,
id
=
template_id
)
if
template
.
instance_set
.
exists
()
:
if
template
.
running_instances
()
>
0
:
return
HttpResponse
(
unicode
(
_
(
"There are running instances of this template."
)),
status
=
404
)
elif
template
.
share_set
.
exists
():
return
HttpResponse
(
unicode
(
_
(
"Template is still shared."
)),
status
=
404
)
elif
template
.
owner
!=
request
.
user
:
return
HttpResponse
(
unicode
(
_
(
"You don't have permission to delete this template."
)),
status
=
404
)
else
:
template
.
safe_delete
()
if
template
.
safe_delete
():
return
HttpResponse
(
unicode
(
_
(
"Template successfully deleted."
)))
else
:
return
HttpResponse
(
unicode
(
_
(
"Unexpected error happened."
)),
status
=
404
)
def
ajax_template_name_unique
(
request
,
name
):
s
=
"True"
...
...
@@ -107,12 +109,12 @@ def ajax_template_name_unique(request, name):
@login_required
def
vm_credentials
(
request
,
iid
):
vm
=
get_object_or_404
(
Instance
,
pk
=
iid
)
if
vm
.
owner
==
request
.
user
:
try
:
vm
=
get_object_or_404
(
Instance
,
pk
=
iid
,
owner
=
request
.
user
)
return
render_to_response
(
'vm-credentials.html'
,
RequestContext
(
request
,
{
'i'
:
vm
}))
e
lse
:
return
HttpResponse
(
"Stale id."
)
e
xcept
:
return
HttpResponse
(
_
(
"Could not get Virtual Machine credentials."
),
code
=
404
)
messages
.
error
(
request
,
_
(
'Failed to power off virtual machine.'
))
class
AjaxTemplateWizard
(
View
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
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