# Documentation: Ocore and Oggui

## Scenario

We want to register a computer in the system and configure it so it can boot via PXE on a new subnet. This is the scenario:

- **Computer**:
  - MAC Address: `00:50:56:1e:9f:11`
  - Name: `pc11`
  - IP Address: `192.168.3.11`

- **Subnet**:
  - Address: `192.168.3.0`
  - Netmask: `255.255.255.0`

- **Boot Server**:
  - `next-server`: `172.17.8.37` (ogboot component hosting the boot files)
  - Boot File: `undionly.kpxe`

The objective is to create the subnet `192.168.2.0/24`, add the computer `pc11` to this subnet with IP `192.168.3.11`, and generate the custom boot file for `pc11` from the `ogLive` PXE template.

## Register a Computer

### Create an Organizational Unit (Classroom)

1. On the **Manage Groups** screen, click **New Organizational Unit**.
2. In the form:
   - Select **Type** as `Classroom`.
   - Assign a **Name** to the classroom, such as `Test Classroom`.
   - Choose a **Parent Organizational Unit**, for example, `Classroom Groups 1`.
3. Click the **Next** button.

![Menu of centers](../../assets/images/screenshots/menu_centers.png "Menu of centers")

![Create classroom](../../assets/images/screenshots/create-classroom.png "Create classroom")

4. In the next step of the Organizational Unit form, configure the network parameters. These parameters will later be used as kernel parameters when we create the boot files for the PCs in that classroom:
   - **Netmask**: Set the subnet mask, for example, `255.255.255.0`.
   - **Router**: Specify the default gateway for the subnet (e.g., `192.168.2.1`).
5. Click **Add** to create the organizational unit.

![Classroom network configuration](../../assets/images/screenshots/create-classroom-network-configuration.png "Classroom network configuration")

### Add a New Computer

1. On the **Manage Groups** screen, click **New Client**.
2. Fill in the following fields:
   - **Parent**: Select the Organizational Unit created earlier (e.g., `Test Classroom`).
   - **Name**: The computer name `pc11`.
   - **MAC**: The client's MAC address `00:50:56:1e:8f:11`.
   - **IP Address**: The IP within the configured subnet `192.168.2.11`.
   - **PXE Template**: Select the associated PXE template `ogLive` for Oglive boot.
   - **Network Interface**: The client's network interface (e.g., `Eth0`).
   - **Network Driver**: e.g., `Generic`.
3. Click **Add** to save the computer.

![Create a computer](../../assets/images/screenshots/create_pc.png "Create a computer")

## Create a New Subnet

The goal is to create a subnet in the system and synchronize it with the **ogdhcp** component, which uses Kea DHCP to manage network configurations.

### Create the Subnet

1. Go to the **Manage Subnets** section.
2. Click the **Add Subnet** button.
3. In the subnet creation form, complete the following fields:
   - **Name**: Assign an identifier, e.g., `Test Subnet`.
   - **Netmask**: Specify the subnet mask `255.255.255.0`.
   - **IP Address**: Set the base address of the subnet `192.168.3.0`.
   - **Next Server**: Enter the boot server IP `172.17.8.37`.
   - **Boot File Name**: Set the PXE boot file name `undionly.kpxe`.
4. Click **Save** to create the subnet in the system database.

![Create a subnet](../../assets/images/screenshots/create_subnet.png "Create a subnet")

Once created, the subnet will appear in the list with the status **Not Synchronized**. This indicates the subnet is registered in the database but has not yet been applied to the Kea DHCP service.

![Created subnet not synced](../../assets/images/screenshots/created_subnet_no_sync.png "Created subnet not synced")

---

### Synchronize the Subnet with Kea DHCP

1. In the subnet list, locate the newly created subnet.
2. Click the actions button (menu icon) and select **Create in og-dhcp**.
3. This will send the subnet configuration to the `ogdhcp` component, which will update the **Kea DHCP** service.

![Sync subnet](../../assets/images/screenshots/sync_subnet.png "Sync subnet")

---

### Subnet Synchronized

Once synchronized, the subnet will appear with the status **Synchronized** in the list (with a ✔️ icon). This indicates the configuration has been successfully applied to the Kea DHCP service.

You can view the configuration created in Kea DHCP by clicking **Information on ogDHCP server** (at the top) and then **View information**.

![Subnet KEA](../../assets/images/screenshots/subnet_kea.png "Subnet KEA")

## Add a Client to a Subnet

The goal is to add a PC to a specific subnet that is already registered and synchronized with the **ogdhcp** component.

### Add Client to the Subnet

1. In the subnet list, find the subnet to which you want to add the client, e.g., `192.168.3.0`.
2. Ensure the subnet is **Synchronized** (status icon with a ✔️). If it is not synchronized, perform the synchronization process first.
3. Click the actions button (menu icon) for the selected subnet.
4. In the dropdown menu, select **Add Client**.

![Synchronized subnet](../../assets/images/screenshots/synced_subnet.png "Synchronized subnet")

5. In the form:
   - Search for the client name `pc11`.
   - Ensure the client appears in the **Selected Clients** list.
6. Click the **Add** button.

![Add client to subnet](../../assets/images/screenshots/add_client_to_subnet.png "Add client to subnet")

7. You can view the updated Kea configuration with the new client by clicking **Information on ogDHCP server** (at the top) and then **View information**.

![Client KEA](../../assets/images/screenshots/client_kea.png "Client KEA")

## Create a PXE Boot File

The goal is to generate a custom boot file for the client `pc11`, using the `ogLive` PXE template so it boots via Oglive.

### Create the Boot File

1. Go to the **PXE Templates** section under the **Boot** menu.
2. Locate the `ogLive` template that was previously assigned when creating the **pc11** client.
3. Click the computer icon button.

![PXE Templates](../../assets/images/screenshots/pxe_templates.menu.png "PXE Templates")

4. Find the client **pc11**.
5. Click the sync data button (the two circular arrows).

![Advanced netboot](../../assets/images/screenshots/create_pxe_file.png "Advanced netboot")

6. You will see that the **pc11** computer icon turns green. This means the boot file has been created in **ogboot** successfully.

![PXE file created](../../assets/images/screenshots/created_pxe_file.png "PXE file created")
