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
e1497ebf
authored
Sep 26, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add merge function
parent
ca4ffe04
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
disk.py
+22
-2
No files found.
disk.py
View file @
e1497ebf
...
...
@@ -103,16 +103,36 @@ class Disk(object):
# Check if base file exist
if
not
os
.
path
.
isfile
(
self
.
get_base
()):
raise
Exception
(
'Image Base does not exists:
%
s'
%
self
.
get_base
())
qemu_format
=
self
.
match_types
(
self
.
SNAPSHOT_TYPES
)
# Build list of Strings as command parameters
cmdline
=
[
'qemu-img'
,
'create'
,
'-f'
,
qemu_
format
,
'-f'
,
self
.
format
,
'-b'
,
self
.
get_base
(),
str
(
self
.
size
)]
# Call subprocess
subprocess
.
check_output
(
cmdline
)
def
merge
(
self
,
new_disk
):
''' Merging a new_disk from the actual disk and its base.
'''
# Check if snapshot type match
if
self
.
format
!=
'qcow2'
:
raise
Exception
(
'Invalid format:
%
s'
%
self
.
format
)
# Check if file already exists
if
os
.
path
.
isfile
(
new_disk
.
get_path
()):
raise
Exception
(
'File already exists:
%
s'
%
self
.
get_path
())
# Check if base file exist
if
not
os
.
path
.
isfile
(
self
.
get_path
()):
raise
Exception
(
'Original image does not exists:
%
s'
%
self
.
get_base
())
cmdline
=
[
'qemu-img'
,
'convert'
,
self
.
get_path
(),
'-O'
,
new_disk
.
format
,
new_disk
.
get_path
()]
# Call subprocess
subprocess
.
check_output
(
cmdline
)
def
delete
(
self
):
''' Delete file
'''
...
...
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