# `cli contributing network address suggest` ๐ŸŒ This page documents the contract of the `cli contributing network address suggest` helper and the rules contributors MUST follow when calling it. Primary file: - [__main__.py](../../../../cli/contributing/network/address/suggest/__main__.py) ## Purpose ๐ŸŽฏ `cli contributing network address suggest` proposes the next free per-role IPv4 subnet(s) based on the live role tree. It walks every `roles/*/meta/server.yml`, collects occupied `networks.local.subnet` assignments, picks the smallest CIDR prefix that fits the requested client count, and proposes free sub-blocks gap-first then by increment within the established umbrella blocks. ## Inputs ๐Ÿ”ง | Flag | Required | Default | Description | |---------------------|:--------:|:-------:|---------------------------------------------------------------------------------------------------| | `--clients N` | yes | n/a | Minimum number of usable client IPs the role's subnet MUST hold. | | `--count K` | no | `1` | How many free subnets to return. | | `--block ` | no | n/a | Force suggestions inside a specific umbrella block (e.g. `--block 192.168.101.0/24`). Default is the union of currently used /24 umbrella blocks for the chosen prefix length. | ## Behaviour ๐Ÿงฎ 1. Translate `--clients N` to the smallest CIDR prefix that fits (โ‰ค14 โ†’ `/28`, โ‰ค30 โ†’ `/27`, โ‰ค62 โ†’ `/26`, โ‰ค126 โ†’ `/25`, โ‰ค254 โ†’ `/24`, โ€ฆ). 2. Walk every `roles/*/meta/server.yml` and collect occupied CIDRs from `networks.local.subnet`. 3. Within each umbrella `/24` block already in use for the chosen prefix length: enumerate all sub-blocks of that prefix length, mark occupied vs. free. 4. __Gap-first:__ propose the lowest unoccupied sub-block. 5. __Increment fallback:__ if all sub-blocks of the active `/24` blocks are used, propose the next `/24` block in the established sequence (currently `192.168.101โ€“105` for `/28`, `192.168.200โ€“203` for `/24`). 6. __No established sequence:__ if the requested prefix size has no umbrella block established yet (e.g. `--clients 1000` โ†’ `/22` and no `/22` is in use), exit non-zero with a clear error suggesting that the operator pass `--block ` to bootstrap a new umbrella block manually. 7. For each suggestion, also print the __client capacity__ (`/28 โ†’ 14`, `/24 โ†’ 254`, โ€ฆ). ## Output ๐Ÿ“ค - __stdout__ prints one subnet per line. - __stderr__ prints per-suggestion capacity and a human-readable summary noting which umbrella block(s) were scanned. ## Examples ๐Ÿ’ก Suggest two free `/28` subnets (14 clients each) inside the established umbrella blocks: ```bash cli contributing network address suggest --clients 14 --count 2 ``` Suggest one free `/24` subnet (254 clients) bootstrapped inside an explicit umbrella block: ```bash cli contributing network address suggest --clients 254 --block 192.168.200.0/22 ``` Suggest a single `/28` subnet (the default `--count 1`): ```bash cli contributing network address suggest --clients 14 ``` ## Determinism ๐Ÿงช Given the same on-disk role layout and the same arguments, the helper produces identical output. It exits non-zero with a clear error when the requested capacity cannot be satisfied within the configured umbrella block(s). ## Integration with `cli create role` ๐Ÿงฉ When `cli create role` scaffolds a new role, it prompts for `--clients N` and calls `cli contributing network address suggest --clients N --count 1` to fill in `meta/server.yml.networks.local.subnet` automatically. The contributor MAY override the suggestion interactively. See [port.md](port.md) for the matching ports flow. ## Related Pages ๐Ÿ“š - [port.md](port.md) is the sibling helper for host-bound ports. - [layout.md](../../design/role/services/layout.md) describes the per-role `networks:` shape in `meta/server.yml`.