Skip to content

Commit dc93268

Browse files
committed
CLOUDSTACK-9524: Check router hypervisor before ssh to VR
SSH to VR for vmware, goes via the mgmt server and uses ssh keys at /var/cloudstack path. Add suitable checks to tests failing on vmware. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 1f27874 commit dc93268

4 files changed

Lines changed: 127 additions & 61 deletions

File tree

test/integration/smoke/test_password_server.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def tearDownClass(cls):
169169

170170
def setUp(self):
171171
self.apiclient = self.testClient.getApiClient()
172+
self.hypervisor = self.testClient.getHypervisorInfo()
172173
return
173174

174175
def test_ssh_command(self, vm, nat_rule, rule_label):
@@ -204,20 +205,31 @@ def test_password_file_not_empty(self, vm, router):
204205
host.user = self.hostConfig['username']
205206
host.passwd = self.hostConfig['password']
206207
host.port = self.services["configurableData"]["host"]["port"]
207-
208-
try:
208+
209+
if self.hypervisor.lower() in ('vmware', 'hyperv'):
209210
result = get_process_status(
210-
host.ipaddress,
211-
host.port,
212-
host.user,
213-
host.passwd,
211+
self.apiclient.connection.mgtSvr,
212+
22,
213+
self.apiclient.connection.user,
214+
self.apiclient.connection.passwd,
214215
router.linklocalip,
215-
"cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}'" % (vm.nic[0].gateway, vm.nic[0].ipaddress))
216-
except KeyError:
217-
self.skipTest(
218-
"Provide a marvin config file with host\
219-
credentials to run %s" %
220-
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)
221233

222234
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))
223235
res = str(result)

test/integration/smoke/test_privategw_acl.py

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -750,24 +750,43 @@ def check_private_gateway_interfaces(self, status_to_check = "UP"):
750750
host.passwd = self.hostConfig['password']
751751
host.port = self.services["configurableData"]["host"]["port"]
752752

753-
try:
753+
if self.hypervisor.lower() in ('vmware', 'hyperv'):
754754
state = get_process_status(
755-
host.ipaddress,
756-
host.port,
757-
host.user,
758-
host.passwd,
759-
router.linklocalip,
760-
"ip addr | grep eth6 | grep state | awk '{print $9;}'")
755+
self.apiclient.connection.mgtSvr,
756+
22,
757+
self.apiclient.connection.user,
758+
self.apiclient.connection.passwd,
759+
router.linklocalip,
760+
"ip addr | grep eth6 | grep state | awk '{print $9;}'",
761+
hypervisor=self.hypervisor)
761762

762763
mac = get_process_status(
763-
host.ipaddress,
764-
host.port,
765-
host.user,
766-
host.passwd,
767-
router.linklocalip,
768-
"ip addr | grep link/ether | awk '{print $2;}' | sed -n 7p")
769-
except KeyError:
770-
self.skipTest("Provide a marvin config file with host credentials to run %s" % self._testMethodName)
764+
self.apiclient.connection.mgtSvr,
765+
22,
766+
self.apiclient.connection.user,
767+
self.apiclient.connection.passwd,
768+
router.linklocalip,
769+
"ip addr | grep link/ether | awk '{print $2;}' | sed -n 7p",
770+
hypervisor=self.hypervisor)
771+
else:
772+
try:
773+
state = get_process_status(
774+
host.ipaddress,
775+
host.port,
776+
host.user,
777+
host.passwd,
778+
router.linklocalip,
779+
"ip addr | grep eth6 | grep state | awk '{print $9;}'")
780+
781+
mac = get_process_status(
782+
host.ipaddress,
783+
host.port,
784+
host.user,
785+
host.passwd,
786+
router.linklocalip,
787+
"ip addr | grep link/ether | awk '{print $2;}' | sed -n 7p")
788+
except KeyError:
789+
self.skipTest("Provide a marvin config file with host credentials to run %s" % self._testMethodName)
771790

772791
state = str(state[0])
773792
mac = str(mac[0])

test/integration/smoke/test_router_dhcphosts.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def tearDownClass(cls):
169169

170170
def setUp(self):
171171
self.apiclient = self.testClient.getApiClient()
172+
self.hypervisor = self.testClient.getHypervisorInfo()
172173
self.cleanup = []
173174
return
174175

@@ -212,20 +213,30 @@ def test_dhcphosts(self, vm, router):
212213
host.user = self.hostConfig['username']
213214
host.passwd = self.hostConfig['password']
214215
host.port = self.services["configurableData"]["host"]["port"]
215-
#mac1,10.7.32.101,infinite
216-
try:
216+
217+
if self.hypervisor.lower() in ('vmware', 'hyperv'):
217218
result = get_process_status(
218-
host.ipaddress,
219-
host.port,
220-
host.user,
221-
host.passwd,
219+
self.apiclient.connection.mgtSvr,
220+
22,
221+
self.apiclient.connection.user,
222+
self.apiclient.connection.passwd,
222223
router.linklocalip,
223-
"cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}'" % (vm.nic[0].ipaddress))
224-
except KeyError:
225-
self.skipTest(
226-
"Provide a marvin config file with host\
227-
credentials to run %s" %
228-
self._testMethodName)
224+
"cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}'" % (vm.nic[0].ipaddress),
225+
hypervisor=self.hypervisor)
226+
else:
227+
try:
228+
result = get_process_status(
229+
host.ipaddress,
230+
host.port,
231+
host.user,
232+
host.passwd,
233+
router.linklocalip,
234+
"cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}'" % (vm.nic[0].ipaddress))
235+
except KeyError:
236+
self.skipTest(
237+
"Provide a marvin config file with host\
238+
credentials to run %s" %
239+
self._testMethodName)
229240

230241
self.logger.debug("cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}' RESULT IS ==> %s" % (vm.nic[0].ipaddress, result))
231242
res = str(result)

test/integration/smoke/test_routers_iptables_default_policy.py

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def tearDownClass(cls):
253253
return
254254

255255
def setUp(self):
256+
self.hypervisor = self.testClient.getHypervisorInfo()
256257
self.logger.debug("Creating a VPC offering.")
257258
self.vpc_off = VpcOffering.create(
258259
self.apiclient,
@@ -317,19 +318,30 @@ def test_01_single_VPC_iptables_policies(self):
317318
tables = [self.services["configurableData"]["input"], self.services["configurableData"]["forward"]]
318319

319320
for table in tables:
320-
try:
321+
result = None
322+
if self.hypervisor.lower() in ('vmware', 'hyperv'):
321323
result = get_process_status(
322-
host.ipaddress,
323-
host.port,
324-
host.user,
325-
host.passwd,
324+
self.apiclient.connection.mgtSvr,
325+
22,
326+
self.apiclient.connection.user,
327+
self.apiclient.connection.passwd,
326328
router.linklocalip,
327-
'iptables -L %s' % table)
328-
except KeyError:
329-
self.skipTest(
330-
"Provide a marvin config file with host\
331-
credentials to run %s" %
332-
self._testMethodName)
329+
'iptables -L %s' % table,
330+
hypervisor=self.hypervisor)
331+
else:
332+
try:
333+
result = get_process_status(
334+
host.ipaddress,
335+
host.port,
336+
host.user,
337+
host.passwd,
338+
router.linklocalip,
339+
'iptables -L %s' % table)
340+
except KeyError:
341+
self.skipTest(
342+
"Provide a marvin config file with host\
343+
credentials to run %s" %
344+
self._testMethodName)
333345

334346
self.logger.debug("iptables -L %s: %s" % (table, result))
335347
res = str(result)
@@ -392,6 +404,7 @@ def tearDownClass(cls):
392404
return
393405

394406
def setUp(self):
407+
self.hypervisor = self.testClient.getHypervisorInfo()
395408
self.cleanup = []
396409
self.entity_manager.set_cleanup(self.cleanup)
397410
return
@@ -434,19 +447,30 @@ def test_02_routervm_iptables_policies(self):
434447
tables = [self.services["configurableData"]["input"], self.services["configurableData"]["forward"]]
435448

436449
for table in tables:
437-
try:
450+
result = None
451+
if self.hypervisor.lower() in ('vmware', 'hyperv'):
438452
result = get_process_status(
439-
host.ipaddress,
440-
host.port,
441-
host.user,
442-
host.passwd,
453+
self.apiclient.connection.mgtSvr,
454+
22,
455+
self.apiclient.connection.user,
456+
self.apiclient.connection.passwd,
443457
router.linklocalip,
444-
'iptables -L %s' % table)
445-
except KeyError:
446-
self.skipTest(
447-
"Provide a marvin config file with host\
448-
credentials to run %s" %
449-
self._testMethodName)
458+
'iptables -L %s' % table,
459+
hypervisor=self.hypervisor)
460+
else:
461+
try:
462+
result = get_process_status(
463+
host.ipaddress,
464+
host.port,
465+
host.user,
466+
host.passwd,
467+
router.linklocalip,
468+
'iptables -L %s' % table)
469+
except KeyError:
470+
self.skipTest(
471+
"Provide a marvin config file with host\
472+
credentials to run %s" %
473+
self._testMethodName)
450474

451475
self.logger.debug("iptables -L %s: %s" % (table, result))
452476
res = str(result)

0 commit comments

Comments
 (0)