Estadísticas del código: Clase para configurar el archivo dhcpd.conf de nuestro servidor - Python

Imágen de perfil
Val: 666
Bronce
Ha disminuido 1 puesto en Python (en relación al último mes)
Gráfica de Python

Clase para configurar el archivo dhcpd.conf de nuestro servidor


Python

estrellaestrellaestrellaestrellaestrella(1)
Publicado el 26 de Junio del 2019 por Xavi (548 códigos)
1.709 visualizaciones desde el 26 de Junio del 2019
Clase para gestionar el archivo dhcpd.conf de nuestro servidor

readFile() -> lea el archivo dhcpd recibido en el constructor y ponga los datos en dos listas
getValue() -> devuelve el valor de la clave recibida
setValue() -> actualizar el valor si existe o agregar un nuevo valor si no existe
removeValue() -> eliminar valores
clearSubnet() -> elimina las subredes creadas o leídas del archivo
newSubnet() -> crea una nueva subred
getSubnetNumber() -> devuelve el número de subredes
getSubnetValue() -> devuelve el valor de la subred indicada
setSubnetValue() -> agregar o actualizar valores de la subred
guardar() -> guardar cualquier cambio en el archivo

Un archivo de configuración es similar a:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
option domain-name "example.org";                               getValue(), setValue()
option domain-name-servers ns1.example.org, ns2.example.org;    getValue(), setValue()
default-lease-time 600;                                         getValue(), setValue()
max-lease-time 7200;                                            getValue(), setValue()
subnet 10.5.5.0 netmask 255.255.255.224 {                       getSubnetNumber(), newSubnet(), clearSubnet(), getSubnetValue()
    range 10.5.5.26 10.5.5.30;                                  setSubnetValue(), getSubnetValue()
    option domain-name-servers ns1.internal.example.org;        setSubnetValue(), getSubnetValue()
    option domain-name "internal.example.org";                  setSubnetValue(), getSubnetValue()
    option routers 10.5.5.1;                                    setSubnetValue(), getSubnetValue()
    option broadcast-address 10.5.5.31;                         setSubnetValue(), getSubnetValue()
    default-lease-time 600;                                     setSubnetValue(), getSubnetValue()
    max-lease-time 7200;                                        setSubnetValue(), getSubnetValue()
}
subnet 10.10.10.0 netmask 255.255.255.0 {                       getSubnetNumber(), newSubnet(), clearSubnet(), getSubnetValue()
    range 10.10.10.200 10.10.10.230;                            setSubnetValue(), getSubnetValue()
    option domain-name-servers 8.8.8.8;                         setSubnetValue(), getSubnetValue()
    option domain-name "internal.example.org";                  setSubnetValue(), getSubnetValue()
    option routers 10.10.10.1;                                  setSubnetValue(), getSubnetValue()
    option broadcast-address 10.10.10.255;                      setSubnetValue(), getSubnetValue()
}

53 visualizaciones durante los últimos 90 días


4
0