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
6b3d5ad3
authored
Aug 08, 2022
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ci-integration' into 'master'
Ci integration See merge request
!2
parents
2ee7f788
b21ada3c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
disk.py
+24
-2
storagedriver.py
+9
-0
No files found.
disk.py
View file @
6b3d5ad3
...
@@ -193,6 +193,27 @@ class Disk(object):
...
@@ -193,6 +193,27 @@ class Disk(object):
return
True
return
True
return
False
return
False
def
create_ci_disk
(
self
,
meta_data
,
user_data
):
tmp_dir
=
self
.
dir
+
'/dir'
+
self
.
name
os
.
mkdir
(
tmp_dir
)
meta_path
=
tmp_dir
+
'/meta-data'
user_path
=
tmp_dir
+
'/user-data'
with
open
(
meta_path
,
'w'
)
as
f
:
f
.
write
(
meta_data
)
with
open
(
user_path
,
'w'
)
as
f
:
f
.
write
(
user_data
)
cmdline
=
[
'genisoimage'
,
'-output'
,
self
.
get_path
(),
'-V'
,
'cidata'
,
'-r'
,
'-J'
,
meta_path
,
user_path
]
subprocess
.
check_output
(
cmdline
)
os
.
remove
(
meta_path
)
os
.
remove
(
user_path
)
os
.
removedirs
(
tmp_dir
)
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
):
# noqa
"""Download image from url."""
"""Download image from url."""
disk_path
=
self
.
get_path
()
disk_path
=
self
.
get_path
()
...
@@ -365,6 +386,7 @@ class Disk(object):
...
@@ -365,6 +386,7 @@ class Disk(object):
def
snapshot
(
self
):
def
snapshot
(
self
):
""" Creating qcow2 snapshot with base image.
""" Creating qcow2 snapshot with base image.
"""
"""
logger
.
debug
(
'Create snapshot from base-image:
%
s'
,
self
.
get_desc
())
# Check if snapshot type and qcow2 format matchmatch
# Check if snapshot type and qcow2 format matchmatch
if
self
.
type
!=
'snapshot'
:
if
self
.
type
!=
'snapshot'
:
raise
Exception
(
'Invalid type:
%
s'
%
self
.
type
)
raise
Exception
(
'Invalid type:
%
s'
%
self
.
type
)
...
@@ -380,10 +402,10 @@ class Disk(object):
...
@@ -380,10 +402,10 @@ class Disk(object):
elif
self
.
format
==
'raw'
:
elif
self
.
format
==
'raw'
:
raise
NotImplemented
()
raise
NotImplemented
()
else
:
else
:
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
cmdline
=
[
#
'ionice', '-c', 'idle',
'qemu-img'
,
'create'
,
'qemu-img'
,
'create'
,
'-f'
,
self
.
format
,
'-F'
,
'qcow2'
,
'-b'
,
self
.
get_base
(),
'-b'
,
self
.
get_base
(),
'-f'
,
self
.
format
,
self
.
get_path
()]
self
.
get_path
()]
# Call subprocess
# Call subprocess
subprocess
.
check_output
(
cmdline
)
subprocess
.
check_output
(
cmdline
)
...
...
storagedriver.py
View file @
6b3d5ad3
...
@@ -28,6 +28,15 @@ def create(disk_desc):
...
@@ -28,6 +28,15 @@ def create(disk_desc):
disk
.
create
()
disk
.
create
()
@celery.task
()
def
create_ci_disk
(
disk_desc
,
meta_data
,
user_data
):
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
create_ci_disk
(
meta_data
=
meta_data
,
user_data
=
user_data
)
return
{
'size'
:
disk
.
size
,
'type'
:
'raw-ro'
,
'checksum'
:
disk
.
checksum
,
}
class
download
(
AbortableTask
):
class
download
(
AbortableTask
):
time_limit
=
18000
# TODO: calculate proper value it's 5h now
time_limit
=
18000
# TODO: calculate proper value it's 5h now
...
...
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