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
28bda55b
authored
Sep 02, 2022
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create disk for vm
parent
aba1160b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
5 deletions
+42
-5
circle/dashboard/serializers.py
+7
-2
circle/dashboard/urls.py
+2
-0
circle/dashboard/views/vm.py
+33
-3
No files found.
circle/dashboard/serializers.py
View file @
28bda55b
...
...
@@ -54,4 +54,9 @@ class InterfaceSerializer(serializers.ModelSerializer):
class
VlanSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
Vlan
fields
=
[
'id'
,
'vid'
,
'name'
,
'description'
,
'comment'
,
'domain'
]
\ No newline at end of file
fields
=
[
'id'
,
'vid'
,
'name'
,
'description'
,
'comment'
,
'domain'
]
class
CreateDiskSerializer
(
serializers
.
Serializer
):
size
=
serializers
.
IntegerField
()
name
=
serializers
.
CharField
(
max_length
=
100
)
\ No newline at end of file
circle/dashboard/urls.py
View file @
28bda55b
...
...
@@ -56,6 +56,7 @@ from .views import (
NodeActivityView
,
UserList
,
TemplateREST
,
LeaseREST
,
DiskRest
,
InstanceREST
,
InterfaceREST
,
InstanceFromTemplateREST
,
InstanceFTforUsersREST
,
DownloadDiskREST
,
StorageDetail
,
DiskDetail
,
MessageList
,
MessageDetail
,
MessageCreate
,
MessageDelete
,
EnableTwoFactorView
,
DisableTwoFactorView
,
...
...
@@ -73,6 +74,7 @@ urlpatterns = [
path
(
'acpi/disk/'
,
DiskRest
.
as_view
()),
path
(
'acpi/interface/'
,
InterfaceREST
.
as_view
()),
path
(
'acpi/ftusers/'
,
InstanceFTforUsersREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/createdisk/'
,
DownloadDiskREST
.
as_view
()),
url
(
r'^$'
,
IndexView
.
as_view
(),
name
=
"dashboard.index"
),
url
(
r"^profile/list/$"
,
UserList
.
as_view
(),
name
=
"dashboard.views.user-list"
),
...
...
circle/dashboard/views/vm.py
View file @
28bda55b
...
...
@@ -94,7 +94,7 @@ from rest_framework.parsers import JSONParser
from
rest_framework.authentication
import
TokenAuthentication
,
BasicAuthentication
from
rest_framework.permissions
import
IsAdminUser
from
dashboard.serializers
import
InstanceSerializer
,
InterfaceSerializer
from
dashboard.serializers
import
InstanceSerializer
,
InterfaceSerializer
,
CreateDiskSerializer
class
InterfaceREST
(
APIView
):
...
...
@@ -145,12 +145,42 @@ class InstanceREST(APIView):
base_activity
=
act
)
if
'create_disk'
in
data
:
inst
.
create_disk
(
size
=
data
[
'createdisk'
][
'size'
],
user
=
inst
.
owner
,
name
=
data
[
'createdisk'
][
'name'
],
activity
=
None
)
inst
.
create_disk
(
size
=
data
[
'create_disk'
][
'size'
],
user
=
inst
.
owner
,
name
=
data
[
'create_disk'
][
'name'
],
activity
=
None
)
if
'download_disk'
in
data
:
inst
.
download_disk
(
user
=
inst
.
owner
,
name
=
data
[
'download_disk'
][
'name'
])
return
JsonResponse
(
serializer
.
data
,
status
=
201
)
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
class
DownloadDiskREST
(
APIView
):
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
permission_classes
=
[
IsAdminUser
]
def
post
(
self
,
request
,
pk
,
format
=
None
):
data
=
JSONParser
()
.
parse
(
request
)
serializer
=
CreateDiskSerializer
(
data
=
data
)
if
serializer
.
is_valid
():
vm_id
=
pk
disk_size
=
int
(
data
[
'size'
])
disk_name
=
str
(
data
[
'name'
])
instance
=
Instance
.
objects
.
get
(
pk
=
vm_id
)
instance
.
create_disk
(
size
=
disk_size
,
user
=
instance
.
owner
,
name
=
disk_name
,
activity
=
None
)
ret
=
InstanceSerializer
(
instance
,
many
=
False
)
return
JsonResponse
(
ret
.
data
,
status
=
201
)
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
class
StateOperationREST
(
APIView
):
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
permission_classes
=
[
IsAdminUser
]
def
post
(
self
,
request
,
pk
,
format
=
None
):
pass
return
JsonResponse
(
status
=
400
)
class
VmDetailVncTokenView
(
CheckedDetailView
):
template_name
=
"dashboard/vm-detail.html"
model
=
Instance
...
...
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