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

Python nm.nm_activated_devices函数代码示例

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

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



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

示例1: _update_network_data

    def _update_network_data(self):
        hostname = self.data.network.hostname

        self.data.network.network = []
        for i, name in enumerate(nm.nm_devices()):
            if network.is_ibft_configured_device(name):
                continue
            nd = network.ksdata_from_ifcfg(name)
            if not nd:
                continue
            if name in nm.nm_activated_devices():
                nd.activate = True
            else:
                # First network command defaults to --activate so we must
                # use --no-activate explicitly to prevent the default
                if i == 0:
                    nd.activate = False
            self.data.network.network.append(nd)

        (valid, error) = network.sanityCheckHostname(self.hostname_dialog.value)
        if valid:
            hostname = self.hostname_dialog.value
        else:
            self.errors.append(_("Host name is not valid: %s") % error)
            self.hostname_dialog.value = hostname
        network.update_hostname_data(self.data, hostname)
开发者ID:dougsland,项目名称:anaconda,代码行数:26,代码来源:network.py


示例2: completed

 def completed(self):
     """ Check whether this spoke is complete or not. Do an additional
         check if we're installing from CD/DVD, since a network connection
         should not be required in this case.
     """
     return (not can_touch_runtime_system("require network connection")
             or nm.nm_activated_devices())
开发者ID:dougsland,项目名称:anaconda,代码行数:7,代码来源:network.py


示例3: getHostname

def getHostname():

    hn = None

    # First address (we prefer ipv4) of last device (as it used to be) wins
    for dev in nm.nm_activated_devices():
        addrs = (nm.nm_device_ip_addresses(dev, version=4) +
                 nm.nm_device_ip_addresses(dev, version=6))
        for ipaddr in addrs:
            try:
                hinfo = socket.gethostbyaddr(ipaddr)
            except socket.herror as e:
                log.debug("Exception caught trying to get host name of %s: %s", ipaddr, e)
            else:
                if len(hinfo) == 3:
                    hn = hinfo[0]
                    break

    if not hn or hn in ('(none)', 'localhost', 'localhost.localdomain'):
        hn = socket.gethostname()

    if not hn or hn in ('(none)', 'localhost', 'localhost.localdomain'):
        hn = DEFAULT_HOSTNAME

    return hn
开发者ID:mairin,项目名称:anaconda,代码行数:25,代码来源:network.py


示例4: _discover

    def _discover(self, credentials, bind):
        # This needs to be in its own thread, not marked with gtk_action_* because it's
        # called from on_start_clicked, which is in the GTK main loop.  Those decorators
        # won't do anything special in that case.
        if not self.iscsi.initiatorSet:
            self.iscsi.initiator = credentials.initiator

        # interfaces created here affect nodes that iscsi.discover would return
        if self.iscsi.mode == "none" and not bind:
            self.iscsi.delete_interfaces()
        elif (self.iscsi.mode == "bind"
              or self.iscsi.mode == "none" and bind):
            activated = set(nm.nm_activated_devices())
            created = set(self.iscsi.ifaces.values())
            self.iscsi.create_interfaces(activated - created)

        try:
            self._discoveredNodes = self.iscsi.discover(credentials.targetIP,
                                                        username=credentials.username,
                                                        password=credentials.password,
                                                        r_username=credentials.rUsername,
                                                        r_password=credentials.rPassword)
        except IOError as e:
            self._discoveryError = str(e)
            return

        if len(self._discoveredNodes) == 0:
            self._discoveryError = "No nodes discovered."
开发者ID:mairin,项目名称:anaconda,代码行数:28,代码来源:iscsi.py


示例5: get_device_name

def get_device_name(devspec):

    devices = nm.nm_devices()
    devname = None

    if not devspec:
        if "ksdevice" in flags.cmdline:
            msg = "ksdevice boot parameter"
            devname = ks_spec_to_device_name(flags.cmdline["ksdevice"])
        elif nm.nm_is_connected():
            # device activated in stage 1 by network kickstart command
            msg = "first active device"
            try:
                devname = nm.nm_activated_devices()[0]
            except IndexError:
                log.debug("get_device_name: NM is connected but no activated devices found")
        else:
            msg = "first device found"
            devname = min(devices)
        log.info("unspecified network --device in kickstart, using %s (%s)", devname, msg)
    else:
        if iutil.lowerASCII(devspec) == "ibft":
            devname = ""
        if iutil.lowerASCII(devspec) == "link":
            for dev in sorted(devices):
                try:
                    link_up = nm.nm_device_carrier(dev)
                except ValueError as e:
                    log.debug("get_device_name: %s", e)
                    continue
                if link_up:
                    devname = dev
                    break
            else:
                log.error("Kickstart: No network device with link found")
        elif iutil.lowerASCII(devspec) == "bootif":
            if "BOOTIF" in flags.cmdline:
                # MAC address like 01-aa-bb-cc-dd-ee-ff
                devname = flags.cmdline["BOOTIF"][3:]
                devname = devname.replace("-", ":")
            else:
                log.error("Using --device=bootif without BOOTIF= boot option supplied")
        else:
            devname = devspec

    if devname and devname not in devices:
        for d in devices:
            try:
                hwaddr = nm.nm_device_hwaddress(d)
            except ValueError as e:
                log.debug("get_device_name: %s", e)
                continue
            if hwaddr.lower() == devname.lower():
                devname = d
                break
        else:
            return ""

    return devname
开发者ID:uofis,项目名称:qubes-installer-qubes-os,代码行数:59,代码来源:network.py


示例6: getIPs

def getIPs():
    ips = []
    for devname in nm.nm_activated_devices():
        try:
            ips += nm.nm_device_ip_addresses(devname, version=4) + nm.nm_device_ip_addresses(devname, version=6)
        except (dbus.DBusException, ValueError) as e:
            log.warning("Got an exception trying to get the ip addr " "of %s: %s", devname, e)
    return ips
开发者ID:uofis,项目名称:qubes-installer-qubes-os,代码行数:8,代码来源:network.py


示例7: completed

 def completed(self):
     """ Check whether this spoke is complete or not. Do an additional
         check if we're installing from CD/DVD, since a network connection
         should not be required in this case.
     """
     localinst = bool(self.data.method.method in ["cdrom", "harddrive"])
     return (not can_touch_runtime_system("require network connection")
             or nm.nm_activated_devices() or localinst)
开发者ID:pombreda,项目名称:anaconda,代码行数:8,代码来源:network.py


示例8: wait_for_network_devices

def wait_for_network_devices(devices, timeout=constants.NETWORK_CONNECTION_TIMEOUT):
    devices = set(devices)
    i = 0
    log.debug("waiting for connection of devices %s for iscsi", devices)
    while i < timeout:
        if not devices - set(nm.nm_activated_devices()):
            return True
        i += 1
        time.sleep(1)
    return False
开发者ID:uofis,项目名称:qubes-installer-qubes-os,代码行数:10,代码来源:network.py


示例9: getIPs

def getIPs():
    ips = []
    for devname in nm.nm_activated_devices():
        try:
            ips += (nm.nm_device_ip_addresses(devname, version=4) +
                    nm.nm_device_ip_addresses(devname, version=6))
        except Exception as e:
            log.warning("Got an exception trying to get the ip addr "
                        "of %s: %s" % (devname, e))
    return ips
开发者ID:cs2c-zhangchao,项目名称:nkwin1.0-anaconda,代码行数:10,代码来源:network.py


示例10: _summary_text

 def _summary_text(self):
     """Devices cofiguration shown to user."""
     msg = ""
     activated_devs = nm.nm_activated_devices()
     for name in self.supported_devices:
         if name in activated_devs:
             msg += self._activated_device_msg(name)
         else:
             msg += _("Wired (%(interface_name)s) disconnected\n") \
                 % {"interface_name": name}
     return msg
开发者ID:dougsland,项目名称:anaconda,代码行数:11,代码来源:network.py


示例11: getIPs

def getIPs():
    ipv4_addresses = []
    ipv6_addresses = []
    for devname in nm.nm_activated_devices():
        try:
            ipv4_addresses += nm.nm_device_ip_addresses(devname, version=4)
            ipv6_addresses += nm.nm_device_ip_addresses(devname, version=6)
        except (dbus.DBusException, ValueError) as e:
            log.warning("Got an exception trying to get the ip addr "
                        "of %s: %s", devname, e)
    # prefer IPv4 addresses to IPv6 addresses
    return ipv4_addresses + ipv6_addresses
开发者ID:akozumpl,项目名称:anaconda,代码行数:12,代码来源:network.py


示例12: _update_network_data

    def _update_network_data(self):
        hostname = self.data.network.hostname

        self.data.network.network = []
        for name in nm.nm_devices():
            nd = network.ksdata_from_ifcfg(name)
            if not nd:
                continue
            if name in nm.nm_activated_devices():
                nd.activate = True
            self.data.network.network.append(nd)

        (valid, error) = network.sanityCheckHostname(self.hostname_dialog.value)
        if valid:
            hostname = self.hostname_dialog.value
        else:
            self.errors.append(_("Host name is not valid: %s") % error)
            self.hostname_dialog.value = hostname
        network.update_hostname_data(self.data, hostname)
开发者ID:sujithshankar,项目名称:anaconda,代码行数:19,代码来源:network.py


示例13: status_message

def status_message():
    """ A short string describing which devices are connected. """

    msg = _("Unknown")

    state = nm.nm_state()
    if state == NetworkManager.State.CONNECTING:
        msg = _("Connecting...")
    elif state == NetworkManager.State.DISCONNECTING:
        msg = _("Disconnecting...")
    else:
        active_devs = nm.nm_activated_devices()
        if active_devs:

            slaves = {}
            ssids = {}

            # first find slaves and wireless aps
            for devname in active_devs:
                slaves[devname] = nm.nm_device_slaves(devname) or []
                if nm.nm_device_type_is_wifi(devname):
                    ssids[devname] = nm.nm_device_active_ssid(devname) or ""

            all_slaves = set(itertools.chain.from_iterable(slaves.values()))
            nonslaves = [dev for dev in active_devs if dev not in all_slaves]

            if len(nonslaves) == 1:
                devname = nonslaves[0]
                if nm.nm_device_type_is_ethernet(devname):
                    msg = _("Wired (%(interface_name)s) connected") % {"interface_name": devname}
                elif nm.nm_device_type_is_wifi(devname):
                    msg = _("Wireless connected to %(access_point)s") % {"access_point": ssids[devname]}
                elif nm.nm_device_type_is_bond(devname):
                    msg = _("Bond %(interface_name)s (%(list_of_slaves)s) connected") % {
                        "interface_name": devname,
                        "list_of_slaves": ",".join(slaves[devname]),
                    }
                elif nm.nm_device_type_is_team(devname):
                    msg = _("Team%(interface_name)s (%(list_of_slaves)s) connected") % {
                        "interface_name": devname,
                        "list_of_slaves": ",".join(slaves[devname]),
                    }
                elif nm.nm_device_type_is_vlan(devname):
                    parent = nm.nm_device_setting_value(devname, "vlan", "parent")
                    vlanid = nm.nm_device_setting_value(devname, "vlan", "id")
                    msg = _("Vlan %(interface_name)s (%(parent_device)s, ID %(vlanid)s) connected") % {
                        "interface_name": devname,
                        "parent_device": parent,
                        "vlanid": vlanid,
                    }
            elif len(nonslaves) > 1:
                devlist = []
                for devname in nonslaves:
                    if nm.nm_device_type_is_ethernet(devname):
                        devlist.append("%s" % devname)
                    elif nm.nm_device_type_is_wifi(devname):
                        devlist.append("%s" % ssids[devname])
                    elif nm.nm_device_type_is_bond(devname):
                        devlist.append("%s (%s)" % (devname, ",".join(slaves[devname])))
                    elif nm.nm_device_type_is_team(devname):
                        devlist.append("%s (%s)" % (devname, ",".join(slaves[devname])))
                    elif nm.nm_device_type_is_vlan(devname):
                        devlist.append("%s" % devname)
                msg = _("Connected: %(list_of_interface_names)s") % {"list_of_interface_names": ", ".join(devlist)}
        else:
            msg = _("Not connected")

    if not nm.nm_devices():
        msg = _("No network devices available")

    return msg
开发者ID:uofis,项目名称:qubes-installer-qubes-os,代码行数:71,代码来源:network.py


示例14: completed

 def completed(self):
     return (not can_touch_runtime_system("require network connection")
             or nm.nm_activated_devices())
开发者ID:Sabayon,项目名称:anaconda,代码行数:3,代码来源:network.py


示例15: completed

 def completed(self):
     """ Check whether this spoke is complete or not."""
     # If we can't configure network, don't require it
     return (not conf.system.can_configure_network
             or nm.nm_activated_devices())
开发者ID:zhangsju,项目名称:anaconda,代码行数:5,代码来源:network.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python nm.nm_devices函数代码示例发布时间:2022-05-25
下一篇:
Python services.STORAGE类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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