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
0794ccb1
authored
Oct 20, 2022
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resize add via qemu
parent
2b5fe878
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 @
0794ccb1
...
@@ -217,8 +217,14 @@ class Disk(object):
...
@@ -217,8 +217,14 @@ class Disk(object):
os
.
removedirs
(
tmp_dir
)
os
.
removedirs
(
tmp_dir
)
self
.
size
=
Disk
.
get
(
self
.
dir
,
self
.
name
)
.
size
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."""
"""Download image from url."""
disk_path
=
self
.
get_path
()
disk_path
=
self
.
get_path
()
logger
.
info
(
"Downloading image from
%
s to
%
s"
,
url
,
disk_path
)
logger
.
info
(
"Downloading image from
%
s to
%
s"
,
url
,
disk_path
)
...
@@ -267,6 +273,10 @@ class Disk(object):
...
@@ -267,6 +273,10 @@ class Disk(object):
self
.
size
=
Disk
.
get
(
self
.
dir
,
self
.
name
)
.
size
self
.
size
=
Disk
.
get
(
self
.
dir
,
self
.
name
)
.
size
logger
.
debug
(
"Download finished
%
s (
%
s bytes)"
,
logger
.
debug
(
"Download finished
%
s (
%
s bytes)"
,
self
.
name
,
self
.
size
)
self
.
name
,
self
.
size
)
if
resize
:
self
.
resize
(
resize
)
logger
.
debug
(
"Resize finished
%
s (
%
s bytes)"
,
self
.
name
,
self
.
size
)
except
AbortException
:
except
AbortException
:
# Cleanup file:
# Cleanup file:
os
.
unlink
(
disk_path
)
os
.
unlink
(
disk_path
)
...
...
storagedriver.py
View file @
0794ccb1
...
@@ -29,6 +29,12 @@ def create(disk_desc):
...
@@ -29,6 +29,12 @@ def create(disk_desc):
@celery.task
()
@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
):
def
create_ci_disk
(
disk_desc
,
meta_data
,
user_data
,
network_data
):
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
create_ci_disk
(
meta_data
=
meta_data
,
user_data
=
user_data
,
network_data
=
network_data
)
disk
.
create_ci_disk
(
meta_data
=
meta_data
,
user_data
=
user_data
,
network_data
=
network_data
)
...
@@ -44,8 +50,9 @@ class download(AbortableTask):
...
@@ -44,8 +50,9 @@ class download(AbortableTask):
disk_desc
=
kwargs
[
'disk'
]
disk_desc
=
kwargs
[
'disk'
]
url
=
kwargs
[
'url'
]
url
=
kwargs
[
'url'
]
parent_id
=
kwargs
.
get
(
"parent_id"
,
None
)
parent_id
=
kwargs
.
get
(
"parent_id"
,
None
)
resize
=
kwargs
.
get
(
'resize'
,
None
)
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
download
(
self
,
url
,
parent_id
)
disk
.
download
(
self
,
url
,
parent_id
,
resize
)
return
{
'size'
:
disk
.
size
,
return
{
'size'
:
disk
.
size
,
'type'
:
disk
.
format
,
'type'
:
disk
.
format
,
'checksum'
:
disk
.
checksum
,
}
'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