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
006dcfa1
authored
Apr 03, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: add full Meta class to all models
fixes #118
parent
1191cf0b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletions
+21
-1
one/models.py
+21
-1
No files found.
one/models.py
View file @
006dcfa1
...
...
@@ -188,6 +188,11 @@ class Share(models.Model):
'user.'
))
owner
=
models
.
ForeignKey
(
User
,
null
=
True
,
blank
=
True
,
related_name
=
'share_set'
)
class
Meta
:
ordering
=
[
'group'
,
'template'
,
'owner'
,
]
verbose_name
=
_
(
'share'
)
verbose_name_plural
=
_
(
'shares'
)
def
get_type
(
self
):
t
=
TYPES
[
self
.
type
]
t
[
'deletex'
]
=
(
datetime
.
now
()
+
td
(
seconds
=
1
)
+
t
[
'delete'
]
...
...
@@ -210,9 +215,14 @@ class Share(models.Model):
return
running
.
filter
(
owner
=
user
)
.
count
()
else
:
return
running
.
count
()
def
get_instance_pc
(
self
):
return
float
(
self
.
get_running
())
/
self
.
instance_limit
*
100
def
__unicode__
(
self
):
return
u"
%(group)
s:
%(tpl)
s
%(owner)
s"
%
{
'group'
:
self
.
group
,
'tpl'
:
self
.
template
,
'owner'
:
self
.
owner
}
class
Disk
(
models
.
Model
):
"""Virtual disks automatically synchronized with OpenNebula."""
name
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
...
...
@@ -220,6 +230,8 @@ class Disk(models.Model):
class
Meta
:
ordering
=
[
'name'
]
verbose_name
=
_
(
'disk'
)
verbose_name_plural
=
_
(
'disks'
)
def
__unicode__
(
self
):
return
u"
%
s (#
%
d)"
%
(
self
.
name
,
self
.
id
)
...
...
@@ -259,6 +271,9 @@ class Network(models.Model):
class
Meta
:
ordering
=
[
'name'
]
verbose_name
=
_
(
'network'
)
verbose_name_plural
=
_
(
'networks'
)
def
__unicode__
(
self
):
return
self
.
name
...
...
@@ -298,6 +313,8 @@ class InstanceType(models.Model):
class
Meta
:
ordering
=
[
'credit'
]
verbose_name
=
_
(
'instance type'
)
verbose_name_plural
=
_
(
'instance types'
)
def
__unicode__
(
self
):
return
u"
%
s"
%
self
.
name
...
...
@@ -332,6 +349,8 @@ class Template(models.Model):
class
Meta
:
verbose_name
=
_
(
'template'
)
verbose_name_plural
=
_
(
'templates'
)
ordering
=
[
'name'
,
]
def
__unicode__
(
self
):
return
self
.
name
...
...
@@ -357,7 +376,7 @@ class Template(models.Model):
class
Instance
(
models
.
Model
):
"""Virtual machine instance."""
name
=
models
.
CharField
(
max_length
=
100
,
name
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
_
(
'name'
),
blank
=
True
)
ip
=
models
.
IPAddressField
(
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'IP address'
))
...
...
@@ -396,6 +415,7 @@ class Instance(models.Model):
class
Meta
:
verbose_name
=
_
(
'instance'
)
verbose_name_plural
=
_
(
'instances'
)
ordering
=
[
'pk'
,
]
def
__unicode__
(
self
):
return
self
.
name
...
...
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