Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
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):
...
@@ -188,6 +188,11 @@ class Share(models.Model):
'user.'
))
'user.'
))
owner
=
models
.
ForeignKey
(
User
,
null
=
True
,
blank
=
True
,
related_name
=
'share_set'
)
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
):
def
get_type
(
self
):
t
=
TYPES
[
self
.
type
]
t
=
TYPES
[
self
.
type
]
t
[
'deletex'
]
=
(
datetime
.
now
()
+
td
(
seconds
=
1
)
+
t
[
'delete'
]
t
[
'deletex'
]
=
(
datetime
.
now
()
+
td
(
seconds
=
1
)
+
t
[
'delete'
]
...
@@ -210,9 +215,14 @@ class Share(models.Model):
...
@@ -210,9 +215,14 @@ class Share(models.Model):
return
running
.
filter
(
owner
=
user
)
.
count
()
return
running
.
filter
(
owner
=
user
)
.
count
()
else
:
else
:
return
running
.
count
()
return
running
.
count
()
def
get_instance_pc
(
self
):
def
get_instance_pc
(
self
):
return
float
(
self
.
get_running
())
/
self
.
instance_limit
*
100
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
):
class
Disk
(
models
.
Model
):
"""Virtual disks automatically synchronized with OpenNebula."""
"""Virtual disks automatically synchronized with OpenNebula."""
name
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
name
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
...
@@ -220,6 +230,8 @@ class Disk(models.Model):
...
@@ -220,6 +230,8 @@ class Disk(models.Model):
class
Meta
:
class
Meta
:
ordering
=
[
'name'
]
ordering
=
[
'name'
]
verbose_name
=
_
(
'disk'
)
verbose_name_plural
=
_
(
'disks'
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
u"
%
s (#
%
d)"
%
(
self
.
name
,
self
.
id
)
return
u"
%
s (#
%
d)"
%
(
self
.
name
,
self
.
id
)
...
@@ -259,6 +271,9 @@ class Network(models.Model):
...
@@ -259,6 +271,9 @@ class Network(models.Model):
class
Meta
:
class
Meta
:
ordering
=
[
'name'
]
ordering
=
[
'name'
]
verbose_name
=
_
(
'network'
)
verbose_name_plural
=
_
(
'networks'
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
self
.
name
return
self
.
name
...
@@ -298,6 +313,8 @@ class InstanceType(models.Model):
...
@@ -298,6 +313,8 @@ class InstanceType(models.Model):
class
Meta
:
class
Meta
:
ordering
=
[
'credit'
]
ordering
=
[
'credit'
]
verbose_name
=
_
(
'instance type'
)
verbose_name_plural
=
_
(
'instance types'
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
u"
%
s"
%
self
.
name
return
u"
%
s"
%
self
.
name
...
@@ -332,6 +349,8 @@ class Template(models.Model):
...
@@ -332,6 +349,8 @@ class Template(models.Model):
class
Meta
:
class
Meta
:
verbose_name
=
_
(
'template'
)
verbose_name
=
_
(
'template'
)
verbose_name_plural
=
_
(
'templates'
)
verbose_name_plural
=
_
(
'templates'
)
ordering
=
[
'name'
,
]
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
self
.
name
return
self
.
name
...
@@ -357,7 +376,7 @@ class Template(models.Model):
...
@@ -357,7 +376,7 @@ class Template(models.Model):
class
Instance
(
models
.
Model
):
class
Instance
(
models
.
Model
):
"""Virtual machine instance."""
"""Virtual machine instance."""
name
=
models
.
CharField
(
max_length
=
100
,
name
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
_
(
'name'
),
blank
=
True
)
verbose_name
=
_
(
'name'
),
blank
=
True
)
ip
=
models
.
IPAddressField
(
blank
=
True
,
null
=
True
,
ip
=
models
.
IPAddressField
(
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'IP address'
))
verbose_name
=
_
(
'IP address'
))
...
@@ -396,6 +415,7 @@ class Instance(models.Model):
...
@@ -396,6 +415,7 @@ class Instance(models.Model):
class
Meta
:
class
Meta
:
verbose_name
=
_
(
'instance'
)
verbose_name
=
_
(
'instance'
)
verbose_name_plural
=
_
(
'instances'
)
verbose_name_plural
=
_
(
'instances'
)
ordering
=
[
'pk'
,
]
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
self
.
name
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