• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.exec_cmd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: chown_file

def chown_file(filepath, logger):
    """touch a file and setting the chown
    """
    if os.path.exists(filepath):
        os.remove(filepath)

    touch_cmd = "touch %s" % filepath
    logger.info(touch_cmd)
    ret, out = utils.exec_cmd(touch_cmd, shell=True)
    if ret:
        logger.error("failed to touch a new file")
        logger.error(out[0])
        return 1

    logger.info("set chown of %s as 107:107" % filepath)
    chown_cmd = "chown 107:107 %s" % filepath
    ret, out = utils.exec_cmd(chown_cmd, shell=True)
    if ret:
        logger.error("failed to set the ownership of %s" % filepath)
        return 1

    logger.info("set %s mode as 664" % filepath)
    cmd = "chmod 664 %s" % filepath
    ret, out = utils.exec_cmd(cmd, shell=True)
    if ret:
        logger.error("failed to set the mode of %s" % filepath)
        return 1

    return 0
开发者ID:libvirt,项目名称:libvirt-test-API,代码行数:29,代码来源:ownership_test.py


示例2: vcpupin_check

def vcpupin_check(guestname, vcpu, cpulist):
    """check vcpu subprocess status of the running virtual machine
       grep Cpus_allowed_list /proc/PID/task/*/status
    """
    cmd_pid = "cat /var/run/libvirt/qemu/%s.pid" % guestname
    status, pid = utils.exec_cmd(cmd_pid, shell=True)
    if status:
        logger.error("failed to get the pid of domain %s" % guestname)
        return 1

    cmd_vcpu_task_id = "virsh qemu-monitor-command %s --hmp info cpus|grep '#%s'|cut -d '=' -f3"\
        % (guestname, vcpu)
    status, vcpu_task_id = utils.exec_cmd(cmd_vcpu_task_id, shell=True)
    if status:
        logger.error("failed to get the threadid of domain %s" % guestname)
        return 1

    logger.debug("vcpu id %s:" % vcpu_task_id[0])
    cmd_cpus_allowed_list = "grep Cpus_allowed_list /proc/%s/task/%s/status" % (pid[
                                                                                0], vcpu_task_id[0])
    status, output = utils.exec_cmd(cmd_cpus_allowed_list, shell=True)
    if status:
        logger.error("failed to get the cpu_allowed_list of vcpu %s")
        return 1

    logger.debug("the output of command 'grep Cpus_allowed_list \
                          /proc/%s/task/%s/status' is %s" % (pid[0], vcpu_task_id[0], output))

    if output[0].split('\t')[1] == cpulist:
        logger.info("vcpu process cpus allowed list is expected")
        return 0
    else:
        logger.error("vcpu process cpus allowed list is not expected")
        return 1
开发者ID:libvirt,项目名称:libvirt-test-API,代码行数:34,代码来源:vcpupin_live.py


示例3: CA_setting_up

def CA_setting_up(logger):
    """ setting up a Certificate Authority """
    # Create a private key for CA
    logger.info("generate CA certificates")

    cakey_fd = open(CAKEY, "w")
    ret, out = utils.exec_cmd([CERTTOOL, "--generate-privkey"], outfile=cakey_fd)
    cakey_fd.close()
    if ret != 0:
        logger.error("failed to create CA private key")
        return 1

    # ca.info file
    cainfo = os.path.join(TEMP_TLS_FOLDER, "ca.info")
    cainfo_fd = open(cainfo, "w")
    cainfo_str = "cn = Libvirt_test_API\n" + "ca\n" + "cert_signing_key\n"

    cainfo_fd.write(cainfo_str)
    cainfo_fd.close()

    # Generate cacert.pem
    cacert_args = [CERTTOOL, "--generate-self-signed", "--load-privkey", CAKEY, "--template", cainfo]
    cacert_fd = open(CACERT, "w")
    ret, out = utils.exec_cmd(cacert_args, outfile=cacert_fd)
    cacert_fd.close()
    if ret != 0:
        logger.error("failed to create cacert.pem")
        return 1

    logger.info("done the CA certificates job")
    return 0
开发者ID:rbian,项目名称:libvirt-test-API,代码行数:31,代码来源:tls_setup.py


示例4: get_security_driver

def get_security_driver(logger):
    """get security driver from /etc/libvirt/qemu.conf"""

    cmds = "grep \"^security_driver\" /etc/libvirt/qemu.conf"
    (ret, conf) = utils.exec_cmd(cmds, shell=True)
    if ret:
        cmds = "getenforce"
        (ret, policy) = utils.exec_cmd(cmds, shell=True)

        if policy[0] == "Disabled":
            return "none"
        else:
            return "selinux"

    tmp = conf[0].split(' = ')
    if len(tmp[1].split(', ')) > 1:
        driver = tmp[1].split(', ')
        return (filter(str.isalpha, driver[0]))
    else:
        cmds = "echo '%s' | awk -F '\"' '{print $2}'" % conf[0]
        (ret, driver) = utils.exec_cmd(cmds, shell=True)

        if driver[0] == "selinux":
            return "selinux"
        elif driver[0] == "none":
            return "none"
        elif driver[0] == "apparmor":
            return "apparmor"
        elif driver[0] == "stack":
            return "stack"
        else:
            return ""
开发者ID:libvirt,项目名称:libvirt-test-API,代码行数:32,代码来源:connection_security_model.py


示例5: check_numa_params

def check_numa_params(guestname, mode, node_tuple):
    """dump domain live xml description to check numa params and
       check memory allowed list of domain pid
    """
    cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname
    status, pid = utils.exec_cmd(cmd, shell=True)
    if status:
        logger.error("failed to get the pid of domain %s" % guestname)
        return 1

    cmd = "grep Mems_allowed_list /proc/%s/status" % pid[0]
    status, output = utils.exec_cmd(cmd, shell=True)
    nodeval = output[0].split('\t')[1]
    ret = utils.param_to_tuple(nodeval, node_num)
    logger.info("Mems_allowed_list in domain pid status is: %s" % nodeval)
    logger.debug("parse nodeset to tuple is:")
    logger.debug(ret)
    if not ret:
        logger.error("fail to parse nodeset to tuple")
        return 1

    # TODO: add check for mode

    if ret == node_tuple:
        return 0
    else:
        return 1
开发者ID:libvirt,项目名称:libvirt-test-API,代码行数:27,代码来源:numa_param_live.py


示例6: nfs_setup

def nfs_setup(root_squash, logger):
    """setup nfs on localhost
    """
    logger.info("set nfs service")
    if root_squash == "yes":
        option = "root_squash"
    elif root_squash == "no":
        option = "no_root_squash"
    else:
        logger.error("wrong root_squash value")
        return 1

    cmd = "echo /tmp *\(rw,%s\) >> /etc/exports" % option
    ret, out = utils.exec_cmd(cmd, shell=True)
    if ret:
        logger.error("failed to config nfs export")
        return 1

    logger.info("restart nfs service")
    cmd = "service nfs restart"
    ret, out = utils.exec_cmd(cmd, shell=True)
    if ret:
        logger.error("failed to restart nfs service")
        return 1
    else:
        for i in range(len(out)):
            logger.info(out[i])

    return 0
开发者ID:carriercomm,项目名称:libvirt-test-API,代码行数:29,代码来源:domain_nfs_start.py


示例7: check_pinemulator

def check_pinemulator(guestname, maxcpu, pininfo_after):
    """check emulator status of the running virtual machine
    """

    cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname
    status, pid = utils.exec_cmd(cmd, shell=True)
    if status:
        logger.error("failed to get the pid of domain %s" % guestname)
        return 1

    cmd = "grep Cpus_allowed_list /proc/%s/task/%s/status" % (pid[0], pid[0])
    status, output = utils.exec_cmd(cmd, shell=True)
    if status:
        logger.error("failed to get Cpus_allowed_list")
        return 1

    cpu_allowed_list = output[0]
    cpulistcheck = cpu_allowed_list.split('\t')[1]
    pininfo_in_process = str(utils.param_to_tuple(cpulistcheck, maxcpu))

    if cmp(pininfo_in_process, pininfo_after):
        logger.error("domain emulator pin failed")
        return 1
    else:
        logger.info("domain emulator pin successed")
        return 0
开发者ID:libvirt,项目名称:libvirt-test-API,代码行数:26,代码来源:pinemulator.py


示例8: deliver_cert

def deliver_cert(target_machine, username, password, pkipath, logger):
    """ deliver CA, server and client certificates """
    # transmit cacert.pem to remote host
    logger.info("deliver CA, server and client certificates to both local and remote server")
    ret = utils.scp_file(target_machine, username, password, CA_FOLDER, CACERT)
    if ret:
        logger.error("scp cacert.pem to %s error" % target_machine)
        return 1

    # copy cacert.pem to local CA folder
    cacert_cp = [CP, "-f", CACERT, (pkipath and pkipath) or CA_FOLDER]
    ret, out = utils.exec_cmd(cacert_cp)
    if ret:
        logger.error("copying cacert.pem to %s error" % CA_FOLDER)
        return 1

    # mkdir /etc/pki/libvirt/private on remote host
    libvirt_priv_cmd = "mkdir -p %s" % PRIVATE_KEY_FOLDER
    ret, output = utils.remote_exec_pexpect(target_machine, username, password, libvirt_priv_cmd)
    if ret:
        logger.error("failed to make /etc/pki/libvirt/private on %s" % target_machine)
        return 1

    # transmit serverkey.pem to remote host
    ret = utils.scp_file(target_machine, username, password, PRIVATE_KEY_FOLDER, SERVERKEY)
    if ret:
        logger.error("failed to scp serverkey.pem to %s" % target_machine)
        return 1

    # transmit servercert.pem to remote host
    ret = utils.scp_file(target_machine, username, password, CERTIFICATE_FOLDER, SERVERCERT)
    if ret:
        logger.error("failed to scp servercert.pem to %s" % target_machine)
        return 1

    libvirt_priv_cmd_local = [MKDIR, "-p", PRIVATE_KEY_FOLDER]
    ret, out = utils.exec_cmd(libvirt_priv_cmd_local)
    if ret:
        logger.error("failed to make %s on local" % PRIVATE_KEY_FOLDER)
        return 1

    # copy clientkey.pem to local folder
    clientkey_cp = [CP, "-f", CLIENTKEY, (pkipath and pkipath) or PRIVATE_KEY_FOLDER]
    ret, out = utils.exec_cmd(clientkey_cp)
    if ret:
        logger.error("failed to copy clientkey.pem to %s" % PRIVATE_KEY_FOLDER)
        return 1

    # copy clientcert.pem to local folder
    clientcert_cp = [CP, "-f", CLIENTCERT, (pkipath and pkipath) or CERTIFICATE_FOLDER]
    ret, out = utils.exec_cmd(clientcert_cp)
    if ret:
        logger.error("failed to copy clientcert.pem to %s" % CERTIFICATE_FOLDER)
        return 1

    logger.info("done to delivery")
    return 0
开发者ID:rbian,项目名称:libvirt-test-API,代码行数:57,代码来源:tls_setup.py


示例9: tls_client_cert

def tls_client_cert(local_machine, logger):
    """ generating client certificates """
    # Create tls client key
    logger.info("generate client certificates")

    clientkey_fd = open(CLIENTKEY, "w")
    ret, out = utils.exec_cmd([CERTTOOL, "--generate-privkey"], outfile=clientkey_fd)
    clientkey_fd.close()
    if ret != 0:
        logger.error("failed to create client key")
        return 1

    # client.info
    clientinfo = os.path.join(TEMP_TLS_FOLDER, "client.info")
    clientinfo_fd = open(clientinfo, "w")
    clientinfo_str = (
        "country = xxx\n"
        + "state = xxx\n"
        + "locality = xxx\n"
        + "organization = Libvirt_test_API\n"
        + "cn = %s\n" % local_machine
        + "tls_www_client\n"
        + "encryption_key\n"
        + "signing_key\n"
    )

    clientinfo_fd.write(clientinfo_str)
    clientinfo_fd.close()

    # Generate clientcert.pem
    clientcert_args = [
        CERTTOOL,
        "--generate-certificate",
        "--load-privkey",
        CLIENTKEY,
        "--load-ca-certificate",
        CACERT,
        "--load-ca-privkey",
        CAKEY,
        "--template",
        clientinfo,
    ]

    clientcert_fd = open(CLIENTCERT, "w")
    ret, out = utils.exec_cmd(clientcert_args, outfile=clientcert_fd)
    clientcert_fd.close()
    if ret != 0:
        logger.error("failed to create client certificates")
        return 1

    logger.info("done the client certificates job")
    return 0
开发者ID:rbian,项目名称:libvirt-test-API,代码行数:52,代码来源:tls_setup.py


示例10: tls_server_cert

def tls_server_cert(target_machine, logger):
    """ generating server certificates """
    # Create tls server key
    logger.info("generate server certificates")

    serverkey_fd = open(SERVERKEY, "w")
    ret, out = utils.exec_cmd([CERTTOOL, "--generate-privkey"], outfile=serverkey_fd)
    serverkey_fd.close()
    if ret != 0:
        logger.error("failed to create server key")
        return 1

    # server.info
    serverinfo = os.path.join(TEMP_TLS_FOLDER, "server.info")
    serverinfo_fd = open(serverinfo, "w")
    serverinfo_str = (
        "organization = Libvirt_test_API\n"
        + "cn = %s\n" % target_machine
        + "tls_www_server\n"
        + "encryption_key\n"
        + "signing_key\n"
    )

    serverinfo_fd.write(serverinfo_str)
    serverinfo_fd.close()

    # Generate servercert.pem
    servercert_args = [
        CERTTOOL,
        "--generate-certificate",
        "--load-privkey",
        SERVERKEY,
        "--load-ca-certificate",
        CACERT,
        "--load-ca-privkey",
        CAKEY,
        "--template",
        serverinfo,
    ]
    servercert_fd = open(SERVERCERT, "w")
    ret, out = utils.exec_cmd(servercert_args, outfile=servercert_fd)
    servercert_fd.close()
    if ret != 0:
        logger.error("failed to create servercert.pem")
        return 1

    logger.info("done the server certificates job")
    return 0
开发者ID:rbian,项目名称:libvirt-test-API,代码行数:48,代码来源:tls_setup.py


示例11: validate_caps_from_hv

def validate_caps_from_hv(emulatorbin, logger):
    """
        Validate the relative caps between libvirt and qemu-kvm
    """
    F1 = '%s -h| grep "\-drive"'
    F2 = '%s -h| grep "format="'
    F3 = '%s -h| grep "readonly="'
    F4 = '%s -h| grep "^\\-device"'
    l = [F1, F2, F3, F4]
    flags = []
    for item in l:
        status, temp = utils.exec_cmd(item % emulatorbin, shell=True)
        if not status:
            flags.append(True)
            logger.debug("Got: %s from vh" % temp)
        else:
            flags.append(False)
            logger.debug("Got: %s from vh" % temp)
    if get_hypervisor_ver(emulatorbin, logger) >= 11000:
        flags.append(True)
    else:
        flags.append(False)
    libvirt_f = [drive, drive_forma, drive_readonly, device, blk_sg_io]
    if flags == libvirt_f:
        return True
    else:
        return False
开发者ID:rbian,项目名称:libvirt-test-API,代码行数:27,代码来源:connection_getDomainCapabilities.py


示例12: qemu_hang

def qemu_hang(params):
    """Hang qemu process, check libvirtd status"""
    logger = params['logger']
    guestname = params['guestname']

    conn = sharedmod.libvirtobj['conn']

    logger.info("check the domain state")
    ret = check_domain_running(conn, guestname, logger)
    if ret:
        return 1

    logger.info("check the libvirtd status:")
    ret = libvirtd_check(logger)
    if ret:
        return 1

    ret, pid = get_domain_pid(logger, guestname)
    if ret:
        return 1

    cmd = "kill -STOP %s" % pid
    logger.info(cmd)
    ret, out = utils.exec_cmd(cmd, shell=True)
    if ret:
        logger.error("failed to stop qemu process of %s" % guestname)
        return 1

    logger.info("recheck libvirtd status:")
    ret = libvirtd_check(logger)
    if ret:
        return 1

    return 0
开发者ID:carriercomm,项目名称:libvirt-test-API,代码行数:34,代码来源:qemu_hang.py


示例13: get_cpu_list

def get_cpu_list(state_type, logger):
    """ get all cpu in the same type state
    """
    ret = list()

    if state_type == "online":
        match = '1'
        ret.append(0)
    elif state_type == "offline":
        match = '0'
    else:
        logger.error("Unidentified cpu state type %s" % state_type)
        return ret

    cpu_num = get_cpu_num(logger)
    if cpu_num < 0:
        return ret

    for i in range(1, cpu_num):
        cmd = CPUSTATE % i
        status, out = utils.exec_cmd(cmd, shell=True)
        if status != 0:
            logger.error("Exec %s fails" % cmd)
            return ret
        logger.debug("Exec outputs %s" % out[0])

        if out[0] == match:
            ret.append(i)

    return ret
开发者ID:ryanmiao,项目名称:libvirt-test-API,代码行数:30,代码来源:cpu_map.py


示例14: check_pool_sources

def check_pool_sources(host, xmlstr):
    """check the netfs sources with command:
       showmount --no-headers -e HOSTNAME
    """
    source_val = []

    doc = minidom.parseString(xmlstr)
    for diskTag in doc.getElementsByTagName("source"):
        device_element = diskTag.getElementsByTagName("dir")[0]
        attr = device_element.getAttributeNode('path')
        path_val = attr.nodeValue

        source_val.append(path_val)

    logger.debug("pool source info list is: %s" % source_val)

    cmd = "showmount --no-headers -e %s | awk -F' ' '{print $1}'" % host
    ret, path_list = utils.exec_cmd(cmd, shell=True)

    logger.debug("showmount command output list is: %s" % path_list)

    if source_val == path_list:
        logger.info("source list matched with showmount command output")
        return 0
    else:
        logger.error("source list did not match with showmount command output")
        return 1
开发者ID:carriercomm,项目名称:libvirt-test-API,代码行数:27,代码来源:find_netfs_pool_sources.py


示例15: check_pool_sources

def check_pool_sources(host, xmlstr):
    """check the iscsi sources with command:
       iscsiadm --mode discovery --type sendtargets --portal
    """
    source_val = []

    doc = minidom.parseString(xmlstr)
    for diskTag in doc.getElementsByTagName("source"):
        device_element = diskTag.getElementsByTagName("device")[0]
        attr = device_element.getAttributeNode('path')
        path_val = attr.nodeValue

        source_val.append(path_val)

    logger.debug("pool source info list is: %s" % source_val)

    cmd = "iscsiadm --mode discovery --type sendtargets --portal %s:3260,1 |\
           awk -F' ' '{print $2}'" % host
    ret, path_list = utils.exec_cmd(cmd, shell=True)

    logger.debug("iscsiadm command output list is: %s" % path_list)

    if source_val == path_list:
        logger.info("source list matched with iscsiadm command output")
        return 0
    else:
        logger.error("source list did not match with iscsiadm command output")
        return 1
开发者ID:libvirt,项目名称:libvirt-test-API,代码行数:28,代码来源:find_iscsi_pool_sources.py


示例16: check_hypervisor_ver_num

def check_hypervisor_ver_num(conn, logger):
    """check hypervisor version number
    """
    # TODO: modify utils.get_hypervisor, support lxc, openvz, and so on
    conn_type = conn.getType()
    logger.info("connection's type is %s" % conn_type)

    if str.lower(conn_type) == 'qemu':
        cmds = "rpm -q qemu-kvm"
        ver_num_pos = 2
        (status, output) = utils.exec_cmd(cmds, shell=True)
        if status != 0:
            cmds = "rpm -q qemu-kvm-rhev"
            ver_num_pos = 3
            (status, output) = utils.exec_cmd(cmds, shell=True)
            if status != 0:
                logger.error("Could not be aware of qemu")
                return False
        hyper_version = output[0]
        ver = hyper_version.split('-')[ver_num_pos]
        x = int(ver.split('.')[0])
        y = int(ver.split('.')[1])
        z = int(ver.split('.')[2])
    elif str.lower(conn_type) == 'lxc':
        cmds = "uname -r"
        (status, output) = utils.exec_cmd(cmds, shell=True)
        if status != 0:
            logger.error("Exec_cmd failed: %s" % cmds)
            return False
        hyper_version = output[0]
        ver = hyper_version.split('-')[0]
        x = int(ver.split('.')[0])
        y = int(ver.split('.')[1])
        z = int(ver.split('.')[2])
    else:
        logger.error("This hypervisor %s is unsupported currently" % conn_type)
        return False

    hyper_ver_num = produce_ver_num(x, y, z)

    conn_hyper_ver = conn.getVersion()
    logger.info("get hypervisor version from connection: %s" % conn_hyper_ver)
    if conn_hyper_ver != hyper_ver_num:
        logger.error("libvirt version is wrong, should be %s" % hyper_ver_num)
        return False
    return True
开发者ID:carriercomm,项目名称:libvirt-test-API,代码行数:46,代码来源:connection_version.py


示例17: get_info_from_dnsmasq

def get_info_from_dnsmasq(network,macaddr,logger):
    """
       generate dict for lease info from virtual network's lease file
    """
    title = ['expirytime','mac','ipaddr','hostname','clientid']
    output_list = []
    lease_dnsmasq = []
    temp = []
    remove_list = []
    GREP_MAC = "grep -w %s" + " " + LEASE_FILE_DNSMASQ
    CAT_FILE = "cat" + " " + LEASE_FILE_DNSMASQ

    status, output = utils.exec_cmd(CAT_FILE, shell=True)
    if not status:
        for i in range(0, len(output)):
            output_list = []
            output_str = output[i]
            for item in output_str.split(" "):
                output_list.append(item)
            lease_dnsmasq.append(dict(zip(title,output_list)))

        #due to no mac field in IPv6 line, so do nothing here temporarily.
        if macaddr != None:
             pass

        #remove bridge duid line
        for i in range(0, len(lease_dnsmasq)):
            if lease_dnsmasq[i]['expirytime'] == 'duid':
                remove_list.append(lease_dnsmasq[i])

        for i in range(0, len(remove_list)):
                lease_dnsmasq.remove(remove_list[i])

        #remove expiry leases
        for i in range(0, len(lease_dnsmasq)):
            temp = int(lease_dnsmasq[i]['expirytime'])
            lease_dnsmasq[i]['expirytime'] = temp

        remove_list = []
        for i in range(0, len(lease_dnsmasq)):
            if time.time() >= int(lease_dnsmasq[i]['expirytime']):
                remove_list.append(lease_dnsmasq[i])

        for i in range(0, len(remove_list)):
                lease_dnsmasq.remove(remove_list[i])

        #replace * to None
        for i in range(0, len(lease_dnsmasq)):
            if lease_dnsmasq[i]['hostname'] == "*":
                lease_dnsmasq[i]['hostname'] = None
            if lease_dnsmasq[i]['clientid'] == "*":
                lease_dnsmasq[i]['clientid'] = None

        return lease_dnsmasq
    else:
        logger.error("\"" + CAT_FILE + "\"" + "error")
        logger.error(output)
        return False
开发者ID:carriercomm,项目名称:libvirt-test-API,代码行数:58,代码来源:network_dhcp_leases.py


示例18: ownership_test_clean

def ownership_test_clean(params):
    """clean testing environment"""
    logger = params['logger']
    use_nfs = params['use_nfs']

    if use_nfs == 'enable':
        if os.path.ismount("/mnt"):
            umount_cmd = "umount /mnt"
            ret, out = utils.exec_cmd(umount_cmd, shell=True)
            if ret:
                logger.error("Failed to unmount the nfs path")
                for i in range(len(out)):
                    logger.error(out[i])

        clean_nfs_conf = "sed -i '$d' /etc/exports"
        utils.exec_cmd(clean_nfs_conf, shell=True)

        filepath = TEMP_FILE
    elif use_nfs == 'disable':
        filepath = SAVE_FILE

    if os.path.exists(filepath):
        os.remove(filepath)

    clean_qemu_conf = "sed -i '$d' %s" % QEMU_CONF
    utils.exec_cmd(clean_qemu_conf, shell=True)

    cmd = "service libvirtd restart"
    utils.exec_cmd(cmd, shell=True)

    return 0
开发者ID:libvirt,项目名称:libvirt-test-API,代码行数:31,代码来源:ownership_test.py


示例19: get_ip_prefix

def get_ip_prefix(network, iptype, logger):
    """
       get ip prefix according to IP type
    """
    br = get_bridge_name(network, logger)
    PREFIX = "ip -4 -o ad show %s | awk '{print $4}'|awk -F\"/\" '{print $2}'"
    PREFIX_6 = "ip -6 -o ad show %s|awk '{print $4}'|awk -F\"/\" '{print $2}'"
    if iptype == "ipv4":
        status, output = utils.exec_cmd(PREFIX % br, shell=True)
    elif iptype == "ipv6":
        status, output = utils.exec_cmd(PREFIX_6 % br, shell=True)
    if not status:
        pass
    else:
        logger.error("\"" + GREP_BRIDGE + "\"" + "error")
        logger.error(output)
        return False
    return output[0]
开发者ID:carriercomm,项目名称:libvirt-test-API,代码行数:18,代码来源:network_dhcp_leases.py


示例20: clean_env

def clean_env(logger):
    """
       clean testing environment
    """
    status, output = utils.exec_cmd(CMD % API_FILE, shell=True)
    if status != 0:
        logger.error("Can not delete %s" % API_FILE)
    else:
        logger.debug("Deleted %s successfully" % API_FILE)
开发者ID:rbian,项目名称:libvirt-test-API,代码行数:9,代码来源:connection_getDomainCapabilities.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_csv_writer函数代码示例发布时间:2022-05-26
下一篇:
Python utils.download函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap