Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
snf-occi
Commits
f882a314
Commit
f882a314
authored
Apr 19, 2012
by
John Giannelos
Browse files
Fixed compute instances attributes: actions, states
parent
4b86ec7c
Changes
1
Show whitespace changes
Inline
Side-by-side
snf-occi-server.py
View file @
f882a314
...
@@ -72,18 +72,22 @@ class ComputeBackend(MyBackend):
...
@@ -72,18 +72,22 @@ class ComputeBackend(MyBackend):
raise
AttributeError
(
"This action is currently no applicable."
)
raise
AttributeError
(
"This action is currently no applicable."
)
elif
action
==
START
:
elif
action
==
START
:
entity
.
attributes
[
'occi.compute.state'
]
=
'active'
entity
.
attributes
[
'occi.compute.state'
]
=
'active'
entity
.
actions
=
[
STOP
,
SUSPEND
,
RESTART
]
# read attributes from action and do something with it :-)
# read attributes from action and do something with it :-)
print
(
'Starting virtual machine with id'
+
entity
.
identifier
)
print
(
'Starting virtual machine with id'
+
entity
.
identifier
)
elif
action
==
STOP
:
elif
action
==
STOP
:
entity
.
attributes
[
'occi.compute.state'
]
=
'inactive'
entity
.
attributes
[
'occi.compute.state'
]
=
'inactive'
entity
.
actions
=
[
START
]
# read attributes from action and do something with it :-)
# read attributes from action and do something with it :-)
print
(
'Stopping virtual machine with id'
+
entity
.
identifier
)
print
(
'Stopping virtual machine with id'
+
entity
.
identifier
)
elif
action
==
RESTART
:
elif
action
==
RESTART
:
entity
.
actions
=
[
STOP
,
SUSPEND
,
RESTART
]
entity
.
attributes
[
'occi.compute.state'
]
=
'active'
entity
.
attributes
[
'occi.compute.state'
]
=
'active'
# read attributes from action and do something with it :-)
# read attributes from action and do something with it :-)
print
(
'Restarting virtual machine with id'
+
entity
.
identifier
)
print
(
'Restarting virtual machine with id'
+
entity
.
identifier
)
elif
action
==
SUSPEND
:
elif
action
==
SUSPEND
:
entity
.
attributes
[
'occi.compute.state'
]
=
'suspended'
entity
.
attributes
[
'occi.compute.state'
]
=
'suspended'
entity
.
actions
=
[
START
]
# read attributes from action and do something with it :-)
# read attributes from action and do something with it :-)
print
(
'Suspending virtual machine with id'
+
entity
.
identifier
)
print
(
'Suspending virtual machine with id'
+
entity
.
identifier
)
...
@@ -97,6 +101,7 @@ class MyAPP(Application):
...
@@ -97,6 +101,7 @@ class MyAPP(Application):
sec_obj
=
{
'username'
:
'password'
}
sec_obj
=
{
'username'
:
'password'
}
snf
=
ComputeClient
(
Config
())
snf
=
ComputeClient
(
Config
())
images
=
snf
.
list_images
()
images
=
snf
.
list_images
()
for
image
in
images
:
for
image
in
images
:
IMAGE
=
Mixin
(
"http://schemas.ogf.org/occi/infrastructure#"
,
str
(
image
[
'name'
]),
[
OS_TEMPLATE
])
IMAGE
=
Mixin
(
"http://schemas.ogf.org/occi/infrastructure#"
,
str
(
image
[
'name'
]),
[
OS_TEMPLATE
])
...
...
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