Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ea2d0b89
authored
Feb 08, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: instance delete hook
parent
89258183
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletions
+13
-1
one/models.py
+13
-1
No files found.
one/models.py
View file @
ea2d0b89
...
@@ -12,6 +12,8 @@ from firewall.tasks import reload_firewall_lock
...
@@ -12,6 +12,8 @@ from firewall.tasks import reload_firewall_lock
from
one.util
import
keygen
from
one.util
import
keygen
from
school.models
import
Person
,
Group
from
school.models
import
Person
,
Group
from
datetime
import
timedelta
as
td
from
datetime
import
timedelta
as
td
from
django.db.models.signals
import
post_delete
import
subprocess
,
tempfile
,
os
,
stat
,
re
,
base64
,
struct
import
subprocess
,
tempfile
,
os
,
stat
,
re
,
base64
,
struct
...
@@ -436,7 +438,7 @@ class Instance(models.Model):
...
@@ -436,7 +438,7 @@ class Instance(models.Model):
"""
"""
Delete host in OpenNebula.
Delete host in OpenNebula.
"""
"""
def
delete
(
self
):
def
one_
delete
(
self
):
proc
=
subprocess
.
Popen
([
"/opt/occi.sh"
,
"compute"
,
proc
=
subprocess
.
Popen
([
"/opt/occi.sh"
,
"compute"
,
"delete"
,
"
%
d"
%
self
.
one_id
],
stdout
=
subprocess
.
PIPE
)
"delete"
,
"
%
d"
%
self
.
one_id
],
stdout
=
subprocess
.
PIPE
)
(
out
,
err
)
=
proc
.
communicate
()
(
out
,
err
)
=
proc
.
communicate
()
...
@@ -503,3 +505,13 @@ class Instance(models.Model):
...
@@ -503,3 +505,13 @@ class Instance(models.Model):
class
Meta
:
class
Meta
:
verbose_name
=
_
(
'instance'
)
verbose_name
=
_
(
'instance'
)
verbose_name_plural
=
_
(
'instances'
)
verbose_name_plural
=
_
(
'instances'
)
def
delete_instance
(
sender
,
instance
,
using
,
**
kwargs
):
if
instance
.
state
!=
"DONE"
:
instance
.
one_delete
()
try
:
instance
.
host
.
delete
()
except
:
pass
post_delete
.
connect
(
delete_instance
,
sender
=
Instance
,
dispatch_uid
=
"delete_instance"
)
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