--- name: omc-cloud description: Create and manage OMC Cloud servers through the OMC Cloud API (console.omc.cloud) - create, firewall, power, resize, disks, snapshots, clone and delete - safely, with the rules that prevent duplicate billed servers and servers exposed without a firewall. Use when the user asks to create, change, list or delete OMC Cloud servers or mentions console.omc.cloud. --- # OMC Cloud servers, managed through the API This skill lets you run a user's OMC Cloud servers through the OMC Cloud REST API. It comes with a small Python client, `omc_cloud.py` (standard library only), which has the safety rules below built in. Prefer the client over hand-written requests. Full API reference: https://omc.cloud/api ## Install (for the person setting this up) 1. Save this file as `~/.claude/skills/omc-cloud/SKILL.md` and the client next to it: ```bash mkdir -p ~/.claude/skills/omc-cloud curl -fsSL https://omc.cloud/wp-content/uploads/omc-cloud-skill/SKILL.md -o ~/.claude/skills/omc-cloud/SKILL.md curl -fsSL https://omc.cloud/wp-content/uploads/omc-cloud-skill/omc_cloud.py -o ~/.claude/skills/omc-cloud/omc_cloud.py ``` 2. Create an API key in the OMC Cloud console and put it in your shell environment, not in a chat and not in a file under git: ```bash export OMC_CLIENT_ID="your client id" export OMC_SECRET="your secret" ``` 3. Ask your AI assistant something like: "Create an Ubuntu 24.04 server in Milan with 2 vCPU and 4 GB RAM, firewall on, SSH only from my IP." ## Rules that prevent real damage **Ask the user before anything that costs money or deletes.** Say what will be created, changed or deleted, in which data center and at roughly what size, and wait for a clear yes. This covers create, clone, add disk, resize, snapshot create and revert, power off or restart of a running server, remove disk and terminate. 1. **Never retry a create, clone or disk add** after a timeout or a bare 5xx. It may already have been accepted, and a retry can create a second billed server. Treat the outcome as unknown and list the servers by name to find out (`UnknownOutcome` in the client). 2. **Create servers powered off** (never send `power` on create), arm the cloud firewall, read it back, and only then power on. A new server has a public IP and its cloud firewall starts **disabled**. 3. **`fwac: 0` means the firewall is ENABLED**, `fwac: 1` means disabled. 4. **A 200 from a firewall PUT does not mean it is armed.** Fresh servers can silently revert early writes. Write, wait, read back, retry; never power on until the read-back passes. 5. **A firewall PUT replaces the whole configuration.** Always send the `nics` array from a GET and every rule you want to keep. Per-network-card policies go inside `nics[].default` with a boolean `enable`. 6. **Prove deletion by absence** from a successful `GET /service/servers`. A by-id 400/404 is ambiguous. 7. **Read bodies as text.** Some calls answer 200 with an empty body, and an error envelope `{"errors": [...]}` can arrive with HTTP 200. Parse only a non-empty body, then check it for `errors`. 8. **Do not follow redirects** (the auth headers would be re-sent) and never disable TLS verification. 9. **Retry only idempotent calls**, and only on the transient errors below or HTTP 429, with backoff. 10. **Never open RDP, SSH or database ports to `0.0.0.0/0`** (an empty `source` in a rule means the same: anyone). Allow the user's own `/32` only. 11. **Never print or log** `OMC_SECRET` or server passwords. A create needs a root password: generate a strong one (16 to 32 characters, upper and lower case letters and numbers), show it to the user once, and keep it out of logs and files. ## Basics | | | |---|---| | Classic API | `https://console.omc.cloud/service` | | Console API | `https://console.omc.cloud/svc` | | Auth | headers `AuthClientId: ` and `AuthSecret: ` on every request | **Use both APIs.** Read server details through `/svc`, change through `/service`. The cloud firewall and BIOS exist only on `/svc`. Whether a server exists is decided by `GET /service/servers`. | | Classic `/service/...` | Console `/svc/...` | |---|---|---| | Best for | create, power, resize, disks, terminate, queue, snapshots, billing | reading, firewall, BIOS | | Server list | `GET /service/servers`: id, name, datacenter, power | `GET /svc/servers`: adds state, network cards, tags; filters and paging | | One server | | `GET /svc/servers?server_uuid={id}` | Changes are asynchronous: they return a command id (as `[n]`, `n`, `"n"`, `{"commandId": n}` or `{"cmdId": n}`). Wait for it before the next step (`k.wait(...)`, see "Command queue"). ## Using the client ```python import os, sys sys.path.insert(0, os.path.expanduser("~/.claude/skills/omc-cloud")) from omc_cloud import OmcCloud, rule k = OmcCloud() # reads OMC_CLIENT_ID / OMC_SECRET for s in k.servers(): print(s["name"], s["datacenter"], s["power"]) ``` ### Create a server safely ```python image = "EU-ML:6000C29549da189eaef6ea8a31001a34" # Ubuntu 24.04 in Milan ram = k.smallest_ram(image, "2B", at_least=4096) # valid for THIS image in THIS data center root_pw = generated_password() # strong, random; show it to the user once (rule 11) sid = k.create_server("web-01", password=root_pw, datacenter="EU-ML", cpu="2B", ram=ram, image_id=image, disk_gb=20) # comes up OFF k.arm_firewall(sid, [rule(source="203.0.113.10/32", dport=22, comment="SSH from my IP"), rule(dport=443, comment="HTTPS")]) # raises FirewallNotArmed if it never arms k.power(sid, "on") ``` To allow only outbound traffic (no inbound at all), call `k.arm_firewall(sid, [])`. `arm_firewall` refuses a rule that opens SSH, RDP, a database port or every port to anyone (empty or `0.0.0.0/0` source); it returns only when the read-back shows the firewall on, every network card on DROP, and at least the rules you wrote. If a create, clone or disk add raises `UnknownOutcome`, do not try again: list the servers (or disks) and tell the user what you find. ### Everyday tasks ```python k.power(sid, "off"); k.resize(sid, "4B", 8192); k.power(sid, "on") # resize needs the server off k.snapshot_create(sid, "before-upgrade") # then k.snapshots(sid) k.add_disk(sid, 50) # billed, server off, never retried k.grow_disk(sid, 0, 40) # index is a 0-based int; grow only k.rename(sid, "web-01-prod") k.terminate(sid) # proves the server is gone ``` `k.clone(sid, "web-02", password)` copies every disk into a new server, powered off: arm its firewall before powering it on. ## Catalog **Per-image options (use this one):** `GET /service/server/options/image/{DC:imageId}` (URL-encode the id) returns, in seconds, the CPU types, RAM sizes (`ram[]`), disk sizes and networks valid for one image in one data center, plus `imageRequirements.minRamMb`. RAM below the minimum fails with `code 1000 "The selected RAM is out or range."`. **Data centers:** `GET /service/server/options/datacenters` lists the codes you can deploy to. Always take the list from the API. Common codes: `IL` (Israel), `EU-ML` (Milan), `EU-FR` (Frankfurt), `EU` (Amsterdam), `EU-LO` (London), `EU-MD` (Madrid), `EU-ST` (Stockholm), `US-NY2` (New York), `US-SC` (Santa Clara), `CA-TR` (Toronto), `AS-SG` (Singapore), `AS-TY` (Tokyo), `AU-SY` (Sydney). CPU is `{cores}{type}`: `A` availability (general purpose), `B` burstable, `T` dedicated, `D` dedicated high clock. **Public Linux images:** an image id is `"{DC}:{suffix}"` and the suffix is the same in every data center. | Image | Suffix | Min RAM | |---|---|---| | Ubuntu 24.04 | `6000C29549da189eaef6ea8a31001a34` | 1024 MB | | Ubuntu 22.04 | `6000C29f959b953a3796673ce2c2f312` | 1024 MB | | Debian 12 | `6000C29b382ba66866e72a6bc6d49360` | 1024 MB | | AlmaLinux 9 | `6000C29dc1ac6a10be8959e5964e14cb` | 2048 MB | | Rocky Linux 9 | `6000C296026eea7023f5768b2d0b0d25` | 2048 MB | Checked in Milan, Israel and Frankfurt on 2026-11-23. Confirm with the per-image options call before relying on them. ## Power and resize - `PUT /service/server/{id}/power` with `{"power": "on" | "off" | "restart"}` returns a command id. "already powered on/off" is success. - `PUT /service/server/{id}/cpu` with `{"cpu": "4B", "ram": 8192}` changes CPU and RAM in one command. **The server must be off.** Right after a resize the server can stay busy: the next call may get `code 5 "Existing operation is currently running"`. Retry with backoff. ## Disks | Action | Call | |---|---| | Grow | `PUT /service/server/{id}/disk` with `{"size": 30, "index": 1, "provision": 0}`. `index` is a **0-based integer**; grow only | | Add | `POST /service/server/{id}/disk` with `{"size": 50, "provision": 0}`, server off. Billed: **never retry** | | Remove | `DELETE /service/server/{id}/disk/remove` with `{"index": 1, "confirm": 1}`. **Deletes the data.** Index 0 is the OS disk | A disk belongs to a server; there is no detach-and-keep. ## Firewall `GET /svc/server/{id}/firewall` returns `rules`, `ipSets`, `aliases`, `fwac` and `nics` (each with a `default` block; GET shows `enable` as 0/1). `PUT` the same path replaces everything: send `fwac`, the `nics` from the GET, every rule, `ipSets` and `aliases`. In the PUT, `enable` is a boolean. "Armed" means, read back: `fwac == 0`; the rule count is at least what you wrote; `nics` is non-empty; and every nic has `default.enable == 1` and `default.inPolicy == "DROP"`. Rule fields: `pos` (0-based, first match wins), `action` (`ACCEPT`/`DROP`/`REJECT`), `type` (`in`/`out`), `proto` (`tcp`/`udp`/`icmp`) or `macro`, `source`/`dest` (IP or CIDR, `""` = any), `sport`/`dport` (port, range `6900:7999`, or `""`), `enable` (boolean), `log` (`nolog`/`log`), `iface` (`""`), `comment`. With `inPolicy: DROP` and `outPolicy: ACCEPT`, connections the server opens work (replies are let in). Rules match the packet's destination IP. To keep rule sets re-runnable, tag your rules with a comment prefix, drop and re-add only those on each run, renumber `pos` from 0, PUT, read back. ## BIOS `PUT /svc/server/{id}/bios` with `{"bios": "seabios" | "ovmf"}` (server off). Answers 200 with an empty body. ## Command queue - `GET /service/queue/{id}` can answer `code 10 "invalid cmdId"` for several seconds after a command is created and again after it ages out. That is not a failure: look for the id in `GET /service/queue` (the account's recent commands). `?id=` is ignored. - Statuses: `pending`, `progress`, `complete`, `error`, `cancelled`. Treat anything matching `error|fail|cancel` as failure. Poll about every 10 to 15 seconds; a create can take several minutes. ## Rename, password, snapshots, billing - Rename: `PUT /service/server/{id}/rename` `{"name": "..."}`. Password: `PUT /service/server/{id}/password` `{"password": "..."}`. - Terminate: `DELETE /service/server/{id}/terminate` with `{"confirm": 1, "force": 1}`, wait for the command, then confirm the id is absent from `GET /service/servers`. - Snapshots: `GET .../snapshots`, `POST .../snapshot` `{"name"}`, `PUT .../snapshot` `{"snapshotId"}` (revert), `DELETE .../snapshot` `{"snapshotId"}`. - Billing: `GET /service/server/{id}/billing` returns the active and future billing mode. ## Errors | HTTP / error | Meaning | Do | |---|---|---| | 200 with `{"errors": [...]}` | failure | read `info` | | 3xx | treat as an error | do not follow | | 401 | wrong key | check OMC_CLIENT_ID / OMC_SECRET | | 429 | rate limited | exponential backoff | | `code 5 "Existing operation is currently running"` | server busy | retry with backoff | | `"init policy was not completed"`, `"server is in progress"` | server still settling | retry with backoff | | `code 1000 "The selected RAM is out or range."` | RAM below the image minimum | use per-image options | | `code 26 "Illegal disk index"`, `code 110 "Illegal disk size"` | bad disk call | 0-based int index; size at least 10 | | `"already powered on/off"` | nothing to do | treat as success | Bound every request (about 45 s; 300 s for a create). Never auto-retry create, clone or disk add. ## Linux access Open port 22 in the cloud firewall for the user's own `/32` only. The client creates servers with a root password; after the first login, add the user's public key to `~/.ssh/authorized_keys` and turn off password login if they want. If a server goes dark after a firewall change, check the firewall read-back first: a missing `nics[].default` block or an `out` rule that matches the wrong destination are the usual causes. ## Common mistakes | Wrong | Right | |---|---| | `fwac: 1` = firewall on | `fwac: 0` = on | | `"enable": 1` in a firewall PUT | `"enable": true` | | `inPolicy` / `outPolicy` at the firewall root | inside `nics[].default` | | Trust the firewall PUT's 200 | read back until armed | | `power: true` on create or clone | omit `power` (or `false`); arm the firewall first | | Retry a create, clone or disk add on timeout | never; list servers by name | | RAM from the global catalog | per-image options | | `PUT .../disk/{index}` | `PUT .../disk` with `{"index": <0-based int>}` | | `POST .../terminate` | `DELETE .../terminate` with `{"confirm": 1, "force": 1}` | | A by-id 404 means deleted | only absence from `GET /service/servers` | | `curl -k` or following redirects | never |