def read_status_datas(): status_text = [] if network_up(): network_status = {} client = gudev.Client(['net']) # reload augeas tree aug.load() for nic in client.query_by_subsystem("net"): try: interface = nic.get_property("INTERFACE") logger.debug(interface) if not interface == "lo": if(has_ip_address(interface) or get_ipv6_address(interface)): ipv4_address = get_ip_address(interface) try: ipv6_address, netmask = get_ipv6_address(interface) except: ipv6_address = "" network_status[interface] = ( ipv4_address, ipv6_address) except: pass # remove parent/bridge duplicates for key in sorted(network_status.iterkeys()): if key.startswith("br"): parent_dev = key[+2:] if network_status.has_key(parent_dev): del network_status[parent_dev] for key in sorted(network_status.iterkeys()): ipv4_addr, ipv6_addr = network_status[key] cmd = "/files/etc/sysconfig/network-scripts/" +\ "ifcfg-%s/BOOTPROTO" % str(key) dev_bootproto = augtool_get(cmd) if dev_bootproto is None: cmd = "/files/etc/sysconfig/network-scripts/" +\ "ifcfg-br%s/BOOTPROTO" % str(key) dev_bootproto = augtool_get(cmd) if dev_bootproto is None: dev_bootproto = "Disabled" if not nic_link_detected(key): ipv4_addr = "(Link Inactive)" if ipv4_addr.strip() == "" and dev_bootproto.strip() == "dhcp": if "Inactive" in ipv4_addr: ipv4_addr = "(Link Inactive)" else: ipv4_addr = "(DHCP Failed)" if OVIRT_VARS.has_key("OVIRT_IPV6") and ipv6_addr != "": pass else: ipv6_addr = "" status_text.append([key.strip(), dev_bootproto.strip(), ipv4_addr.strip(), ipv6_addr.strip()]) logger.debug(status_text) logger.debug(network_status) else: status_text.append(["Not Connected", "", "", ""]) return status_text
def __init__(self, treeview_datas): super(NetworkDetail, self).__init__('network_detail', 'invisible_tab') ifname = treeview_datas[0] (self.dev_interface, dev_bootproto, dev_vendor, dev_address, dev_driver, dev_conf_status, dev_bridge) =\ datautil.read_nics(lambda allinfos: allinfos[0][ifname].split(',')) if nic_link_detected(ifname): link_status = "Active" else: link_status = "Inactive" network_detail_if = WidgetBase( 'interface', 'Label', '', get_conf=lambda: _("Interface: ") + self.dev_interface) network_detail_driver = WidgetBase( 'driver', 'Label', '', get_conf=lambda: _("Driver: ") + dev_driver) network_detail_proto = WidgetBase( 'protocol', 'Label', '', get_conf=lambda: _('Protocol: ') + dev_bootproto) network_detail_vendor = WidgetBase( 'vendor', 'Label', '', get_conf=lambda: _('Vendor: ') + dev_vendor) network_detail_link_status = WidgetBase( 'link_status', 'Label', '', get_conf=lambda: _('Link Status: ') + link_status) network_detail_mac_address = WidgetBase( 'mac_address', 'Label', '', get_conf=lambda: _('Mac Address: ') + dev_address) network_detail_ipv4_setting_label = WidgetBase('ipv4_setting', 'Label', _('IPV4 Settings:')) network_detail_ipv4_settings = WidgetBase('ipv4_settings', RadioButtonList, '', params={ 'labels': ['Disable', 'Static'], 'type': 'CheckButton' }) network_detail_ipv4_address = WidgetBase('ipv4_address', 'Label', 'IP Address:') network_detail_ipv4_address_val = WidgetBase( 'ipv4_address', 'Entry', set_conf=datautil.augtool_set, conf_path=NIC_IP_PATH) network_detail_ipv4_netmask = WidgetBase('ipv4_netmask', 'Label', 'Netmask:') network_detail_ipv4_netmask_val = WidgetBase( 'ipv4_netmask', 'Entry', set_conf=datautil.augtool_set, conf_path=NIC_NETMASK_PATH) network_detail_ipv4_gateway = WidgetBase('ipv4_gateway', 'Label', 'Gateway:') network_detail_ipv4_gateway_val = WidgetBase( 'ipv4_gateway', 'Entry', set_conf=datautil.augtool_set, conf_path=NIC_GATEWAY_PATH) network_detail_vlan_id = WidgetBase('vlan_id', 'Label', _('Vlan Id')) network_detail_vlan_id_val = WidgetBase('vlan_id', 'Entry', '') network_detail_back = WidgetBase('ipv4_back', ButtonList, '', params={ 'labels': ['Back'], 'callback': [self.network_detail_back] }) network_change = WidgetBase('network_detail_apply_reset', ApplyResetBtn, params={'apply_cb': self.network_apply_cb}) self.append([ (network_detail_if, network_detail_driver), (network_detail_proto, network_detail_vendor), (network_detail_link_status, network_detail_mac_address), (WidgetBase('empty', 'Label', '', vhelp=30), ), (network_detail_ipv4_setting_label, ), (network_detail_ipv4_settings, ), (network_detail_ipv4_address, network_detail_ipv4_address_val), (network_detail_ipv4_netmask, network_detail_ipv4_netmask_val), (network_detail_ipv4_gateway, network_detail_ipv4_gateway_val), (WidgetBase('empty', 'Label', '', vhelp=30), ), ( network_detail_vlan_id, network_detail_vlan_id_val, ), ( network_change, network_detail_back, ) ])
def read_status_datas(): status_text = [] if network_up(): network_status = {} client = gudev.Client(['net']) # reload augeas tree aug.load() for nic in client.query_by_subsystem("net"): try: interface = nic.get_property("INTERFACE") logger.debug(interface) if not interface == "lo": if (has_ip_address(interface) or get_ipv6_address(interface)): ipv4_address = get_ip_address(interface) try: ipv6_address, netmask = get_ipv6_address(interface) except: ipv6_address = "" network_status[interface] = (ipv4_address, ipv6_address) except: pass # remove parent/bridge duplicates for key in sorted(network_status.iterkeys()): if key.startswith("br"): parent_dev = key[+2:] if network_status.has_key(parent_dev): del network_status[parent_dev] for key in sorted(network_status.iterkeys()): ipv4_addr, ipv6_addr = network_status[key] cmd = "/files/etc/sysconfig/network-scripts/" +\ "ifcfg-%s/BOOTPROTO" % str(key) dev_bootproto = augtool_get(cmd) if dev_bootproto is None: cmd = "/files/etc/sysconfig/network-scripts/" +\ "ifcfg-br%s/BOOTPROTO" % str(key) dev_bootproto = augtool_get(cmd) if dev_bootproto is None: dev_bootproto = "Disabled" if not nic_link_detected(key): ipv4_addr = "(Link Inactive)" if ipv4_addr.strip() == "" and dev_bootproto.strip() == "dhcp": if "Inactive" in ipv4_addr: ipv4_addr = "(Link Inactive)" else: ipv4_addr = "(DHCP Failed)" if OVIRT_VARS.has_key("OVIRT_IPV6") and ipv6_addr != "": pass else: ipv6_addr = "" status_text.append([ key.strip(), dev_bootproto.strip(), ipv4_addr.strip(), ipv6_addr.strip() ]) logger.debug(status_text) logger.debug(network_status) else: status_text.append(["Not Connected", "", "", ""]) return status_text
def __init__(self, treeview_datas): super(NetworkDetail, self).__init__("network_detail", "invisible_tab") ifname = treeview_datas[0] ( self.dev_interface, dev_bootproto, dev_vendor, dev_address, dev_driver, dev_conf_status, dev_bridge, ) = datautil.read_nics(lambda allinfos: allinfos[0][ifname].split(",")) if nic_link_detected(ifname): link_status = "Active" else: link_status = "Inactive" network_detail_if = WidgetBase("interface", "Label", "", get_conf=lambda: _("Interface: ") + self.dev_interface) network_detail_driver = WidgetBase("driver", "Label", "", get_conf=lambda: _("Driver: ") + dev_driver) network_detail_proto = WidgetBase("protocol", "Label", "", get_conf=lambda: _("Protocol: ") + dev_bootproto) network_detail_vendor = WidgetBase("vendor", "Label", "", get_conf=lambda: _("Vendor: ") + dev_vendor) network_detail_link_status = WidgetBase( "link_status", "Label", "", get_conf=lambda: _("Link Status: ") + link_status ) network_detail_mac_address = WidgetBase( "mac_address", "Label", "", get_conf=lambda: _("Mac Address: ") + dev_address ) network_detail_ipv4_setting_label = WidgetBase("ipv4_setting", "Label", _("IPV4 Settings:")) network_detail_ipv4_settings = WidgetBase( "ipv4_settings", RadioButtonList, "", params={"labels": ["Disable", "Static"], "type": "CheckButton"} ) network_detail_ipv4_address = WidgetBase("ipv4_address", "Label", "IP Address:") network_detail_ipv4_address_val = WidgetBase( "ipv4_address", "Entry", set_conf=datautil.augtool_set, conf_path=NIC_IP_PATH ) network_detail_ipv4_netmask = WidgetBase("ipv4_netmask", "Label", "Netmask:") network_detail_ipv4_netmask_val = WidgetBase( "ipv4_netmask", "Entry", set_conf=datautil.augtool_set, conf_path=NIC_NETMASK_PATH ) network_detail_ipv4_gateway = WidgetBase("ipv4_gateway", "Label", "Gateway:") network_detail_ipv4_gateway_val = WidgetBase( "ipv4_gateway", "Entry", set_conf=datautil.augtool_set, conf_path=NIC_GATEWAY_PATH ) network_detail_vlan_id = WidgetBase("vlan_id", "Label", _("Vlan Id")) network_detail_vlan_id_val = WidgetBase("vlan_id", "Entry", "") network_detail_back = WidgetBase( "ipv4_back", ButtonList, "", params={"labels": ["Back"], "callback": [self.network_detail_back]} ) network_change = WidgetBase( "network_detail_apply_reset", ApplyResetBtn, params={"apply_cb": self.network_apply_cb} ) self.append( [ (network_detail_if, network_detail_driver), (network_detail_proto, network_detail_vendor), (network_detail_link_status, network_detail_mac_address), (WidgetBase("empty", "Label", "", vhelp=30),), (network_detail_ipv4_setting_label,), (network_detail_ipv4_settings,), (network_detail_ipv4_address, network_detail_ipv4_address_val), (network_detail_ipv4_netmask, network_detail_ipv4_netmask_val), (network_detail_ipv4_gateway, network_detail_ipv4_gateway_val), (WidgetBase("empty", "Label", "", vhelp=30),), (network_detail_vlan_id, network_detail_vlan_id_val), (network_change, network_detail_back), ] )
def __init__(self, treeview_datas): super(NetworkDetail, self).__init__('network_detail', 'invisible_tab') ifname = treeview_datas[0] (self.dev_interface, dev_bootproto, dev_vendor, dev_address, dev_driver, dev_conf_status, dev_bridge) =\ datautil.read_nics(lambda allinfos: allinfos[0][ifname].split(',')) if nic_link_detected(ifname): link_status = "Active" else: link_status = "Inactive" network_detail_if = WidgetBase( 'interface', 'Label', '', get_conf=lambda: _("Interface: ") + self.dev_interface) network_detail_driver = WidgetBase( 'driver', 'Label', '', get_conf=lambda: _("Driver: ") + dev_driver) network_detail_proto = WidgetBase( 'protocol', 'Label', '', get_conf=lambda: _('Protocol: ') + dev_bootproto) network_detail_vendor = WidgetBase( 'vendor', 'Label', '', get_conf=lambda: _('Vendor: ') + dev_vendor) network_detail_link_status = WidgetBase( 'link_status', 'Label', '', get_conf=lambda: _('Link Status: ') + link_status) network_detail_mac_address = WidgetBase( 'mac_address', 'Label', '', get_conf=lambda: _('Mac Address: ') + dev_address) network_detail_ipv4_setting_label = WidgetBase( 'ipv4_setting', 'Label', _('IPV4 Settings:')) network_detail_ipv4_settings = WidgetBase( 'ipv4_settings', RadioButtonList, '', params={'labels': ['Disable', 'Static'], 'type': 'CheckButton'}) network_detail_ipv4_address = WidgetBase( 'ipv4_address', 'Label', 'IP Address:') network_detail_ipv4_address_val = WidgetBase( 'ipv4_address', 'Entry', set_conf=datautil.augtool_set, conf_path=NIC_IP_PATH) network_detail_ipv4_netmask = WidgetBase( 'ipv4_netmask', 'Label', 'Netmask:') network_detail_ipv4_netmask_val = WidgetBase( 'ipv4_netmask', 'Entry', set_conf=datautil.augtool_set, conf_path=NIC_NETMASK_PATH) network_detail_ipv4_gateway = WidgetBase( 'ipv4_gateway', 'Label', 'Gateway:') network_detail_ipv4_gateway_val = WidgetBase( 'ipv4_gateway', 'Entry', set_conf=datautil.augtool_set, conf_path=NIC_GATEWAY_PATH) network_detail_vlan_id = WidgetBase('vlan_id', 'Label', _('Vlan Id')) network_detail_vlan_id_val = WidgetBase('vlan_id', 'Entry', '') network_detail_back = WidgetBase( 'ipv4_back', ButtonList, '', params={'labels': ['Back'], 'callback': [self.network_detail_back]}) network_change = WidgetBase( 'network_detail_apply_reset', ApplyResetBtn, params={'apply_cb': self.network_apply_cb}) self.append([ (network_detail_if, network_detail_driver), (network_detail_proto, network_detail_vendor), (network_detail_link_status, network_detail_mac_address), (WidgetBase('empty', 'Label', '', vhelp=30),), (network_detail_ipv4_setting_label,), (network_detail_ipv4_settings,), (network_detail_ipv4_address, network_detail_ipv4_address_val), (network_detail_ipv4_netmask, network_detail_ipv4_netmask_val), (network_detail_ipv4_gateway, network_detail_ipv4_gateway_val), (WidgetBase('empty', 'Label', '', vhelp=30),), (network_detail_vlan_id, network_detail_vlan_id_val,), (network_change, network_detail_back,)])