Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
5
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
b15a5b61
authored
2 years ago
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setup datastore for disk download
parent
9bc075e4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
5 deletions
+14
-5
circle/dashboard/serializers.py
+2
-0
circle/dashboard/views/vm.py
+9
-2
circle/storage/models.py
+1
-1
circle/vm/tasks/local_tasks.py
+2
-2
No files found.
circle/dashboard/serializers.py
View file @
b15a5b61
...
@@ -158,6 +158,7 @@ class VlanSerializer(serializers.ModelSerializer):
...
@@ -158,6 +158,7 @@ class VlanSerializer(serializers.ModelSerializer):
class
CreateDiskSerializer
(
serializers
.
Serializer
):
class
CreateDiskSerializer
(
serializers
.
Serializer
):
size
=
serializers
.
CharField
(
max_length
=
50
)
size
=
serializers
.
CharField
(
max_length
=
50
)
name
=
serializers
.
CharField
(
max_length
=
100
)
name
=
serializers
.
CharField
(
max_length
=
100
)
datastore
=
serializers
.
CharField
(
max_length
=
40
,
required
=
False
,
allow_blank
=
True
,
default
=
None
)
class
ResizeDiskSerializer
(
serializers
.
Serializer
):
class
ResizeDiskSerializer
(
serializers
.
Serializer
):
...
@@ -168,6 +169,7 @@ class DownloadDiskSerializer(serializers.Serializer):
...
@@ -168,6 +169,7 @@ class DownloadDiskSerializer(serializers.Serializer):
url
=
serializers
.
CharField
(
max_length
=
500
)
url
=
serializers
.
CharField
(
max_length
=
500
)
name
=
serializers
.
CharField
(
max_length
=
100
)
name
=
serializers
.
CharField
(
max_length
=
100
)
resize
=
serializers
.
CharField
(
max_length
=
30
,
required
=
False
,
allow_blank
=
True
,
default
=
None
)
resize
=
serializers
.
CharField
(
max_length
=
30
,
required
=
False
,
allow_blank
=
True
,
default
=
None
)
datastore
=
serializers
.
CharField
(
max_length
=
40
,
required
=
False
,
allow_blank
=
True
,
default
=
None
)
class
Meta
:
class
Meta
:
extra_kwargs
=
{
'resize'
:
{
'required'
:
False
,
'allow_blank'
:
True
,
'allow_empty'
:
True
}}
extra_kwargs
=
{
'resize'
:
{
'required'
:
False
,
'allow_blank'
:
True
,
'allow_empty'
:
True
}}
...
...
This diff is collapsed.
Click to expand it.
circle/dashboard/views/vm.py
View file @
b15a5b61
...
@@ -133,7 +133,10 @@ class CreatePersistentDiskREST(APIView):
...
@@ -133,7 +133,10 @@ class CreatePersistentDiskREST(APIView):
if
serializer
.
is_valid
():
if
serializer
.
is_valid
():
disk_size
=
str
(
size_util
(
str
(
data
[
'size'
])))
disk_size
=
str
(
size_util
(
str
(
data
[
'size'
])))
disk_name
=
str
(
data
[
'name'
])
disk_name
=
str
(
data
[
'name'
])
disk
=
Disk
.
create
(
size
=
disk_size
,
name
=
disk_name
,
type
=
"qcow2-norm"
)
datastore
=
'default'
if
'datastore'
in
data
:
datastore
=
data
[
'datastore'
]
disk
=
Disk
.
create
(
size
=
disk_size
,
name
=
disk_name
,
type
=
"qcow2-norm"
,
datastore
=
datastore
)
disk
.
full_clean
()
disk
.
full_clean
()
disk
.
dev_num
=
'f'
disk
.
dev_num
=
'f'
disk
.
save
()
disk
.
save
()
...
@@ -155,8 +158,12 @@ class DownloadPersistentDiskREST(APIView):
...
@@ -155,8 +158,12 @@ class DownloadPersistentDiskREST(APIView):
resize
=
None
resize
=
None
if
'resize'
in
data
:
if
'resize'
in
data
:
resize
=
str
(
data
[
'resize'
])
resize
=
str
(
data
[
'resize'
])
datastore
=
'default'
if
'datastore'
in
data
:
datastore
=
data
[
'datastore'
]
store_act
=
StorageActivity
.
create
(
code_suffix
=
"download_disk"
,
user
=
request
.
user
)
store_act
=
StorageActivity
.
create
(
code_suffix
=
"download_disk"
,
user
=
request
.
user
)
abortable_async_downloaddisk_operation
.
apply_async
(
args
=
(
store_act
.
id
,
disk_url
,
disk_name
,
resize
),
queue
=
'localhost.man.slow'
)
abortable_async_downloaddisk_operation
.
apply_async
(
args
=
(
store_act
.
id
,
disk_url
,
disk_name
,
resize
,
datastore
),
queue
=
'localhost.man.slow'
)
serializer
=
StorageActivitySerializer
(
store_act
,
many
=
False
)
serializer
=
StorageActivitySerializer
(
store_act
,
many
=
False
)
return
JsonResponse
(
serializer
.
data
,
status
=
201
)
return
JsonResponse
(
serializer
.
data
,
status
=
201
)
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
...
...
This diff is collapsed.
Click to expand it.
circle/storage/models.py
View file @
b15a5b61
...
@@ -453,7 +453,7 @@ class Disk(TimeStampedModel):
...
@@ -453,7 +453,7 @@ class Disk(TimeStampedModel):
params
.
setdefault
(
'name'
,
'ci-disk'
)
params
.
setdefault
(
'name'
,
'ci-disk'
)
params
.
setdefault
(
'type'
,
'raw-ro'
)
params
.
setdefault
(
'type'
,
'raw-ro'
)
params
.
setdefault
(
'size'
,
None
)
params
.
setdefault
(
'size'
,
None
)
disk
=
cls
.
__create
(
params
=
params
,
user
=
user
)
disk
=
cls
.
__create
(
params
=
params
,
user
=
user
,
datastore
=
'default'
)
queue_name
=
disk
.
get_remote_queue_name
(
'storage'
,
priority
=
"fast"
)
queue_name
=
disk
.
get_remote_queue_name
(
'storage'
,
priority
=
"fast"
)
disk_desc
=
disk
.
get_disk_desc
()
disk_desc
=
disk
.
get_disk_desc
()
result
=
storage_tasks
.
create_ci_disk
.
apply_async
(
args
=
[
disk_desc
,
meta_data
,
user_data
,
network_data
],
result
=
storage_tasks
.
create_ci_disk
.
apply_async
(
args
=
[
disk_desc
,
meta_data
,
user_data
,
network_data
],
...
...
This diff is collapsed.
Click to expand it.
circle/vm/tasks/local_tasks.py
View file @
b15a5b61
...
@@ -60,12 +60,12 @@ def abortable_async_node_operation(task, operation_id, node_pk, activity_pk,
...
@@ -60,12 +60,12 @@ def abortable_async_node_operation(task, operation_id, node_pk, activity_pk,
@celery.task
(
base
=
AbortableTask
,
bind
=
True
)
@celery.task
(
base
=
AbortableTask
,
bind
=
True
)
def
abortable_async_downloaddisk_operation
(
task
,
activity_pk
,
url
,
name
,
resize
):
def
abortable_async_downloaddisk_operation
(
task
,
activity_pk
,
url
,
name
,
resize
,
datastore
):
activity
=
StorageActivity
.
objects
.
get
(
pk
=
activity_pk
)
activity
=
StorageActivity
.
objects
.
get
(
pk
=
activity_pk
)
activity
.
task_uuid
=
task
.
request
.
id
activity
.
task_uuid
=
task
.
request
.
id
activity
.
save
()
activity
.
save
()
disk
=
Disk
.
download
(
url
=
url
,
name
=
name
,
task
=
task
,
resize
=
resize
)
disk
=
Disk
.
download
(
url
=
url
,
name
=
name
,
task
=
task
,
resize
=
resize
,
datastore
=
datastore
)
disk
.
dev_num
=
'g'
disk
.
dev_num
=
'g'
disk
.
full_clean
()
disk
.
full_clean
()
disk
.
save
()
disk
.
save
()
...
...
This diff is collapsed.
Click to expand it.
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