当前位置: 首页>>代码示例>>Python>>正文


Python SshClient.execute方法代码示例

本文整理汇总了Python中marvin.sshClient.SshClient.execute方法的典型用法代码示例。如果您正苦于以下问题:Python SshClient.execute方法的具体用法?Python SshClient.execute怎么用?Python SshClient.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marvin.sshClient.SshClient的用法示例。


在下文中一共展示了SshClient.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: download_systemplates_sec_storage

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
def download_systemplates_sec_storage(server, services):
    """Download System templates on sec storage"""

    try:
        # Login to management server
        ssh = SshClient(server["ipaddress"], server["port"], server["username"], server["password"])
    except Exception:
        raise Exception("SSH access failed for server with IP address: %s" % server["ipaddess"])
    # Mount Secondary Storage on Management Server
    cmds = [
        "mkdir -p %s" % services["mnt_dir"],
        "mount -t nfs %s:/%s %s" % (services["sec_storage"], services["path"], services["mnt_dir"]),
        "%s -m %s -u %s -h %s -F"
        % (services["command"], services["mnt_dir"], services["download_url"], services["hypervisor"]),
    ]
    for c in cmds:
        result = ssh.execute(c)

    res = str(result)

    # Unmount the Secondary storage
    ssh.execute("umount %s" % (services["mnt_dir"]))

    if res.count("Successfully installed system VM template") == 1:
        return
    else:
        raise Exception("Failed to download System Templates on Sec Storage")
    return
开发者ID:rafaelthedevops,项目名称:cloudstack,代码行数:30,代码来源:common.py

示例2: RestartServers

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
 def RestartServers(self):
     """ Restart management
     server and usage server """
     sshClient = SshClient(
         self.mgtSvrDetails["mgtSvrIp"], 22, self.mgtSvrDetails["user"], self.mgtSvrDetails["passwd"]
     )
     command = "service cloudstack-management restart"
     sshClient.execute(command)
     return
开发者ID:bheuvel,项目名称:cloudstack,代码行数:11,代码来源:test_vpc.py

示例3: restartUsageServer

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
def restartUsageServer(self):
    #Restart usage server

    sshClient = SshClient(
        self.mgtSvrDetails["mgtSvrIp"],
        22,
        self.mgtSvrDetails["user"],
        self.mgtSvrDetails["passwd"]
    )
    command = "service cloudstack-usage restart"
    sshClient.execute(command)
    return
开发者ID:PCextreme,项目名称:cloudstack,代码行数:14,代码来源:test_ss_volume_usage.py

示例4: RestartServer

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
    def RestartServer(cls):
        """Restart management server"""

        sshClient = SshClient(
                cls.mgtSvrDetails["mgtSvrIp"],
                22,
                cls.mgtSvrDetails["user"],
                cls.mgtSvrDetails["passwd"]
                )
        command = "service cloudstack-management restart"
        sshClient.execute(command)

        return
开发者ID:rarotonga82,项目名称:cloudstack,代码行数:15,代码来源:testpath_same_vm_name.py

示例5: setUpClass

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
    def setUpClass(self):
        testClient = super(TestDeployvGPUenabledVM, self).getClsTestClient()
        self.apiclient = testClient.getApiClient()
        self.testdata = self.testClient.getParsedTestDataConfig()
        self._cleanup = []
        self.unsupportedHypervisor = False
        self.noSuitableHost = False
        # Need to add check whether zone containing the xen hypervisor or not
        # as well
        hosts = list_hosts(
            self.apiclient,
            hypervisor="XenServer"
        )
        if hosts is None:
             # GPU feature is supported only on XenServer.Check listhosts response
             self.unsupportedHypervisor = True
             return
        else:
            gpuhosts = 0
            for ghost in hosts:
                if ghost.hypervisorversion >= "6.2.0":
                    sshClient = SshClient(
                        host=ghost.ipaddress,
                        port=self.testdata['configurableData']['host']["publicport"],
                        user=self.testdata['configurableData']['host']["username"],
                        passwd=self.testdata['configurableData']['host']["password"])
                    if ghost.hypervisorversion == "6.2.0":
                        res = sshClient.execute(
                            "xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503")
                        if len(res) == 0:
                            continue
                    res = sshClient.execute(
                        "xe vgpu-type-list model-name=\"GRID K120Q\"")
                    if len(res) != 0:
                        gpuhosts = gpuhosts + 1
                    else:
                        continue
        if gpuhosts == 0:
            # No XenServer available with GPU Drivers installed
            self.noSuitableHost = True
            return

        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        # Creating Account
        self.account = Account.create(
            self.apiclient,
            self.testdata["account"],
            domainid=self.domain.id
        )
        self._cleanup.append(self.account)
开发者ID:nvazquez,项目名称:cloudstack,代码行数:53,代码来源:test_deploy_vgpu_enabled_vm.py

示例6: get_process_status

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
def get_process_status(hostip, port, username, password, linklocalip, process, hypervisor=None):
    """Double hop and returns a process status"""

    #SSH to the machine
    ssh = SshClient(hostip, port, username, password)
    if (str(hypervisor).lower() == 'vmware'
		or str(hypervisor).lower() == 'hyperv'):
        ssh_command = "ssh -i /var/cloudstack/management/.ssh/id_rsa -ostricthostkeychecking=no "
    else:
        ssh_command = "ssh -i ~/.ssh/id_rsa.cloud -ostricthostkeychecking=no "

    ssh_command = ssh_command +\
                  "-oUserKnownHostsFile=/dev/null -p 3922 %s %s" % (
                      linklocalip,
                      process)

    # Double hop into router
    if str(hypervisor).lower() == 'hyperv':
        timeout = 12
    else:
        timeout = 5
    # Ensure the SSH login is successful
    while True:
        res = ssh.execute(ssh_command)
        if "Connection refused".lower() in res[0].lower():
            pass
        elif res[0] != "Host key verification failed.":
            break
        elif timeout == 0:
            break

        time.sleep(5)
        timeout = timeout - 1
    return res
开发者ID:Tosta-Mixta,项目名称:cloudstack,代码行数:36,代码来源:utils.py

示例7: test_es_1236_cloudstack_sccs

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
 def test_es_1236_cloudstack_sccs(self):
     """
     @Desc: Test whether cloudstack-sccs is available on management server
     @Steps:
     Step1: run cloudstack-sccs on management server
     Step2: It should return a commit hash
     """
     # Step1: run cloudstack-sccs on management server
     mgmt_ssh = SshClient(
         self.apiClient.connection.mgtSvr,
         22,
         self.apiClient.connection.user,
         self.apiClient.connection.passwd
     )
     mgmt_ssh.execute("cloudstack-sccs")
     # Step2: It should return a commit hash
     return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:19,代码来源:test_bugs.py

示例8: test_multiple_mgmt_srvr_session_timeout

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
    def test_multiple_mgmt_srvr_session_timeout(self):
        """
        @Desc: Check whether mgmt server session times out with in 30s
        @Steps:
        Step1: run 'telnet localhot 8250' on the management server
        and see that it times out with in 30seconds
        """
        # Step1: run cloudstack-sccs on management server
        mgmt_ssh = SshClient(
            self.apiClient.connection.mgtSvr,
            22,
            self.apiClient.connection.user,
            self.apiClient.connection.passwd
        )
        mgmt_ssh.execute("time telnet localhost 8250")

        # Step2: It should return a commit hash
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:20,代码来源:test_bugs.py

示例9: restartServer

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
    def restartServer(cls):
        """Restart management server"""

        sshClient = SshClient(
                    cls.mgtSvrDetails["mgtSvrIp"],
            22,
            cls.mgtSvrDetails["user"],
            cls.mgtSvrDetails["passwd"]
        )
        command = "service cloudstack-management stop"
        sshClient.execute(command)

        command = "service cloudstack-management start"
        sshClient.execute(command)

        #time.sleep(cls.services["sleep"])
        time.sleep(300)

        return
开发者ID:krissterckx,项目名称:cloudstack,代码行数:21,代码来源:test_deploy_vm_root_resize.py

示例10: restartServer

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
    def restartServer(cls):
        """Restart management server"""

        sshClient = SshClient(
                    cls.mgtSvrDetails["mgtSvrIp"],
            22,
            cls.mgtSvrDetails["user"],
            cls.mgtSvrDetails["passwd"]
        )
        command = "service cloudstack-management stop"
        sshClient.execute(command)

        command = "service cloudstack-management start"
        sshClient.execute(command)

        #Waits for management to come up in 5 mins, when it's up it will continue
        timeout = time.time() + 300
        while time.time() < timeout:
            if cls.isManagementUp() is True: return
            time.sleep(5)
        return cls.fail("Management server did not come up, failing")
开发者ID:PCextreme,项目名称:cloudstack,代码行数:23,代码来源:test_deploy_vm_root_resize.py

示例11: checkHostUp

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
 def checkHostUp(self, fromHostIp, testHostIp):
     try:
         ssh = SshClient(fromHostIp, 22, "root", "password") 
         res = ssh.execute("ping -c 1 %s" % testHostIp)
         result = str(res)
         if result.count(" 0% packet loss") == 1:
             return True, 1
         else:
             return False, 1
     except Exception as e:
         self.logger.debug("Got exception %s" % e)
         return False, 1
开发者ID:PCextreme,项目名称:cloudstack,代码行数:14,代码来源:test_host.py

示例12: setUpClass

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
    def setUpClass(self):
        testClient = super(TestDeployvGPUenabledVM, self).getClsTestClient()
        self.apiclient = testClient.getApiClient()
        self.testdata = self.testClient.getParsedTestDataConfig()
        #Need to add check whether zone containing the xen hypervisor or not as well
        hosts = list_hosts(
               self.apiclient,
               hypervisor="XenServer"
               )
        if hosts is None:
            raise unittest.SkipTest("There are no XenServers available. GPU feature is supported only on XenServer.Check listhosts response")
        else: 
             gpuhosts=0
             for ghost in hosts :
                    if ghost.hypervisorversion >= "6.2.0":
                       sshClient = SshClient(host=ghost.ipaddress, port=22, user='root',passwd=self.testdata["host_password"]) 
                       if ghost.hypervisorversion == "6.2.0":
                          res = sshClient.execute("xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503")
                          if len(res) == 0:
                              continue
                       res = sshClient.execute("xe vgpu-type-list model-name=\"GRID K120Q\"")
                       if len(res) != 0 :
                           gpuhosts=gpuhosts+1 
                       else:        
                           continue
        if gpuhosts == 0:
           raise unittest.SkipTest("No XenServer available with GPU Drivers installed")

        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        #Creating Account 
        self.account = Account.create(
            self.apiclient,
            self.testdata["account"],
            domainid=self.domain.id
            )
        self._cleanup = [
                         self.account
                        ]
开发者ID:Skotha,项目名称:cloudstack,代码行数:41,代码来源:test_deploy_vgpu_enabled_vm.py

示例13: try_ssh

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
    def try_ssh(self, ip_addr, hostnames):
        try:
            self.debug("SSH into NAT Rule (Public IP: %s)" % ip_addr)

            # If Round Robin Algorithm is chosen,
            # each ssh command should alternate between VMs

            ssh_1 = SshClient(ip_addr, 22, self.services["natrule"]["username"], self.services["natrule"]["password"])
            hostnames.append(ssh_1.execute("hostname")[0])
            self.debug(hostnames)
        except Exception as e:
            self.fail("%s: SSH failed for VM with IP Address: %s" % (e, ip_addr))
        return hostnames
开发者ID:ktenzer,项目名称:cloudstack,代码行数:15,代码来源:test_haproxy.py

示例14: _execute_ssh_command

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
def _execute_ssh_command(hostip, port, username, password, ssh_command):
    #SSH to the machine
    ssh = SshClient(hostip, port, username, password)
    # Ensure the SSH login is successful
    while True:
        res = ssh.execute(ssh_command)
        if "Connection refused".lower() in res[0].lower():
            pass
        elif res[0] != "Host key verification failed.":
            break
        elif timeout == 0:
            break

        time.sleep(5)
        timeout = timeout - 1
    return res
开发者ID:DKrul,项目名称:cloudstack,代码行数:18,代码来源:utils.py

示例15: ssh_kvm_host

# 需要导入模块: from marvin.sshClient import SshClient [as 别名]
# 或者: from marvin.sshClient.SshClient import execute [as 别名]
def ssh_kvm_host(password, ipaddr, instance_name):
    """Ssh into kvm host and get vm mem details"""
    mem = []
    sshClient = SshClient(
        ipaddr,
        22,
        "root",
        password
    )

    command = "virsh dominfo %s" % instance_name
    vm_detail = sshClient.execute(command)
    max = vm_detail[7].split()
    min = vm_detail[8].split()
    mem.append(int(max[2]))
    mem.append(int(min[2]))
    return mem
开发者ID:Accelerite,项目名称:cloudstack,代码行数:19,代码来源:test_overcommit.py


注:本文中的marvin.sshClient.SshClient.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。