Permalink
Browse files

Server.run_script() and Status support.

  • Loading branch information...
1 parent 2af1717 commit a88609e1000a94bcc122d3b18fd4767117ce562e silver committed Aug 1, 2011
Showing with 55 additions and 0 deletions.
  1. +9 −0 src/rightscale/Server.py
  2. +46 −0 src/rightscale/Status.py
View
@@ -4,6 +4,7 @@
from Tags import Tags
from ServerSettings import ServerSettings
from ServerTemplate import ServerTemplate
+from Status import Status
# TODO(sissel): Refactor
import xml.etree.ElementTree as ElementTree
@@ -135,6 +136,14 @@ def tags(self, value):
self._tags = value
# def tags
+ def run_script(self, script_id):
+ """ Runs script on this Server. """
+ href = self.href + "/run_script"
+ params = {'right_script': script_id}
+ response, content = self.rsapi.request(href, params, method="POST")
+ return Status(response.get('location'), self.rsapi)
+
+
def save(self):
""" Save any modifications made to this Server.
View
@@ -0,0 +1,46 @@
+from XMLModel import XMLModel
+from rightscale.util import ElementTreeValueOK
+
+class Status(XMLModel):
+ _state = None
+ _description = None
+ _href = None
+
+ @property
+ def state(self):
+ """ State of script execution: "queued", "in progress", "aborted",
+ "completed", "failed"
+ """
+ return self._state
+
+ @state.setter
+ @ElementTreeValueOK
+ def state(self, value):
+ self._state = value
+
+ @property
+ def description(self):
+ return self._description
+
+ @description.setter
+ @ElementTreeValueOK
+ def description(self, value):
+ self._description = value
+
+ @property
+ def href(self):
+ return self._href
+
+ @href.setter
+ @ElementTreeValueOK
+ def href(self, value):
+ self._href = value
+
+
+ ELEMENTS = {
+ 'state': state,
+ 'description': description,
+ 'href': href
+ }
+
+# class Status

0 comments on commit a88609e

Please sign in to comment.