Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ED54210E40 for ; Tue, 4 Feb 2014 05:54:11 +0000 (UTC) Received: (qmail 86653 invoked by uid 500); 4 Feb 2014 05:54:11 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 86396 invoked by uid 500); 4 Feb 2014 05:54:00 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 86369 invoked by uid 99); 4 Feb 2014 05:53:59 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Feb 2014 05:53:59 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E27F4314544; Tue, 4 Feb 2014 05:53:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: girish@apache.org To: commits@cloudstack.apache.org Message-Id: <54b83071921f4176af21e7329db7117e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/marvin to a908b8d Date: Tue, 4 Feb 2014 05:53:58 +0000 (UTC) Updated Branches: refs/heads/marvin df58f51e3 -> a908b8d94 CLOUDSTACK-5793: Fixed few issues related CLOUDSTACK-5973 Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a908b8d9 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a908b8d9 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a908b8d9 Branch: refs/heads/marvin Commit: a908b8d94b3af207f4556d7d1271758c38ece3f4 Parents: df58f51 Author: Santhosh Edukulla Authored: Tue Feb 4 11:23:10 2014 +0530 Committer: Girish Shilamkar Committed: Tue Feb 4 11:23:10 2014 +0530 ---------------------------------------------------------------------- .../component/test_add_remove_network.py | 46 ++++++++++---------- tools/marvin/marvin/sshClient.py | 40 +++++++++++++---- 2 files changed, 55 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a908b8d9/test/integration/component/test_add_remove_network.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_add_remove_network.py b/test/integration/component/test_add_remove_network.py index 6eef71e..67ab24a 100644 --- a/test/integration/component/test_add_remove_network.py +++ b/test/integration/component/test_add_remove_network.py @@ -67,7 +67,7 @@ class Services: def __init__(self): self.services = { - + "sleep": 60, "ostype": "CentOS 5.3 (64-bit)", # Cent OS 5.3 (64 bit) @@ -392,8 +392,7 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase): # Trying to add same network to vm for the second time with self.assertRaises(Exception) as e: self.addNetworkToVm(network, self.virtual_machine) - - self.debug("Adding same network again failed with exception: %s" % e.exception) + self.debug("Adding same network again failed with exception: %s" % e.exception) return @@ -515,7 +514,7 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase): with self.assertRaises(Exception) as e: self.addNetworkToVm(self.shared_network, self.virtual_machine, ipaddress = ipaddress) - self.debug("API failed with exception: %s" % e.exception) + self.debug("API failed with exception: %s" % e.exception) return @@ -552,9 +551,7 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase): with self.assertRaises(Exception) as e: self.virtual_machine.add_nic(self.apiclient, network.id) - network.delete(self.apiclient) - - self.debug("Operation failed with exception %s" % e.exception) + self.debug("Operation failed with exception %s" % e.exception) return @@ -606,15 +603,13 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase): domainid=self.child_do_admin_2.domainid, serviceofferingid=self.service_offering.id, mode=self.zone.networktype) + time.sleep(self.services["sleep"]) self.debug("Trying to %s network in domain %s to a vm in domain %s, This should fail" % (network.type, self.child_domain_1.name, self.child_domain_2.name)) with self.assertRaises(Exception) as e: virtual_machine.add_nic(self.apiclient, network.id) - self.debug("Operation failed with exception %s" % e.exception) - - network.delete(self.apiclient) - + self.debug("Operation failed with exception %s" % e.exception) return @attr(tags = ["advanced"]) @@ -686,7 +681,7 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase): with self.assertRaises(Exception) as e: virtual_machine.add_nic(self.apiclient, network_2.id) - self.debug("Operation failed with exception %s" % e.exception) + self.debug("Operation failed with exception %s" % e.exception) return @@ -836,7 +831,7 @@ class TestRemoveNetworkFromVirtualMachine(cloudstackTestCase): self.virtual_machine.id) with self.assertRaises(Exception): self.virtual_machine.remove_nic(self.apiclient, vm_list[0].nic[0].id) - self.debug("Removing default nic of vm failed") + self.debug("Removing default nic of vm failed") return @attr(tags = ["advanced"]) @@ -867,7 +862,7 @@ class TestRemoveNetworkFromVirtualMachine(cloudstackTestCase): operation should fail") with self.assertRaises(Exception) as e: self.virtual_machine.remove_nic(self.apiclient, virtual_machine.nic[0].id) - self.debug("Operation failed with exception: %s" % e.exception) + self.debug("Operation failed with exception: %s" % e.exception) return class TestUpdateVirtualMachineNIC(cloudstackTestCase): @@ -1045,7 +1040,7 @@ class TestUpdateVirtualMachineNIC(cloudstackTestCase): self.debug("Trying to set default nic again as default nic, This should fail") with self.assertRaises(Exception) as e: self.virtual_machine.update_default_nic(self.apiclient, nicId = defaultNicId) - self.debug("updateDefaultNic operation failed as expected with exception: %s" % + self.debug("updateDefaultNic operation failed as expected with exception: %s" % e.exception) return @@ -1070,15 +1065,16 @@ class TestUpdateVirtualMachineNIC(cloudstackTestCase): virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"], accountid=account.name,domainid=account.domainid, serviceofferingid=self.service_offering.id,mode=self.zone.networktype) + time.sleep(self.services["sleep"]) self.debug("Deployed virtual machine: %s" % virtual_machine.id) - + foreignNicId = virtual_machine.nic[0].id self.debug("Trying to set nic of new virtual machine as default nic of existing virtual machine, This \ operation should fail") with self.assertRaises(Exception) as e: self.virtual_machine.update_default_nic(self.apiclient, nicId = foreignNicId) - self.debug("updateDefaultNic operation failed as expected with exception: %s" % + self.debug("updateDefaultNic operation failed as expected with exception: %s" % e.exception) return @@ -1224,6 +1220,7 @@ class TestFailureScenariosAddNetworkToVM(cloudstackTestCase): cmd.networkid = isolated_network.id with self.assertRaises(Exception) as e: + time.sleep(5) self.apiclient.addNicToVirtualMachine(cmd) self.debug("addNicToVirtualMachine API failed with exception: %s" % e.exception) @@ -1265,6 +1262,7 @@ class TestFailureScenariosAddNetworkToVM(cloudstackTestCase): virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"], serviceofferingid=self.service_offering.id, mode=basicZone.networktype) + time.sleep(self.services["sleep"]) self.debug("Deployed virtual machine %s: " % virtual_machine.id) cmd = addNicToVirtualMachine.addNicToVirtualMachineCmd() @@ -1274,6 +1272,7 @@ class TestFailureScenariosAddNetworkToVM(cloudstackTestCase): self.dedbug("Trying to add isolated network to VM (both in basic zone,\ this operation should fail") with self.assertRaises(Exception) as e: + time.sleep(5) self.apiclient.addNicToVirtualMachine(cmd) self.debug("addNicToVirtualMachine API failed with exception: %s" % e.exception) @@ -1306,6 +1305,7 @@ class TestFailureScenariosAddNetworkToVM(cloudstackTestCase): insufficient permission") with self.assertRaises(Exception) as e: + time.sleep(5) api_client.addNicToVirtualMachine(cmd) self.debug("addNicToVirtualMachine API failed with exception: %s" % e.exception) @@ -1372,7 +1372,7 @@ class TestFailureScenariosRemoveNicFromVM(cloudstackTestCase): def tearDownClass(cls): try: # Disable Network Offerings - #cls.isolated_network_offering.update(cls.api_client, state='Disabled') + cls.isolated_network_offering.update(cls.api_client, state='Disabled') # Cleanup resources used cleanup_resources(cls.api_client, cls._cleanup) @@ -1601,7 +1601,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase): with self.assertRaises(Exception) as e: self.apiclient.updateDefaultNicForVirtualMachine(cmd) - self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" % + self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" % e.exception) return @@ -1647,7 +1647,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase): with self.assertRaises(Exception) as e: self.apiclient.updateDefaultNicForVirtualMachine(cmd) - self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" % + self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" % e.exception) return @@ -1676,7 +1676,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase): accountid=account.name,domainid=account.domainid, serviceofferingid=self.service_offering.id, mode=self.zone.networktype) - + time.sleep(self.services["sleep"]) self.debug("Created virtual machine %s" % virtual_machine.id) self.debug("Creating isolated network in account %s" % account.name) @@ -1729,7 +1729,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase): with self.assertRaises(Exception) as e: self.apiclient.updateDefaultNicForVirtualMachine(cmd) - self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" % + self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" % e.exception) return @@ -1779,7 +1779,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase): with self.assertRaises(Exception) as e: api_client.updateDefaultNicForVirtualMachine(cmd) - self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" % + self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" % e.exception) return http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a908b8d9/tools/marvin/marvin/sshClient.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/sshClient.py b/tools/marvin/marvin/sshClient.py index 588c978..09dc6f3 100644 --- a/tools/marvin/marvin/sshClient.py +++ b/tools/marvin/marvin/sshClient.py @@ -16,6 +16,14 @@ # under the License. import paramiko +from paramiko import (BadHostKeyException, + AuthenticationException, + SSHException, + SSHClient, + AutoAddPolicy, + Transport, + SFTPClient) +import socket import time from cloudstackException import ( internalError, @@ -40,8 +48,8 @@ class SshClient(object): self.user = user self.passwd = passwd self.keyPairFiles = keyPairFiles - self.ssh = paramiko.SSHClient() - self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + self.ssh = SSHClient() + self.ssh.set_missing_host_key_policy(AutoAddPolicy()) self.logger = logging.getLogger('sshClient') self.retryCnt = 0 self.delay = 0 @@ -60,7 +68,7 @@ class SshClient(object): self.delay = delay if timeout is not None and timeout > 0: self.timeout = timeout - if port is not None or port >= 0: + if port is not None and port >= 0: self.port = port if self.createConnection() == FAIL: raise internalError("Connection Failed") @@ -91,6 +99,7 @@ class SshClient(object): FAIL If connection through ssh failed ''' ret = FAIL + except_msg = '' while self.retryCnt >= 0: try: self.logger.debug("SSH Connection: Host:%s User:%s\ @@ -114,7 +123,20 @@ class SshClient(object): ) ret = SUCCESS break - except Exception as se: + except BadHostKeyException, e: + except_msg = GetDetailExceptionInfo(e) + except AuthenticationException, e: + except_msg = GetDetailExceptionInfo(e) + except SSHException, e: + except_msg = GetDetailExceptionInfo(e) + except socket.error, e: + except_msg = GetDetailExceptionInfo(e) + except Exception, e: + except_msg = GetDetailExceptionInfo(e) + finally: + self.logger.exception("SshClient: " + "Exception under createConnection: %s" + % except_msg) self.retryCnt = self.retryCnt - 1 if self.retryCnt == 0: break @@ -156,15 +178,17 @@ class SshClient(object): except Exception as e: ret["status"] = EXCEPTION_OCCURRED ret["stderr"] = GetDetailExceptionInfo(e) + self.logger.exception("SshClient: Exception under runCommand :%s" % + GetDetailExceptionInfo(e)) finally: - self.logger.debug(" Host: %s Cmd: %s Output:%s Exception: %s" % - (self.host, command, str(ret), ret["stderr"])) + self.logger.debug(" Host: %s Cmd: %s Output:%s" % + (self.host, command, str(ret))) return ret def scp(self, srcFile, destPath): - transport = paramiko.Transport((self.host, int(self.port))) + transport = Transport((self.host, int(self.port))) transport.connect(username=self.user, password=self.passwd) - sftp = paramiko.SFTPClient.from_transport(transport) + sftp = SFTPClient.from_transport(transport) try: sftp.put(srcFile, destPath) except IOError, e: