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
2dea86ba
authored
Feb 11, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: Added Share quota
parent
82dccc14
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
5 deletions
+11
-5
one/models.py
+8
-2
one/templates/home.html
+2
-2
one/views.py
+1
-1
No files found.
one/models.py
View file @
2dea86ba
...
@@ -169,6 +169,12 @@ class Share(models.Model):
...
@@ -169,6 +169,12 @@ class Share(models.Model):
per_user_limit
=
models
.
IntegerField
(
verbose_name
=
_
(
'per user limit'
),
per_user_limit
=
models
.
IntegerField
(
verbose_name
=
_
(
'per user limit'
),
help_text
=
_
(
'Maximal count of instances launchable by a single user.'
))
help_text
=
_
(
'Maximal count of instances launchable by a single user.'
))
def
get_running_or_stopped
(
self
):
return
Instance
.
objects
.
all
()
.
exclude
(
state
=
'DONE'
)
.
filter
(
share
=
self
)
.
count
()
def
get_running
(
self
):
return
Instance
.
objects
.
all
()
.
exclude
(
state
=
'DONE'
)
.
exclude
(
state
=
'STOPPED'
)
.
filter
(
share
=
self
)
.
count
()
def
get_instance_pc
(
self
):
return
float
(
self
.
get_running
())
/
self
.
instance_limit
*
100
"""
"""
Virtual disks automatically synchronized with OpenNebula.
Virtual disks automatically synchronized with OpenNebula.
"""
"""
...
@@ -417,10 +423,10 @@ class Instance(models.Model):
...
@@ -417,10 +423,10 @@ class Instance(models.Model):
Submit a new instance to OpenNebula.
Submit a new instance to OpenNebula.
"""
"""
@classmethod
@classmethod
def
submit
(
cls
,
template
,
owner
,
extra
=
""
):
def
submit
(
cls
,
template
,
owner
,
extra
=
""
,
share
=
None
):
from
django.template.defaultfilters
import
escape
from
django.template.defaultfilters
import
escape
out
=
""
out
=
""
inst
=
Instance
(
pw
=
pwgen
(),
template
=
template
,
owner
=
owner
)
inst
=
Instance
(
pw
=
pwgen
(),
template
=
template
,
owner
=
owner
,
share
=
share
)
inst
.
save
()
inst
.
save
()
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
as
f
:
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
as
f
:
os
.
chmod
(
f
.
name
,
stat
.
S_IRUSR
|
stat
.
S_IWUSR
|
stat
.
S_IRGRP
|
stat
.
S_IROTH
)
os
.
chmod
(
f
.
name
,
stat
.
S_IRUSR
|
stat
.
S_IWUSR
|
stat
.
S_IRGRP
|
stat
.
S_IROTH
)
...
...
one/templates/home.html
View file @
2dea86ba
...
@@ -26,11 +26,11 @@
...
@@ -26,11 +26,11 @@
<li
class=
"wm"
>
<li
class=
"wm"
>
<div
class=
"summary"
>
<div
class=
"summary"
>
<div
class=
"quota"
>
<div
class=
"quota"
>
<div
class=
"used"
style=
"width:
40
%"
></div>
<div
class=
"used"
style=
"width:
{{ s.get_instance_pc }}
%"
></div>
</div>
</div>
<div
class=
"name wm-on"
>
{{s.name}}
</div>
<div
class=
"name wm-on"
>
{{s.name}}
</div>
<div
class=
"status"
>
<div
class=
"status"
>
3/10
{{s.get_running}}/{{s.instance_limit}}
</div>
</div>
<div
class=
"clear"
></div>
<div
class=
"clear"
></div>
</div>
</div>
...
...
one/views.py
View file @
2dea86ba
...
@@ -210,7 +210,7 @@ def vm_new(request, template=None, share=None):
...
@@ -210,7 +210,7 @@ def vm_new(request, template=None, share=None):
t
.
save
()
t
.
save
()
base
=
t
base
=
t
try
:
try
:
i
=
Instance
.
submit
(
base
,
request
.
user
,
extra
=
"<RECONTEXT>YES</RECONTEXT>"
)
i
=
Instance
.
submit
(
base
,
request
.
user
,
extra
=
"<RECONTEXT>YES</RECONTEXT>"
,
share
=
share
)
return
redirect
(
i
)
return
redirect
(
i
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
'Failed to create virtual machine.'
+
unicode
(
e
))
logger
.
error
(
'Failed to create virtual machine.'
+
unicode
(
e
))
...
...
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