Allow the evacuator to enable passing shared storage parameter to nova

Boolean flag will be set to True in case of compute nodes are running
on a shared storage and will be False otherwise

Depends-On: Ie6f3f12efafbca530271d6771fac83480ee19000

Change-Id: I46e9eb2e1ace17959a02b3107e5ad3e85e2cd851
implements: blueprint dr-enable-shared-storage
This commit is contained in:
Saad Zaher 2016-06-04 02:35:35 +01:00
parent 60459fd6e3
commit 3c6c6b8697
6 changed files with 22 additions and 9 deletions

View File

@ -130,6 +130,11 @@ _EVACUATION = [
help='Number of retries to put node in maintenance mode before '
'reporting failure to evacuate the node',
dest='retries'),
cfg.BoolOpt('shared-storage',
default=False,
help='Set this option to True in case your compute nodes are '
'running on a shared storage or False if not',
dest='shared_storage'),
cfg.DictOpt(
'options',
default={},

View File

@ -114,11 +114,13 @@ class OSClient:
return neutron_agents
def evacuate(self, nodes):
def evacuate(self, nodes, shared_storage=False):
"""
Will get the hypervisors and list all running VMs on it and then start
Evacuating one by one ...
:param nodes: List of nodes to be evacuated !
:param shared_storage: Boolean, True if your compute nodes are running
under shared storage and False otherwise
:return: List of nodes with VMs that were running on that node
"""
auth_session = session.Session(auth=self.auth_session.auth)
@ -134,7 +136,7 @@ class OSClient:
for server in hypervisor.servers:
try:
nova.servers.evacuate(server.get('uuid'),
on_shared_storage=True)
on_shared_storage=shared_storage)
except Exception as e:
LOG.error(e)
host = {'host': node.get(

View File

@ -22,19 +22,22 @@ class EvacuatorBaseDriver(object):
a unified interface
"""
def __init__(self, wait, retries, **kwargs):
def __init__(self, wait, retries, shared_storage, **kwargs):
"""
Initialize Evacuation driver with the config args
:param wait: time in seconds that the evcauator should wait before
retrying to disable the node
:param retries: Number of times the evacuator will try to disable the
compute node
:param shared_storage: Boolean; True if the compute nodes are running
on shared storage and False otherwise
:param kwargs: Dict of arguments that any future driver may need to
load it from the config file
:return: None
"""
self.wait = wait
self.retries = retries
self.shared_storage = shared_storage
self.options = kwargs
@abc.abstractmethod

View File

@ -30,6 +30,7 @@ class EvacuationManager(object):
evcuation_conf.get('driver'),
evcuation_conf.get('wait'),
evcuation_conf.get('retries'),
evcuation_conf.get('shared_storage'),
**evcuation_conf.get('options')
)
self.enable_fencing = enable_fencing

View File

@ -21,8 +21,9 @@ LOG = log.getLogger(__name__)
class StandardEvacuator(EvacuatorBaseDriver):
def __init__(self, wait, retires, **kwargs):
super(StandardEvacuator, self).__init__(wait, retires, **kwargs)
def __init__(self, wait, retires, shared_storage, **kwargs):
super(StandardEvacuator, self).__init__(wait, retires, shared_storage,
**kwargs)
self.client = get_os_client()
def get_node_instances(self, node):
@ -38,7 +39,7 @@ class StandardEvacuator(EvacuatorBaseDriver):
return self.client.get_node_status(node)
def evacuate_nodes(self, nodes):
return self.client.evacuate(nodes)
return self.client.evacuate(nodes, shared_storage=self.shared_storage)

View File

@ -16,11 +16,12 @@ from freezer_dr.evacuators.common.driver import EvacuatorBaseDriver
class DummyEvacuator(EvacuatorBaseDriver):
""" Evacuation driver that does nothing. Useful for testing other parts
of OSHA.
of Freezer-DR.
"""
def __init__(self, wait, retires, **kwargs):
super(DummyEvacuator, self).__init__(wait, retires, **kwargs)
def __init__(self, wait, retires, shared_storage, **kwargs):
super(DummyEvacuator, self).__init__(wait, retires, shared_storage,
**kwargs)
def disable_node(self, node):
return True