Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
storagedriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
4
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
89bbef63
authored
Sep 26, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
declare TYPES need review
parent
1ccb2da4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
disk.py
+12
-5
No files found.
disk.py
View file @
89bbef63
...
@@ -8,19 +8,26 @@ re_qemu_img = re.compile(r'(file format: (?P<format>(qcow2|raw))|'
...
@@ -8,19 +8,26 @@ re_qemu_img = re.compile(r'(file format: (?P<format>(qcow2|raw))|'
class
Disk
(
object
):
class
Disk
(
object
):
''' Storage driver DISK object.
Handle qcow2, raw and iso images.
TYPES, CREATE_TYPES, SNAPSHOT_TYPES are hand managed restrictions.
'''
TYPES
=
[(
'qcow2-norm'
,
'qcow2 normal'
),
(
'qcow2-snap'
,
'qcow2 snapshot'
),
(
'iso'
,
'iso'
),
(
'raw-ro'
,
'raw read-only'
),
(
'raw-rw'
,
'raw'
)]
def
__init__
(
self
,
dir
,
name
,
format
,
size
,
base_name
,
type
):
CREATE_TYPES
=
[(
'qcow2-norm'
,
'qcow2'
),
(
'raw-ro'
,
'raw'
),
(
'raw-rw'
,
'raw'
)]
SNAPSHOT_TYPES
=
[(
'qcow2-snap'
,
'qcow2'
)]
def
__init__
(
self
,
dir
,
name
,
format
,
size
,
base_name
):
# TODO: tests
# TODO: tests
self
.
name
=
name
self
.
name
=
name
self
.
dir
=
os
.
path
.
realpath
(
dir
)
self
.
dir
=
os
.
path
.
realpath
(
dir
)
if
format
not
in
[
'qcow2'
,
'raw'
]:
if
format
not
in
[
k
[
0
]
for
k
in
self
.
TYPES
]:
raise
Exception
(
'Invalid format:
%
s'
%
format
)
raise
Exception
(
'Invalid format:
%
s'
%
format
)
self
.
format
=
format
self
.
format
=
format
self
.
size
=
int
(
size
)
self
.
size
=
int
(
size
)
self
.
base_name
=
base_name
self
.
base_name
=
base_name
if
type
not
in
[
'normal'
,
'snapshot'
]:
raise
Exception
(
'Invalid type:
%
s'
%
type
)
self
.
type
=
type
@classmethod
@classmethod
def
deserialize
(
cls
,
desc
):
def
deserialize
(
cls
,
desc
):
...
...
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