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
3d3c1adb
authored
Oct 20, 2022
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resize via download
parent
3cb1a197
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
19 additions
and
7 deletions
+19
-7
circle/dashboard/serializers.py
+5
-0
circle/dashboard/static/dashboard/dashboard.css
+0
-0
circle/dashboard/views/vm.py
+4
-1
circle/storage/models.py
+2
-2
circle/storage/tasks/storage_tasks.py
+4
-1
circle/vm/models/instance.py
+1
-1
circle/vm/tasks/local_tasks.py
+3
-2
No files found.
circle/dashboard/serializers.py
View file @
3d3c1adb
from
typing_extensions
import
Required
from
rest_framework.renderers
import
JSONRenderer
from
rest_framework.renderers
import
JSONRenderer
from
rest_framework
import
serializers
from
rest_framework
import
serializers
from
django.contrib.auth.models
import
Group
,
User
from
django.contrib.auth.models
import
Group
,
User
...
@@ -161,6 +162,10 @@ class ResizeDiskSerializer(serializers.Serializer):
...
@@ -161,6 +162,10 @@ class ResizeDiskSerializer(serializers.Serializer):
class
DownloadDiskSerializer
(
serializers
.
Serializer
):
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
)
class
Meta
:
extra_kwargs
=
{
'resize'
:
{
'required'
:
False
,
'allow_blank'
:
True
,
'allow_empty'
:
True
}}
class
CreateTemplateSerializer
(
serializers
.
Serializer
):
class
CreateTemplateSerializer
(
serializers
.
Serializer
):
name
=
serializers
.
CharField
(
max_length
=
100
)
name
=
serializers
.
CharField
(
max_length
=
100
)
...
...
circle/dashboard/static/dashboard/dashboard.css
View file @
3d3c1adb
circle/dashboard/views/vm.py
View file @
3d3c1adb
...
@@ -152,8 +152,11 @@ class DownloadPersistentDiskREST(APIView):
...
@@ -152,8 +152,11 @@ class DownloadPersistentDiskREST(APIView):
if
serializer
.
is_valid
():
if
serializer
.
is_valid
():
disk_url
=
str
(
data
[
'url'
])
disk_url
=
str
(
data
[
'url'
])
disk_name
=
str
(
data
[
'name'
])
disk_name
=
str
(
data
[
'name'
])
resize
=
None
if
'resize'
in
data
:
resize
=
str
(
data
[
'resize'
])
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
),
queue
=
'localhost.man.slow'
)
abortable_async_downloaddisk_operation
.
apply_async
(
args
=
(
store_act
.
id
,
disk_url
,
disk_name
,
resize
),
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
)
...
...
circle/storage/models.py
View file @
3d3c1adb
...
@@ -469,7 +469,7 @@ class Disk(TimeStampedModel):
...
@@ -469,7 +469,7 @@ class Disk(TimeStampedModel):
return
disk
return
disk
@classmethod
@classmethod
def
download
(
cls
,
url
,
task
,
user
=
None
,
**
params
):
def
download
(
cls
,
url
,
task
,
user
=
None
,
resize
=
None
,
**
params
):
"""Create disk object and download data from url synchronusly.
"""Create disk object and download data from url synchronusly.
:param url: image url to download.
:param url: image url to download.
...
@@ -491,7 +491,7 @@ class Disk(TimeStampedModel):
...
@@ -491,7 +491,7 @@ class Disk(TimeStampedModel):
queue_name
=
disk
.
get_remote_queue_name
(
'storage'
,
priority
=
'slow'
)
queue_name
=
disk
.
get_remote_queue_name
(
'storage'
,
priority
=
'slow'
)
remote
=
storage_tasks
.
download
.
apply_async
(
remote
=
storage_tasks
.
download
.
apply_async
(
kwargs
=
{
'url'
:
url
,
'parent_id'
:
task
.
request
.
id
,
kwargs
=
{
'url'
:
url
,
'parent_id'
:
task
.
request
.
id
,
'disk'
:
disk
.
get_disk_desc
()},
'disk'
:
disk
.
get_disk_desc
()
,
'resize'
:
resize
},
queue
=
queue_name
)
queue
=
queue_name
)
result
=
cls
.
_run_abortable_task
(
remote
,
task
)
result
=
cls
.
_run_abortable_task
(
remote
,
task
)
disk
.
size
=
result
[
'size'
]
disk
.
size
=
result
[
'size'
]
...
...
circle/storage/tasks/storage_tasks.py
View file @
3d3c1adb
...
@@ -37,9 +37,12 @@ def create(disk_desc):
...
@@ -37,9 +37,12 @@ def create(disk_desc):
def
create_ci_disk
(
disk_desc
,
meta_data
,
user_data
,
network_data
):
def
create_ci_disk
(
disk_desc
,
meta_data
,
user_data
,
network_data
):
pass
pass
@celery.task
(
name
=
'storagedriver.resizeqemu'
)
def
resizeqemu
(
disk_desc
,
newsize
):
pass
@celery.task
(
name
=
'storagedriver.download'
)
@celery.task
(
name
=
'storagedriver.download'
)
def
download
(
disk_desc
,
url
):
def
download
(
disk_desc
,
url
,
resize
):
pass
pass
...
...
circle/vm/models/instance.py
View file @
3d3c1adb
...
@@ -500,7 +500,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -500,7 +500,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
if
self
.
hookurl
:
if
self
.
hookurl
:
logger
.
info
(
"notify remote host (callhookurl): "
+
str
(
self
.
hookurl
))
logger
.
info
(
"notify remote host (callhookurl): "
+
str
(
self
.
hookurl
))
try
:
try
:
req
.
post
(
url
=
str
(
self
.
hookurl
))
req
.
post
(
url
=
str
(
self
.
hookurl
,
json
=
{
id
:
self
.
id
}
))
except
:
except
:
logger
.
info
(
"Error when call hookurl: "
+
str
(
self
.
hookurl
))
logger
.
info
(
"Error when call hookurl: "
+
str
(
self
.
hookurl
))
...
...
circle/vm/tasks/local_tasks.py
View file @
3d3c1adb
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License along
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
ctypes
import
resize
from
datetime
import
timezone
from
datetime
import
timezone
from
celery.contrib.abortable
import
AbortableTask
from
celery.contrib.abortable
import
AbortableTask
from
common.models
import
ActivityModel
from
common.models
import
ActivityModel
...
@@ -59,12 +60,12 @@ def abortable_async_node_operation(task, operation_id, node_pk, activity_pk,
...
@@ -59,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
):
def
abortable_async_downloaddisk_operation
(
task
,
activity_pk
,
url
,
name
,
resize
):
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
)
disk
=
Disk
.
download
(
url
=
url
,
name
=
name
,
task
=
task
,
resize
=
resize
)
disk
.
dev_num
=
'g'
disk
.
dev_num
=
'g'
disk
.
full_clean
()
disk
.
full_clean
()
disk
.
save
()
disk
.
save
()
...
...
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