@@ -64,6 +64,7 @@ def setUpClass(cls):
6464 cls .testClient = super (TestIsolatedNetworksPasswdServer , cls ).getClsTestClient ()
6565 cls .api_client = cls .testClient .getApiClient ()
6666
67+ cls .hostConfig = cls .config .__dict__ ["zones" ][0 ].__dict__ ["pods" ][0 ].__dict__ ["clusters" ][0 ].__dict__ ["hosts" ][0 ].__dict__
6768 cls .services = cls .testClient .getParsedTestDataConfig ()
6869 # Get Zone, Domain and templates
6970 cls .domain = get_domain (cls .api_client )
@@ -141,8 +142,6 @@ def setUpClass(cls):
141142
142143 cls .services ["configurableData" ] = {
143144 "host" : {
144- "password" : "password" ,
145- "username" : "root" ,
146145 "port" : 22
147146 },
148147 "input" : "INPUT" ,
@@ -170,6 +169,7 @@ def tearDownClass(cls):
170169
171170 def setUp (self ):
172171 self .apiclient = self .testClient .getApiClient ()
172+ self .hypervisor = self .testClient .getHypervisorInfo ()
173173 return
174174
175175 def test_ssh_command (self , vm , nat_rule , rule_label ):
@@ -181,12 +181,12 @@ def test_ssh_command(self, vm, nat_rule, rule_label):
181181 ssh = vm .get_ssh_client (ipaddress = nat_rule .ipaddress , port = self .services [rule_label ]["publicport" ], retries = 5 )
182182 result = str (ssh .execute (ssh_command ))
183183
184- self .logger .debug ("SSH result: %s; COUNT is ==> %s" % (result , result .count ("3 packets received " )))
184+ self .logger .debug ("SSH result: %s; COUNT is ==> %s" % (result , result .count (" 0% packet loss " )))
185185 except :
186186 self .fail ("Failed to SSH into VM - %s" % (nat_rule .ipaddress ))
187187
188188 self .assertEqual (
189- result .count ("3 packets received " ),
189+ result .count (" 0% packet loss " ),
190190 1 ,
191191 "Ping to outside world from VM should be successful"
192192 )
@@ -202,23 +202,34 @@ def test_password_file_not_empty(self, vm, router):
202202 "Check for list hosts response return valid data" )
203203
204204 host = hosts [0 ]
205- host .user = self .services [ "configurableData" ][ "host" ][ " username" ]
206- host .passwd = self .services [ "configurableData" ][ "host" ][ " password" ]
205+ host .user = self .hostConfig [ ' username' ]
206+ host .passwd = self .hostConfig [ ' password' ]
207207 host .port = self .services ["configurableData" ]["host" ]["port" ]
208-
209- try :
208+
209+ if self . hypervisor . lower () in ( 'vmware' , 'hyperv' ) :
210210 result = get_process_status (
211- host . ipaddress ,
212- host . port ,
213- host .user ,
214- host .passwd ,
211+ self . apiclient . connection . mgtSvr ,
212+ 22 ,
213+ self . apiclient . connection .user ,
214+ self . apiclient . connection .passwd ,
215215 router .linklocalip ,
216- "cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}'" % (vm .nic [0 ].gateway , vm .nic [0 ].ipaddress ))
217- except KeyError :
218- self .skipTest (
219- "Provide a marvin config file with host\
220- credentials to run %s" %
221- self ._testMethodName )
216+ "cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}'" % (vm .nic [0 ].gateway , vm .nic [0 ].ipaddress ),
217+ hypervisor = self .hypervisor
218+ )
219+ else :
220+ try :
221+ result = get_process_status (
222+ host .ipaddress ,
223+ host .port ,
224+ host .user ,
225+ host .passwd ,
226+ router .linklocalip ,
227+ "cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}'" % (vm .nic [0 ].gateway , vm .nic [0 ].ipaddress ))
228+ except KeyError :
229+ self .skipTest (
230+ "Provide a marvin config file with host\
231+ credentials to run %s" %
232+ self ._testMethodName )
222233
223234 self .logger .debug ("cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}' RESULT IS ==> %s" % (vm .nic [0 ].gateway , vm .nic [0 ].ipaddress , result ))
224235 res = str (result )
0 commit comments