def repositories(self): """ get module repositories """ self._repositories = [] repositories = self._desc.get("repositories", []) if repositories: # Don't return repositories already installed for repository in repositories: repository['url'] = repository['url'].replace('@ARCH@', ModuleManager().arch) if 'url' in repository and not grep(repository['url'].split('://')[1], '/etc/urpmi/urpmi.cfg'): repository['module_slug'] = self.slug self._repositories.append(Media(**repository)) return self._repositories
def get_interfaces(): CONFIG_DIR = "/etc/sysconfig/network-scripts" for interface in netifaces.interfaces(): if interface.startswith(MANAGED_INTERFACE_NAMES): if_file = os.path.join(CONFIG_DIR, "ifcfg-%s" % interface) if_detail = netifaces.ifaddresses(interface) configured = os.path.exists(if_file) and netifaces.AF_INET in if_detail if configured: if grep("BOOTPROTO=dhcp", if_file): method = "dhcp" else: method = "static" addr = if_detail[netifaces.AF_INET][0]['addr'] yield (interface, addr, method)
def check_configured(): return grep('mirror.mandriva.com/mbs1/x86_64', '/etc/urpmi/urpmi.cfg')
def get_interfaces_config(config): """ Dynamic configuration for ethernet interfaces """ CONFIG_DIR = "/etc/sysconfig/network-scripts" for interface in netifaces.interfaces(): if interface.startswith(MANAGED_INTERFACE_NAMES): interface_id = re.sub(r'[a-z]', '', interface) if_file = os.path.join(CONFIG_DIR, "ifcfg-%s" % interface) if_detail = netifaces.ifaddresses(interface) configured = os.path.exists(if_file) and netifaces.AF_INET in if_detail method = "none" addr = "" netmask = "" dns1 = "" dns2 = "" domain = "" gateway = "" type = "" with open('/etc/shorewall/interfaces') as h: for line in h.readlines(): if interface in line: type = line.split()[0] break # need a type even if not configured if not configured: type = "none" else: type = "lan" + interface_id if configured: if grep("BOOTPROTO=dhcp", if_file): method = "dhcp" else: method = "static" addr = if_detail[netifaces.AF_INET][0]['addr'] netmask = if_detail[netifaces.AF_INET][0]['netmask'] dns1 = get_config_option(if_file, "DNS1") dns2 = get_config_option(if_file, "DNS2") domain = get_config_option(if_file, "DOMAIN") gateway = get_config_option(if_file, "GATEWAY") if addr: title = _("Interface %(int_name)s (%(addr)s)", "network") % {'int_name': interface, 'addr': addr} else: title = _("Interface %(int_name)s (no IP address)", "network") % {'int_name': interface} config.append({'slug': 'network', 'type': 'subtitle', 'label': title}) config.append({'slug': 'network', 'name': interface + '_name', 'type': 'text', 'hidden': 'yes', 'default': interface}) config.append({'slug': 'network', 'name': interface + '_type', 'require': 'yes', 'default': type, 'label': _('Interface type', 'network'), 'help': _('Choose "External" if the interface is connected to the Internet. If the interface is connected to an internal network, choose "Internal"', 'network'), 'type': 'options', 'options': [ {'name': _('No configuration', 'network'), 'value': 'none'}, {'name': _('Internal network', 'network'), 'value': 'lan' + interface_id}, {'name': _('External network', 'network'), 'value': 'wan' + interface_id} ] }) config.append({'slug': 'network', 'name': interface + '_method', 'default': method, 'require': 'yes', 'label': _('Configuration method', 'network'), 'type': 'options', 'options': [ {'name': _('No configuration', 'network'), 'value': 'none'}, {'name': _('DHCP configuration', 'network'), 'value': 'dhcp'}, {'name': _('Manual configuration', 'network'), 'value': 'static', 'toggle': [interface + '_addr', interface + '_netmask', interface + '_dns1', interface + '_dns2', interface + '_domain', interface + '_gateway']} ] }) config.append({'slug': 'network', 'name': interface + '_addr', 'default': addr, 'label': _('IP Address', 'network'), 'type': 'text', 'validation': 'ip'}) config.append({'slug': 'network', 'name': interface + '_netmask', 'default': netmask, 'label': _('Netmask', 'network'), 'type': 'text', 'validation': 'ip'}) config.append({'slug': 'network', 'name': interface + '_dns1', 'default': dns1, 'label': _('First DNS server', 'network'), 'type': 'text', 'validation': 'ip'}) config.append({'slug': 'network', 'name': interface + '_dns2', 'default': dns2, 'label': _('Second DNS server', 'network'), 'type': 'text', 'validation': 'ip'}) config.append({'slug': 'network', 'name': interface + '_domain', 'default': domain, 'label': _('Domain search', 'network'), 'type': 'text', 'validation': 'fqdn'}) config.append({'slug': 'network', 'name': interface + '_gateway', 'default': gateway, 'label': _('Gateway', 'network'), 'type': 'text', 'validation': 'ip'}) config.append({'slug': 'network', 'type': 'subtitle', 'label': _('Firewall configuration', 'network')}) config.append({'slug': 'network', 'name': 'fw_mss_lan', 'default': 'on', 'label': _('Allow access to Management Server Setup from internal networks', 'network'), 'type': 'check'}) config.append({'slug': 'network', 'name': 'fw_ssh_lan', 'default': 'on', 'label': _('Allow SSH access from internal networks', 'network'), 'type': 'check'}) config.append({'slug': 'network', 'name': 'fw_mss_wan', 'default': 'off', 'label': _('Allow access to Management Server Setup from external networks', 'network'), 'type': 'check'}) config.append({'slug': 'network', 'name': 'fw_ssh_wan', 'default': 'on', 'label': _('Allow SSH access from external networks', 'network'), 'type': 'check'}) return config
def get_interfaces_config(config): """ Dynamic configuration for ethernet interfaces """ CONFIG_DIR = "/etc/sysconfig/network-scripts" for interface in netifaces.interfaces(): if interface.startswith(MANAGED_INTERFACE_NAMES): interface_id = re.sub(r'[a-z]', '', interface) if_file = os.path.join(CONFIG_DIR, "ifcfg-%s" % interface) if_detail = netifaces.ifaddresses(interface) configured = os.path.exists( if_file) and netifaces.AF_INET in if_detail method = "none" addr = "" netmask = "" dns1 = "" dns2 = "" domain = "" gateway = "" type = "" with open('/etc/shorewall/interfaces') as h: for line in h.readlines(): if interface in line: type = line.split()[0] break # need a type even if not configured if not configured: type = "none" else: type = "lan" + interface_id if configured: if grep("BOOTPROTO=dhcp", if_file): method = "dhcp" else: method = "static" addr = if_detail[netifaces.AF_INET][0]['addr'] netmask = if_detail[netifaces.AF_INET][0]['netmask'] dns1 = get_config_option(if_file, "DNS1") dns2 = get_config_option(if_file, "DNS2") domain = get_config_option(if_file, "DOMAIN") gateway = get_config_option(if_file, "GATEWAY") if addr: title = _("Interface %(int_name)s (%(addr)s)", "network") % { 'int_name': interface, 'addr': addr } else: title = _("Interface %(int_name)s (no IP address)", "network") % { 'int_name': interface } config.append({ 'slug': 'network', 'type': 'subtitle', 'label': title }) config.append({ 'slug': 'network', 'name': interface + '_name', 'type': 'text', 'hidden': 'yes', 'default': interface }) config.append({ 'slug': 'network', 'name': interface + '_type', 'require': 'yes', 'default': type, 'label': _('Interface type', 'network'), 'help': _( 'Choose "External" if the interface is connected to the Internet. If the interface is connected to an internal network, choose "Internal"', 'network'), 'type': 'options', 'options': [{ 'name': _('No configuration', 'network'), 'value': 'none' }, { 'name': _('Internal network', 'network'), 'value': 'lan' + interface_id }, { 'name': _('External network', 'network'), 'value': 'wan' + interface_id }] }) config.append({ 'slug': 'network', 'name': interface + '_method', 'default': method, 'require': 'yes', 'label': _('Configuration method', 'network'), 'type': 'options', 'options': [{ 'name': _('No configuration', 'network'), 'value': 'none' }, { 'name': _('DHCP configuration', 'network'), 'value': 'dhcp' }, { 'name': _('Manual configuration', 'network'), 'value': 'static', 'toggle': [ interface + '_addr', interface + '_netmask', interface + '_dns1', interface + '_dns2', interface + '_domain', interface + '_gateway' ] }] }) config.append({ 'slug': 'network', 'name': interface + '_addr', 'default': addr, 'label': _('IP Address', 'network'), 'type': 'text', 'validation': 'ip' }) config.append({ 'slug': 'network', 'name': interface + '_netmask', 'default': netmask, 'label': _('Netmask', 'network'), 'type': 'text', 'validation': 'ip' }) config.append({ 'slug': 'network', 'name': interface + '_dns1', 'default': dns1, 'label': _('First DNS server', 'network'), 'type': 'text', 'validation': 'ip' }) config.append({ 'slug': 'network', 'name': interface + '_dns2', 'default': dns2, 'label': _('Second DNS server', 'network'), 'type': 'text', 'validation': 'ip' }) config.append({ 'slug': 'network', 'name': interface + '_domain', 'default': domain, 'label': _('Domain search', 'network'), 'type': 'text', 'validation': 'fqdn' }) config.append({ 'slug': 'network', 'name': interface + '_gateway', 'default': gateway, 'label': _('Gateway', 'network'), 'type': 'text', 'validation': 'ip' }) config.append({ 'slug': 'network', 'type': 'subtitle', 'label': _('Firewall configuration', 'network') }) config.append({ 'slug': 'network', 'name': 'fw_mss_lan', 'default': 'on', 'label': _('Allow access to Management Server Setup from internal networks', 'network'), 'type': 'check' }) config.append({ 'slug': 'network', 'name': 'fw_ssh_lan', 'default': 'on', 'label': _('Allow SSH access from internal networks', 'network'), 'type': 'check' }) config.append({ 'slug': 'network', 'name': 'fw_mss_wan', 'default': 'off', 'label': _('Allow access to Management Server Setup from external networks', 'network'), 'type': 'check' }) config.append({ 'slug': 'network', 'name': 'fw_ssh_wan', 'default': 'on', 'label': _('Allow SSH access from external networks', 'network'), 'type': 'check' }) return config
def get_interfaces_config(config): """ Dynamic configuration for ethernet interfaces """ CONFIG_DIR = "/etc/sysconfig/network-scripts" for interface in netifaces.interfaces(): if interface.startswith("eth"): if_file = os.path.join(CONFIG_DIR, "ifcfg-%s" % interface) if_detail = netifaces.ifaddresses(interface) configured = os.path.exists( if_file) and netifaces.AF_INET in if_detail method = "none" addr = "" netmask = "" dns1 = "" dns2 = "" domain = "" gateway = "" if configured: if grep("BOOTPROTO=dhcp", if_file): method = "dhcp" else: method = "static" addr = if_detail[netifaces.AF_INET][0]['addr'] netmask = if_detail[netifaces.AF_INET][0]['netmask'] dns1 = get_config_option(if_file, "DNS1") dns2 = get_config_option(if_file, "DNS2") domain = get_config_option(if_file, "DOMAIN") gateway = get_config_option(if_file, "GATEWAY") config.append({ 'slug': 'network', 'type': 'subtitle', 'label': interface }) config.append({ 'slug': 'network', 'name': interface + '_name', 'type': 'text', 'hidden': 'yes', 'default': interface }) config.append({ 'slug': 'network', 'name': interface + '_type', 'require': 'yes', 'label': _('Interface type', 'network'), 'help': _( 'Choose "External" if the interface is connected to the Internet. If the interface is connected to an internal network, choose "Internal"', 'network'), 'type': 'options', 'options': [{ 'name': _('Internal network', 'network'), 'value': 'lan' + interface[-1] }, { 'name': _('External network', 'network'), 'value': 'wan' + interface[-1] }] }) config.append({ 'slug': 'network', 'name': interface + '_method', 'default': method, 'require': 'yes', 'label': _('Configuration method', 'network'), 'type': 'options', 'options': [{ 'name': _('No configuration', 'network'), 'value': 'none' }, { 'name': _('DHCP configuration', 'network'), 'value': 'dhcp' }, { 'name': _('Manual configuration', 'network'), 'value': 'static', 'toggle': [ interface + '_addr', interface + '_netmask', interface + '_dns1', interface + '_dns2', interface + '_domain', interface + '_gateway' ] }] }) config.append({ 'slug': 'network', 'name': interface + '_addr', 'default': addr, 'label': _('IP Address', 'network'), 'type': 'text', 'validation': 'ip' }) config.append({ 'slug': 'network', 'name': interface + '_netmask', 'default': netmask, 'label': _('Netmask', 'network'), 'type': 'text', 'validation': 'ip' }) config.append({ 'slug': 'network', 'name': interface + '_dns1', 'default': dns1, 'label': _('First DNS server', 'network'), 'type': 'text', 'validation': 'ip' }) config.append({ 'slug': 'network', 'name': interface + '_dns2', 'default': dns2, 'label': _('Second DNS server', 'network'), 'type': 'text', 'validation': 'ip' }) config.append({ 'slug': 'network', 'name': interface + '_domain', 'default': domain, 'label': _('Domain search', 'network'), 'type': 'text', 'validation': 'fqdn' }) config.append({ 'slug': 'network', 'name': interface + '_gateway', 'default': gateway, 'label': _('Gateway', 'network'), 'type': 'text', 'validation': 'ip' }) config.append({ 'slug': 'network', 'type': 'subtitle', 'label': _('Firewall configuration', 'network') }) config.append({ 'slug': 'network', 'name': 'fw_mss_lan', 'default': 'on', 'label': _('Allow access to Mandriva Server Setup from internal networks', 'network'), 'type': 'check' }) config.append({ 'slug': 'network', 'name': 'fw_ssh_lan', 'default': 'on', 'label': _('Allow SSH access from internal networks', 'network'), 'type': 'check' }) config.append({ 'slug': 'network', 'name': 'fw_mss_wan', 'default': 'off', 'label': _('Allow access to Mandriva Server Setup from external networks', 'network'), 'type': 'check' }) config.append({ 'slug': 'network', 'name': 'fw_ssh_wan', 'default': 'on', 'label': _('Allow SSH access from external networks', 'network'), 'type': 'check' }) return config