Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
af334a69
authored
Sep 03, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: adding proprties and serializer
parent
01578707
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletions
+23
-1
storage/models.py
+23
-1
No files found.
storage/models.py
View file @
af334a69
...
...
@@ -14,6 +14,9 @@ logger = logging.getLogger(__name__)
class
DataStore
(
models
.
Model
):
'''
'''
name
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
verbose_name
=
_
(
'name'
))
path
=
models
.
CharField
(
max_length
=
200
,
unique
=
True
,
...
...
@@ -40,13 +43,15 @@ class Disk(TimeStampedModel):
type
=
models
.
CharField
(
max_length
=
10
,
choices
=
TYPES
)
base
=
models
.
ForeignKey
(
'self'
,
blank
=
True
null
=
True
,
related_name
=
'derivatives'
)
ready
=
models
.
BooleanField
(
default
=
False
)
dev_num
=
models
.
CharField
(
max_length
=
1
,
verbose_name
=
"device number"
)
class
Meta
:
ordering
=
[
'name'
]
verbose_name
=
_
(
'disk'
)
verbose_name_plural
=
_
(
'disks'
)
def
get_exc
ul
sive
(
self
):
def
get_exc
lu
sive
(
self
):
"""Get an instance of the disk for exclusive usage.
It might mean copying the disk, creating a snapshot or creating a
...
...
@@ -55,6 +60,23 @@ class Disk(TimeStampedModel):
# TODO implement (or call) logic
return
self
@property
def
device_type
(
self
):
return
{
'qcow2'
:
'vd'
,
'raw'
:
'vd'
,
'iso'
:
'hd'
,
}[
self
.
format
]
def
get_vmdisk_desc
(
self
):
return
{
'source'
:
self
.
datastore
.
path
+
'/'
+
self
.
name
,
'driver_type'
:
self
.
format
,
'driver_cache'
:
'default'
,
'target_device'
:
self
.
device_type
+
self
.
dev_num
}
def
to_json
(
self
):
self
.
base_name
=
self
.
base
.
name
if
self
.
base
else
None
self
.
dir
=
self
.
datastore
.
path
...
...
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