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
31bb2f5c
authored
2 years ago
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webhook for system operations
parent
2ca1821d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
2 deletions
+34
-2
circle/dashboard/serializers.py
+4
-2
circle/vm/migrations/0011_instance_hookurl.py
+18
-0
circle/vm/models/instance.py
+8
-0
circle/vm/operations.py
+4
-0
No files found.
circle/dashboard/serializers.py
View file @
31bb2f5c
...
...
@@ -89,11 +89,13 @@ class InstanceSerializer(serializers.ModelSerializer):
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'
,
'interface_set'
,
'has_agent'
,
'num_cores'
,
'ram_size'
,
'max_ram_size'
,
'arch'
,
'priority'
,
'disks'
,
'node'
,
'ipv4addr'
,
'ipv6addr'
,
'vlans'
]
'has_agent'
,
'num_cores'
,
'ram_size'
,
'max_ram_size'
,
'arch'
,
'priority'
,
'disks'
,
'node'
,
'ipv4addr'
,
'ipv6addr'
,
'vlans'
'hookurl'
]
extra_kwargs
=
{
'disks'
:
{
'required'
:
False
,
'allow_empty'
:
True
,},
'req_traits'
:
{
'required'
:
False
,
'allow_empty'
:
True
,},
'interface_set'
:
{
'required'
:
False
,
'allow_empty'
:
True
,}
'interface_set'
:
{
'required'
:
False
,
'allow_empty'
:
True
,},
'hookurl'
:
{
'required'
:
False
,
'allow_empty'
:
True
,}
}
...
...
This diff is collapsed.
Click to expand it.
circle/vm/migrations/0011_instance_hookurl.py
0 → 100644
View file @
31bb2f5c
# Generated by Django 3.2.3 on 2022-10-04 09:53
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'vm'
,
'0010_auto_20220914_1532'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'instance'
,
name
=
'hookurl'
,
field
=
models
.
CharField
(
blank
=
True
,
help_text
=
'If expiration due, call remote url.'
,
max_length
=
250
,
verbose_name
=
'hookurl'
),
),
]
This diff is collapsed.
Click to expand it.
circle/vm/models/instance.py
View file @
31bb2f5c
...
...
@@ -23,6 +23,7 @@ from functools import partial
from
importlib
import
import_module
from
ipaddress
import
ip_interface
from
logging
import
getLogger
from
urllib
import
request
from
warnings
import
warn
from
xml.dom.minidom
import
Text
...
...
@@ -325,6 +326,8 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
)
name
=
CharField
(
blank
=
True
,
max_length
=
100
,
verbose_name
=
_
(
'name'
),
help_text
=
_
(
"Human readable name of instance."
))
hookurl
=
CharField
(
blank
=
True
,
max_length
=
250
,
verbose_name
=
_
(
'hookurl'
),
help_text
=
_
(
"If expiration due, call remote url."
))
description
=
TextField
(
blank
=
True
,
verbose_name
=
_
(
'description'
))
template
=
ForeignKey
(
InstanceTemplate
,
blank
=
True
,
null
=
True
,
related_name
=
'instance_set'
,
on_delete
=
SET_NULL
,
...
...
@@ -454,6 +457,11 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
yaml
.
dump
(
yaml
.
load
(
data
,
Loader
=
yaml
.
Loader
))
return
True
def
callhookurl
(
self
):
import
requests
as
req
if
self
.
hookurl
:
req
.
get
(
url
=
self
.
hookurl
)
def
_update_status
(
self
):
"""Set the proper status of the instance to Instance.status.
"""
...
...
This diff is collapsed.
Click to expand it.
circle/vm/operations.py
View file @
31bb2f5c
...
...
@@ -616,6 +616,8 @@ class DestroyOperation(InstanceOperation):
self
.
instance
.
destroyed_at
=
timezone
.
now
()
self
.
instance
.
save
()
if
system
:
self
.
instance
.
callhookurl
()
@register_operation
class
DeleteVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
...
...
@@ -1027,6 +1029,8 @@ class SleepOperation(InstanceOperation):
self
.
instance
.
shutdown_net
()
self
.
instance
.
_suspend_vm
(
parent_activity
=
activity
)
self
.
instance
.
yield_node
()
if
system
:
self
.
instance
.
callhookurl
()
@register_operation
class
SuspendVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
...
...
This diff is collapsed.
Click to expand it.
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