def revertResize(self, server): """ Revert a resize operation, restoring the server from the backup made when the resize was performed. """ data = json.dumps({"revertResize": None}) id = server.id self._post_action(id, data)
def confirmResize(self, server): """ Confirm resized server, i.e. confirm that resize worked and it's OK to delete all backups made when resize was performed. """ data = json.dumps({"confirmResize": None}) id = server.id self._post_action(id, data) self.notify(server, _confirmResizeNotifyCallback)
def rebuild(self, server, imageId=None): """ Rebuild a server, optionally specifying a different image. If no new image is supplied, the original is used. """ if not imageId: imageId = server.imageId data = json.dumps({"rebuild": {"imageId":imageId}}) id = server.id self._post_action(id, data)
def resize(self, server, flavorId): """ Change a server to a different size/flavor. A backup is kept of the original until you confirmResize or it recycles automatically (after 24 hours). """ if not flavorId: flavorId = server.flavorId data = json.dumps({"resize": {"flavorId":flavorId}}) id = server.id self._post_action(id, data) self.notify(server, _resizeNotifyCallback)
def reboot(self, server, rebootType): """ Reboot a server either "HARD", "SOFT". "SOFT" signals reboot with notification i.e. 'graceful' "HARD" forces reboot with no notification i.e. power cycle the server. """ if rebootType in ("HARD", "SOFT"): id = server.id data = json.dumps({"reboot": {"type": rebootType}}) self._post_action(id, data) self.refresh(server) # get updated status else: raise ClientErrors.InvalidArgumentsFault("Bad value %s passed for reboot type,\ must be 'HARD' or 'SOFT'", rebootType)
def asJSON(self): """ Return the backup schedule object converted to JSON """ return json.dumps(self.asDict)
def asJSON(self): """ Return the server object converted to JSON suitable for creating a server. """ return json.dumps(self.asDict)
def shareIp (self, server, ipAddr, sharedIpGroupId, configureServer): url_parts = (server.id, "ips", "public", ipAddr) data = json.dumps({"shareIp": {"sharedIpGroupId": sharedIpGroupId, \ "configureServer": configureServer}}) self._PUT(data, url_parts)