Python

Python will be installed alongside the Orbital node if you enable the Orbital Script feature. This Orbital installation of Python is secure and completely independent of any prior or subsequent Python installations; it is only available to Orbital. Orbital uses Python version 3.10 or later.

Python Libraries Included With Script

These Python libraries are provided for use with Orbital scripts:

Script Limits

Orbital scripts have these limits:

  • Scripts can be up to 64 KB in size.

  • Script execution will time out after 10 minutes.

  • Script output will be capped at 16MB each for stdout and stderr.

  • Any child processes spawned by a script will not be terminated by Orbital. It must exit on its own.

Script Parameters

Orbital scripts support various parameter types to enable more flexible scripts and reduce potential errors when using parameters. The list of supported parameter types and their required format is:

  • Basic String - This string type is escaped when the \ character is involved.

  • Raw String - This string type is the raw non-escaped string type.

  • Integer - Any signed whole number or zero.

  • Float - Any signed whole number with a decimal point.

  • Email - An email address in localpart@domain format.

  • URL - URL in the format https://www.cisco.com. Supported prefixes are:

    • http

    • https

    • ftp

    • ftps

    • gopher

    • telnet

    • nttp

    • mailto

    • news

  • IPv4 - IP addresses that adhere to the IPv4 standard format.

  • IPv6 - IP addresses that adhere to the IPv6 standard format.

This script includes all the parameters:

basic = "{{ .orbital_basic_string }}"

raw = "{{ .orbital_raw_string }}"

intNum = {{ .orbital_int }}

fNum = {{ .orbital_float }}

email = "{{ .orbital_email }}"

url = "{{ .orbital_url }}"

ip4 = "{{ .orbital_ip4 }}"

ip6 = "{{ .orbital_ip6 }}"

print("printing Basic String %s" % basic)

print("printing Raw String %s" % raw)

print("printing Integer %d" % intNum)

print("printing Float %f" % fNum)

print("printing Email %s" % email)

print("printing URL %s" % url)

print("printing IPV4 %s" % ip4)

print("printing IPV6 %s" % ip6)

Paste this code into the Orbital builder and click Get parameters from custom script to populate the Parameters field. Each parameter type will need to be adjusted after they are detected.

Escaping Special Characters

Orbital automatically escapes these special Python characters:

  • '

  • "

  • \

There is no need to consider special handling of these characters when authoring a script.

Examples of Using Script's Parameters in Python

Note: We recommended that you set the Orbital Script parameters as Python variables and use the Python variables instead of the Script parameters.

An example of using a Script parameter as an int input for a Python function is:

pid = {{ .orbital_param_pid }}

 

print("killing pid: %d" % pid)

os.kill(pid, SIGKILL)

An example of using a Script parameter as a string input for a Python function is:

Important Note: Quotation marks must fully enclose the Script parameter before it is passed to Python, as it is passed directly inline.

 

# use quotes to create a python string

filename = "{{ .orbital_param_filename }}"

 

print("opening file: %s" % filename)

file = open(filename)

Script Parameter Definition Through the Orbital User Interface

Define the parameter values for the script before you save the script to the Catalog when using the Orbital interface. This will inform future users of the values needed to run the script.

For example, if your are creating the script:

print("hello, my name is {{ .name }} and my occupation is {{ .occupation }}")

Add the name and occupation parameters to the Parameters fields of the Orbital Builder.

More Info