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
b171f0a4
authored
Nov 28, 2019
by
Bálint Máhonfai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix indentation errors
parent
63579fd2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
15 deletions
+8
-15
disk.py
+8
-15
No files found.
disk.py
View file @
b171f0a4
...
...
@@ -299,8 +299,7 @@ class Disk(object):
finally
:
os
.
unlink
(
exported_path
)
def
extract_iso_from_zip
(
self
,
disk_path
):
def
extract_iso_from_zip
(
self
,
disk_path
):
with
ZipFile
(
disk_path
,
'r'
)
as
z
:
isos
=
z
.
namelist
()
if
len
(
isos
)
!=
1
:
...
...
@@ -318,8 +317,7 @@ def extract_iso_from_zip(self, disk_path):
logger
.
info
(
"Extracting
%
s failed, keeping original."
,
disk_path
)
def
snapshot
(
self
):
def
snapshot
(
self
):
""" Creating qcow2 snapshot with base image.
"""
# Check if snapshot type and qcow2 format matchmatch
...
...
@@ -345,8 +343,7 @@ def snapshot(self):
# Call subprocess
subprocess
.
check_output
(
cmdline
)
def
merge_disk_with_base
(
self
,
task
,
new_disk
,
parent_id
=
None
):
def
merge_disk_with_base
(
self
,
task
,
new_disk
,
parent_id
=
None
):
proc
=
None
try
:
cmdline
=
[
...
...
@@ -398,8 +395,7 @@ def merge_disk_with_base(self, task, new_disk, parent_id=None):
os
.
unlink
(
new_disk
.
get_path
())
raise
def
merge_disk_without_base
(
self
,
task
,
new_disk
,
parent_id
=
None
,
def
merge_disk_without_base
(
self
,
task
,
new_disk
,
parent_id
=
None
,
length
=
1024
*
1024
):
try
:
fsrc
=
open
(
self
.
get_path
(),
'rb'
)
...
...
@@ -436,8 +432,7 @@ def merge_disk_without_base(self, task, new_disk, parent_id=None,
os
.
unlink
(
new_disk
.
get_path
())
raise
def
merge
(
self
,
task
,
new_disk
,
parent_id
=
None
):
def
merge
(
self
,
task
,
new_disk
,
parent_id
=
None
):
""" Merging a new_disk from the actual disk and its base.
"""
...
...
@@ -455,14 +450,12 @@ def merge(self, task, new_disk, parent_id=None):
else
:
self
.
merge_disk_without_base
(
task
,
new_disk
,
parent_id
)
def
delete
(
self
):
def
delete
(
self
):
""" Delete file. """
if
os
.
path
.
isfile
(
self
.
get_path
()):
os
.
unlink
(
self
.
get_path
())
@classmethod
def
list
(
cls
,
dir
):
@classmethod
def
list
(
cls
,
dir
):
""" List all files in <dir> directory."""
return
[
cls
.
get
(
dir
,
file
)
for
file
in
os
.
listdir
(
dir
)]
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