cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [30/76] [abbrv] Revert "CLOUSTACK-5099: Utils.py-has-wrong-reference, cleaned it. As well added Uniform naming convention"
Date Fri, 08 Nov 2013 18:08:46 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/65b12f45/tools/marvin/build/lib/marvin/settings.py
----------------------------------------------------------------------
diff --git a/tools/marvin/build/lib/marvin/settings.py b/tools/marvin/build/lib/marvin/settings.py
deleted file mode 100644
index a31e182..0000000
--- a/tools/marvin/build/lib/marvin/settings.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Settings for the XML test runner
-
-# Use this setting to choose between a verbose and a non-verbose output.
-TEST_OUTPUT_VERBOSE = 2.
-
-# If your test methods contains docstrings, you can display such docstrings
-# instead of display the test name (ex: module.TestCase.test_method).
-# In order to use this feature, you have to enable verbose output by setting
-# TEST_OUTPUT_VERBOSE = 2.
-
-TEST_OUTPUT_DESCRIPTIONS = True

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/65b12f45/tools/marvin/build/lib/marvin/testSetupSuccess.py
----------------------------------------------------------------------
diff --git a/tools/marvin/build/lib/marvin/testSetupSuccess.py b/tools/marvin/build/lib/marvin/testSetupSuccess.py
deleted file mode 100644
index 1701626..0000000
--- a/tools/marvin/build/lib/marvin/testSetupSuccess.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import marvin
-import unittest
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from time import sleep as delay
-
-
-class TestSetupSuccess(cloudstackTestCase):
-    """
-    Test to verify if the cloudstack is ready to launch tests upon
-    1. Verify that system VMs are up and running in all zones
-    2. Verify that built-in templates are Ready in all zones
-    """
-    @classmethod
-    def setUpClass(cls):
-        testClient = super(TestSetupSuccess, cls).getClsTestClient()
-        cls.apiClient = testClient.getApiClient()
-
-        zones = listZones.listZonesCmd()
-        cls.zones_list = cls.apiClient.listZones(zones)
-        cls.retry = 2
-
-    def test_systemVmReady(self):
-        """
-        system VMs need to be ready and Running for each zone in cloudstack
-        """
-        for z in self.zones_list:
-            retry = self.retry
-            while retry != 0:
-                self.debug("looking for system VMs in zone: %s, %s" %
-                           (z.id, z.name))
-                sysvms = listSystemVms.listSystemVmsCmd()
-                sysvms.zoneid = z.id
-                sysvms.state = 'Running'
-                sysvms_list = self.apiClient.listSystemVms(sysvms)
-                if sysvms_list is not None and len(sysvms_list) == 2:
-                    assert len(sysvms_list) == 2
-                    self.debug("found %d system VMs running {%s}" %
-                               (len(sysvms_list), sysvms_list))
-                    break
-                retry = retry - 1
-                delay(60)  # wait a minute for retry
-            self.assertNotEqual(retry, 0,
-                                "system VMs not Running in zone %s" %
-                                z.name)
-
-    def test_templateBuiltInReady(self):
-        """
-        built-in templates CentOS to be ready
-        """
-        for z in self.zones_list:
-            retry = self.retry
-            while retry != 0:
-                self.debug("Looking for at least one ready builtin template")
-                templates = listTemplates.listTemplatesCmd()
-                templates.templatefilter = 'featured'
-                templates.listall = 'true'
-                templates_list = self.apiClient.listTemplates(templates)
-                if templates_list is not None:
-                    builtins = [tmpl
-                                for tmpl in templates_list
-                                if tmpl.templatetype == 'BUILTIN'
-                                and tmpl.isready]
-                    if len(builtins) > 0:
-                        self.debug("Found %d builtins ready for use %s" %
-                                   (len(builtins), builtins))
-                        break
-                retry = retry - 1
-                delay(60)  # wait a minute for retry
-            self.assertNotEqual(retry, 0,
-                                "builtIn templates not ready in zone %s" %
-                                z.name)
-
-    def test_deployVmWithBuiltIn(self):
-        """
-        Deploys a VM with the built-in CentOS template
-        """
-
-    @classmethod
-    def tearDownClass(cls):
-        pass

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/65b12f45/tools/marvin/marvin/integration/lib/utils.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/utils.py b/tools/marvin/marvin/integration/lib/utils.py
index d2bfb8f..58a9bf9 100644
--- a/tools/marvin/marvin/integration/lib/utils.py
+++ b/tools/marvin/marvin/integration/lib/utils.py
@@ -118,7 +118,7 @@ def is_server_ssh_ready(ipaddress, port, username, password, retries=20,
retryin
     @Name: is_server_ssh_ready
     @Input: timeout: tcp connection timeout flag,
             others information need to be added
-    @Output:object for SshClient    
+    @Output:object for remoteSSHClient
     Name of the function is little misnomer and is not
               verifying anything as such mentioned
     '''
@@ -129,12 +129,12 @@ def is_server_ssh_ready(ipaddress, port, username, password, retries=20,
retryin
             port=port,
             user=username,
             passwd=password,
-            keyPairFiles=keyPairFileLocation,
+            keyPairFileLocation=keyPairFileLocation,
             retries=retries,
             delay=retryinterv,
             timeout=timeout)
     except Exception, e:
-        raise Exception("SSH connection has Failed. Waited %ss. Error is %s" % (retries *
retryinterv, str(e)))
+        raise Exception("SSH connection has Failed. Waited %ss. Error is %s" % (retries *
retryinterv, e))
     else:
         return ssh
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/65b12f45/tools/marvin/marvin/integration/lib/utils.py.rej
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/utils.py.rej b/tools/marvin/marvin/integration/lib/utils.py.rej
deleted file mode 100644
index acae528..0000000
--- a/tools/marvin/marvin/integration/lib/utils.py.rej
+++ /dev/null
@@ -1,10 +0,0 @@
-diff a/tools/marvin/marvin/integration/lib/utils.py b/tools/marvin/marvin/integration/lib/utils.py
(rejected hunks)
-@@ -118,7 +118,7 @@ def is_server_ssh_ready(ipaddress, port, username, password, retries=20,
retryin
-     @Name: is_server_ssh_ready
-     @Input: timeout: tcp connection timeout flag,
-             others information need to be added
--    @Output:object for remoteSSHClient
-+    @Output:object for SshClient
-     Name of the function is little misnomer and is not 
-               verifying anything as such mentioned
-     '''

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/65b12f45/tools/marvin/marvin/remoteSSHClient.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/remoteSSHClient.py b/tools/marvin/marvin/remoteSSHClient.py
new file mode 100644
index 0000000..c9720e3
--- /dev/null
+++ b/tools/marvin/marvin/remoteSSHClient.py
@@ -0,0 +1,182 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import paramiko
+import time
+import cloudstackException
+import contextlib
+import logging
+from marvin.codes import (
+    SUCCESS, FAIL, INVALID_INPUT, EXCEPTION_OCCURRED
+    )
+from contextlib import closing
+
+
+class remoteSSHClient(object):
+    '''
+    Added timeout flag for ssh connect calls.Default to 3.0 seconds
+    '''
+    def __init__(self, host, port, user, passwd, retries=20, delay=30,
+                 log_lvl=logging.INFO, keyPairFiles=None, timeout=10.0):
+        self.host = None
+        self.port = 22
+        self.user = user
+        self.passwd = passwd
+        self.keyPairFiles = keyPairFiles
+        self.ssh = paramiko.SSHClient()
+        self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+        self.logger = logging.getLogger('sshClient')
+        self.retryCnt = 0
+        self.delay = 0
+        self.timeout = 3.0
+        ch = logging.StreamHandler()
+        ch.setLevel(log_lvl)
+        self.logger.addHandler(ch)
+
+        #Check invalid host value and raise exception
+        #Atleast host is required for connection
+        if host is not None and host != '':
+            self.host = host
+        if retries is not None and retries > 0:
+            self.retryCnt = retries
+        if delay is not None and delay > 0:
+            self.delay = delay
+        if timeout is not None and timeout > 0:
+            self.timeout = timeout
+        if port is not None or port >= 0:
+            self.port = port
+        if self.createConnection() == FAIL:
+            raise cloudstackException.\
+                internalError("Connection Failed")
+
+    def execute(self, command):
+        stdin, stdout, stderr = self.ssh.exec_command(command)
+        output = stdout.readlines()
+        errors = stderr.readlines()
+        results = []
+        if output is not None and len(output) == 0:
+            if errors is not None and len(errors) > 0:
+                for error in errors:
+                    results.append(error.rstrip())
+
+        else:
+            for strOut in output:
+                results.append(strOut.rstrip())
+        self.logger.debug("{Cmd: %s via Host: %s} {returns: %s}" %
+                          (command, str(self.host), results))
+        return results
+
+    def createConnection(self):
+        '''
+        @Name: createConnection
+        @Desc: Creates an ssh connection for
+               retries mentioned,along with sleep mentioned
+        @Output: SUCCESS on successful connection
+                 FAIL If connection through ssh failed
+        '''
+        ret = FAIL
+        while self.retryCnt >= 0:
+            try:
+                self.logger.debug("SSH Connection: Host:%s User:%s\
+                                   Port:%s KeyPairFile: %s" %
+                                  (self.host, self.user, str(self.port),
+                                   str(self.keyPairFiles)))
+                if self.keyPairFiles is None:
+                    self.ssh.connect(hostname=self.host,
+                                     port=self.port,
+                                     username=self.user,
+                                     password=self.passwd,
+                                     timeout=self.timeout)
+                else:
+                    self.ssh.connect(hostname=self.host,
+                                     port=self.port,
+                                     username=self.user,
+                                     password=self.passwd,
+                                     key_filename=self.keyPairFiles,
+                                     timeout=self.timeout,
+                                     look_for_keys=False
+                                     )
+                ret = SUCCESS
+                break
+            except Exception as se:
+                self.retryCnt = self.retryCnt - 1
+                if self.retryCnt == 0:
+                    break
+                time.sleep(self.delay)
+        return ret
+
+    def runCommand(self, command):
+        '''
+        @Name: runCommand
+        @Desc: Runs a command over ssh and
+               returns the result along with status code
+        @Input: command to execute
+        @Output: 1: status of command executed.
+                 Default to None
+                 SUCCESS : If command execution is successful
+                 FAIL    : If command execution has failed
+                 EXCEPTION_OCCURRED: Exception occurred while executing
+                                     command
+                 INVALID_INPUT : If invalid value for command is passed
+                 2: stdin,stdout,stderr values of command output
+        '''
+        excep_msg = ''
+        ret = {"status": None, "stdin": None, "stdout": None, "stderr": None}
+        if command is None or command == '':
+            ret["status"] = INVALID_INPUT
+            return ret
+        try:
+            status_check = 1
+            stdin, stdout, stderr = self.ssh.exec_command(command)
+            output = stdout.readlines()
+            errors = stderr.readlines()
+            inp = stdin.readlines()
+            ret["stdin"] = inp
+            ret["stdout"] = output
+            ret["stderr"] = errors
+            if stdout is not None:
+                status_check = stdout.channel.recv_exit_status()
+            if status_check == 0:
+                ret["status"] = SUCCESS
+            else:
+                ret["status"] = FAIL
+        except Exception as e:
+            excep_msg = str(e)
+            ret["status"] = EXCEPTION_OCCURRED
+        finally:
+            self.logger.debug(" Host: %s Cmd: %s Output:%s Exception: %s" %
+                              (self.host, command, str(ret), excep_msg))
+            return ret
+
+    def scp(self, srcFile, destPath):
+        transport = paramiko.Transport((self.host, int(self.port)))
+        transport.connect(username=self.user, password=self.passwd)
+        sftp = paramiko.SFTPClient.from_transport(transport)
+        try:
+            sftp.put(srcFile, destPath)
+        except IOError, e:
+            raise e
+
+    def close(self):
+            if self.ssh is not None:
+                self.ssh.close()
+
+
+if __name__ == "__main__":
+    with contextlib.closing(remoteSSHClient("10.223.75.10", 22, "root",
+                                            "password")) as ssh:
+        print ssh.execute("ls -l")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/65b12f45/tools/marvin/marvin/sshClient.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/sshClient.py b/tools/marvin/marvin/sshClient.py
deleted file mode 100644
index 58f2602..0000000
--- a/tools/marvin/marvin/sshClient.py
+++ /dev/null
@@ -1,182 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import paramiko
-import time
-import cloudstackException
-import contextlib
-import logging
-from marvin.codes import (
-    SUCCESS, FAIL, INVALID_INPUT, EXCEPTION_OCCURRED
-    )
-from contextlib import closing
-
-
-class SshClient(object):
-    '''
-    Added timeout flag for ssh connect calls.Default to 3.0 seconds
-    '''
-    def __init__(self, host, port, user, passwd, retries=20, delay=30,
-                 log_lvl=logging.INFO, keyPairFiles=None, timeout=10.0):
-        self.host = None
-        self.port = 22
-        self.user = user
-        self.passwd = passwd
-        self.keyPairFiles = keyPairFiles
-        self.ssh = paramiko.SSHClient()
-        self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
-        self.logger = logging.getLogger('sshClient')
-        self.retryCnt = 0
-        self.delay = 0
-        self.timeout = 3.0
-        ch = logging.StreamHandler()
-        ch.setLevel(log_lvl)
-        self.logger.addHandler(ch)
-
-        #Check invalid host value and raise exception
-        #Atleast host is required for connection
-        if host is not None and host != '':
-            self.host = host
-        if retries is not None and retries > 0:
-            self.retryCnt = retries
-        if delay is not None and delay > 0:
-            self.delay = delay
-        if timeout is not None and timeout > 0:
-            self.timeout = timeout
-        if port is not None or port >= 0:
-            self.port = port
-        if self.createConnection() == FAIL:
-            raise cloudstackException.\
-                internalError("Connection Failed")
-
-    def execute(self, command):
-        stdin, stdout, stderr = self.ssh.exec_command(command)
-        output = stdout.readlines()
-        errors = stderr.readlines()
-        results = []
-        if output is not None and len(output) == 0:
-            if errors is not None and len(errors) > 0:
-                for error in errors:
-                    results.append(error.rstrip())
-
-        else:
-            for strOut in output:
-                results.append(strOut.rstrip())
-        self.logger.debug("{Cmd: %s via Host: %s} {returns: %s}" %
-                          (command, str(self.host), results))
-        return results
-
-    def createConnection(self):
-        '''
-        @Name: createConnection
-        @Desc: Creates an ssh connection for
-               retries mentioned,along with sleep mentioned
-        @Output: SUCCESS on successful connection
-                 FAIL If connection through ssh failed
-        '''
-        ret = FAIL
-        while self.retryCnt >= 0:
-            try:
-                self.logger.debug("SSH Connection: Host:%s User:%s\
-                                   Port:%s" %
-                                  (self.host, self.user, str(self.port)
-                                   ))
-                if self.keyPairFiles is None:
-                    self.ssh.connect(hostname=self.host,
-                                     port=self.port,
-                                     username=self.user,
-                                     password=self.passwd,
-                                     timeout=self.timeout)
-                else:
-                    self.ssh.connect(hostname=self.host,
-                                     port=self.port,
-                                     username=self.user,
-                                     password=self.passwd,
-                                     key_filename=self.keyPairFiles,
-                                     timeout=self.timeout,
-                                     look_for_keys=False
-                                     )
-                ret = SUCCESS
-                break
-            except Exception as se:
-                self.retryCnt = self.retryCnt - 1
-                if self.retryCnt == 0:
-                    break
-                time.sleep(self.delay)
-        return ret
-
-    def runCommand(self, command):
-        '''
-        @Name: runCommand
-        @Desc: Runs a command over ssh and
-               returns the result along with status code
-        @Input: command to execute
-        @Output: 1: status of command executed.
-                 Default to None
-                 SUCCESS : If command execution is successful
-                 FAIL    : If command execution has failed
-                 EXCEPTION_OCCURRED: Exception occurred while executing
-                                     command
-                 INVALID_INPUT : If invalid value for command is passed
-                 2: stdin,stdout,stderr values of command output
-        '''
-        excep_msg = ''
-        ret = {"status": None, "stdin": None, "stdout": None, "stderr": None}
-        if command is None or command == '':
-            ret["status"] = INVALID_INPUT
-            return ret
-        try:
-            status_check = 1
-            stdin, stdout, stderr = self.ssh.exec_command(command)
-            output = stdout.readlines()
-            errors = stderr.readlines()
-            inp = stdin.readlines()
-            ret["stdin"] = inp
-            ret["stdout"] = output
-            ret["stderr"] = errors
-            if stdout is not None:
-                status_check = stdout.channel.recv_exit_status()
-            if status_check == 0:
-                ret["status"] = SUCCESS
-            else:
-                ret["status"] = FAIL
-        except Exception as e:
-            excep_msg = str(e)
-            ret["status"] = EXCEPTION_OCCURRED
-        finally:
-            self.logger.debug(" Host: %s Cmd: %s Output:%s Exception: %s" %
-                              (self.host, command, str(ret), excep_msg))
-            return ret
-
-    def scp(self, srcFile, destPath):
-        transport = paramiko.Transport((self.host, int(self.port)))
-        transport.connect(username=self.user, password=self.passwd)
-        sftp = paramiko.SFTPClient.from_transport(transport)
-        try:
-            sftp.put(srcFile, destPath)
-        except IOError, e:
-            raise e
-
-    def close(self):
-            if self.ssh is not None:
-                self.ssh.close()
-
-
-if __name__ == "__main__":
-    with contextlib.closing(SshClient("10.223.75.10", 22, "root",
-                                            "password")) as ssh:
-        print ssh.execute("ls -l")


Mime
View raw message