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
42092a44
authored
Sep 21, 2022
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rules and interfaces endpoint
parent
0c41ced7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
circle/dashboard/serializers.py
+5
-1
circle/dashboard/urls.py
+2
-1
circle/dashboard/views/vm.py
+11
-2
No files found.
circle/dashboard/serializers.py
View file @
42092a44
...
...
@@ -71,6 +71,7 @@ class InstanceSerializer(serializers.ModelSerializer):
ipv4addr
=
serializers
.
SerializerMethodField
(
'get_ipv4'
)
ipv6addr
=
serializers
.
SerializerMethodField
(
'get_ipv6'
)
vlans
=
serializers
.
SerializerMethodField
(
'get_vlans'
)
#interfaces = serializers.SerializerMethodField('get_interfaces')
def
get_ipv4
(
self
,
i
):
return
str
(
i
.
ipv4
)
...
...
@@ -81,10 +82,13 @@ class InstanceSerializer(serializers.ModelSerializer):
def
get_vlans
(
self
,
i
):
return
list
(
net
.
vlan
.
id
for
net
in
i
.
interface_set
.
all
()
if
net
.
host
)
def
get_interfaces
(
self
,
i
):
return
i
.
interface_set
.
all
()
class
Meta
:
model
=
Instance
fields
=
[
'id'
,
'name'
,
'description'
,
'status'
,
'owner'
,
'access_method'
,
'boot_menu'
,
'pw'
,
'is_base'
,
'lease'
,
'raw_data'
,
'cloud_init'
,
'ci_meta_data'
,
'ci_user_data'
,
'system'
,
'req_traits'
,
'lease'
,
'raw_data'
,
'cloud_init'
,
'ci_meta_data'
,
'ci_user_data'
,
'system'
,
'req_traits'
,
'interface_set'
,
'has_agent'
,
'num_cores'
,
'ram_size'
,
'max_ram_size'
,
'arch'
,
'priority'
,
'disks'
,
'node'
,
'ipv4addr'
,
'ipv6addr'
,
'vlans'
]
extra_kwargs
=
{
'disks'
:
{
'required'
:
False
,
'allow_empty'
:
True
,},
...
...
circle/dashboard/urls.py
View file @
42092a44
...
...
@@ -64,7 +64,7 @@ from .views import (
SleepInstanceREST
,
WakeUpInstanceREST
,
DownloadPersistentDiskREST
,
CreatePersistentDiskREST
,
GetStorageActivityREST
,
GetTemplateREST
,
MessageList
,
MessageDetail
,
MessageCreate
,
MessageDelete
,
SetupPortREST
,
SetupPortREST
,
RulesREST
,
EnableTwoFactorView
,
DisableTwoFactorView
,
AclUserGroupAutocomplete
,
AclUserAutocomplete
,
RescheduleView
,
GroupImportView
,
GroupExportView
,
...
...
@@ -101,6 +101,7 @@ urlpatterns = [
path
(
'acpi/ftusersid/'
,
InstanceFTforUsersIdREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/downloaddisk/'
,
DownloadDiskREST
.
as_view
()),
path
(
'acpi/vm/<int:vm_id>/port/<int:vlan_id>/'
,
SetupPortREST
.
as_view
()),
path
(
'acpi/vm/<int:vm_id>/rules/<int:vlan_id>/'
,
RulesREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/createdisk/'
,
CreateDiskREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/deploy/'
,
DeployInstanceREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/shutdown/'
,
ShutdownInstanceREST
.
as_view
()),
...
...
circle/dashboard/views/vm.py
View file @
42092a44
...
...
@@ -338,8 +338,17 @@ class SleepInstanceREST(APIView):
class
RulesREST
(
APIView
):
def
post
():
pass
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
permission_classes
=
[
IsAdminUser
]
def
get
(
self
,
request
,
vm_id
,
vlan_id
,
format
=
None
):
instance
=
Instance
.
objects
.
get
(
pk
=
vm_id
)
vlan
=
Vlan
.
objects
.
get
(
pk
=
vlan_id
)
interface
=
Interface
.
objects
.
filter
(
instance
=
instance
)
.
filter
(
vlan
=
vlan
)
.
get
()
rules
=
Rule
.
objects
.
filter
(
host
=
interface
.
host
)
serializer
=
RuleSerializer
(
rules
,
many
=
True
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
,
status
=
200
)
class
SetupPortREST
(
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