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
c0e53280
authored
Mar 16, 2023
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blancer api
parent
724e1aa1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletions
+37
-1
circle/dashboard/urls.py
+2
-1
circle/dashboard/views/template.py
+35
-0
No files found.
circle/dashboard/urls.py
View file @
c0e53280
...
...
@@ -64,7 +64,7 @@ from .views import (
SleepInstanceREST
,
WakeUpInstanceREST
,
DownloadPersistentDiskREST
,
CreatePersistentDiskREST
,
GetStorageActivityREST
,
GetTemplateREST
,
MessageList
,
MessageDetail
,
MessageCreate
,
MessageDelete
,
SetupPortREST
,
RulesREST
,
SetupPortREST
,
RulesREST
,
InstanceBalancerTemplateREST
,
EnableTwoFactorView
,
DisableTwoFactorView
,
AclUserGroupAutocomplete
,
AclUserAutocomplete
,
RescheduleView
,
GroupImportView
,
GroupExportView
,
...
...
@@ -91,6 +91,7 @@ urlpatterns = [
path
(
'acpi/vm/<int:pk>/'
,
GetInstanceREST
.
as_view
()),
path
(
'acpi/template/<int:pk>/'
,
GetTemplateREST
.
as_view
()),
path
(
'acpi/template/'
,
TemplateREST
.
as_view
()),
path
(
'acpi/bvm/'
,
InstanceBalancerTemplateREST
.
as_view
()),
path
(
'acpi/ft/'
,
InstanceFromTemplateREST
.
as_view
()),
path
(
'acpi/lease/'
,
LeaseREST
.
as_view
()),
path
(
'acpi/lease/<int:pk>/'
,
GetLeaseREST
.
as_view
()),
...
...
circle/dashboard/views/template.py
View file @
c0e53280
...
...
@@ -230,6 +230,41 @@ class GetTemplateREST(APIView):
def
delete
(
self
,
request
,
pk
,
format
=
None
):
return
JsonResponse
(
status
=
400
)
class
InstanceBalancerTemplateREST
(
APIView
):
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
permission_classes
=
[
IsAdminUser
]
def
post
(
self
,
request
,
format
=
None
):
data
=
JSONParser
()
.
parse
(
request
)
user
=
User
.
objects
.
filter
(
username
=
data
[
'username'
])
.
get
()
template
=
InstanceTemplate
.
objects
.
filter
(
name
=
data
[
'template_name'
])
.
get
()
ikwargs
=
{
'name'
:
data
[
'name'
],
'template'
:
template
,
'owner'
:
user
,
}
amount
=
data
.
get
(
"amount"
,
1
)
if
'num_cores'
in
data
:
ikwargs
.
update
({
'num_cores'
:
data
[
'num_cores'
]})
if
'ram_size'
in
data
:
ikwargs
.
update
({
'ram_size'
:
data
[
'ram_size'
]})
if
'priority'
in
data
:
ikwargs
.
update
({
'priority'
:
data
[
'priority'
]})
if
'max_ram_size'
in
data
:
ikwargs
.
update
({
'max_ram_size'
:
data
[
'ram_size'
]})
instances
=
Instance
.
mass_create_from_template
(
amount
=
amount
,
**
ikwargs
)
for
i
in
instances
:
i
.
deploy
.
_async
(
user
=
user
)
if
amount
==
1
:
serializer
=
InstanceSerializer
(
instances
,
many
=
True
)
return
JsonResponse
(
serializer
.
data
,
status
=
201
,
safe
=
False
)
serializer
=
InstanceSerializer
(
instances
,
many
=
True
)
return
JsonResponse
(
serializer
.
data
,
status
=
201
,
safe
=
False
)
class
InstanceFromTemplateREST
(
APIView
):
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
...
...
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