Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
storagedriver
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
a9c1e76b
authored
Oct 23, 2022
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'resize-via-qemu' into 'master'
resize add via qemu See merge request
!4
parents
2b5fe878
0794ccb1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
disk.py
+11
-1
storagedriver.py
+8
-1
No files found.
disk.py
View file @
a9c1e76b
...
...
@@ -217,8 +217,14 @@ class Disk(object):
os
.
removedirs
(
tmp_dir
)
self
.
size
=
Disk
.
get
(
self
.
dir
,
self
.
name
)
.
size
def
resize
(
self
,
newsize
):
file
=
self
.
get_path
()
# can't resize an image which has snapchots
cmdline
=
[
'qemu-img'
,
'resize'
,
file
,
newsize
]
subprocess
.
check_output
(
cmdline
)
self
.
size
=
Disk
.
get
(
self
.
dir
,
self
.
name
)
.
size
def
download
(
self
,
task
,
url
,
parent_id
=
None
):
# noqa
def
download
(
self
,
task
,
url
,
parent_id
=
None
,
resize
=
None
):
# noqa
"""Download image from url."""
disk_path
=
self
.
get_path
()
logger
.
info
(
"Downloading image from
%
s to
%
s"
,
url
,
disk_path
)
...
...
@@ -267,6 +273,10 @@ class Disk(object):
self
.
size
=
Disk
.
get
(
self
.
dir
,
self
.
name
)
.
size
logger
.
debug
(
"Download finished
%
s (
%
s bytes)"
,
self
.
name
,
self
.
size
)
if
resize
:
self
.
resize
(
resize
)
logger
.
debug
(
"Resize finished
%
s (
%
s bytes)"
,
self
.
name
,
self
.
size
)
except
AbortException
:
# Cleanup file:
os
.
unlink
(
disk_path
)
...
...
storagedriver.py
View file @
a9c1e76b
...
...
@@ -29,6 +29,12 @@ def create(disk_desc):
@celery.task
()
def
resizeqemu
(
disk_desc
,
newsize
):
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
resize
(
newsize
)
@celery.task
()
def
create_ci_disk
(
disk_desc
,
meta_data
,
user_data
,
network_data
):
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
create_ci_disk
(
meta_data
=
meta_data
,
user_data
=
user_data
,
network_data
=
network_data
)
...
...
@@ -44,8 +50,9 @@ class download(AbortableTask):
disk_desc
=
kwargs
[
'disk'
]
url
=
kwargs
[
'url'
]
parent_id
=
kwargs
.
get
(
"parent_id"
,
None
)
resize
=
kwargs
.
get
(
'resize'
,
None
)
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
download
(
self
,
url
,
parent_id
)
disk
.
download
(
self
,
url
,
parent_id
,
resize
)
return
{
'size'
:
disk
.
size
,
'type'
:
disk
.
format
,
'checksum'
:
disk
.
checksum
,
}
...
...
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