Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
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
283da340
authored
Sep 25, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: create model for disk activity
parent
d8650c62
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
20 deletions
+35
-20
circle/storage/models.py
+35
-20
No files found.
circle/storage/models.py
View file @
283da340
...
@@ -3,7 +3,9 @@
...
@@ -3,7 +3,9 @@
import
logging
import
logging
import
uuid
import
uuid
from
django.db
import
models
from
django.contrib.auth.models
import
User
from
django.db.models
import
(
Model
,
BooleanField
,
CharField
,
DateTimeField
,
ForeignKey
,
TextField
)
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
model_utils.models
import
TimeStampedModel
from
model_utils.models
import
TimeStampedModel
from
sizefield.models
import
FileSizeField
from
sizefield.models
import
FileSizeField
...
@@ -13,16 +15,14 @@ from .tasks import local_tasks, remote_tasks
...
@@ -13,16 +15,14 @@ from .tasks import local_tasks, remote_tasks
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
class
DataStore
(
models
.
Model
):
class
DataStore
(
Model
):
"""Collection of virtual disks.
"""Collection of virtual disks.
"""
"""
name
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
name
=
CharField
(
max_length
=
100
,
unique
=
True
,
verbose_name
=
_
(
'name'
))
verbose_name
=
_
(
'name'
))
path
=
CharField
(
max_length
=
200
,
unique
=
True
,
verbose_name
=
_
(
'path'
))
path
=
models
.
CharField
(
max_length
=
200
,
unique
=
True
,
hostname
=
CharField
(
max_length
=
40
,
unique
=
True
,
verbose_name
=
_
(
'path'
))
verbose_name
=
_
(
'hostname'
))
hostname
=
models
.
CharField
(
max_length
=
40
,
unique
=
True
,
verbose_name
=
_
(
'hostname'
))
class
Meta
:
class
Meta
:
ordering
=
[
'name'
]
ordering
=
[
'name'
]
...
@@ -39,17 +39,17 @@ class Disk(TimeStampedModel):
...
@@ -39,17 +39,17 @@ class Disk(TimeStampedModel):
"""
"""
TYPES
=
[(
'qcow2-norm'
,
'qcow2 normal'
),
(
'qcow2-snap'
,
'qcow2 snapshot'
),
TYPES
=
[(
'qcow2-norm'
,
'qcow2 normal'
),
(
'qcow2-snap'
,
'qcow2 snapshot'
),
(
'iso'
,
'iso'
),
(
'raw-ro'
,
'raw read-only'
),
(
'raw-rw'
,
'raw'
)]
(
'iso'
,
'iso'
),
(
'raw-ro'
,
'raw read-only'
),
(
'raw-rw'
,
'raw'
)]
name
=
models
.
CharField
(
blank
=
True
,
max_length
=
100
,
name
=
CharField
(
blank
=
True
,
max_length
=
100
,
verbose_name
=
_
(
"name"
))
verbose_name
=
_
(
'name'
))
filename
=
CharField
(
max_length
=
256
,
verbose_name
=
_
(
"filename"
))
filename
=
models
.
CharField
(
max_length
=
256
,
verbose_name
=
_
(
'filename'
))
datastore
=
ForeignKey
(
DataStore
,
verbose_name
=
_
(
"datastore"
),
datastore
=
models
.
ForeignKey
(
DataStore
)
help_text
=
_
(
"The datastore that holds the disk."
)
)
type
=
models
.
CharField
(
max_length
=
10
,
choices
=
TYPES
)
type
=
CharField
(
max_length
=
10
,
choices
=
TYPES
)
size
=
FileSizeField
()
size
=
FileSizeField
()
base
=
models
.
ForeignKey
(
'self'
,
blank
=
True
,
null
=
True
,
base
=
ForeignKey
(
'self'
,
blank
=
True
,
null
=
True
,
related_name
=
'derivatives'
)
related_name
=
'derivatives'
)
ready
=
models
.
BooleanField
(
default
=
False
)
ready
=
BooleanField
(
default
=
False
)
dev_num
=
models
.
CharField
(
default
=
'a'
,
max_length
=
1
,
dev_num
=
CharField
(
default
=
'a'
,
max_length
=
1
,
verbose_name
=
"device number"
)
verbose_name
=
"device number"
)
class
Meta
:
class
Meta
:
ordering
=
[
'name'
]
ordering
=
[
'name'
]
...
@@ -91,8 +91,9 @@ class Disk(TimeStampedModel):
...
@@ -91,8 +91,9 @@ class Disk(TimeStampedModel):
'raw-ro'
:
'raw-rw'
,
'raw-ro'
:
'raw-rw'
,
}[
self
.
type
]
}[
self
.
type
]
return
Disk
(
base
=
self
,
datastore
=
self
.
datastore
,
filename
=
filename
,
return
Disk
.
objects
.
create
(
base
=
self
,
datastore
=
self
.
datastore
,
name
=
self
.
name
,
size
=
self
.
size
,
type
=
new_type
)
filename
=
filename
,
name
=
self
.
name
,
size
=
self
.
size
,
type
=
new_type
)
@property
@property
def
device_type
(
self
):
def
device_type
(
self
):
...
@@ -149,3 +150,17 @@ class Disk(TimeStampedModel):
...
@@ -149,3 +150,17 @@ class Disk(TimeStampedModel):
# TODO
# TODO
# StorageDriver.delete_disk.delay(instance.to_json()).get()
# StorageDriver.delete_disk.delay(instance.to_json()).get()
pass
pass
class
DiskActivity
(
TimeStampedModel
):
activity_code
=
CharField
(
verbose_name
=
_
(
'activity_code'
),
max_length
=
100
)
task_uuid
=
CharField
(
verbose_name
=
_
(
'task_uuid'
),
blank
=
True
,
max_length
=
50
,
null
=
True
,
unique
=
True
)
disk
=
ForeignKey
(
Disk
,
verbose_name
=
_
(
'disk'
),
related_name
=
'activity_log'
)
user
=
ForeignKey
(
User
,
verbose_name
=
_
(
'user'
),
blank
=
True
,
null
=
True
)
started
=
DateTimeField
(
verbose_name
=
_
(
'started'
),
blank
=
True
,
null
=
True
)
finished
=
DateTimeField
(
verbose_name
=
_
(
'finished'
),
blank
=
True
,
null
=
True
)
result
=
TextField
(
verbose_name
=
_
(
'result'
),
blank
=
True
,
null
=
True
)
state
=
CharField
(
verbose_name
=
_
(
'state'
),
default
=
'PENDING'
,
max_length
=
50
)
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