Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4b62f1c2
authored
Mar 02, 2021
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ssh_export_import' into 'master'
Export and import disks using SSH See merge request
!424
parents
b7436aa6
d09eb778
Pipeline
#1425
passed with stage
in 0 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
15 deletions
+28
-15
circle/dashboard/store_api.py
+16
-1
circle/storage/models.py
+5
-6
circle/storage/tasks/storage_tasks.py
+2
-2
circle/vm/operations.py
+5
-6
No files found.
circle/dashboard/store_api.py
View file @
4b62f1c2
...
@@ -47,7 +47,7 @@ class NoStoreException(StoreApiException):
...
@@ -47,7 +47,7 @@ class NoStoreException(StoreApiException):
class
Store
(
object
):
class
Store
(
object
):
def
__init__
(
self
,
user
,
default_timeout
=
0.
5
):
def
__init__
(
self
,
user
,
default_timeout
=
5
):
self
.
store_url
=
settings
.
STORE_URL
self
.
store_url
=
settings
.
STORE_URL
if
not
self
.
store_url
:
if
not
self
.
store_url
:
raise
NoStoreException
raise
NoStoreException
...
@@ -127,6 +127,21 @@ class Store(object):
...
@@ -127,6 +127,21 @@ class Store(object):
r
=
self
.
_request_cmd
(
"UPLOAD"
,
PATH
=
path
)
r
=
self
.
_request_cmd
(
"UPLOAD"
,
PATH
=
path
)
return
r
.
json
()[
'LINK'
]
return
r
.
json
()[
'LINK'
]
def
request_ssh_download
(
self
,
path
):
r
=
self
.
_request_cmd
(
"SSH_DOWNLOAD"
,
PATH
=
path
)
return
r
.
json
()[
'LINK'
],
r
.
json
()[
'PORT'
]
def
request_ssh_upload
(
self
):
r
=
self
.
_request_cmd
(
"SSH_UPLOAD"
)
return
r
.
json
()[
'LINK'
],
r
.
json
()[
'PORT'
]
def
ssh_upload_finished
(
self
,
uploaded_name
,
path
):
self
.
_request_cmd
(
"SSH_UPLOAD_FINISHED"
,
FILENAME
=
uploaded_name
,
PATH
=
path
,
)
def
remove
(
self
,
path
):
def
remove
(
self
,
path
):
self
.
_request_cmd
(
"REMOVE"
,
PATH
=
path
)
self
.
_request_cmd
(
"REMOVE"
,
PATH
=
path
)
...
...
circle/storage/models.py
View file @
4b62f1c2
...
@@ -477,7 +477,7 @@ class Disk(TimeStampedModel):
...
@@ -477,7 +477,7 @@ class Disk(TimeStampedModel):
return
disk
return
disk
@classmethod
@classmethod
def
import_disk
(
cls
,
user
,
name
,
download_link
,
task
):
def
import_disk
(
cls
,
user
,
name
,
download_link
,
port
,
task
):
params
=
{
'name'
:
name
,
params
=
{
'name'
:
name
,
'type'
:
'qcow2-norm'
}
'type'
:
'qcow2-norm'
}
disk
=
cls
.
__create
(
user
=
user
,
params
=
params
)
disk
=
cls
.
__create
(
user
=
user
,
params
=
params
)
...
@@ -486,7 +486,7 @@ class Disk(TimeStampedModel):
...
@@ -486,7 +486,7 @@ class Disk(TimeStampedModel):
kwargs
=
{
kwargs
=
{
"disk_desc"
:
disk
.
get_disk_desc
(),
"disk_desc"
:
disk
.
get_disk_desc
(),
"url"
:
download_link
,
"url"
:
download_link
,
"
task"
:
task
.
request
.
id
"
port"
:
port
},
},
queue
=
queue_name
queue
=
queue_name
)
)
...
@@ -497,18 +497,17 @@ class Disk(TimeStampedModel):
...
@@ -497,18 +497,17 @@ class Disk(TimeStampedModel):
disk
.
save
()
disk
.
save
()
return
disk
return
disk
def
export
(
self
,
exported_name
,
disk_format
,
upload_link
,
task
):
def
export
(
self
,
disk_format
,
upload_link
,
port
,
task
):
queue_name
=
self
.
get_remote_queue_name
(
'storage'
,
priority
=
'slow'
)
queue_name
=
self
.
get_remote_queue_name
(
'storage'
,
priority
=
'slow'
)
remote
=
storage_tasks
.
export_disk
.
apply_async
(
remote
=
storage_tasks
.
export_disk
.
apply_async
(
kwargs
=
{
kwargs
=
{
"disk_desc"
:
self
.
get_disk_desc
(),
"disk_desc"
:
self
.
get_disk_desc
(),
"disk_format"
:
disk_format
,
"disk_format"
:
disk_format
,
"exported_name"
:
exported_name
,
"upload_link"
:
upload_link
,
"upload_link"
:
upload_link
,
"
task"
:
task
.
request
.
id
"
port"
:
port
},
},
queue
=
queue_name
)
queue
=
queue_name
)
self
.
_run_abortable_task
(
remote
,
task
)
return
self
.
_run_abortable_task
(
remote
,
task
)
def
destroy
(
self
,
user
=
None
,
task_uuid
=
None
):
def
destroy
(
self
,
user
=
None
,
task_uuid
=
None
):
if
self
.
destroyed
:
if
self
.
destroyed
:
...
...
circle/storage/tasks/storage_tasks.py
View file @
4b62f1c2
...
@@ -39,12 +39,12 @@ def download(disk_desc, url):
...
@@ -39,12 +39,12 @@ def download(disk_desc, url):
@celery.task
(
name
=
'storagedriver.import_disk'
)
@celery.task
(
name
=
'storagedriver.import_disk'
)
def
import_disk
(
disk_desc
,
url
):
def
import_disk
(
disk_desc
,
url
,
port
):
pass
pass
@celery.task
(
name
=
'storagedriver.export_disk'
)
@celery.task
(
name
=
'storagedriver.export_disk'
)
def
export_disk
(
disk_desc
,
forma
t
):
def
export_disk
(
disk_desc
,
disk_format
,
url
,
por
t
):
pass
pass
...
...
circle/vm/operations.py
View file @
4b62f1c2
...
@@ -352,7 +352,6 @@ class ImportDiskOperation(InstanceOperation):
...
@@ -352,7 +352,6 @@ class ImportDiskOperation(InstanceOperation):
'from the user store. The disk image has to be in the '
'from the user store. The disk image has to be in the '
'root directory of the store.'
)
'root directory of the store.'
)
abortable
=
True
abortable
=
True
has_percentage
=
True
required_perms
=
(
'storage.import_disk'
,)
required_perms
=
(
'storage.import_disk'
,)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'RUNNING'
)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'RUNNING'
)
async_queue
=
'localhost.man.slow'
async_queue
=
'localhost.man.slow'
...
@@ -366,8 +365,8 @@ class ImportDiskOperation(InstanceOperation):
...
@@ -366,8 +365,8 @@ class ImportDiskOperation(InstanceOperation):
def
_operation
(
self
,
user
,
name
,
disk_path
,
task
):
def
_operation
(
self
,
user
,
name
,
disk_path
,
task
):
store
=
Store
(
user
)
store
=
Store
(
user
)
download_link
=
store
.
request
_download
(
disk_path
)
download_link
,
port
=
store
.
request_ssh
_download
(
disk_path
)
disk
=
Disk
.
import_disk
(
user
,
name
,
download_link
,
task
)
disk
=
Disk
.
import_disk
(
user
,
name
,
download_link
,
port
,
task
)
self
.
instance
.
disks
.
add
(
disk
)
self
.
instance
.
disks
.
add
(
disk
)
...
@@ -377,7 +376,6 @@ class ExportDiskOperation(InstanceOperation):
...
@@ -377,7 +376,6 @@ class ExportDiskOperation(InstanceOperation):
name
=
_
(
'export disk'
)
name
=
_
(
'export disk'
)
description
=
_
(
'Export disk to the selected format.'
)
description
=
_
(
'Export disk to the selected format.'
)
abortable
=
True
abortable
=
True
has_percentage
=
True
required_perms
=
(
'storage.export_disk'
,)
required_perms
=
(
'storage.export_disk'
,)
accept_states
=
(
'STOPPED'
,)
accept_states
=
(
'STOPPED'
,)
async_queue
=
'localhost.man.slow'
async_queue
=
'localhost.man.slow'
...
@@ -391,8 +389,9 @@ class ExportDiskOperation(InstanceOperation):
...
@@ -391,8 +389,9 @@ class ExportDiskOperation(InstanceOperation):
def
_operation
(
self
,
user
,
disk
,
exported_name
,
disk_format
,
task
):
def
_operation
(
self
,
user
,
disk
,
exported_name
,
disk_format
,
task
):
store
=
Store
(
user
)
store
=
Store
(
user
)
upload_link
=
store
.
request_upload
(
'/'
)
upload_link
,
port
=
store
.
request_ssh_upload
()
disk
.
export
(
exported_name
,
disk_format
,
upload_link
,
task
)
file_name
=
disk
.
export
(
disk_format
,
upload_link
,
port
,
task
)
store
.
ssh_upload_finished
(
file_name
,
exported_name
+
'.'
+
disk_format
)
@register_operation
@register_operation
...
...
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