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
355ad49c
authored
Sep 15, 2022
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bugs
parent
8a880eb5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
10 deletions
+58
-10
circle/dashboard/serializers.py
+3
-0
circle/dashboard/urls.py
+3
-1
circle/dashboard/views/group.py
+10
-0
circle/dashboard/views/user.py
+9
-0
circle/dashboard/views/vm.py
+31
-8
circle/vm/tasks/local_tasks.py
+2
-1
No files found.
circle/dashboard/serializers.py
View file @
355ad49c
...
@@ -128,6 +128,9 @@ class DestroyDiskSerializer(serializers.Serializer):
...
@@ -128,6 +128,9 @@ class DestroyDiskSerializer(serializers.Serializer):
class
Meta
:
class
Meta
:
extra_kwargs
=
{
'instance'
:
{
'required'
:
False
,
'allow_null'
:
True
}}
extra_kwargs
=
{
'instance'
:
{
'required'
:
False
,
'allow_null'
:
True
}}
class
AddPortSerializer
(
serializers
.
Serializer
):
port_type
=
serializers
.
CharField
(
max_length
=
5
)
port_number
=
serializers
.
IntegerField
()
class
VMDeploySerializer
(
serializers
.
Serializer
):
class
VMDeploySerializer
(
serializers
.
Serializer
):
node
=
serializers
.
IntegerField
(
required
=
False
)
node
=
serializers
.
IntegerField
(
required
=
False
)
...
...
circle/dashboard/urls.py
View file @
355ad49c
...
@@ -60,7 +60,7 @@ from .views import (
...
@@ -60,7 +60,7 @@ from .views import (
GetLeaseREST
,
GetDiskRest
,
DeployInstanceREST
,
CreateDiskREST
,
GetLeaseREST
,
GetDiskRest
,
DeployInstanceREST
,
CreateDiskREST
,
VlanREST
,
ResizeDiskREST
,
GetVlanREST
,
DestroyDiskREST
,
VlanREST
,
ResizeDiskREST
,
GetVlanREST
,
DestroyDiskREST
,
StorageDetail
,
DiskDetail
,
UserREST
,
GroupREST
,
StorageDetail
,
DiskDetail
,
UserREST
,
GroupREST
,
InstanceActivityREST
,
GetInstanceActivityREST
,
InstanceActivityREST
,
GetInstanceActivityREST
,
GetGroupREST
,
GetUserREST
,
SleepInstanceREST
,
WakeUpInstanceREST
,
DownloadPersistentDiskREST
,
SleepInstanceREST
,
WakeUpInstanceREST
,
DownloadPersistentDiskREST
,
CreatePersistentDiskREST
,
GetStorageActivityREST
,
CreatePersistentDiskREST
,
GetStorageActivityREST
,
MessageList
,
MessageDetail
,
MessageCreate
,
MessageDelete
,
MessageList
,
MessageDetail
,
MessageCreate
,
MessageDelete
,
...
@@ -78,7 +78,9 @@ urlpatterns = [
...
@@ -78,7 +78,9 @@ urlpatterns = [
path
(
'acpi/vmact/'
,
InstanceActivityREST
.
as_view
()),
path
(
'acpi/vmact/'
,
InstanceActivityREST
.
as_view
()),
path
(
'acpi/vmact/<int:pk>/'
,
GetInstanceActivityREST
.
as_view
()),
path
(
'acpi/vmact/<int:pk>/'
,
GetInstanceActivityREST
.
as_view
()),
path
(
'acpi/user/'
,
UserREST
.
as_view
()),
path
(
'acpi/user/'
,
UserREST
.
as_view
()),
path
(
'acpi/user/<int:pk>/'
,
GetUserREST
.
as_view
()),
path
(
'acpi/group/'
,
GroupREST
.
as_view
()),
path
(
'acpi/group/'
,
GroupREST
.
as_view
()),
path
(
'acpi/group/<int:pk>/'
,
GetGroupREST
.
as_view
()),
path
(
'acpi/vm/'
,
InstanceREST
.
as_view
()),
path
(
'acpi/vm/'
,
InstanceREST
.
as_view
()),
path
(
'acpi/node/'
,
NodeREST
.
as_view
()),
path
(
'acpi/node/'
,
NodeREST
.
as_view
()),
path
(
'acpi/node/<int:pk>/'
,
GetNodeREST
.
as_view
()),
path
(
'acpi/node/<int:pk>/'
,
GetNodeREST
.
as_view
()),
...
...
circle/dashboard/views/group.py
View file @
355ad49c
...
@@ -80,6 +80,16 @@ class GroupREST(APIView):
...
@@ -80,6 +80,16 @@ class GroupREST(APIView):
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
class
GetGroupREST
(
APIView
):
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
permission_classes
=
[
IsAdminUser
]
def
get
(
self
,
request
,
pk
,
format
=
None
):
groups
=
Group
.
objects
.
get
(
pk
=
pk
)
serializer
=
GroupSerializer
(
groups
,
many
=
False
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
class
GroupCodeMixin
(
object
):
class
GroupCodeMixin
(
object
):
@classmethod
@classmethod
...
...
circle/dashboard/views/user.py
View file @
355ad49c
...
@@ -91,6 +91,15 @@ class UserREST(APIView):
...
@@ -91,6 +91,15 @@ class UserREST(APIView):
serializer
=
UserSerializer
(
users
,
many
=
True
)
serializer
=
UserSerializer
(
users
,
many
=
True
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
class
GetUserREST
(
APIView
):
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
permission_classes
=
[
IsAdminUser
]
def
get
(
self
,
request
,
pk
,
format
=
None
):
users
=
User
.
objects
.
get
(
pk
=
pk
)
serializer
=
UserSerializer
(
users
,
many
=
False
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
def
set_session_expiry
(
request
,
user
):
def
set_session_expiry
(
request
,
user
):
if
user
.
is_superuser
:
if
user
.
is_superuser
:
messages
.
info
(
request
,
_
(
"You've logged in with an administrator "
messages
.
info
(
request
,
_
(
"You've logged in with an administrator "
...
...
circle/dashboard/views/vm.py
View file @
355ad49c
...
@@ -49,7 +49,7 @@ from braces.views import SuperuserRequiredMixin, LoginRequiredMixin
...
@@ -49,7 +49,7 @@ from braces.views import SuperuserRequiredMixin, LoginRequiredMixin
from
storage.tasks
import
storage_tasks
from
storage.tasks
import
storage_tasks
from
vm.tasks.local_tasks
import
abortable_async_downloaddisk_operation
from
vm.tasks.local_tasks
import
abortable_async_downloaddisk_operation
from
vm.operations
import
(
DeployOperation
,
DestroyOperation
,
DownloadDiskOperation
,
ShutdownOperation
,
RenewOperation
,
from
vm.operations
import
(
DeployOperation
,
DestroyOperation
,
DownloadDiskOperation
,
ShutdownOperation
,
RenewOperation
,
ResizeDiskOperation
,
RemoveDiskOperation
,
SleepOperation
,
WakeUpOperation
ResizeDiskOperation
,
RemoveDiskOperation
,
SleepOperation
,
WakeUpOperation
,
AddPortOperation
,
)
)
from
common.models
import
(
from
common.models
import
(
...
@@ -105,6 +105,7 @@ from rest_framework.permissions import IsAdminUser
...
@@ -105,6 +105,7 @@ from rest_framework.permissions import IsAdminUser
from
dashboard.serializers
import
(
from
dashboard.serializers
import
(
DiskSerializer
,
InstanceSerializer
,
InterfaceSerializer
,
CreateDiskSerializer
,
DownloadDiskSerializer
,
DiskSerializer
,
InstanceSerializer
,
InterfaceSerializer
,
CreateDiskSerializer
,
DownloadDiskSerializer
,
VMDeploySerializer
,
VlanSerializer
,
ResizeDiskSerializer
,
InstanceActivitySerializer
,
DestroyDiskSerializer
,
StorageActivitySerializer
,
VMDeploySerializer
,
VlanSerializer
,
ResizeDiskSerializer
,
InstanceActivitySerializer
,
DestroyDiskSerializer
,
StorageActivitySerializer
,
AddPortSerializer
,
)
)
def
size_util
(
size
:
str
):
def
size_util
(
size
:
str
):
...
@@ -216,6 +217,9 @@ class InstanceREST(APIView):
...
@@ -216,6 +217,9 @@ class InstanceREST(APIView):
def
post
(
self
,
request
,
format
=
None
):
def
post
(
self
,
request
,
format
=
None
):
data
=
JSONParser
()
.
parse
(
request
)
data
=
JSONParser
()
.
parse
(
request
)
data
[
'pw'
]
=
pwgen
()
data
[
'pw'
]
=
pwgen
()
req_deploy
=
False
if
'status'
in
data
:
req_deploy
=
data
[
'status'
]
==
"RUNNING"
data
[
'status'
]
=
'STOPPED'
data
[
'status'
]
=
'STOPPED'
if
'owner'
not
in
data
:
if
'owner'
not
in
data
:
data
[
'owner'
]
=
request
.
user
.
id
data
[
'owner'
]
=
request
.
user
.
id
...
@@ -242,12 +246,17 @@ class InstanceREST(APIView):
...
@@ -242,12 +246,17 @@ class InstanceREST(APIView):
Interface
.
create
(
instance
=
inst
,
vlan
=
net
.
vlan
,
Interface
.
create
(
instance
=
inst
,
vlan
=
net
.
vlan
,
owner
=
inst
.
owner
,
managed
=
net
.
managed
,
owner
=
inst
.
owner
,
managed
=
net
.
managed
,
base_activity
=
act
)
base_activity
=
act
)
if
'create_disk'
in
data
:
if
'disks'
in
data
:
inst
.
create_disk
(
size
=
data
[
'create_disk'
][
'size'
],
user
=
inst
.
owner
,
import
string
name
=
data
[
'create_disk'
][
'name'
],
activity
=
None
)
devnums
=
list
(
string
.
ascii_lowercase
)
if
'download_disk'
in
data
:
for
l
in
data
[
'disks'
]:
inst
.
download_disk
(
user
=
inst
.
owner
,
name
=
data
[
'download_disk'
][
'name'
])
disk
=
Disk
.
objects
.
get
(
pk
=
int
(
l
))
disk
.
dev_num
=
devnums
.
pop
(
0
)
disk
.
save
()
if
req_deploy
:
DeployOperation
(
inst
)
.
call
(
node
=
None
,
user
=
inst
.
owner
)
return
JsonResponse
(
serializer
.
data
,
status
=
201
)
return
JsonResponse
(
serializer
.
data
,
status
=
201
)
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
...
@@ -298,7 +307,21 @@ class DeployInstanceREST(APIView):
...
@@ -298,7 +307,21 @@ class DeployInstanceREST(APIView):
DeployOperation
(
instance
)
.
call
(
node
=
None
,
user
=
instance
.
owner
)
DeployOperation
(
instance
)
.
call
(
node
=
None
,
user
=
instance
.
owner
)
serializer
=
InstanceSerializer
(
instance
,
many
=
False
)
serializer
=
InstanceSerializer
(
instance
,
many
=
False
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
return
JsonResponse
(
deploy
.
errors
,
status
=
201
)
return
JsonResponse
(
deploy
.
errors
,
status
=
400
)
class
AddPortREST
(
APIView
):
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
permission_classes
=
[
IsAdminUser
]
def
post
(
self
,
request
,
pk
,
format
=
None
):
instance
=
Instance
.
objects
.
get
(
pk
=
pk
)
data
=
JSONParser
()
.
parse
(
request
)
addport
=
AddPortSerializer
(
data
=
data
)
if
addport
.
is_valid
():
AddPortOperation
(
instance
)
.
call
(
port
=
int
(
data
[
'port_number'
]),
proto
=
str
(
data
[
'port_type'
]))
return
JsonResponse
({},
status
=
201
)
return
JsonResponse
(
addport
.
errors
,
status
=
400
)
class
SleepInstanceREST
(
APIView
):
class
SleepInstanceREST
(
APIView
):
...
...
circle/vm/tasks/local_tasks.py
View file @
355ad49c
...
@@ -71,6 +71,6 @@ def abortable_async_downloaddisk_operation(task, activity_pk, url, name):
...
@@ -71,6 +71,6 @@ def abortable_async_downloaddisk_operation(task, activity_pk, url, name):
activity
.
disk
=
disk
activity
.
disk
=
disk
activity
.
succeeded
=
True
activity
.
succeeded
=
True
activity
.
finished
=
timezone
.
now
()
#
activity.finished = timezone.now()
activity
.
save
()
activity
.
save
()
return
return
\ No newline at end of file
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