External Scripts

Overview

Ruby scripts that run outside the context of your installation are referred to as external scripts. These may be run standalone, or integrated into your installation with an external method hook (see: Registry method types).

The most basic example of an external script can be seen below:

require 'bcome'

# Define an orchestrator
orchestrator = ::Bcome::Orchestrator.instance

# Load in a namespace
namespace = orchestrator.get("some:namespace:breadcrumb")

# Work with your namespace
...

All namespaces retrieved by the orchestrator are instances of @node.

Note

To return the root namespace using the orchestrator, pass a null breadcrumb i.e. orchestrator.get()

See Executing Commands for invoking commands and Command Menu for a list of commands.

See also @node methods for a list of public instance methods.

Hint

Any command available to you in the Console, using Keyed-Access or via the Registry is available to you within your Ruby scripts.

Some additional useful functions

Prompt for a metadata decryption key:

::Bcome::Node::MetaDataLoader.instance.prompt_for_decryption_key

Silence command output:

::Bcome::Orchestrator.instance.silence_command_output!

Initiate an SSH connection to all server instances within a given namespace (rather than lazy-load them):

# with a progress bar
::Bcome::Ssh::Connector.connect(namespace, show_progress: true)

# without a progress bar
::Bcome::Ssh::Connector.connect(namespace, show_progress: false)