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
aa2237b4
authored
Oct 18, 2022
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'webhook-iac' into 'master'
variable delete method, bugfix See merge request
!20
parents
c7ef78f0
a2f4cde8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
5 deletions
+27
-5
circle/dashboard/serializers.py
+11
-1
circle/dashboard/views/util.py
+6
-1
circle/vm/models/instance.py
+9
-3
circle/vm/operations.py
+1
-0
No files found.
circle/dashboard/serializers.py
View file @
aa2237b4
...
...
@@ -79,6 +79,8 @@ class InstanceSerializer(serializers.ModelSerializer):
ipv6addr
=
serializers
.
SerializerMethodField
(
'get_ipv6'
)
vlans
=
serializers
.
SerializerMethodField
(
'get_vlans'
)
macaddr
=
serializers
.
SerializerMethodField
(
'get_mac'
)
sshportipv4
=
serializers
.
SerializerMethodField
(
'get_sshportipv4'
)
hostipv4
=
serializers
.
SerializerMethodField
(
'get_hostipv4'
)
#interfaces = serializers.SerializerMethodField('get_interfaces')
def
get_ipv4
(
self
,
i
):
...
...
@@ -96,12 +98,18 @@ class InstanceSerializer(serializers.ModelSerializer):
def
get_interfaces
(
self
,
i
):
return
i
.
interface_set
.
all
()
def
get_sshportipv4
(
self
,
i
):
return
i
.
get_connect_port
(
use_ipv6
=
False
)
def
get_hostipv4
(
self
,
i
):
return
i
.
get_connect_host
(
use_ipv6
=
False
)
class
Meta
:
model
=
Instance
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'
]
'hookurl'
,
'sshportipv4'
,
'hostipv4'
]
extra_kwargs
=
{
'disks'
:
{
'required'
:
False
,
'allow_empty'
:
True
,},
'req_traits'
:
{
'required'
:
False
,
'allow_empty'
:
True
,},
...
...
@@ -111,6 +119,8 @@ class InstanceSerializer(serializers.ModelSerializer):
'ci_user_data'
:
{
'required'
:
False
,
},
'ci_meta_data'
:
{
'required'
:
False
,
},
'raw_data'
:
{
'required'
:
False
,
},
'sshportipv4'
:
{
'required'
:
False
,
},
'hostipv4'
:
{
'required'
:
False
,
},
}
...
...
circle/dashboard/views/util.py
View file @
aa2237b4
...
...
@@ -127,7 +127,7 @@ class VariableREST(APIView):
def
post
(
self
,
request
,
format
=
None
):
data
=
JSONParser
()
.
parse
(
request
)
serializer
=
VariableSerializer
(
data
=
data
)
serializer
=
VariableSerializer
(
data
=
data
,
context
=
{
'request'
:
request
}
)
if
serializer
.
is_valid
():
serializer
.
save
()
return
JsonResponse
(
serializer
.
data
,
status
=
201
)
...
...
@@ -143,6 +143,11 @@ class GetVariableREST(APIView):
serializer
=
VariableSerializer
(
act
,
many
=
False
,
context
=
{
'request'
:
request
})
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
def
delete
(
self
,
request
,
pk
,
format
=
None
):
var
=
Variable
.
objects
.
get
(
pk
=
pk
)
var
.
delete
()
return
JsonResponse
({},
status
=
204
)
class
RedirectToLoginMixin
(
AccessMixin
):
redirect_exception_classes
=
(
PermissionDenied
,
)
...
...
circle/vm/models/instance.py
View file @
aa2237b4
...
...
@@ -111,8 +111,8 @@ network:
match:
macaddress: {{ net.mac }}
addresses:
- {{ net.ipv4 }}/
24
gateway4:
ipv4
- {{ net.ipv4 }}/
{{ net.mask4 }}
gateway4:
{{ net.gateway4 }}
nameservers:
addresses:
- 8.8.8.8
...
...
@@ -317,6 +317,8 @@ class NetTemplate:
self
.
ipv4
=
str
(
net
.
host
.
ipv4
)
self
.
ipv6
=
str
(
net
.
host
.
ipv6
)
self
.
name
=
str
(
net
.
vlan
.
name
)
self
.
gateway4
=
str
(
net
.
vlan
.
network4
)
.
split
(
"/"
)[
0
]
self
.
mask4
=
str
(
net
.
vlan
.
network4
)
.
split
(
"/"
)[
1
]
self
.
mac
=
str
(
net
.
host
.
mac
)
def
__init__
(
self
,
instance
):
...
...
@@ -324,6 +326,10 @@ class NetTemplate:
self
.
ipv4
=
str
(
instance
.
ipv4
)
self
.
ipv6
=
str
(
instance
.
ipv6
)
self
.
mac
=
str
(
instance
.
mac
)
if
instance
.
primary_host
:
addr
=
str
(
instance
.
primary_host
.
vlan
.
network4
)
.
split
(
"/"
)
self
.
gateway4
=
addr
[
0
]
self
.
mask4
=
addr
[
1
]
class
Instance
(
AclBase
,
VirtualMachineDescModel
,
StatusModel
,
OperatedMixin
,
...
...
@@ -604,7 +610,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
common_fields
=
[
'name'
,
'description'
,
'num_cores'
,
'ram_size'
,
'max_ram_size'
,
'arch'
,
'priority'
,
'boot_menu'
,
'raw_data'
,
'lease'
,
'access_method'
,
'system'
,
'cloud_init'
,
'ci_meta_data'
,
'ci_user_data'
,
'has_agent'
]
'cloud_init'
,
'ci_meta_data'
,
'ci_user_data'
,
'
ci_network_config'
,
'
has_agent'
]
params
=
dict
(
template
=
template
,
owner
=
owner
,
pw
=
pwgen
())
params
.
update
([(
f
,
getattr
(
template
,
f
))
for
f
in
common_fields
])
params
.
update
(
kwargs
)
# override defaults w/ user supplied values
...
...
circle/vm/operations.py
View file @
aa2237b4
...
...
@@ -889,6 +889,7 @@ class SaveAsTemplateOperation(InstanceOperation):
'cloud_init'
:
self
.
instance
.
cloud_init
,
'ci_meta_data'
:
self
.
instance
.
ci_meta_data
,
'ci_user_data'
:
self
.
instance
.
ci_user_data
,
'ci_network_config'
:
self
.
instance
.
ci_network_config
,
}
params
.
update
(
kwargs
)
...
...
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