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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
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):
...
@@ -299,8 +299,7 @@ class Disk(object):
finally
:
finally
:
os
.
unlink
(
exported_path
)
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
:
with
ZipFile
(
disk_path
,
'r'
)
as
z
:
isos
=
z
.
namelist
()
isos
=
z
.
namelist
()
if
len
(
isos
)
!=
1
:
if
len
(
isos
)
!=
1
:
...
@@ -318,8 +317,7 @@ def extract_iso_from_zip(self, disk_path):
...
@@ -318,8 +317,7 @@ def extract_iso_from_zip(self, disk_path):
logger
.
info
(
"Extracting
%
s failed, keeping original."
,
logger
.
info
(
"Extracting
%
s failed, keeping original."
,
disk_path
)
disk_path
)
def
snapshot
(
self
):
def
snapshot
(
self
):
""" Creating qcow2 snapshot with base image.
""" Creating qcow2 snapshot with base image.
"""
"""
# Check if snapshot type and qcow2 format matchmatch
# Check if snapshot type and qcow2 format matchmatch
...
@@ -345,8 +343,7 @@ def snapshot(self):
...
@@ -345,8 +343,7 @@ def snapshot(self):
# Call subprocess
# Call subprocess
subprocess
.
check_output
(
cmdline
)
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
proc
=
None
try
:
try
:
cmdline
=
[
cmdline
=
[
...
@@ -398,8 +395,7 @@ def merge_disk_with_base(self, task, new_disk, parent_id=None):
...
@@ -398,8 +395,7 @@ def merge_disk_with_base(self, task, new_disk, parent_id=None):
os
.
unlink
(
new_disk
.
get_path
())
os
.
unlink
(
new_disk
.
get_path
())
raise
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
):
length
=
1024
*
1024
):
try
:
try
:
fsrc
=
open
(
self
.
get_path
(),
'rb'
)
fsrc
=
open
(
self
.
get_path
(),
'rb'
)
...
@@ -436,8 +432,7 @@ def merge_disk_without_base(self, task, new_disk, parent_id=None,
...
@@ -436,8 +432,7 @@ def merge_disk_without_base(self, task, new_disk, parent_id=None,
os
.
unlink
(
new_disk
.
get_path
())
os
.
unlink
(
new_disk
.
get_path
())
raise
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.
""" Merging a new_disk from the actual disk and its base.
"""
"""
...
@@ -455,14 +450,12 @@ def merge(self, task, new_disk, parent_id=None):
...
@@ -455,14 +450,12 @@ def merge(self, task, new_disk, parent_id=None):
else
:
else
:
self
.
merge_disk_without_base
(
task
,
new_disk
,
parent_id
)
self
.
merge_disk_without_base
(
task
,
new_disk
,
parent_id
)
def
delete
(
self
):
def
delete
(
self
):
""" Delete file. """
""" Delete file. """
if
os
.
path
.
isfile
(
self
.
get_path
()):
if
os
.
path
.
isfile
(
self
.
get_path
()):
os
.
unlink
(
self
.
get_path
())
os
.
unlink
(
self
.
get_path
())
@classmethod
@classmethod
def
list
(
cls
,
dir
):
def
list
(
cls
,
dir
):
""" List all files in <dir> directory."""
""" List all files in <dir> directory."""
return
[
cls
.
get
(
dir
,
file
)
for
file
in
os
.
listdir
(
dir
)]
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