Skip to content

Commit 345a2f8

Browse files
Gaurav AradhyeSrikanteswaraRao Talluri
authored andcommitted
CLOUDSTACK-8059: test_host_high_availability.py - Adding necessary code to check the hosts in cluster and update the host with appropriate tags to make it HA enabled
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
1 parent aae393d commit 345a2f8

1 file changed

Lines changed: 34 additions & 2 deletions

File tree

‎test/integration/component/maint/test_host_high_availability.py‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@
1919
"""
2020
#Import Local Modules
2121
from nose.plugins.attrib import attr
22-
from marvin.cloudstackTestCase import cloudstackTestCase
22+
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
2323
from marvin.cloudstackAPI import (migrateVirtualMachine,
2424
prepareHostForMaintenance,
2525
cancelHostMaintenance)
2626
from marvin.lib.utils import cleanup_resources
2727
from marvin.lib.base import (Account,
2828
VirtualMachine,
29-
ServiceOffering)
29+
ServiceOffering,
30+
Cluster,
31+
Host,
32+
Configurations)
3033
from marvin.lib.common import (get_zone,
3134
get_domain,
3235
get_template,
@@ -99,6 +102,33 @@ def setUpClass(cls):
99102
cls.zone.id,
100103
cls.services["ostype"]
101104
)
105+
106+
107+
clusterWithSufficientHosts = None
108+
clusters = Cluster.list(cls.api_client, zoneid=cls.zone.id)
109+
for cluster in clusters:
110+
cls.hosts = Host.list(cls.api_client, clusterid=cluster.id, type="Routing")
111+
if len(cls.hosts) >= 3:
112+
clusterWithSufficientHosts = cluster
113+
break
114+
115+
if clusterWithSufficientHosts is None:
116+
raise unittest.SkipTest("No Cluster with 3 hosts found")
117+
118+
configs = Configurations.list(
119+
cls.api_client,
120+
name='ha.tag'
121+
)
122+
123+
assert isinstance(configs, list), "Config list not\
124+
retrieved for ha.tag"
125+
126+
if configs[0].value != "ha":
127+
raise unittest.SkipTest("Please set the global config\
128+
value for ha.tag as 'ha'")
129+
130+
Host.update(cls.api_client, id=cls.hosts[2].id, hosttags="ha")
131+
102132
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
103133
cls.services["virtual_machine"]["template"] = cls.template.id
104134

@@ -123,6 +153,8 @@ def setUpClass(cls):
123153
@classmethod
124154
def tearDownClass(cls):
125155
try:
156+
# Remove the host from HA
157+
Host.update(cls.api_client, id=cls.hosts[2].id, hosttags="")
126158
#Cleanup resources used
127159
cleanup_resources(cls.api_client, cls._cleanup)
128160
except Exception as e:

0 commit comments

Comments
 (0)