Adds support for live migrations

* Updated live migrate client function to take correct params
* Added live migrate model

Change-Id: Ic2b60ff322a2568418c8ef0a16c53e69d0619269
This commit is contained in:
Daryl Walleck
2013-10-18 15:20:57 -05:00
parent e1e06206fd
commit 09342d3f4c
2 changed files with 40 additions and 4 deletions

View File

@@ -30,7 +30,7 @@ from cloudcafe.compute.servers_api.models.requests import UpdateServer
from cloudcafe.compute.servers_api.models.requests import ChangePassword, \
ConfirmResize, RevertResize, Resize, Reboot, MigrateServer, Lock, \
Unlock, Start, Stop, Suspend, Resume, Pause, Unpause, CreateImage, \
Rebuild, ResetState, CreateBackup
Rebuild, ResetState, CreateBackup, LiveMigrateServer
class ServersClient(AutoMarshallingRestClient):
@@ -434,9 +434,11 @@ class ServersClient(AutoMarshallingRestClient):
requestslib_kwargs=requestslib_kwargs)
return resp
def live_migrate_server(self, server_id, requestslib_kwargs=None):
def live_migrate_server(self, server_id, disk_over_commit=None,
block_migration=None, host=None,
requestslib_kwargs=None):
"""
@summary: Migrates a server live to a new host
@summary: Migrates a server to a new host without rebooting
@param server_id: The id of the server to migrate
@type server_id: String
@return: An object that represents the response to the request
@@ -445,8 +447,11 @@ class ServersClient(AutoMarshallingRestClient):
url = '{base_url}/servers/{server_id}/action'.format(
base_url=self.url, server_id=server_id)
request = LiveMigrateServer(
host=host, disk_over_commit=disk_over_commit,
block_migration=block_migration)
resp = self.request('POST', url,
request_entity=MigrateServer(),
request_entity=request,
requestslib_kwargs=requestslib_kwargs)
return resp

View File

@@ -387,6 +387,37 @@ class MigrateServer(AutoMarshallingModel):
return xml
class LiveMigrateServer(AutoMarshallingModel):
"""
@summary: Live Migration Request Object
"""
def __init__(self, disk_over_commit=None,
block_migration=None, host=None):
super(LiveMigrateServer, self).__init__()
self.disk_over_commit = disk_over_commit
self.block_migration = block_migration
self.host = host
def _obj_to_json(self):
body = {
'disk_over_commit': self.disk_over_commit,
'block_migration': self.block_migration,
'host': self.host
}
return json.dumps({'os-migrateLive': body})
def _obj_to_xml(self):
xml = Constants.XML_HEADER
element = ET.Element('os-migrateLive')
element.set('xmlns', Constants.XML_API_NAMESPACE)
element.set('disk_over_commit', self.disk_over_commit)
element.set('block_migration', self.block_migration)
element.set('host', self.host)
xml += ET.tostring(element)
return xml
class ConfirmServerMigration(AutoMarshallingModel):
"""
@summary: Confirm Server Migration Request Object