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
cd77d510
authored
Oct 25, 2023
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vcpu num update
parent
ee0f699e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
circle/dashboard/urls.py
+3
-1
circle/dashboard/views/vm.py
+18
-1
No files found.
circle/dashboard/urls.py
View file @
cd77d510
...
...
@@ -68,7 +68,8 @@ from .views import (
EnableTwoFactorView
,
DisableTwoFactorView
,
AclUserGroupAutocomplete
,
AclUserAutocomplete
,
RescheduleView
,
GroupImportView
,
GroupExportView
,
VariableREST
,
GetVariableREST
,
HotplugMemSetREST
,
HotplugVCPUSetREST
VariableREST
,
GetVariableREST
,
HotplugMemSetREST
,
HotplugVCPUSetREST
,
GetInstanceRESTSum
)
from
.views.node
import
node_ops
,
NodeREST
,
GetNodeREST
,
GetNodeRESTSum
from
.views.vm
import
vm_ops
,
vm_mass_ops
...
...
@@ -89,6 +90,7 @@ urlpatterns = [
path
(
'acpi/node/'
,
NodeREST
.
as_view
()),
path
(
'acpi/node/<int:pk>/'
,
GetNodeREST
.
as_view
()),
path
(
'acpi/nodesum/'
,
GetNodeRESTSum
.
as_view
()),
path
(
'acpi/vmsum/'
,
GetInstanceRESTSum
.
as_view
()),
path
(
'acpi/vm/<int:pk>/'
,
GetInstanceREST
.
as_view
()),
path
(
'acpi/template/<int:pk>/'
,
GetTemplateREST
.
as_view
()),
path
(
'acpi/template/'
,
TemplateREST
.
as_view
()),
...
...
circle/dashboard/views/vm.py
View file @
cd77d510
...
...
@@ -95,7 +95,6 @@ except NameError:
logger
=
logging
.
getLogger
(
__name__
)
from
rest_framework
import
status
from
rest_framework.views
import
APIView
from
rest_framework.parsers
import
JSONParser
...
...
@@ -108,6 +107,10 @@ from dashboard.serializers import (
AddPortSerializer
,
RuleSerializer
,
)
from
django.utils.decorators
import
method_decorator
from
django.views.decorators.cache
import
cache_page
from
rest_framework.response
import
Response
def
size_util
(
size
:
str
):
size_dict
=
{
"GB"
:
1000000000
,
...
...
@@ -248,6 +251,20 @@ class GetInterfaceREST(APIView):
serializer
=
InterfaceSerializer
(
interface
,
many
=
False
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
class
GetInstanceRESTSum
(
APIView
):
permission_classes
=
[]
@method_decorator
(
cache_page
(
60
*
1
))
def
get
(
self
,
request
,
format
=
None
):
instances
=
Instance
.
objects
.
filter
(
status
=
"RUNNING"
)
.
all
()
cpu_core
=
0
max_memory
=
0
for
i
in
instances
:
cpu_core
=
cpu_core
+
i
.
num_cores
max_memory
=
max_memory
+
i
.
ram_size
return
Response
(
{
"core_num_sum"
:
cpu_core
,
"ram_size_num"
:
max_memory
}
)
class
InstanceREST
(
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