From 5db56714b613ef591e4695931a0f4caba79fa14b Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 23 Mar 2022 13:07:49 -0700 Subject: [PATCH 1/5] add instructions for the cli Signed-off-by: Jess Frazelle --- README.adoc | 331 ++++++++++++------------------- tools/oxapi_demo | 492 ----------------------------------------------- 2 files changed, 128 insertions(+), 695 deletions(-) delete mode 100755 tools/oxapi_demo diff --git a/README.adoc b/README.adoc index 2806412b589..8061dff2d19 100644 --- a/README.adoc +++ b/README.adoc @@ -188,7 +188,8 @@ Dec 02 18:00:01.093 DEBG registered endpoint, path: /producers, method: POST, lo ... ---- -Once everything is up and running, you can use `curl` directly to hit either of the servers. But it's easier to use the `oxapi_demo` wrapper (see below). +Once everything is up and running, you can use `curl` directly to hit either of +the servers. But it's easier to use the [`oxide` cli](https://docs.oxide.computer/cli/manual) (see below). == Docker image @@ -196,200 +197,65 @@ This repo includes a Dockerfile that builds an image containing the Nexus and sl == Quick demo -There's a small demo tool called `./tools/oxapi_demo` that provides a slightly friendlier interface than `curl`, with the same output format. To use the demo, the `node` and `json` programs should be installed and available in the users PATH: - -[source,text] ----- -pkg install node-12 -npm i -g json ----- +The `oxide` CLI can be installed from the [latest +release](https://github.com/oxidecomputer/cli/releases). Here's a small demo that creates a project, creates an instance, and attaches a disk to it: [source,text] ---- -$ ./tools/oxapi_demo -oxapi_demo: command not specified -usage: oxapi_demo [-A] [cmd] [args] - -GENERAL OPTIONS - - -A do not attempt to authenticate - (default behavior: use "spoof" authentication for endpoints - that require it) - -ORGANIZATIONS - - organizations_list - organization_create_demo ORGANIZATION_NAME - organization_delete ORGANIZATION_NAME - organization_get ORGANIZATION_NAME - -PROJECTS - - projects_list ORGANIZATION_NAME - project_create_demo ORGANIZATION_NAME PROJECT_NAME - project_delete ORGANIZATION_NAME PROJECT_NAME - project_get ORGANIZATION_NAME PROJECT_NAME - project_list_instances ORGANIZATION_NAME PROJECT_NAME - project_list_disks ORGANIZATION_NAME PROJECT_NAME - project_list_vpcs ORGANIZATION_NAME PROJECT_NAME - -INSTANCES - - instance_create_demo ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME - instance_get ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME - instance_delete ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME - - instance_stop ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME - instance_start ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME - instance_reboot ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME - - instance_attach_disk ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME DISK_NAME - instance_detach_disk ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME DISK_NAME - instance_list_disks ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME - instance_get_disk ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME DISK_NAME - -DISKS - - disk_create_demo ORGANIZATION_NAME PROJECT_NAME DISK_NAME - disk_get ORGANIZATION_NAME PROJECT_NAME DISK_NAME - disk_delete ORGANIZATION_NAME PROJECT_NAME DISK_NAME - -VPCS - - vpc_create_demo ORGANIZATION_NAME PROJECT_NAME VPC_NAME DNS_NAME - vpc_get ORGANIZATION_NAME PROJECT_NAME VPC_NAME - vpc_delete ORGANIZATION_NAME PROJECT_NAME VPC_NAME - -HARDWARE - - racks_list - rack_get RACK_ID - - sleds_list - sled_get SLED_ID -$ ./tools/oxapi_demo organization_create_demo myorg -++ curl -sSi http://127.0.0.1:12220/organizations -X POST -T - -H 'oxide-authn-spoof: 001de000-05e4-0000-0000-000000004007' -++ json -ga -HTTP/1.1 100 Continue - -HTTP/1.1 201 Created -content-type: application/json -x-request-id: 60ffbc0b-212a-4ffd-84f0-39aeb4b3b772 -content-length: 194 -date: Wed, 17 Nov 2021 01:43:52 GMT - -{ - "id": "dbaf046f-1c05-4b6a-a749-5111a8cd9aa1", - "name": "myorg", - "description": "an organization called myorg", - "timeCreated": "2021-11-17T01:43:52.322629Z", - "timeModified": "2021-11-17T01:43:52.322629Z" -} -$ ./tools/oxapi_demo project_create_demo myorg myproject -++ curl -sSi http://127.0.0.1:12220/organizations/myorg/projects -X POST -T - -++ json -ga -HTTP/1.1 100 Continue - -HTTP/1.1 201 Created -content-type: application/json -x-request-id: bea0ba10-2916-473c-b3e4-461984b85c6b -content-length: 252 -date: Wed, 17 Nov 2021 01:44:01 GMT - -{ - "id": "c197b9d2-285c-4e9f-9461-1815ef093c8d", - "name": "myproject", - "description": "a project called myproject", - "timeCreated": "2021-11-17T01:44:01.933615Z", - "timeModified": "2021-11-17T01:44:01.933615Z", - "organizationId": "dbaf046f-1c05-4b6a-a749-5111a8cd9aa1" -} -$ ./tools/oxapi_demo instance_create_demo myorg myproject myinstance -++ curl -sSi http://127.0.0.1:12220/organizations/myorg/projects/myproject/instances -X POST -T - -++ json -ga -HTTP/1.1 100 Continue - -HTTP/1.1 201 Created -content-type: application/json -x-request-id: 3d07dfa2-efda-4085-ac9f-9e6bd3040997 -content-length: 377 -date: Wed, 17 Nov 2021 01:45:07 GMT - +$ oxide org create myorg \ + --description "My organization" +✔ Created organization myorg + +$ oxide project create myproject \ + --description "My project" \ + --organization myorg +✔ Created project myorg/myproject + +$ oxide instance create myinstance \ + --description "My instance" \ + --project myproject \ + --org myorg \ + --hostname "myinstance.maze-war.com" \ + --ncpus 1 \ + --memory 8 +✔ Created instance myinstance in myorg/myproject + +$ oxide instance view myinstance \ + --org myorg \ + --project myproject \ + --format json { "id": "99ad2514-050c-4493-9cb9-d9ceba980a98", "name": "myinstance", - "description": "an instance called myinstance", + "description": "My instance", "timeCreated": "2021-11-17T01:45:07.606749Z", "timeModified": "2021-11-17T01:45:07.606749Z", "projectId": "c197b9d2-285c-4e9f-9461-1815ef093c8d", "ncpus": 1, - "memory": 268435456, - "hostname": "myproject", - "runState": "starting", - "timeRunStateUpdated": "2021-11-17T01:45:07.618960Z" -} -$ ./tools/oxapi_demo instance_get myorg myproject myinstance -++ curl -sSi http://127.0.0.1:12220/organizations/myorg/projects/myproject/instances/myinstance -++ json -ga -HTTP/1.1 200 OK -content-type: application/json -x-request-id: 5870f965-06a8-41fc-967f-9021ec640ad4 -content-length: 376 -date: Wed, 17 Nov 2021 01:46:41 GMT - -{ - "id": "99ad2514-050c-4493-9cb9-d9ceba980a98", - "name": "myinstance", - "description": "an instance called myinstance", - "timeCreated": "2021-11-17T01:45:07.606749Z", - "timeModified": "2021-11-17T01:45:07.606749Z", - "projectId": "c197b9d2-285c-4e9f-9461-1815ef093c8d", - "ncpus": 1, - "memory": 268435456, - "hostname": "myproject", + "memory": 8, + "hostname": "myinstance.maze-war.com", "runState": "running", "timeRunStateUpdated": "2021-11-17T01:45:09.120652Z" } -$ ./tools/oxapi_demo disk_create_demo myorg myproject mydisk -++ curl -sSi http://127.0.0.1:12220/organizations/myorg/projects/myproject/disks -X POST -T - -++ json -ga -HTTP/1.1 100 Continue -HTTP/1.1 201 Created -content-type: application/json -x-request-id: f6073b9d-4b07-4eba-b8cf-55d8158785eb -content-length: 324 -date: Wed, 17 Nov 2021 01:47:36 GMT +$ oxide disk create nginx \ + -D "The nginx disk." \ + -o myorg \ + -p myproject \ + --size 10 +✔ Created disk nginx in myorg/myproject -{ - "id": "551bbe67-3640-41c9-b968-249a136e5e31", - "name": "mydisk", - "description": "a disk called mydisk", - "timeCreated": "2021-11-17T01:47:36.524136Z", - "timeModified": "2021-11-17T01:47:36.524136Z", - "projectId": "c197b9d2-285c-4e9f-9461-1815ef093c8d", - "snapshotId": null, - "size": 1024, - "state": { - "state": "creating" - }, - "devicePath": "/mnt/mydisk" -} -$ ./tools/oxapi_demo disk_get myorg myproject mydisk -++ curl -sSi http://127.0.0.1:12220/organizations/myorg/projects/myproject/disks/mydisk -++ json -ga -HTTP/1.1 200 OK -content-type: application/json -x-request-id: bd1083a8-67f2-407a-8d33-068906e9f2f1 -content-length: 324 -date: Wed, 17 Nov 2021 01:48:17 GMT +$ oxide disk view nginx \ + --org myorg \ + --project myproject \ + --format json { "id": "551bbe67-3640-41c9-b968-249a136e5e31", - "name": "mydisk", - "description": "a disk called mydisk", + "name": "nginx", + "description": "The nginx disk.", "timeCreated": "2021-11-17T01:47:36.524136Z", "timeModified": "2021-11-17T01:47:36.524136Z", "projectId": "c197b9d2-285c-4e9f-9461-1815ef093c8d", @@ -398,46 +264,105 @@ date: Wed, 17 Nov 2021 01:48:17 GMT "state": { "state": "detached" }, - "devicePath": "/mnt/mydisk" + "devicePath": "/mnt/nginx" } -$ ./tools/oxapi_demo instance_attach_disk myorg myproject myinstance mydisk -++ curl -sSi http://127.0.0.1:12220/organizations/myorg/projects/myproject/instances/myinstance/disks -/mydisk -X PUT -T /dev/null -++ json -ga -HTTP/1.1 201 Created -content-type: application/json -x-request-id: da298038-28fc-4eb2-a283-4182859d6f33 -content-length: 205 -date: Wed, 17 Nov 2021 01:48:41 GMT +$ oxide disk attach nginx myinstance \ + -o maze-war \ + -p prod-online +✔ Attached disk nginx to instance myinstance in myorg/myproject + +$ oxide instance disks myinstance \ + -o maze-war \ + -p prod-online \ + --format json { "instanceId": "99ad2514-050c-4493-9cb9-d9ceba980a98", "diskId": "551bbe67-3640-41c9-b968-249a136e5e31", - "diskName": "mydisk", + "diskName": "nginx", "diskState": { - "state": "attaching", + "state": "attached", "instance": "99ad2514-050c-4493-9cb9-d9ceba980a98" } } -$ ./tools/oxapi_demo instance_list_disks myorg myproject myinstance -++ curl -sSi http://127.0.0.1:12220/organizations/myorg/projects/myproject/instances/myinstance/disks -++ json -ga -HTTP/1.1 200 OK -content-type: application/json -x-request-id: 9f0490d5-e09e-4831-900c-d39f5f07d2c8 -content-length: 206 -date: Wed, 17 Nov 2021 01:49:10 GMT +# Alternatively, you can use the API command to run any endpoint. +# This operates like a fancy, authenticated curl. + +$ oxide api --help +Makes an authenticated HTTP request to the Oxide API and prints the response. + +The endpoint argument should be a path of a Oxide API endpoint. + +The default HTTP request method is "GET" normally and "POST" if any parameters +were added. Override the method with `--method`. + +Pass one or more `-f/--raw-field` values in "key=value" format to add static string +parameters to the request payload. To add non-string or otherwise dynamic values, see +`--field` below. Note that adding request parameters will automatically switch the +request method to POST. To send the parameters as a GET query string instead, use +`--method GET`. + +The `-F/--field` flag has magic type conversion based on the format of the value: + +- literal values "true", "false", "null", and integer/float numbers get converted to + appropriate JSON types; +- if the value starts with "@", the rest of the value is interpreted as a + filename to read the value from. Pass "-" to read from standard input. + +Raw request body may be passed from the outside via a file specified by `--input`. +Pass "-" to read from standard input. In this mode, parameters specified via +`--field` flags are serialized into URL query parameters. + +In `--paginate` mode, all pages of results will sequentially be requested until +there are no more pages of results. + +USAGE: + oxide api [OPTIONS] + +ARGS: + + The endpoint to request + +OPTIONS: + -d, --debug + Print debug info + + [env: DEBUG=] + + -f, --raw-field + Add a string parameter in key=value format + + -F, --field + Add a typed parameter in key=value format + + -h, --help + Print help information + + -H, --header
+ Add a HTTP request header in `key:value` format + + -i, --include + Include HTTP response headers in the output + + --input + The file to use as body for the HTTP request (use "-" to read from standard input) + + [default: ] + + --paginate + Make additional HTTP requests to fetch all pages of results + + -X, --method + The HTTP method for the request + +$ oxide api /session/me { - "instanceId": "99ad2514-050c-4493-9cb9-d9ceba980a98", - "diskId": "551bbe67-3640-41c9-b968-249a136e5e31", - "diskName": "mydisk", - "diskState": { - "state": "attached", - "instance": "99ad2514-050c-4493-9cb9-d9ceba980a98" - } + "id": "99ad2514-050c-4493-9cb9-d9ceba980a98" } ----- + + +----- == Deploying Omicron diff --git a/tools/oxapi_demo b/tools/oxapi_demo deleted file mode 100755 index e22ca9f221c..00000000000 --- a/tools/oxapi_demo +++ /dev/null @@ -1,492 +0,0 @@ -#!/usr/bin/env bash - -# -# oxapi_demo: wrapper around curl(1) to run basic requests against the Oxide API -# prototype server. -# - -OXAPI_URL="${OXAPI_URL:-http://127.0.0.1:12220}" -ARG0="$(basename "${BASH_SOURCE[0]}")" -NO_AUTHENTICATE=false -AUTH_HEADER="Authorization: Bearer" -AUTH_HEADER="$AUTH_HEADER oxide-spoof-001de000-05e4-4000-8000-000000004007" -HELP="$(cat < /dev/null 2>&1 || fail "curl not found in PATH." - - if ! type json > /dev/null 2>&1; - then - if ! type jq > /dev/null 2>&1; - then - fail "json or jq not found in PATH. Install with 'npm i -g json' or 'apt install jq'" - else - JSONTOOL="jq ." - fi - else - JSONTOOL="json -ga" - fi - - if [[ "$1" == "-A" ]]; then - NO_AUTHENTICATE=true - shift - fi - - [[ $# -gt 0 ]] || usage "command not specified" - - func="cmd_$1" - type "$func" > /dev/null 2>&1 || usage "no such command: $1" - shift - $func "$@" -} - -# TODO add list of valid commands to output -function usage -{ - echo "$ARG0: $@" >&2 - echo "$HELP" - exit 2 -} - -function fail -{ - echo "$ARG0: $@" >&2 - exit 1 -} - -# -# Utility functions -# - -function do_curl -{ - local path - - path="$1" - shift - (set -o xtrace; curl -sSq "$OXAPI_URL$path" "$@" | ${JSONTOOL}) -} - -function do_curl_authn -{ - if [[ $NO_AUTHENTICATE == true ]]; then - do_curl "$@" - else - do_curl "$@" -H "$AUTH_HEADER" - fi -} - -# TODO-cleanup We could do a lot better than this. -function mkjson -{ - str="{" - first=true - for arg in "$@"; do - IFS='=' read key value <<< "$arg" - - if [[ $first != true ]]; then - str="$str," - fi - first=false - - if ! [[ $value =~ ^[0-9]+$ ]]; then - value="\"$value\"" - fi - - str="$str \"$key\": $value" - done - str="$str }" - echo "$str" | ${JSONTOOL} -} - -# -# API commands -# - -function cmd_organizations_list -{ - [[ $# != 0 ]] && usage "expected no arguments" - do_curl_authn /organizations -} - -function cmd_organization_create_demo -{ - [[ $# != 1 ]] && usage "expected ORGANIZATION_NAME" - mkjson name="$1" description="an organization called $1" | - do_curl_authn "/organizations" -X POST -T - -} - -function cmd_organization_delete -{ - [[ $# != 1 ]] && usage "expected ORGANIZATION_NAME" - do_curl_authn "/organizations/$1" -X DELETE -} - -function cmd_organization_get -{ - [[ $# != 1 ]] && usage "expected ORGANIZATION_NAME" - do_curl_authn "/organizations/$1" -} - -function cmd_projects_list -{ - [[ $# != 1 ]] && usage "expected ORGANIZATION_NAME" - do_curl_authn "/organizations/$1/projects" -} - -function cmd_project_create_demo -{ - [[ $# != 2 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME" - mkjson name="$2" description="a project called $2" | - do_curl_authn "/organizations/$1/projects" -X POST -T - -} - -function cmd_project_delete -{ - [[ $# != 2 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME" - do_curl_authn "/organizations/$1/projects/$2" -X DELETE -} - -function cmd_project_get -{ - [[ $# != 2 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME" - do_curl_authn "/organizations/$1/projects/$2" -} - -function cmd_project_list_instances -{ - [[ $# != 2 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME" - do_curl_authn "/organizations/$1/projects/$2/instances" -} - -function cmd_project_list_disks -{ - [[ $# != 2 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME" - do_curl_authn "/organizations/$1/projects/$2/disks" -} - -function cmd_project_list_vpcs -{ - [[ $# != 2 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME" - do_curl_authn "/organizations/$1/projects/$2/vpcs" -} - -function cmd_instance_create_demo -{ - # memory is 1024 * 1024 * 256 - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME" - mkjson name="$3" description="an instance called $3" ncpus=1 \ - memory=268435456 boot_disk_size=1 hostname="$3" | - do_curl_authn "/organizations/$1/projects/$2/instances" \ - -X POST -T - -} - -function cmd_instance_get -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME" - do_curl_authn "/organizations/$1/projects/$2/instances/$3" -} - -function cmd_instance_delete -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME" - do_curl_authn "/organizations/$1/projects/$2/instances/$3" -X DELETE -} - -function cmd_instance_migrate -{ - [[ $# != 4 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME SLED_ID" - mkjson dst_sled_uuid="$4" | \ - do_curl_authn "/organizations/$1/projects/$2/instances/$3/migrate" -X POST -T - -} - -function cmd_instance_stop -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME" - do_curl_authn "/organizations/$1/projects/$2/instances/$3/stop" -X POST -} - -function cmd_instance_start -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME" - do_curl_authn "/organizations/$1/projects/$2/instances/$3/start" -X POST -} - -function cmd_instance_reboot -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME" - do_curl_authn "/organizations/$1/projects/$2/instances/$3/reboot" -X POST -} - -function cmd_instance_attach_disk -{ - [[ $# != 4 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME DISK_NAME" - mkjson disk="$4" | - do_curl_authn "/organizations/$1/projects/$2/instances/$3/disks/attach" -X POST -T - -} - -function cmd_instance_detach_disk -{ - [[ $# != 4 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME DISK_NAME" - mkjson disk="$4" | - do_curl_authn "/organizations/$1/projects/$2/instances/$3/disks/detach" -X POST -T - -} - -function cmd_instance_list_disks -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME" - do_curl_authn "/organizations/$1/projects/$2/instances/$3/disks" -} - -function cmd_disk_create_demo -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME DISK_NAME" - mkjson name="$3" description="a disk called $3" size=1024 | - do_curl_authn "/organizations/$1/projects/$2/disks" -X POST -T - -} - -function cmd_disk_get -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME DISK_NAME" - do_curl_authn "/organizations/$1/projects/$2/disks/$3" -} - -function cmd_disk_delete -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME DISK_NAME" - do_curl_authn "/organizations/$1/projects/$2/disks/$3" -X DELETE -} - -function cmd_vpc_create_demo -{ - [[ $# != 4 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME VPC_NAME DNS_NAME" - mkjson name="$3" dns_name="$4" description="a vpc called $3" | - do_curl_authn "/organizations/$1/projects/$2/vpcs" -X POST -T - -} - -function cmd_vpc_get -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME VPC_NAME" - do_curl_authn "/organizations/$1/projects/$2/vpcs/$3" -} - -function cmd_vpc_delete -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME VPC_NAME" - do_curl_authn "/organizations/$1/projects/$2/vpcs/$3" -X DELETE -} - -function cmd_vpc_subnets_list -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME VPC_NAME" - do_curl_authn "/organizations/$1/projects/$2/vpcs/$3/subnets" -} - -function cmd_vpc_subnet_get -{ - [[ $# != 4 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME VPC_NAME SUBNET_NAME" - do_curl_authn "/organizations/$1/projects/$2/vpcs/$3/subnets/$4" -} - -function cmd_instance_create_nic -{ - [[ $# != 6 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME - VPC_NAME SUBNET_NAME INTERFACE_NAME" - mkjson \ - name="$6" \ - description="an interface called $6" \ - vpc_name="$4" \ - subnet_name="$5" | - do_curl_authn \ - "/organizations/$1/projects/$2/instances/$3/network-interfaces" \ - -X POST -T - -} - -function cmd_instance_delete_nic -{ - [[ $# != 4 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME - INTERFACE_NAME" - do_curl_authn \ - "/organizations/$1/projects/$2/instances/$3/network-interfaces/$4" -X \ - DELETE -} - -function cmd_subnet_list_nics -{ - [[ $# != 4 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME VPC_NAME SUBNET_NAME" - do_curl_authn "/organizations/$1/projects/$2/vpcs/$3/subnets/$4/network-interfaces" -} - -function cmd_instance_get_nic -{ - [[ $# != 5 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME INTERFACE_NAME" - do_curl \ - "/organizations/$1/projects/$2/instances/$3/network-interfaces/$4" -} - -function cmd_instance_list_nics -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME INSTANCE_NAME" - do_curl_authn \ - "/organizations/$1/projects/$2/instances/$3/network-interfaces" -} - -function cmd_vpc_firewall_rules_get -{ - [[ $# != 3 ]] && usage "expected ORGANIZATION_NAME PROJECT_NAME VPC_NAME" - do_curl "/organizations/$1/projects/$2/vpcs/$3/firewall/rules" -} - -function cmd_racks_list -{ - [[ $# != 0 ]] && usage "expected no arguments" - do_curl /hardware/racks -} - -function cmd_rack_get -{ - [[ $# != 1 ]] && usage "expected RACK_ID" - do_curl "/hardware/racks/$1" -} - -function cmd_sleds_list -{ - [[ $# != 0 ]] && usage "expected no arguments" - do_curl /hardware/sleds -} - -function cmd_sled_get -{ - [[ $# != 1 ]] && usage "expected SLED_ID" - do_curl "/hardware/sleds/$1" -} - -function cmd_users_list -{ - [[ $# != 0 ]] && usage "expected no arguments" - do_curl_authn "/users" -} - -function cmd_user_get -{ - [[ $# != 1 ]] && usage "expected USER_NAME" - do_curl_authn "/users/$1" -} - -function cmd_roles_list -{ - [[ $# != 0 ]] && usage "expected no arguments" - do_curl_authn "/roles" -} - -function cmd_role_get -{ - [[ $# != 1 ]] && usage "expected ROLE_NAME" - do_curl_authn "/roles/$1" -} - -function cmd_updates_refresh -{ - do_curl /updates/refresh -X POST -} - -main "$@" From 7bea738947fd604ad97aeedc9697b52b926098f7 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 23 Mar 2022 13:08:44 -0700 Subject: [PATCH 2/5] update Signed-off-by: Jess Frazelle --- README.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.adoc b/README.adoc index 8061dff2d19..32641b81f26 100644 --- a/README.adoc +++ b/README.adoc @@ -200,6 +200,9 @@ This repo includes a Dockerfile that builds an image containing the Nexus and sl The `oxide` CLI can be installed from the [latest release](https://github.com/oxidecomputer/cli/releases). +Run `oxide auth login` to authenticate with your Oxide account. Alternatively, +oxide will respect the `OXIDE_TOKEN` and `OXIDE_HOST` environment variables. + Here's a small demo that creates a project, creates an instance, and attaches a disk to it: [source,text] From 5f5d3be81d9d3aa4f3ca7e21fb64d01fbbefe59e Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 23 Mar 2022 13:10:39 -0700 Subject: [PATCH 3/5] link to repo for feedback Signed-off-by: Jess Frazelle --- README.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.adoc b/README.adoc index 32641b81f26..e5d13112641 100644 --- a/README.adoc +++ b/README.adoc @@ -203,6 +203,9 @@ release](https://github.com/oxidecomputer/cli/releases). Run `oxide auth login` to authenticate with your Oxide account. Alternatively, oxide will respect the `OXIDE_TOKEN` and `OXIDE_HOST` environment variables. +If you find bugs or have feedback, leave it on the [cli +repo](https://github.com/oxidecomputer/cli/issues). + Here's a small demo that creates a project, creates an instance, and attaches a disk to it: [source,text] From 9e253c4df86b03ebae14c06799621f569223e615 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 23 Mar 2022 13:33:26 -0700 Subject: [PATCH 4/5] Update README.adoc Co-authored-by: David Crespo --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index e5d13112641..2ccbe6a82b1 100644 --- a/README.adoc +++ b/README.adoc @@ -201,7 +201,7 @@ The `oxide` CLI can be installed from the [latest release](https://github.com/oxidecomputer/cli/releases). Run `oxide auth login` to authenticate with your Oxide account. Alternatively, -oxide will respect the `OXIDE_TOKEN` and `OXIDE_HOST` environment variables. +`oxide` will respect the `OXIDE_TOKEN` and `OXIDE_HOST` environment variables. If you find bugs or have feedback, leave it on the [cli repo](https://github.com/oxidecomputer/cli/issues). From e507e3fa5c30abd8e0eac08d6a7a3ac790982abe Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 23 Mar 2022 13:33:32 -0700 Subject: [PATCH 5/5] Update README.adoc Co-authored-by: David Crespo --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 2ccbe6a82b1..0cdcdd3f0f9 100644 --- a/README.adoc +++ b/README.adoc @@ -189,7 +189,7 @@ Dec 02 18:00:01.093 DEBG registered endpoint, path: /producers, method: POST, lo ---- Once everything is up and running, you can use `curl` directly to hit either of -the servers. But it's easier to use the [`oxide` cli](https://docs.oxide.computer/cli/manual) (see below). +the servers. But it's easier to use the [`oxide` CLI](https://docs.oxide.computer/cli/manual) (see below). == Docker image