oci-cli
oci-cli copied to clipboard
Project_O "o" command used from an instance principal
Can the "o" command be used from an instance principal defined in a dynamic group similarly to how regular oci commands can be used? I noticed "o" works from a cloud shell host so I was hoping it worked equally well from instance principal hosts to perform selected tasks from them.
When I ran "o oci_commands" it seemed to be working but the resulting oci_commands file just has a header followed by a bunch of blank lines in it. I ran "export OCI_CLI_AUTH=instance_principal" and retried but got the same result.
Update: Copying the ocids and oci_commands from my Dev laptop to the host's ~/.oci directory seems to be working correctly w/o need for a config file I just had to set OCI_CLI_AUTH as above. Thinking it may be a viable workaround. Please let me know if there's a better way or if some changes to o's code may be needed to fully support its use from an instance principal.
"o" is a great wrapper for working with the underlying OCI commands. It makes scripting and ad hoc tasks much easier and a lot more concise. Love it!
Thanks, Jim
Apologies for my delayed response.
An empty oci_commands file probably is the result of your installed oci-cli being a bit dated. If when you run o oci_commands
it says
Getting analytics commands...
Getting announce commands...
...
but doesn't show a long list of commands for each service, this means that o
is having trouble parsing the oci --help
output from an older oci
. Try running oci --latest-version
to see how current your oci
is... and if oci has no --latest-version
flag that's a strong indication that it's time to update. Because cli updates are frequent, it's not a bad idea to refresh your installed cli every month or two, especially if you plan to use the latest services.
After updating oci
, you should rerun o oci_commands
so that o
has a local list of the all latest commands.
Finally, "o" works well with instance_principal authentication. Setting OCI_CLI_AUTH=instance_principal
is the best way to go about this.
I'm glad you were able to work around the oci_commands
file generation by copying from another source. And I'm happy to hear o
is making oci easier to use!
It appears that oci <service> --help
has changed recently (release 3?) to not providing the usage for all commands under that service. This breaks o
's method of collecting command syntax. I'll look for an alternate, more reliable way of building the oci_commands
file.
oci --help
provides less command detail in some installations. o
was updated (in Sept 2021) to get usage for each command individually when it is unable to get all commands in a service. This makes initial setup take longer in some cases, but allows setup to work.