Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
11ea1162
authored
Feb 06, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: raise exception if user is trying to deploy destroyed vm
parent
1a278f49
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
circle/vm/models/instance.py
+14
-2
No files found.
circle/vm/models/instance.py
View file @
11ea1162
...
@@ -230,6 +230,17 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -230,6 +230,17 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
verbose_name
=
_
(
'instance'
)
verbose_name
=
_
(
'instance'
)
verbose_name_plural
=
_
(
'instances'
)
verbose_name_plural
=
_
(
'instances'
)
class
InstanceDestroyedError
(
Exception
):
def
__init__
(
self
,
instance
,
message
=
None
):
if
message
is
None
:
message
=
(
"The instance (
%
s) has already been destroyed."
%
instance
)
Exception
.
__init__
(
self
,
message
)
self
.
instance
=
instance
def
__unicode__
(
self
):
def
__unicode__
(
self
):
parts
=
[
self
.
name
,
"("
+
str
(
self
.
id
)
+
")"
]
parts
=
[
self
.
name
,
"("
+
str
(
self
.
id
)
+
")"
]
return
" "
.
join
([
s
for
s
in
parts
if
s
!=
""
])
return
" "
.
join
([
s
for
s
in
parts
if
s
!=
""
])
...
@@ -556,11 +567,12 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -556,11 +567,12 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
asynchronously.
asynchronously.
:type task_uuid: str
:type task_uuid: str
"""
"""
if
self
.
destroyed
:
raise
self
.
InstanceDestroyedError
(
self
)
with
instance_activity
(
code_suffix
=
'deploy'
,
instance
=
self
,
with
instance_activity
(
code_suffix
=
'deploy'
,
instance
=
self
,
task_uuid
=
task_uuid
,
user
=
user
)
as
act
:
task_uuid
=
task_uuid
,
user
=
user
)
as
act
:
# Clear destroyed flag
self
.
destroyed
=
None
self
.
__schedule_vm
(
act
)
self
.
__schedule_vm
(
act
)
...
...
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