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
ee30f76a
authored
Oct 07, 2022
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
instance setup network config
parent
cc9b42b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
circle/dashboard/serializers.py
+6
-2
circle/vm/models/instance.py
+2
-0
No files found.
circle/dashboard/serializers.py
View file @
ee30f76a
...
...
@@ -50,7 +50,7 @@ class InstanceTemplateSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
InstanceTemplate
fields
=
[
'id'
,
'name'
,
'description'
,
'parent'
,
'owner'
,
'access_method'
,
'boot_menu'
,
'lease'
,
'raw_data'
,
'cloud_init'
,
'ci_meta_data'
,
'ci_user_data'
,
'system'
,
'lease'
,
'raw_data'
,
'cloud_init'
,
'ci_
network_config'
,
'ci_
meta_data'
,
'ci_user_data'
,
'system'
,
'has_agent'
,
'num_cores'
,
'ram_size'
,
'max_ram_size'
,
'arch'
,
'priority'
,
'disks'
]
...
...
@@ -71,6 +71,7 @@ class InstanceSerializer(serializers.ModelSerializer):
ipv4addr
=
serializers
.
SerializerMethodField
(
'get_ipv4'
)
ipv6addr
=
serializers
.
SerializerMethodField
(
'get_ipv6'
)
vlans
=
serializers
.
SerializerMethodField
(
'get_vlans'
)
macaddr
=
serializers
.
SerializerMethodField
(
'get_mac'
)
#interfaces = serializers.SerializerMethodField('get_interfaces')
def
get_ipv4
(
self
,
i
):
...
...
@@ -79,6 +80,9 @@ class InstanceSerializer(serializers.ModelSerializer):
def
get_ipv6
(
self
,
i
):
return
str
(
i
.
ipv6
)
def
get_mac
(
self
,
i
):
return
str
(
i
.
mac
)
.
lower
()
def
get_vlans
(
self
,
i
):
return
list
(
net
.
vlan
.
id
for
net
in
i
.
interface_set
.
all
()
if
net
.
host
)
...
...
@@ -87,7 +91,7 @@ class InstanceSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Instance
fields
=
[
'id'
,
'name'
,
'description'
,
'status'
,
'owner'
,
'access_method'
,
'boot_menu'
,
'pw'
,
'is_base'
,
fields
=
[
'id'
,
'name'
,
'description'
,
'status'
,
'owner'
,
'access_method'
,
'boot_menu'
,
'pw'
,
'is_base'
,
'macaddr'
,
'lease'
,
'raw_data'
,
'cloud_init'
,
'ci_meta_data'
,
'ci_user_data'
,
'ci_network_config'
,
'system'
,
'req_traits'
,
'interface_set'
,
'has_agent'
,
'num_cores'
,
'ram_size'
,
'max_ram_size'
,
'arch'
,
'priority'
,
'disks'
,
'node'
,
'ipv4addr'
,
'ipv6addr'
,
'vlans'
,
'hookurl'
]
...
...
circle/vm/models/instance.py
View file @
ee30f76a
...
...
@@ -317,11 +317,13 @@ class NetTemplate:
self
.
ipv4
=
str
(
net
.
host
.
ipv4
)
self
.
ipv6
=
str
(
net
.
host
.
ipv6
)
self
.
name
=
str
(
net
.
vlan
.
name
)
self
.
mac
=
str
(
net
.
host
.
mac
)
def
__init__
(
self
,
instance
):
self
.
vlans
=
list
(
NetTemplate
.
Host
(
net
)
for
net
in
instance
.
interface_set
.
all
()
if
net
.
host
)
self
.
ipv4
=
str
(
instance
.
ipv4
)
self
.
ipv6
=
str
(
instance
.
ipv6
)
self
.
mac
=
str
(
instance
.
mac
)
.
lower
()
...
...
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