Merge "cluster: Adds VM clustering failover configuration"

This commit is contained in:
Jenkins 2017-08-11 12:54:12 +00:00 committed by Gerrit Code Review
commit 87352845c5
3 changed files with 25 additions and 3 deletions

View File

@ -58,7 +58,9 @@ class ClusterOps(object):
def add_to_cluster(self, instance):
try:
self._clustutils.add_vm_to_cluster(instance.name)
self._clustutils.add_vm_to_cluster(
instance.name, CONF.hyperv.max_failover_count,
CONF.hyperv.failover_period, CONF.hyperv.auto_failback)
self._instance_map[instance.name] = instance.uuid
except os_win_exc.HyperVClusterException:
LOG.exception('Adding instance to cluster failed.',

View File

@ -36,7 +36,22 @@ hyperv_opts = [
help='Number of seconds to wait for an instance to be '
'live migrated (Only applies to clustered instances '
'for the moment).'),
cfg.IntOpt('max_failover_count',
default=1,
min=1,
help="The maximum number of failovers that can occur in the "
"failover_period timeframe per VM. Once a VM's number "
"failover reaches this number, the VM will simply end up "
"in a Failed state."),
cfg.IntOpt('failover_period',
default=6,
min=1,
help="The number of hours in which the max_failover_count "
"number of failovers can occur."),
cfg.BoolOpt('auto_failback',
default=True,
help="Allow the VM the failback to its original host once it "
"is available."),
]
CONF = nova.conf.CONF

View File

@ -22,9 +22,12 @@ from nova import objects
from os_win import exceptions as os_win_exc
from compute_hyperv.nova.cluster import clusterops
import compute_hyperv.nova.conf
from compute_hyperv.tests import fake_instance
from compute_hyperv.tests.unit import test_base
CONF = compute_hyperv.nova.conf.CONF
@ddt.ddt
class ClusterOpsTestCase(test_base.HyperVBaseTestCase):
@ -58,7 +61,9 @@ class ClusterOpsTestCase(test_base.HyperVBaseTestCase):
self.clusterops.add_to_cluster(mock_instance)
mock_add_vm = self.clusterops._clustutils.add_vm_to_cluster
mock_add_vm.assert_called_once_with(mock_instance.name)
mock_add_vm.assert_called_once_with(
mock_instance.name, CONF.hyperv.max_failover_count,
CONF.hyperv.failover_period, CONF.hyperv.auto_failback)
self.assertEqual(mock_instance.uuid,
self.clusterops._instance_map[mock_instance.name])