Support running actions before the end of a lease

This patch adds a before_end() method to the resource plugin. It is
called from the manager at the before_end_lease event. An actual action
is configurable for each resource plugin. The physical host plugin
currently supports 'snapshot'.

This patch also renames the API parameter 'before_end_notification'
'before_end_date' because actions other than notification get to use
this parameter.

Change-Id: Ifdb42e431f2b5134ed8a720ae040486aee2e4acc
Implements: blueprint on-end-options
This commit is contained in:
Hiroaki Kobayashi
2017-05-29 16:34:42 +09:00
committed by Pierre Riteau
parent 2ea4f6e8ef
commit a5fb773bcd
10 changed files with 130 additions and 60 deletions

View File

@@ -169,12 +169,11 @@ class ServerManager(servers.ServerManager):
"""Unshelve the server."""
self._action('unshelve', server, None)
def create_image(self, server_id, image_name=None, metadata=None):
def create_image(self, server, image_name=None, metadata=None):
"""Snapshot a server."""
server_name = self.get(server_id).name
if image_name is None:
image_name = CONF.nova.image_prefix + server_name
return super(ServerManager, self).create_image(server_id,
image_name = CONF.nova.image_prefix + server.name
return super(ServerManager, self).create_image(server,
image_name=image_name,
metadata=metadata)