2121import time
2222import XenAPI
2323
24+ from solidfire .factory import ElementFactory
25+
2426from util import sf_util
2527
2628# All tests inherit from cloudstackTestCase
3739# utils - utility classes for common cleanup, external library wrappers, etc.
3840from marvin .lib .utils import cleanup_resources
3941
40- from solidfire import solidfire_element_api as sf_api
41-
4242# Prerequisites:
4343# Only one zone
4444# Only one pod
@@ -59,12 +59,10 @@ class TestData:
5959 diskSize = "disksize"
6060 domainId = "domainId"
6161 hypervisor = "hypervisor"
62- login = "login"
6362 mvip = "mvip"
6463 name = "name"
6564 newHost = "newHost"
6665 newHostDisplayName = "newHostDisplayName"
67- osType = "ostype"
6866 password = "password"
6967 podId = "podid"
7068 port = "port"
@@ -89,7 +87,7 @@ def __init__(self):
8987 self .testdata = {
9088 TestData .solidFire : {
9189 TestData .mvip : "192.168.139.112" ,
92- TestData .login : "admin" ,
90+ TestData .username : "admin" ,
9391 TestData .password : "admin" ,
9492 TestData .port : 443 ,
9593 TestData .url : "https://192.168.139.112:443"
@@ -170,7 +168,6 @@ def __init__(self):
170168 "diskname" : "testvolume2" ,
171169 },
172170 TestData .newHostDisplayName : "XenServer-6.5-3" ,
173- TestData .osType : "CentOS 5.6(64-bit) no GUI (XenServer)" ,
174171 TestData .zoneId : 1 ,
175172 TestData .clusterId : 1 ,
176173 TestData .domainId : 1 ,
@@ -186,7 +183,9 @@ class TestAddRemoveHosts(cloudstackTestCase):
186183 def setUpClass (cls ):
187184 # Set up API client
188185 testclient = super (TestAddRemoveHosts , cls ).getClsTestClient ()
186+
189187 cls .apiClient = testclient .getApiClient ()
188+ cls .configData = testclient .getParsedTestDataConfig ()
190189 cls .dbConnection = testclient .getDbConnection ()
191190
192191 cls .testdata = TestData ().testdata
@@ -203,12 +202,14 @@ def setUpClass(cls):
203202 cls .xen_session .xenapi .login_with_password (xenserver [TestData .username ], xenserver [TestData .password ])
204203
205204 # Set up SolidFire connection
206- cls .sf_client = sf_api .SolidFireAPI (endpoint_dict = cls .testdata [TestData .solidFire ])
205+ solidfire = cls .testdata [TestData .solidFire ]
206+
207+ cls .sfe = ElementFactory .create (solidfire [TestData .mvip ], solidfire [TestData .username ], solidfire [TestData .password ])
207208
208209 # Get Resources from Cloud Infrastructure
209210 cls .zone = get_zone (cls .apiClient , zone_id = cls .testdata [TestData .zoneId ])
210211 cls .cluster = list_clusters (cls .apiClient )[0 ]
211- cls .template = get_template (cls .apiClient , cls .zone .id , cls .testdata [ TestData . osType ])
212+ cls .template = get_template (cls .apiClient , cls .zone .id , cls .configData [ "ostype" ])
212213 cls .domain = get_domain (cls .apiClient , cls .testdata [TestData .domainId ])
213214
214215 # Create test account
@@ -249,7 +250,7 @@ def tearDownClass(cls):
249250 try :
250251 cleanup_resources (cls .apiClient , cls ._cleanup )
251252
252- sf_util .purge_solidfire_volumes (cls .sf_client )
253+ sf_util .purge_solidfire_volumes (cls .sfe )
253254 except Exception as e :
254255 logging .debug ("Exception in tearDownClass(cls): %s" % e )
255256
@@ -423,8 +424,8 @@ def test_add_remove_host_with_solidfire_plugin_4(self):
423424
424425 self ._perform_add_remove_host (primary_storage_2 .id , sf_iscsi_name )
425426
426- def _perform_add_remove_host (self , primary_storage_id , sf_iscsi_name ):
427- xen_sr = self .xen_session .xenapi .SR .get_by_name_label (sf_iscsi_name )[0 ]
427+ def _perform_add_remove_host (self , primary_storage_id , sr_name ):
428+ xen_sr = self .xen_session .xenapi .SR .get_by_name_label (sr_name )[0 ]
428429
429430 pbds = self .xen_session .xenapi .SR .get_PBDs (xen_sr )
430431
@@ -651,10 +652,10 @@ def _get_sf_vag_id(self, cluster_id, primary_storage_id):
651652 return sf_vag_id
652653
653654 def _get_sf_vag (self , sf_vag_id ):
654- return self .sf_client .list_volume_access_groups (sf_vag_id , 1 )[ "volumeAccessGroups" ] [0 ]
655+ return self .sfe .list_volume_access_groups (sf_vag_id , 1 ). volume_access_groups [0 ]
655656
656657 def _get_sf_vag_initiators (self , sf_vag ):
657- return sf_vag [ " initiators" ]
658+ return sf_vag . initiators
658659
659660 def _verifyVag (self , host_iscsi_iqns , sf_vag_initiators ):
660661 self .assertEqual (
0 commit comments