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


Python ssh.execute函数代码示例

本文整理汇总了Python中zstacklib.utils.ssh.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _install_zstack_nodes_ha

 def _install_zstack_nodes_ha(self):
     for node in self.nodes:
         cmd = "/root/scripts/network-setting -b %s %s %s %s %s" % (node.ip_, node.netmask_, node.gateway_, node.nic_, node.bridge_)
         ssh.execute(cmd, node.ip_, node.username_, node.password_)
         ssh.scp_file(self.zstack_pkg, "/root/zstack-installer.bin", node.ip_, node.username_, node.password_)
         cmd = "bash %s -o -i -I %s" % ("/root/zstack-installer.bin", node.bridge_)
         ssh.execute(cmd, node.ip_, node.username_, node.password_)
开发者ID:dennis-sun-chao,项目名称:zstack-woodpecker,代码行数:7,代码来源:setup_actions.py

示例2: _install_zstack_nodes_ha

 def _install_zstack_nodes_ha(self):
     for node in self.nodes:
         cmd = "/usr/local/bin/zs-network-setting -b %s %s %s %s" % (node.ip_, node.netmask_, node.gateway_, node.nic_)
         ssh.execute(cmd, node.ip_, node.username_, node.password_)
         ssh.scp_file(self.zstack_pkg, "/root/zstack-installer.bin", node.ip_, node.username_, node.password_)
         cmd = "deactivate; which python; bash %s -o -i -I %s" % ("/root/zstack-installer.bin", node.bridge_)
         ssh.execute(cmd, node.ip_, node.username_, node.password_)
开发者ID:rynetang,项目名称:zstack-woodpecker,代码行数:7,代码来源:setup_actions.py

示例3: test

def test():

    image_name = os.environ.get('ipv6ImageName')
    ipv4_net_uuid = test_lib.lib_get_l3_by_name(os.environ.get('l3PublicNetworkName')).uuid
    ipv6_net_uuid = test_lib.lib_get_l3_by_name(os.environ.get('l3PublicNetworkName1')).uuid
    print "ipv4_net_uuid is : %s , ipv6_net_uuid is : %s" %(ipv4_net_uuid, ipv6_net_uuid)
    vm1 = test_stub.create_vm(l3_name = os.environ.get('l3PublicNetworkName'), vm_name = 'vm_1 IPv6 2 stack test', system_tags = ["dualStackNic::%s::%s" %(ipv4_net_uuid, ipv6_net_uuid)], image_name = image_name)
    vm2 = test_stub.create_vm(l3_name = os.environ.get('l3PublicNetworkName'), vm_name = 'vm_2 IPv6 2 stack test', system_tags = ["dualStackNic::%s::%s" %(ipv4_net_uuid, ipv6_net_uuid)], image_name = image_name)
    time.sleep(120) #waiting for vm bootup
    ipv4 = None
    ipv6 = None
    vms = res_ops.query_resource(res_ops.VM_INSTANCE)
    vm1_nic1 = vms[1].vmNics[0].usedIps[0].ip
    vm1_nic2 = vms[1].vmNics[0].usedIps[1].ip
    vm2_nic1 = vms[0].vmNics[0].usedIps[0].ip
    vm2_nic2 = vms[0].vmNics[0].usedIps[1].ip

    for ip in [vm1_nic1, vm1_nic2]:
        if "172.20" in ip:
            ipv4 = ip
    for ip in [vm2_nic1, vm2_nic2]:
        if "1000:2000" in ip:
            ipv6 = ip
    for ip in [vm2_nic1, vm2_nic2]:
        if "172" in ip:
            vm2_ipv4 = ip
    print "vm1_nic1 : %s, vm1_nic2: %s, vm2_nic1 :%s,vm2_nic2 :%s, ipv4 :%s, ipv6 :%s." %(vm1_nic1, vm1_nic2, vm2_nic1, vm2_nic2, ipv4, ipv6)
    cmd = "ping6 -c 4 %s" %(ipv6)
    (retcode, output, erroutput) = ssh.execute(cmd, ipv4, "root", "password", True, 22)
    cmd1 = "ping -c 4 %s" %(vm2_ipv4)
    (retcode1, output1, erroutput1) = ssh.execute(cmd1, ipv4, "root", "password", True, 22)
    print "retcode is: %s; output is : %s.; erroutput is: %s" %(retcode, output , erroutput)
    print "retcode1 is: %s; output1 is : %s.; erroutput1 is: %s" %(retcode1, output1 , erroutput1)
    if retcode != 0 and retcode1 != 0:
        test_util.test_fail('Test Create IPv6 VM Failed.')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:35,代码来源:test_dualStackNic.py

示例4: cleanup_sftp_backup_storage

def cleanup_sftp_backup_storage():
    backup_obj = test_lib.deploy_config.backupStorages
    sftp_backupstorages = backup_obj.get_child_node_as_list("sftpBackupStorage")
    for storage in sftp_backupstorages:
        cmd = "rm -rf %s/rootVolumeTemplates/*" % storage.url_
        ssh.execute(cmd, storage.hostname_, storage.username_, storage.password_)
        cmd = "rm -rf %s/dataVolumeTemplates/*" % storage.url_
        ssh.execute(cmd, storage.hostname_, storage.username_, storage.password_)
开发者ID:tianshangjun,项目名称:zstack-woodpecker,代码行数:8,代码来源:clean_util.py

示例5: _install_zstack_ha

    def _install_zstack_ha(self):
        node1 = self.nodes[0]
	host_info = ""
        host_id = 1
        for node in self.nodes:
            host_info += "--host%s-info %s:%[email protected]%s " % (host_id, node.username_, node.password_, node.ip_)
	    host_id += 1
        cmd = "zstack-ctl install_ha %s --vip %s" % (host_info, self.zstack_ha_vip)
        ssh.execute(cmd, node1.ip_, node1.username_, node1.password_)
开发者ID:rynetang,项目名称:zstack-woodpecker,代码行数:9,代码来源:setup_actions.py

示例6: _change_node_ip

 def _change_node_ip(self):
     for node in self.nodes:
         cmd = 'zstack-ctl change_ip --ip=%s' % (node.ip_)
         if not linux.is_ip_existing(node.ip_):
             ssh.execute(cmd, node.ip_, node.username_, node.password_)
         else:
             thread = threading.Thread(target=shell_cmd_thread, args=(cmd,))
             thread.start()
             self._wait_for_thread_completion('change management node ip', 60)
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:9,代码来源:setup_actions.py

示例7: _set_extra_node_config

 def _set_extra_node_config(self):
     node1 = self.nodes[0]
     for node in self.nodes:
         cmd = 'zstack-ctl configure --duplicate-to-remote=%s; zstack-ctl configure --host=%s management.server.ip=%s' % \
                 (node.ip_, node.ip_, node.ip_)
         if not linux.is_ip_existing(node.ip_):
             ssh.execute(cmd, node1.ip_, node.username_, node.password_)
         else:
             thread = threading.Thread(target=shell_cmd_thread, args=(cmd,))
             thread.start()
             self._wait_for_thread_completion('set extra management node config', 60)
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:11,代码来源:setup_actions.py

示例8: check_chrony_status

def check_chrony_status(node_ip, port):
    test_util.test_dsc("Check all hosts chrony status.")
    node_ip = node_ip
    port = port
    cmd1 = "chronyc tracking"
    cmd2 = "chronyc sources"
    (retcode1, output, erroutput) = ssh.execute(cmd1, node_ip, 'root', 'password', True, port)
    (retcode2, output, erroutput) = ssh.execute(cmd2, node_ip, 'root', 'password', True, port)
    if retcode1 == 0 and retcode2 == 0:
        test_util.test_logger('@@@DEBUG-> check chrony "chronyc tracking", "chronyc sources" pass')
    else:
        test_util.test_fail('@@@DEBUG-> check chrony "chronyc tracking", "chronyc sources" failed.')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:12,代码来源:test_chrony.py

示例9: test

def test():

    img_option = test_util.ImageOption()
    ipv6_image_url = os.environ.get('ipv6ImageUrl')
    image_name = os.environ.get('ipv6ImageName')
    img_option.set_name(image_name)
    bs_uuid = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, [], None)[0].uuid
    img_option.set_backup_storage_uuid_list([bs_uuid])
    img_option.set_format('qcow2')
    img_option.set_url(ipv6_image_url)
    image_inv = img_ops.add_root_volume_template(img_option)
    image = test_image.ZstackTestImage()
    image.set_image(image_inv)
    image.set_creation_option(img_option)
    test_obj_dict.add_image(image)
    vm1 = test_stub.create_vm(l3_name = "%s,%s" %(os.environ.get('l3PublicNetworkName1'), os.environ.get('l3PublicNetworkName')), vm_name = 'IPv6 2 stack test ipv4 and ipv6', image_name = image_name)
    vm2 = test_stub.create_vm(l3_name = os.environ.get('l3PublicNetworkName1'), vm_name = 'IPv6 2 stack test ipv6', image_name = image_name)
    time.sleep(90) #waiting for vm bootup
    vm1_nic1 = vm1.get_vm().vmNics[0].ip
    vm1_nic2 = vm1.get_vm().vmNics[1].ip
    vm2_nic1 = vm2.get_vm().vmNics[0].ip
    for ip in (vm1_nic1, vm1_nic2):
        if "." in ip:
            ipv4 = ip
    print "vm1_nic1 : %s, vm1_nic2: %s, vm2_nic1 :%s, ipv4 :%s." %(vm1_nic1, vm1_nic2, vm2_nic1,ipv4)
    cmd = "ping6 -c 4 %s" %(vm2_nic1)
    (retcode, output, erroutput) = ssh.execute(cmd, ipv4, "root", "password", True, 22)
    print "retcode is: %s; output is : %s.; erroutput is: %s" %(retcode, output , erroutput)
    if retcode != 0:
        test_util.test_fail('Test Create IPv6 VM Failed.')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:30,代码来源:test_ipv6_2_stack.py

示例10: test

def test():

    image_name = os.environ.get('ipv6ImageName')
    vm1 = test_stub.create_vm(l3_name = "%s,%s" %(os.environ.get('l3PublicNetworkName1'), os.environ.get('l3PublicNetworkName')), vm_name = 'IPv6 2 stack test ipv4 and ipv6', image_name = image_name)
    vm2 = test_stub.create_vm(l3_name = os.environ.get('l3PrivateNetworkName'), vm_name = 'IPv6 private vm', image_name = image_name)
    time.sleep(90) #waiting for vm bootup
    vm1_nic1 = vm1.get_vm().vmNics[0].ip
    vm1_nic2 = vm1.get_vm().vmNics[1].ip
    vm2_nic1 = vm2.get_vm().vmNics[0].ip
    for ip in (vm1_nic1, vm1_nic2):
        if "." in ip:
            ipv4 = ip
    print "vm1_nic1 : %s, vm1_nic2: %s, vm2_nic1 :%s, ipv4 :%s." %(vm1_nic1, vm1_nic2, vm2_nic1,ipv4)
#######################################################################
    pub_l3_name = os.environ.get('l3PublicNetworkName1')
    pub_l3_uuid = test_lib.lib_get_l3_by_name(pub_l3_name).uuid

    vm2_nic_uuid = vm2.get_vm().vmNics[0].uuid
    vip = test_stub.create_vip('create_eip_test', pub_l3_uuid)
    test_obj_dict.add_vip(vip)
    eip = test_stub.create_eip('create eip test', vip_uuid=vip.get_vip().uuid, vnic_uuid=vm2_nic_uuid, vm_obj=vm2)

    vip.attach_eip(eip)
    eip_ip = res_ops.query_resource(res_ops.EIP)[0].vipIp

    print "eip_ip : %s, vm1_nic2: %s, vm2_nic1 :%s, ipv4 :%s." %(eip_ip, vm1_nic2, vm2_nic1,ipv4)
    cmd = "ping6 -c 4 %s" %(eip_ip)
    (retcode, output, erroutput) = ssh.execute(cmd, ipv4, "root", "password", True, 22)
    print "ping6 EIP retcode is: %s; output is : %s.; erroutput is: %s" %(retcode, output , erroutput)
    if retcode != 0:
        test_util.test_fail('Test Create IPv6 VM Failed.')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_ipv6_eip.py

示例11: set_quick_ha_properties

def set_quick_ha_properties():
    host_username = os.environ.get('hostUsername')
    host_password = os.environ.get('hostPassword')
    mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
    cmd = 'zstack-ctl status|grep properties|cut -d: -f2'
    ret, properties_file, stderr = ssh.execute(cmd, mn_ip, host_username, host_password, False, 22)

    cmd = "zstack-ctl stop"
    if test_lib.lib_execute_ssh_cmd(mn_ip, host_username, host_password, cmd,  timeout = 120) == False:
        test_util.test_fail("CMD:%s execute failed on %s" %(cmd, mn_ip))

    cmd = "sed 's/RESTFacade.connectTimeout.*$//g' -i " + properties_file
    if test_lib.lib_execute_ssh_cmd(mn_ip, host_username, host_password, cmd,  timeout = 10) == False:
        test_util.test_fail("CMD:%s execute failed on %s" %(cmd, mn_ip))

    cmd = "sed 's/RESTFacade.readTimeout.*$//g' -i " + properties_file
    if test_lib.lib_execute_ssh_cmd(mn_ip, host_username, host_password, cmd,  timeout = 10) == False:
        test_util.test_fail("CMD:%s execute failed on %s" %(cmd, mn_ip))

    cmd = "echo \"RESTFacade.readTimeout = 10000\" >>" + properties_file
    if test_lib.lib_execute_ssh_cmd(mn_ip, host_username, host_password, cmd,  timeout = 10) == False:
        test_util.test_fail("CMD:%s execute failed on %s" %(cmd, mn_ip))

    cmd = "echo \"RESTFacade.connectTimeout = 5000\" >>" + properties_file
    if test_lib.lib_execute_ssh_cmd(mn_ip, host_username, host_password, cmd,  timeout = 10) == False:
        test_util.test_fail("CMD:%s execute failed on %s" %(cmd, mn_ip))

    cmd = "nohup zstack-ctl start &"
    if test_lib.lib_execute_ssh_cmd(mn_ip, host_username, host_password, cmd,  timeout = 180) == False:
        test_util.test_fail("CMD:%s execute failed on %s" %(cmd, mn_ip))

    time.sleep(60)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:32,代码来源:test_min_ha_param_vm_ha_power_off.py

示例12: ensure_storage_online

def ensure_storage_online(vm):
    ret, output, stderr = ssh.execute("o2cb.init status", vm.get_vm().vmNics[0].ip, "root", "password", False, 22)
    if ret != 0:
        test_util.test_fail( cmd + " failed")

    if "online" not in output.lower():
        test_util.test_fail("not found storage online")
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:7,代码来源:test_sharable_vol_vm_start_stop.py

示例13: _change_node_ip

    def _change_node_ip(self):
        for node in self.nodes:
            cmd = 'zstack-ctl change_ip --ip=%s --mysql_root_password=%s' % (node.ip_, os.environ.get('DBAdminPassword'))
            if not linux.is_ip_existing(node.ip_):
                ssh.execute(cmd, node.ip_, node.username_, node.password_)
            else:
                thread = threading.Thread(target=shell_cmd_thread, args=(cmd,))
                thread.start()
                self._wait_for_thread_completion('change management node ip', 120)

            cmd = 'zstack-ctl configure InfluxDB.startupTimeout=1200'
            if not linux.is_ip_existing(node.ip_):
                ssh.execute(cmd, node.ip_, node.username_, node.password_)
            else:
                thread = threading.Thread(target=shell_cmd_thread, args=(cmd,))
                thread.start()
                self._wait_for_thread_completion('InfluxDB startup time setting to 10 mins', 120)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:17,代码来源:setup_actions.py

示例14: copy_data

 def copy_data(self, vm=None):
     vm = vm if vm else self.vm
     vm_ip = vm.get_vm().vmNics[0].ip
     test_lib.lib_wait_target_up(vm_ip, '22', timeout=600)
     cmd = "find /home -iname 'zstack-all-in-one.*'"
     file_path = commands.getoutput(cmd).split('\n')[0]
     file_name = os.path.basename(file_path)
     dst_file = os.path.join('/mnt', file_name)
     src_file_md5 = commands.getoutput('md5sum %s' % file_path).split(' ')[0]
     ssh.scp_file(file_path, dst_file, vm_ip, 'root', 'password')
     (_, dst_md5, _)= ssh.execute('sync; sync; sleep 60; md5sum %s' % dst_file, vm_ip, 'root', 'password')
     dst_file_md5 = dst_md5.split(' ')[0]
     test_util.test_dsc('src_file_md5: [%s], dst_file_md5: [%s]' % (src_file_md5, dst_file_md5))
     assert dst_file_md5 == src_file_md5, 'dst_file_md5 [%s] and src_file_md5 [%s] is not match, stop test' % (dst_file_md5, src_file_md5)
     extract_cmd = 'tar xvf /mnt/zstack-all-in-one.* -C /mnt > /dev/null 2>&1'
     ssh.execute(extract_cmd, vm_ip, 'root', 'password')
     return self
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:17,代码来源:test_stub.py

示例15: check_qemu_ga_is_alive

def check_qemu_ga_is_alive(vm):
    global ga_process_not_alive_num
    vm.check()
    cmd = "ps -aux|grep ga|grep qemu"
    ret, output, stderr = ssh.execute(cmd, vm.get_vm().vmNics[0].ip, "root", "password", False, 22)
    if ret != 0:
        test_util.test_logger("qemu-ga is not alived when exception triggered: ip:%s; cmd:%s; user:%s; password:%s; stdout:%s, stderr:%s" %(vm.get_vm().vmNics[0].ip, cmd, "root", "password", output, stderr))
        ga_process_not_alive_num = ga_process_not_alive_num + 1
    return ret
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:9,代码来源:test_ga_robust_on_c7.py


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