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
63268de5
authored
Feb 26, 2021
by
Máhonfai Bálint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes to import and export
parent
5ae07b2a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
20 deletions
+8
-20
disk.py
+6
-12
storagedriver.py
+2
-8
No files found.
disk.py
View file @
63268de5
...
...
@@ -266,19 +266,16 @@ class Disk(object):
raise
Exception
(
"Invalid file format. Only qcow and "
"iso files are allowed. Image from:
%
s"
%
url
)
def
import_disk
(
self
,
task
,
url
,
port
=
None
):
def
import_disk
(
self
,
task
,
url
,
port
=
22
):
downloaded_file
=
os
.
path
.
join
(
self
.
dir
,
re
.
split
(
'[:/]'
,
url
)[
-
1
])
cmdline
=
[
'scp'
,
'-B'
]
if
port
is
not
None
:
cmdline
.
extend
([
'-P'
,
str
(
port
)])
cmdline
.
extend
([
downloaded_file
,
url
])
cmdline
=
[
'scp'
,
'-B'
,
'-P'
,
str
(
port
),
url
,
downloaded_file
]
proc
=
subprocess
.
Popen
(
cmdline
)
try
:
while
proc
.
poll
()
is
None
:
if
task
.
is_aborted
():
raise
AbortException
()
sleep
(
1
)
sleep
(
2
)
if
task
.
is_aborted
():
raise
AbortException
()
...
...
@@ -317,7 +314,7 @@ class Disk(object):
self
.
size
=
Disk
.
get
(
self
.
dir
,
self
.
name
)
.
size
def
export
(
self
,
task
,
disk_format
,
upload_link
,
port
=
None
):
def
export
(
self
,
task
,
disk_format
,
upload_link
,
port
=
22
):
exported_path
=
self
.
get_path
()
+
'.'
+
disk_format
cmdline
=
[
'ionice'
,
'-c'
,
'idle'
,
'qemu-img'
,
'convert'
]
...
...
@@ -328,17 +325,14 @@ class Disk(object):
exported_path
])
subprocess
.
check_output
(
cmdline
)
cmdline
=
[
'scp'
,
'-B'
]
if
port
is
not
None
:
cmdline
.
extend
([
'-P'
,
str
(
port
)])
cmdline
.
extend
([
exported_path
,
upload_link
])
cmdline
=
[
'scp'
,
'-B'
,
'-P'
,
str
(
port
),
exported_path
,
upload_link
]
proc
=
subprocess
.
Popen
(
cmdline
)
try
:
while
proc
.
poll
()
is
None
:
if
task
.
is_aborted
():
raise
AbortException
()
sleep
(
1
)
sleep
(
2
)
except
AbortException
:
proc
.
terminate
()
logger
.
info
(
"Export of disk
%
s aborted"
%
self
.
name
)
...
...
storagedriver.py
View file @
63268de5
...
...
@@ -48,10 +48,7 @@ class import_disk(AbortableTask):
def
run
(
self
,
**
kwargs
):
disk_desc
=
kwargs
[
"disk_desc"
]
url
=
kwargs
[
"url"
]
if
"port"
in
kwargs
:
port
=
kwargs
[
"port"
]
else
:
port
=
None
port
=
kwargs
[
"port"
]
disk
=
Disk
.
deserialize
(
disk_desc
)
disk
.
import_disk
(
self
,
url
,
port
)
return
{
...
...
@@ -67,10 +64,7 @@ class export_disk(AbortableTask):
disk_desc
=
kwargs
[
"disk_desc"
]
disk_format
=
kwargs
[
"disk_format"
]
upload_link
=
kwargs
[
"upload_link"
]
if
"port"
in
kwargs
:
port
=
kwargs
[
"port"
]
else
:
port
=
None
port
=
kwargs
[
"port"
]
disk
=
Disk
.
deserialize
(
disk_desc
)
return
disk
.
export
(
self
,
disk_format
,
upload_link
,
port
)
...
...
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