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
ddfe345d
authored
Feb 08, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: refactor _change_state body to _update_vm
parent
eb25f6f3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
one/models.py
+9
-7
No files found.
one/models.py
View file @
ddfe345d
...
...
@@ -443,20 +443,16 @@ class Instance(models.Model):
self
.
firewall_host
.
delete
()
reload_firewall_lock
()
"""
Change host state in OpenNebula.
"""
def
_change_state
(
self
,
new_state
):
from
django.template.defaultfilters
import
escape
def
_update_vm
(
self
,
template
):
out
=
""
with
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
as
f
:
os
.
chmod
(
f
.
name
,
stat
.
S_IRUSR
|
stat
.
S_IWUSR
|
stat
.
S_IRGRP
|
stat
.
S_IROTH
)
tpl
=
u"""
<COMPUTE>
<ID>
%(id)
d</ID>
<STATE>
%(state)
s</STATE>
%(template)
s
</COMPUTE>"""
%
{
"id"
:
self
.
one_id
,
"
state"
:
new_st
ate
}
"
template"
:
templ
ate
}
f
.
write
(
tpl
)
f
.
close
()
import
subprocess
...
...
@@ -467,6 +463,12 @@ class Instance(models.Model):
os
.
unlink
(
f
.
name
)
print
"out: "
+
out
"""
Change host state in OpenNebula.
"""
def
_change_state
(
self
,
new_state
):
self
.
_update_vm
(
"<STATE>"
+
new_state
+
"</STATE>"
)
def
stop
(
self
):
self
.
_change_state
(
"STOPPED"
)
def
resume
(
self
):
...
...
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