From 47bc0c0a9fd8fe43a78785e064ff9428bc1f63eb Mon Sep 17 00:00:00 2001 From: lgromero Date: Mon, 22 Apr 2024 12:50:26 +0200 Subject: [PATCH] refs #199 adds return parameters to pxe-templates --- README.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f1ceb3c..3593b45 100644 --- a/README.md +++ b/README.md @@ -330,6 +330,14 @@ Obtiene una lista de todos los archivos de arranque disponibles. ```bash curl -X GET -H "Authorization: $API_KEY" http://example.com/ogboot/v1/pxes + +{ + "boot_files": [ + "01-00:50:56:22:11:11", + "01-00:50:56:22:11:12" + ] +} + ``` **Respuestas:** @@ -337,20 +345,34 @@ curl -X GET -H "Authorization: $API_KEY" http://example.com/ogboot/v1/pxes - **Contenido:** Lista de archivos de arranque en formato JSON. -### Obtener Archivo de Arranque +### Obtener Configuración de Arranque -Obtiene un archivo de arranque específico utilizando la dirección MAC del cliente. +Obtiene el contenido del archivo de configuración de arranque específico para un cliente utilizando su dirección MAC. **URL:** `/ogboot/v1/clients/pxes/{mac}` **Método HTTP:** GET **Parámetros de la URL:** -- `{mac}`: La dirección MAC del cliente cuyo archivo de arranque se desea obtener. +- `{mac}`: La dirección MAC del cliente cuyo archivo de configuración de arranque se desea obtener. **Ejemplo de Solicitud:** ```bash curl -X GET -H "Authorization: $API_KEY" http://example.com/ogboot/v1/clients/pxes/00:11:22:33:44:55 + +#!ipxe +set timeout 0 +set timeout-style hidden + +set ISODIR ogLive +set default 0 +set kernelargs ro boot=oginit quiet splash irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=true ogdebug=true ogtmpfs=15 oglivedir=${ISODIR} LANG=es_ES.UTF-8 ip=192.168.2.11:192.168.2.1:192.168.2.1:255.255.255.0:pc11:eth0:none group=Aula_virtual ogrepo=192.168.2.1 oglive=192.168.2.1 oglog=192.168.2.1 ogshare=192.168.2.1 ogprof=false vga=788 + +set kernelargs ro boot=oginit quiet splash irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=true ogdebug=true ogtmpfs=15 oglivedir=$ISODIR LANG=es_ES.UTF-8 ip=192.168.2.11:192.168.2.1:192.168.2.1:255.255.255.0:pc11:eth0:none group=Aula_virtual ogrepo=192.168.2.1 oglive=192.168.2.1 oglog=192.168.2.1 ogshare=192.168.2.1 ogprof=false vga=788 +kernel tftp://172.17.8.71/ogLive/ogvmlinuz ${kernelargs} +initrd tftp://172.17.8.71/ogLive/oginitrd.img +boot + ``` **Respuestas:** @@ -373,7 +395,7 @@ Crea un nuevo archivo de arranque utilizando los parámetros proporcionados. **Ejemplo de Solicitud:** ```bash -curl -X POST -H "Authorization: $API_KEY" -d '{"name": "bootfile", "config": "some_configuration"}' http://example.com/ogboot/v1/pxes +curl -X POST -H "Authorization: $API_KEY" -d '{"mac": "00:50:56:22:11:12", "config": "#!ipxe\nset timeout 0\nset timeout-style hidden\n\nset ISODIR ogLive\nset default 0\nset kernelargs ro boot=oginit quiet splash irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=true ogdebug=true ogtmpfs=15 oglivedir=${ISODIR} LANG=es_ES.UTF-8 ip=192.168.2.11:192.168.2.1:192.168.2.1:255.255.255.0:pc11:eth0:none group=Aula_virtual ogrepo=192.168.2.1 oglive=192.168.2.1 oglog=192.168.2.1 ogshare=192.168.2.1 ogprof=false vga=788\n\nset kernelargs ro boot=oginit quiet splash irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=true ogdebug=true ogtmpfs=15 oglivedir=$ISODIR LANG=es_ES.UTF-8 ip=192.168.2.11:192.168.2.1:192.168.2.1:255.255.255.0:pc11:eth0:none group=Aula_virtual ogrepo=192.168.2.1 oglive=192.168.2.1 oglog=192.168.2.1 ogshare=192.168.2.1 ogprof=false vga=788\nkernel tftp://172.17.8.71/ogLive/ogvmlinuz ${kernelargs}\ninitrd tftp://172.17.8.71/ogLive/oginitrd.img\nboot"}' http://example.com/ogboot/v1/pxes ``` **Respuestas:** @@ -416,7 +438,7 @@ Actualiza el repositorio de archivos de arranque con los archivos modificados. **Ejemplo de Solicitud:** ```bash -curl -X PUT -H "Authorization: $API_KEY" -H "Content-Type: application/json" -d @data.json http://example.com/ogboot/v1/pxes +curl -X PUT -H "Authorization: $API_KEY" -H "Content-Type: application/json" -d '{"mac": "00:50:56:22:11:12", "config": "#!ipxe\nset timeout 0\nset timeout-style hidden\n\nset ISODIR ogLive\nset default 0\nset kernelargs ro boot=oginit quiet splash irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=true ogdebug=true ogtmpfs=15 oglivedir=${ISODIR} LANG=es_ES.UTF-8 ip=192.168.2.11:192.168.2.1:192.168.2.1:255.255.255.0:pc11:eth0:none group=Aula_virtual ogrepo=192.168.2.1 oglive=192.168.2.1 oglog=192.168.2.1 ogshare=192.168.2.1 ogprof=false vga=788\n\nset kernelargs ro boot=oginit quiet splash irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=true ogdebug=true ogtmpfs=15 oglivedir=$ISODIR LANG=es_ES.UTF-8 ip=192.168.2.11:192.168.2.1:192.168.2.1:255.255.255.0:pc11:eth0:none group=Aula_virtual ogrepo=192.168.2.1 oglive=192.168.2.1 oglog=192.168.2.1 ogshare=192.168.2.1 ogprof=false vga=788\nkernel tftp://172.17.8.71/ogLive/ogvmlinuz ${kernelargs}\ninitrd tftp://172.17.8.71/ogLive/oginitrd.img\nboot"}' http://example.com/ogboot/v1/pxes ``` **Respuestas:** @@ -458,6 +480,17 @@ Obtiene el contenido de una plantilla de arranque específica utilizando su nomb ```bash curl -X GET -H "Authorization: $API_KEY" http://example.com/ogboot/v1/pxe-templates/template1 + +#!ipxe +set timeout 0 +set timeout-style hidden + +set ISODIR ogLive +set default 0 +set kernelargs ro boot=oginit quiet splash irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=true ogdebug=true ogtmpfs=15 oglivedir=${ISODIR} LANG=es_ES.UTF-8 ip=192.168.1.100:192.168.1.1:192.168.1.1:255.255.255.0:pc01:eth0:none group=Aula_virtual ogrepo=192.168.1.10 oglive=192.168.1.10 oglog=192.168.1.10 ogshare=192.168.1.10 ogprof=false vga=788 +time kernel tftp://172.17.8.71/ogLive/ogvmlinuz ${kernelargs} +time initrd tftp://172.17.8.71/ogLive/oginitrd.img +boot ``` **Respuestas:** @@ -474,16 +507,43 @@ Crea una nueva plantilla de arranque utilizando los datos proporcionados. **Método HTTP:** POST **Cuerpo de la Solicitud:** -- Datos necesarios para la creación de la plantilla de arranque, como el nombre y el contenido. +- {name_template}: Nombre de la plantilla +- {ip}: Dirección IP del cliente. +- {gateway}: Puerta de enlace predeterminada. +- {netmask}: Máscara de red. +- {hostname}: Nombre del host del cliente. +- {interface}: Interfaz de red utilizada por el cliente. +- {group}: Grupo al que pertenece el cliente. +- {ogrepo}: Dirección IP del repositorio de ogLive. +- {oglive}: Dirección IP del servidor ogLive. +- {oglog}: Dirección IP del servidor de logs. +- {ogshare}: Dirección IP del servidor de archivos compartidos. +- {ogprof}: Valor booleano que indica si el perfil del cliente está habilitado o deshabilitado. +- {vga}: Modo VGA utilizado para la interfaz de usuario. **Ejemplo de Solicitud:** ```bash -curl -X POST -H "Authorization: $API_KEY" -H "Content-Type: application/json" -d '{"name": "template1", "content": "template_content"}' http://example.com/ogboot/v1/pxe-templates +curl -X POST -H "Authorization: $API_KEY" -H "Content-Type: application/json" -d '{"name_template":"template1","ip": "192.168.1.100", "gateway": "192.168.1.1", "netmask": "255.255.255.0", "hostname": "pc01", "interface": "eth0", "group": "Aula_virtual", "ogrepo": "192.168.1.10", "oglive": "192.168.1.10", "oglog": "192.168.1.10", "ogshare": "192.168.1.10", "ogprof": false, "vga": 788, "tftp_server_ip": "172.17.8.71"}' http://example.com/ogboot/v1/pxe-templates + + +#!ipxe +set timeout 0 +set timeout-style hidden + +set ISODIR ogLive +set default 0 +set kernelargs ro boot=oginit quiet splash irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=true ogdebug=true ogtmpfs=15 oglivedir=${ISODIR} LANG=es_ES.UTF-8 ip=192.168.1.100:192.168.1.1:192.168.1.1:255.255.255.0:pc01:eth0:none group=Aula_virtual ogrepo=192.168.1.10 oglive=192.168.1.10 oglog=192.168.1.10 ogshare=192.168.1.10 ogprof=false vga=788 +time kernel tftp://172.17.8.71/ogLive/ogvmlinuz ${kernelargs} +time initrd tftp://172.17.8.71/ogLive/oginitrd.img +boot + ``` + **Respuestas:** - **Código 200 OK:** La plantilla de arranque se creó exitosamente. + - **Contenido:** Plantilla generada a partir de los parámetros pasados en la petición. - **Código 400 Bad Request:** La solicitud no pudo ser procesada debido a un error en los datos proporcionados en el cuerpo de la solicitud.