From b2301bedad95a9b5c9f62a8b705e34db4f349c1c Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 23 Jan 2025 20:29:24 +0100 Subject: [PATCH 1/7] DOCS-3430: Add viam machines part cp command --- docs/dev/tools/cli.md | 25 ++++++++++++++++++++++-- docs/manage/troubleshoot/troubleshoot.md | 4 +++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/docs/dev/tools/cli.md b/docs/dev/tools/cli.md index c5d7685851..c4a7022652 100644 --- a/docs/dev/tools/cli.md +++ b/docs/dev/tools/cli.md @@ -1160,6 +1160,7 @@ viam machines part status --organization= --location= - viam machines part run --organization= --location= --machine= [--stream] --data viam machines part shell --organization= --location= --machine= viam machines part restart --machine= --part= +viam machines part cp --organization= --location= --machin= --part= machine:/path/to/file ``` Examples: @@ -1190,6 +1191,24 @@ viam.service.vision.v1.VisionService.GetClassificationsFromCamera # restart a part of a specified machine viam machines part restart --machine=123 --part=456 + +# Copy a single file to the machine with a new name: +viam machine part cp --organization "org" --location "location" --machine "m1" --part "m1-main" my_file machine:/home/user/ + +# Recursively copy a directory to the machine with the same name: +viam machine part cp --part "m1-main" -r my_dir machine:/home/user/ + +# Copy multiple files to the machine with recursion and keep original permissions and metadata: +viam machine part cp --part "m1-main" -r -p my_dir my_file machine:/home/user/some/existing/dir/ + +# Copy a single file from the machine to a local destination: +viam machine part cp --part "m1-main" machine:my_file ~/Downloads/ + +# Recursively copy a directory from the machine to a local destination with the same name: +viam machine part cp --part "m1-main" -r machine:my_dir ~/Downloads/ + +# Copy multiple files from the machine to a local destination with recursion and keep original permissions and metadata: +viam machine part cp --part "m1-main" -r -p machine:my_dir machine:my_file ~/some/existing/dir/ ``` #### Command options @@ -1201,7 +1220,7 @@ viam machines part restart --machine=123 --part=456 | `api-key` | Work with an api-key for your machine | `create` (see [positional arguments: api-key](#positional-arguments-api-key)) | | `status` | Retrieve machine status for a specified machine | - | | `logs` | Retrieve logs for a specified machine | - | -| `part` | Manage a specified machine part | `status`, `run`, `logs`, `shell`, `restart` (see [positional arguments: part](#positional-arguments-part)) | +| `part` | Manage a specified machine part | `status`, `run`, `logs`, `shell`, `restart` (see [positional arguments: part](#positional-arguments-part)), `cp` | | `--help` | Return help | - | ##### Positional arguments: `api-key` @@ -1231,7 +1250,7 @@ viam machines part restart --machine=123 --part=456 | -------- | ----------- | ------------------- | --------- | | `--organization` | Organization name or ID that the machine belongs to | `list`, `status`, `logs`, `part` | **Required** | | `--location` | Location name or ID that the machine belongs to or to list machines in | `list`, `status`, `logs`, `part` | **Required** | -| `--machine` | Machine name or ID for which the command is being issued | `status`, `logs`, `part`, `part restart` | **Required** | +| `--machine` | Machine name or ID for which the command is being issued | `status`, `logs`, `part` | **Required** | | `--errors` | Boolean, return only errors (default: false) | `logs` | Optional | | `--levels` | Filter logs by levels (debug, info, warn, error). Accepts multiple inputs in comma-separated list. | `logs` | Optional | | `--part` | Part name or ID for which the command is being issued | `logs`, `part` | Optional | @@ -1247,6 +1266,8 @@ viam machines part restart --machine=123 --part=456 | `--machine-id` | The machine to create an API key for | `api-key` | **Required** | | `--name` | The optional name of the API key | `api-key` | Optional | | `--org-id` | The optional organization ID to attach the key to | `api-key` | Optional | +| `--recursive`, `-r` | Preserve modification times and file mode bits from the source files. Default: `false`. | `part cp` | Optional | +| `--preserve`, `-p` | Recursively copy files. Default: `false`. | `part cp` | Optional | ##### Using the `--stream` and `--data` arguments diff --git a/docs/manage/troubleshoot/troubleshoot.md b/docs/manage/troubleshoot/troubleshoot.md index 053de4d795..4c1fcd08fb 100644 --- a/docs/manage/troubleshoot/troubleshoot.md +++ b/docs/manage/troubleshoot/troubleshoot.md @@ -78,7 +78,9 @@ Once you have added the fragment, you can use the [Viam CLI](/dev/tools/cli/) to viam machines part shell --organization= --location= --machine= ``` -TODO: You can [access the local log file](/operate/reference/viam-server/manage-viam-server/#view-viam-server-logs) on your machine if needed. +You can [access the local log file](/operate/reference/viam-server/manage-viam-server/#view-viam-server-logs) on your machine if needed. + +If you need to copy files from your machine, use the [`viam machine part cp`](/dev/tools/cli/#machines-alias-robots) command. ## Restart your machine From 66237fc86d66f6dee6abb7c0b2a7d6d288ebe241 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 23 Jan 2025 21:09:24 +0100 Subject: [PATCH 2/7] Update cli.md --- docs/dev/tools/cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/tools/cli.md b/docs/dev/tools/cli.md index c4a7022652..aac00651ca 100644 --- a/docs/dev/tools/cli.md +++ b/docs/dev/tools/cli.md @@ -1160,7 +1160,7 @@ viam machines part status --organization= --location= - viam machines part run --organization= --location= --machine= [--stream] --data viam machines part shell --organization= --location= --machine= viam machines part restart --machine= --part= -viam machines part cp --organization= --location= --machin= --part= machine:/path/to/file +viam machines part cp --organization= --location= --machin= --part= machine:/path/to/file ``` Examples: From 107950c7d9dbfda7b55c71674384b349b6d10a66 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 23 Jan 2025 23:13:44 +0100 Subject: [PATCH 3/7] Update docs/dev/tools/cli.md Co-authored-by: JessamyT <75634662+JessamyT@users.noreply.github.com> --- docs/dev/tools/cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/tools/cli.md b/docs/dev/tools/cli.md index aac00651ca..75d219ccd5 100644 --- a/docs/dev/tools/cli.md +++ b/docs/dev/tools/cli.md @@ -1160,7 +1160,7 @@ viam machines part status --organization= --location= - viam machines part run --organization= --location= --machine= [--stream] --data viam machines part shell --organization= --location= --machine= viam machines part restart --machine= --part= -viam machines part cp --organization= --location= --machin= --part= machine:/path/to/file +viam machines part cp --organization= --location= --machine= --part= machine:/path/to/file ``` Examples: From 61f8b4014183a4003b0a151598acbe64c7345c33 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Fri, 24 Jan 2025 12:47:25 +0100 Subject: [PATCH 4/7] Address feedback --- docs/dev/tools/cli.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/dev/tools/cli.md b/docs/dev/tools/cli.md index 75d219ccd5..15d16d60db 100644 --- a/docs/dev/tools/cli.md +++ b/docs/dev/tools/cli.md @@ -1192,23 +1192,23 @@ viam.service.vision.v1.VisionService.GetClassificationsFromCamera # restart a part of a specified machine viam machines part restart --machine=123 --part=456 -# Copy a single file to the machine with a new name: -viam machine part cp --organization "org" --location "location" --machine "m1" --part "m1-main" my_file machine:/home/user/ +# Copy and a single file to a machine and change the file's name: +viam machine part cp --organization=my_org --location=my_ocation --machine=my_machine --part=m1-main my_file machine:/home/user/ -# Recursively copy a directory to the machine with the same name: -viam machine part cp --part "m1-main" -r my_dir machine:/home/user/ +# Recursively copy a directory to a machine: +viam machine part cp --machine=123 --part=123 -r my_dir machine:/home/user/ -# Copy multiple files to the machine with recursion and keep original permissions and metadata: -viam machine part cp --part "m1-main" -r -p my_dir my_file machine:/home/user/some/existing/dir/ +# Copy multiple files to a machine with recursion and keep original permissions and metadata for the files: +viam machine part cp --machine=123 --part=123 -r -p my_dir my_file machine:/home/user/some/existing/dir/ -# Copy a single file from the machine to a local destination: -viam machine part cp --part "m1-main" machine:my_file ~/Downloads/ +# Copy a single file from a machine to a local destination: +viam machine part cp --machine=123 --part=123 machine:my_file ~/Downloads/ -# Recursively copy a directory from the machine to a local destination with the same name: -viam machine part cp --part "m1-main" -r machine:my_dir ~/Downloads/ +# Recursively copy a directory from a machine to a local destination: +viam machine part cp --machine=123 --part=123 -r machine:my_dir ~/Downloads/ -# Copy multiple files from the machine to a local destination with recursion and keep original permissions and metadata: -viam machine part cp --part "m1-main" -r -p machine:my_dir machine:my_file ~/some/existing/dir/ +# Copy multiple files from the machine to a local destination with recursion and keep original permissions and metadata for the files: +viam machine part cp --machine=123 --part=123 -r -p machine:my_dir machine:my_file ~/some/existing/dir/ ``` #### Command options @@ -1220,7 +1220,7 @@ viam machine part cp --part "m1-main" -r -p machine:my_dir machine:my_file ~/som | `api-key` | Work with an api-key for your machine | `create` (see [positional arguments: api-key](#positional-arguments-api-key)) | | `status` | Retrieve machine status for a specified machine | - | | `logs` | Retrieve logs for a specified machine | - | -| `part` | Manage a specified machine part | `status`, `run`, `logs`, `shell`, `restart` (see [positional arguments: part](#positional-arguments-part)), `cp` | +| `part` | Manage a specified machine part | `status`, `run`, `logs`, `shell`, `restart`, `cp` (see [positional arguments: part](#positional-arguments-part)) | | `--help` | Return help | - | ##### Positional arguments: `api-key` @@ -1241,6 +1241,7 @@ viam machine part cp --part "m1-main" -r -p machine:my_dir machine:my_file ~/som | `logs` | Get logs for the specified machine part | | `shell` | Access a machine part securely using a secure shell. To use this feature you must add the [`ViamShellDanger` fragment](https://app.viam.com/fragment/b511adfa-80ab-4a70-9bd5-fbb14696b17e/json) to your machine. | | `restart` | Restart a machine part. | +| `cp` | Copy files to and from a machine part. | | `--help` | Return help | ##### Named arguments From 202684cc4bf44d2db17e66c0574fb6595cd8199c Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Fri, 24 Jan 2025 12:55:12 +0100 Subject: [PATCH 5/7] Update docs/dev/tools/cli.md Co-authored-by: JessamyT <75634662+JessamyT@users.noreply.github.com> --- docs/dev/tools/cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/tools/cli.md b/docs/dev/tools/cli.md index 15d16d60db..530b0d92df 100644 --- a/docs/dev/tools/cli.md +++ b/docs/dev/tools/cli.md @@ -1251,7 +1251,7 @@ viam machine part cp --machine=123 --part=123 -r -p machine:my_dir machine:my_fi | -------- | ----------- | ------------------- | --------- | | `--organization` | Organization name or ID that the machine belongs to | `list`, `status`, `logs`, `part` | **Required** | | `--location` | Location name or ID that the machine belongs to or to list machines in | `list`, `status`, `logs`, `part` | **Required** | -| `--machine` | Machine name or ID for which the command is being issued | `status`, `logs`, `part` | **Required** | +| `--machine` | Machine name or ID for which the command is being issued. If machine name is used instead of ID, `--organization` and `--location` are required. | `status`, `logs`, `part` | **Required** | | `--errors` | Boolean, return only errors (default: false) | `logs` | Optional | | `--levels` | Filter logs by levels (debug, info, warn, error). Accepts multiple inputs in comma-separated list. | `logs` | Optional | | `--part` | Part name or ID for which the command is being issued | `logs`, `part` | Optional | From 1bae232b473f6c1f0c8e20616fd4904e2df36f15 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:08:35 +0100 Subject: [PATCH 6/7] Update docs/dev/tools/cli.md Co-authored-by: JessamyT <75634662+JessamyT@users.noreply.github.com> --- docs/dev/tools/cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/tools/cli.md b/docs/dev/tools/cli.md index 530b0d92df..78d9e231cd 100644 --- a/docs/dev/tools/cli.md +++ b/docs/dev/tools/cli.md @@ -1193,7 +1193,7 @@ viam.service.vision.v1.VisionService.GetClassificationsFromCamera viam machines part restart --machine=123 --part=456 # Copy and a single file to a machine and change the file's name: -viam machine part cp --organization=my_org --location=my_ocation --machine=my_machine --part=m1-main my_file machine:/home/user/ +viam machine part cp --organization=my_org --location=my_location --machine=my_machine --part=m1-main my_file machine:/home/user/ # Recursively copy a directory to a machine: viam machine part cp --machine=123 --part=123 -r my_dir machine:/home/user/ From 9bb8c57f1420b41d1250787ff961498e0380d735 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:09:20 +0100 Subject: [PATCH 7/7] Update docs/dev/tools/cli.md --- docs/dev/tools/cli.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/dev/tools/cli.md b/docs/dev/tools/cli.md index 78d9e231cd..48b0c7c19f 100644 --- a/docs/dev/tools/cli.md +++ b/docs/dev/tools/cli.md @@ -1267,8 +1267,8 @@ viam machine part cp --machine=123 --part=123 -r -p machine:my_dir machine:my_fi | `--machine-id` | The machine to create an API key for | `api-key` | **Required** | | `--name` | The optional name of the API key | `api-key` | Optional | | `--org-id` | The optional organization ID to attach the key to | `api-key` | Optional | -| `--recursive`, `-r` | Preserve modification times and file mode bits from the source files. Default: `false`. | `part cp` | Optional | -| `--preserve`, `-p` | Recursively copy files. Default: `false`. | `part cp` | Optional | +| `--recursive`, `-r` | Recursively copy files. Default: `false`. | `part cp` | Optional | +| `--preserve`, `-p` | Preserve modification times and file mode bits from the source files. Default: `false`. | `part cp` | Optional | ##### Using the `--stream` and `--data` arguments