Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
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
dea750e2
authored
Aug 08, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: add EnsureAgentMixin
parent
2668ad43
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
circle/vm/models/instance.py
+4
-0
circle/vm/operations.py
+19
-0
No files found.
circle/vm/models/instance.py
View file @
dea750e2
...
...
@@ -290,6 +290,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
message
=
ugettext_noop
(
"Instance
%(instance)
s has already been destroyed."
)
class
NoAgentError
(
InstanceError
):
message
=
ugettext_noop
(
"No agent software is running on instance
%(instance)
s."
)
class
WrongStateError
(
InstanceError
):
message
=
ugettext_noop
(
"Current state (
%(state)
s) of instance
%(instance)
s is "
...
...
circle/vm/operations.py
View file @
dea750e2
...
...
@@ -903,6 +903,25 @@ class ResourcesOperation(InstanceOperation):
register_operation
(
ResourcesOperation
)
class
EnsureAgentMixin
(
object
):
accept_states
=
(
'RUNNING'
,
)
def
check_precond
(
self
):
super
(
EnsureAgentMixin
,
self
)
.
check_precond
()
last_boot_time
=
self
.
instance
.
activity_log
.
filter
(
succeeded
=
True
,
activity_code__in
=
(
"vm.Instance.deploy"
,
"vm.Instance.reset"
,
"vm.Instance.reboot"
))
.
latest
(
"finished"
)
.
finished
try
:
InstanceActivity
.
objects
.
filter
(
activity_code
=
"vm.Instance.agent.starting"
,
started__gt
=
last_boot_time
)
.
latest
(
"started"
)
except
InstanceActivity
.
DoesNotExist
:
# no agent since last boot
raise
self
.
instance
.
NoAgentError
(
self
.
instance
)
class
PasswordResetOperation
(
InstanceOperation
):
activity_code_suffix
=
'Password reset'
id
=
'password_reset'
...
...
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