@@ -29,6 +29,7 @@ class TestMSMaintenanceAndSafeShutdown(cloudstackTestCase):
2929
3030 def setUp (self ):
3131 self .apiclient = self .testClient .getApiClient ()
32+ self .hypervisor = self .testClient .getHypervisorInfo ()
3233 self .mgtSvrDetails = self .config .__dict__ ["mgtSvr" ][0 ].__dict__
3334 self .cleanup = []
3435
@@ -86,8 +87,38 @@ def run_async_cmd(self) :
8687 {"name" : "test" , "displaytext" : "test" }
8788 )
8889
90+ def getActiveManagementServers (self ):
91+ cmd = listManagementServers .listManagementServersCmd ()
92+ servers = self .apiclient .listManagementServers (cmd )
93+ active_servers = []
94+ for idx , server in enumerate (servers ):
95+ if server .state == 'Up' :
96+ active_servers .append (server .serviceip )
97+ return active_servers
98+
8999 @attr (tags = ["advanced" , "smoke" ])
90100 def test_01_prepare_and_cancel_maintenance (self ):
101+ active_management_servers = self .getActiveManagementServers ()
102+ if len (active_management_servers ) <= 1 :
103+ self .skipTest ("Skipping test case, this test is intended for only multiple management servers" )
104+
105+ hypervisor = self .hypervisor .lower ()
106+ if hypervisor == 'kvm' :
107+ list_configurations_cmd = listConfigurations .listConfigurationsCmd ()
108+ list_configurations_cmd .name = "host"
109+ list_configurations_response = self .apiclient .listConfigurations (list_configurations_cmd )
110+ self .assertNotEqual (len (list_configurations_response ), 0 ,
111+ "Check if the list configurations API returns a non-empty response" )
112+
113+ for item in list_configurations_response :
114+ if item .name == list_configurations_cmd .name :
115+ host_config = item
116+
117+ hosts = host_config .value .split ("," )
118+ if len (hosts ) <= 1 :
119+ self .skipTest (
120+ "Skipping test case, this test is intended for only multiple management server hosts configured on host setting for kvm" )
121+
91122 try :
92123 prepare_for_maintenance_cmd = prepareForMaintenance .prepareForMaintenanceCmd ()
93124 prepare_for_maintenance_cmd .managementserverid = 1
0 commit comments