Skip to main content

Update

Change the gateway or the metric of a route.

Writes the route over the one osapi has to the same destination, and applies it. A destination osapi has no route to is not found: create adds it.

osapi client node interface route update [flags]

Examples​

# A new gateway and metric
osapi client node interface route update --target web-01 --name osapi0 --destination 198.51.100.0/24 --via 192.0.2.2 --metric 10

Result​

A new gateway and metric, on one host:

$ osapi client node interface route update --target web-01 --name osapi0 --destination 198.51.100.0/24 --via 192.0.2.2 --metric 10
Results:
  HOSTNAME  STATUS   DESTINATION
  web-01    changed  198.51.100.0/24

  1 host: 1 changed   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

On each host, where one cannot run it:

$ osapi client node interface route update --target _all --name osapi0 --destination 198.51.100.0/24 --via 192.0.2.2 --metric 10
Results:
  HOSTNAME  STATUS   DESTINATION
  web-01    changed  198.51.100.0/24
  web-02    changed  198.51.100.0/24

  3 hosts: 2 changed, 1 skipped   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

Details:
  mac-01  skipped  operation not supported on this OS family

With --json, the API's response:

{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": [
{
"changed": true,
"destination": "198.51.100.0/24",
"hostname": "web-01",
"status": "ok"
}
]
}

With the default settings, each example does this on the host:

ExampleOn the host
A new gateway and metricruns netplan generate; runs netplan apply; writes /etc/netplan/osapi-osapi0-routes.yaml: network:\n version: 2\n ethernets:\n osapi0:\n routes:\n - to: 198.51.100.0/24\n via: 192.0.2.2\n metric: 10

The command fails in these cases:

CallFlagsFails with
A destination osapi has no route to--name osapi0 --destination 198.51.100.0/24 --via 192.0.2.1not found
A destination that is not CIDR--name osapi0 --destination 10.0.0.0 --via 192.0.2.1Destination
A gateway that is not an address--name osapi0 --destination 198.51.100.0/24 --via gatewayVia
A metric below 0--name osapi0 --destination 198.51.100.0/24 --via 192.0.2.1 --metric -1Metric
A metric over 4294967295--name osapi0 --destination 198.51.100.0/24 --via 192.0.2.1 --metric 4294967296Metric
A name that is not an interface name--name "eth0;reboot" --destination 198.51.100.0/24 --via 192.0.2.1Name

Permission​

It needs the interface:write permission. osapi controller role get --name <role> shows what a role grants.

Flags​

FlagDescriptionDefault
--destinationWhere the route goes, in CIDR notation, such as 10.0.0.0/8; not a default route (required)
--metricThe metric, from 0 to 4294967295; none when it is 0
--nameThe interface, such as eth0, or a fact such as @fact.interface.primary (required)
-T, --targetTarget: _all, _any, hostname, or label (group:web.dev)_all
--viaThe gateway, an address of the destination's family, such as 192.168.1.1 (required)

Global flags​

FlagDescriptionDefault
-d, --debugEnable or disable debug mode
-j, --jsonEnable JSON output
-f, --osapi-filePath to config file; without one at the default path, osapi runs on the defaults/etc/osapi/osapi.yaml
--urlBase URL the CLI client connects to (controller.client.url)https://localhost:8080

Output tells how the result is printed, and what --json gives.