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

Python libvirtconnection.get函数代码示例

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

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



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

示例1: testProcessDeviceParamsInvalidEncoding

    def testProcessDeviceParamsInvalidEncoding(self):
        deviceXML = hostdev._process_device_params(
            libvirtconnection.get().nodeDeviceLookupByName(
                _COMPUTER_DEVICE).XMLDesc()
        )

        self.assertEqual(_COMPUTER_DEVICE_PROCESSED, deviceXML)
开发者ID:EdDev,项目名称:vdsm,代码行数:7,代码来源:hostdev_test.py


示例2: testProcessNetDeviceParams

    def testProcessNetDeviceParams(self):
        deviceXML = hostdev._process_device_params(
            libvirtconnection.get().nodeDeviceLookupByName(
                _NET_DEVICE).XMLDesc()
        )

        self.assertEqual(_NET_DEVICE_PROCESSED, deviceXML)
开发者ID:EdDev,项目名称:vdsm,代码行数:7,代码来源:hostdev_test.py


示例3: unregister

def unregister(uuids):
    try:
        uuids = [str(uuid.UUID(s)) for s in uuids]
    except ValueError as e:
        logging.warning("Attempt to unregister invalid uuid %s: %s" %
                        (uuids, e))
        return response.error("secretBadRequestErr")

    con = libvirtconnection.get()
    try:
        for sec_uuid in uuids:
            logging.info("Unregistering secret %r", sec_uuid)
            try:
                virsecret = con.secretLookupByUUIDString(sec_uuid)
            except libvirt.libvirtError as e:
                if e.get_error_code() != libvirt.VIR_ERR_NO_SECRET:
                    raise
                logging.debug("No such secret %r", sec_uuid)
            else:
                virsecret.undefine()
    except libvirt.libvirtError as e:
        logging.error("Could not unregister secrets: %s", e)
        return response.error("secretUnregisterErr")

    return response.success()
开发者ID:andrewlukoshko,项目名称:vdsm,代码行数:25,代码来源:secret.py


示例4: networks

def networks():
    """
    Get dict of networks from libvirt

    :returns: dict of networkname={properties}
    :rtype: dict of dict
            { 'ovirtmgmt': { 'bridge': 'ovirtmgmt', 'bridged': True}
              'red': { 'iface': 'red', 'bridged': False}}
    """
    nets = {}
    conn = libvirtconnection.get()
    allNets = ((net, net.name()) for net in conn.listAllNetworks(0))
    for net, netname in allNets:
        if netname.startswith(LIBVIRT_NET_PREFIX):
            netname = netname[len(LIBVIRT_NET_PREFIX):]
            nets[netname] = {}
            xml = etree.fromstring(net.XMLDesc(0))
            interface = xml.find('.//interface')
            if interface is not None:
                nets[netname]['iface'] = interface.get('dev')
                nets[netname]['bridged'] = False
            else:
                nets[netname]['bridge'] = xml.find('.//bridge').get('name')
                nets[netname]['bridged'] = True
    return nets
开发者ID:andrewlukoshko,项目名称:vdsm,代码行数:25,代码来源:libvirt.py


示例5: attach

def attach(queries, reverse=False, callback="attached"):
    def _getDeviceXML(device_xml):
        devXML = xml.etree.ElementTree.fromstring(device_xml)
        caps = devXML.find("capability")
        bus = caps.find("bus").text
        device = caps.find("device").text

        doc = getDOMImplementation().createDocument(None, "hostdev", None)
        hostdev = doc.documentElement
        hostdev.setAttribute("mode", "subsystem")
        hostdev.setAttribute("type", "usb")

        source = doc.createElement("source")
        hostdev.appendChild(source)

        address = doc.createElement("address")
        address.setAttribute("bus", bus)
        address.setAttribute("device", device)
        source.appendChild(address)

        return doc.toxml()

    vm_id = queries["vmId"][0]
    dev_name = queries["devname"][0]

    c = libvirtconnection.get()
    domain = c.lookupByUUIDString(vm_id)
    device_xml = _getDeviceXML(c.nodeDeviceLookupByName(dev_name).XMLDesc())
    if reverse:
        domain.detachDevice(device_xml)
    else:
        domain.attachDevice(device_xml)
    return "%s(\"%s\", \"%s\");" % (callback, vm_id, dev_name)
开发者ID:aiminickwong,项目名称:hostusb-passthrough-ui-plugin,代码行数:33,代码来源:usb-passthrough.py


示例6: main

def main():
    """
    Defines network filters on libvirt
    """
    conn = libvirtconnection.get()
    NoMacSpoofingFilter().defineNwFilter(conn)
    conn.close()
开发者ID:lukas-bednar,项目名称:vdsm,代码行数:7,代码来源:nwfilter.py


示例7: testCallSucceeded

 def testCallSucceeded(self):
     """Positive test - libvirtMock does not raise any errors"""
     with run_libvirt_event_loop():
         LibvirtMock.virConnect.failGetLibVersion = False
         LibvirtMock.virConnect.failNodeDeviceLookupByName = False
         connection = libvirtconnection.get()
         connection.nodeDeviceLookupByName()
开发者ID:aiminickwong,项目名称:vdsm,代码行数:7,代码来源:libvirtconnectionTests.py


示例8: testListByCaps

    def testListByCaps(self, caps):
        devices = hostdev.list_by_caps(
            libvirtconnection.get().vmContainer, caps)

        for cap in caps:
            self.assertTrue(set(DEVICES_BY_CAPS[cap].keys()).
                            issubset(devices.keys()))
开发者ID:aiminickwong,项目名称:vdsm,代码行数:7,代码来源:hostdevTests.py


示例9: testParseSRIOV_VFDeviceParams

    def testParseSRIOV_VFDeviceParams(self):
        deviceXML = hostdev._parse_device_params(
            libvirtconnection.get().nodeDeviceLookupByName(
                _SRIOV_VF).XMLDesc()
        )

        self.assertEquals(_SRIOV_VF_PARSED, deviceXML)
开发者ID:sshnaidm,项目名称:vdsm,代码行数:7,代码来源:hostdevTests.py


示例10: start

def start(cif):
    global _operations

    _scheduler.start()
    _executor.start()

    def per_vm_operation(func, period):
        disp = VmDispatcher(cif.getVMs, _executor, func, _timeout_from(period))
        return Operation(disp, period)

    _operations = [
        # needs dispatching becuse updating the volume stats needs the
        # access the storage, thus can block.
        per_vm_operation(UpdateVolumes, config.getint("irs", "vol_size_sample_interval")),
        # needs dispatching becuse access FS and libvirt data
        per_vm_operation(NumaInfoMonitor, config.getint("vars", "vm_sample_numa_interval")),
        # Job monitoring need QEMU monitor access.
        per_vm_operation(BlockjobMonitor, config.getint("vars", "vm_sample_jobs_interval")),
        # libvirt sampling using bulk stats can block, but unresponsive
        # domains are handled inside VMBulkSampler for performance reasons;
        # thus, does not need dispatching.
        Operation(
            sampling.VMBulkSampler(libvirtconnection.get(cif), cif.getVMs, sampling.stats_cache),
            config.getint("vars", "vm_sample_interval"),
        ),
        # we do this only until we get high water mark notifications
        # from qemu. Access storage and/or qemu monitor, so can block,
        # thus we need dispatching.
        per_vm_operation(DriveWatermarkMonitor, config.getint("vars", "vm_watermark_interval")),
    ]

    for op in _operations:
        op.start()
开发者ID:kvaps,项目名称:vdsm,代码行数:33,代码来源:periodic.py


示例11: testProcessSRIOV_VFDeviceParams

    def testProcessSRIOV_VFDeviceParams(self):
        deviceXML = hostdev._process_device_params(
            libvirtconnection.get().nodeDeviceLookupByName(
                _SRIOV_VF).XMLDesc()
        )

        self.assertEqual(_SRIOV_VF_PROCESSED, deviceXML)
开发者ID:EdDev,项目名称:vdsm,代码行数:7,代码来源:hostdev_test.py


示例12: testParseNetDeviceParams

    def testParseNetDeviceParams(self):
        deviceXML = hostdev._parse_device_params(
            libvirtconnection.get().nodeDeviceLookupByName(
                _NET_DEVICE).XMLDesc()
        )

        self.assertEquals(_NET_DEVICE_PARSED, deviceXML)
开发者ID:sshnaidm,项目名称:vdsm,代码行数:7,代码来源:hostdevTests.py


示例13: main

def main():
    portProfile = os.environ.get('vmfex')
    if portProfile is not None:
        handleDirectPool(libvirtconnection.get())
        doc = hooking.read_domxml()
        interface, = doc.getElementsByTagName('interface')
        attachProfileToInterfaceXml(interface, portProfile)
        hooking.write_domxml(doc)
开发者ID:aiminickwong,项目名称:vdsm,代码行数:8,代码来源:vmfex_vnic.py


示例14: removeNetwork

def removeNetwork(network):
    netName = netinfo.LIBVIRT_NET_PREFIX + network
    conn = libvirtconnection.get()

    net = conn.networkLookupByName(netName)
    if net.isActive():
        net.destroy()
    if net.isPersistent():
        net.undefine()
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:9,代码来源:libvirtCfg.py


示例15: flush

def flush():
    conn = libvirtconnection.get()
    allNets = ((net, net.name()) for net in conn.listAllNetworks(0))
    for net, netname in allNets:
        if netname.startswith(netinfo.LIBVIRT_NET_PREFIX):
            if net.isActive():
                net.destroy()
            if net.isPersistent():
                net.undefine()
开发者ID:futurice,项目名称:vdsm,代码行数:9,代码来源:libvirt.py


示例16: removeNetwork

def removeNetwork(network):
    netName = LIBVIRT_NET_PREFIX + network
    conn = libvirtconnection.get()

    net = _netlookup_by_name(conn, netName)
    if net:
        if net.isActive():
            net.destroy()
        if net.isPersistent():
            net.undefine()
开发者ID:EdDev,项目名称:vdsm,代码行数:10,代码来源:libvirtnetwork.py


示例17: getNetworkDef

def getNetworkDef(network):
    netName = netinfo.LIBVIRT_NET_PREFIX + network
    conn = libvirtconnection.get()
    try:
        net = conn.networkLookupByName(netName)
        return net.XMLDesc(0)
    except libvirt.libvirtError as e:
        if e.get_error_code() == libvirt.VIR_ERR_NO_NETWORK:
            return

        raise
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:11,代码来源:libvirtCfg.py


示例18: getMemoryStatsByNumaCell

def getMemoryStatsByNumaCell(cell):
    """
    Get the memory stats of a specified numa node, the unit is MiB.

    :param cell: the index of numa node
    :type cell: int
    :return: dict like {'total': '49141', 'free': '46783'}
    """
    cellMemInfo = libvirtconnection.get().getMemoryStats(cell, 0)
    cellMemInfo['total'] = str(cellMemInfo['total'] / 1024)
    cellMemInfo['free'] = str(cellMemInfo['free'] / 1024)
    return cellMemInfo
开发者ID:carriercomm,项目名称:vdsm,代码行数:12,代码来源:caps.py


示例19: _list_domains

def _list_domains():
    conn = libvirtconnection.get()
    for dom_uuid in conn.listDomainsID():
        try:
            dom_obj = conn.lookupByID(dom_uuid)
            dom_xml = dom_obj.XMLDesc(0)
        except libvirt.libvirtError as e:
            if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
                logging.exception("domain %s is dead", dom_uuid)
            else:
                raise
        else:
            yield dom_obj, dom_xml
开发者ID:sshnaidm,项目名称:vdsm,代码行数:13,代码来源:recovery.py


示例20: testCallFailedConnectionUp

 def testCallFailedConnectionUp(self):
     """
     libvirtMock will raise an error when nodeDeviceLookupByName is called.
     When getLibVersion is called
     (used by libvirtconnection to recognize disconnections)
     it will not raise an error -> in that case an error should be raised
     ('Unknown libvirterror').
     """
     connection = libvirtconnection.get(killOnFailure=True)
     LibvirtMock.virConnect.failNodeDeviceLookupByName = True
     LibvirtMock.virConnect.failGetLibVersion = False
     self.assertRaises(LibvirtMock.libvirtError,
                       connection.nodeDeviceLookupByName)
开发者ID:mydaisy2,项目名称:vdsm,代码行数:13,代码来源:libvirtconnectionTests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python netconfpersistence.RunningConfig类代码示例发布时间:2022-05-26
下一篇:
Python jobs.add函数代码示例发布时间: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