Git Product home page Git Product logo

node-triton's Introduction

logo node-triton

This repository is part of the Triton Data Center project. See the contribution guidelines and general documentation at the main Triton project page.

triton is a CLI tool for working with the CloudAPI for Triton public and private clouds.

CloudAPI is a RESTful API for end users of the cloud to manage their accounts, instances, networks, images, and to inquire other relevant details. CloudAPI provides a single view of docker containers, infrastructure containers and hardware virtual machines available in the Triton solution.

There is currently another CLI tool known as node-smartdc for CloudAPI. node-smartdc CLI works off the 32-character object UUID to uniquely identify object instances in API requests, and returns response payload in JSON format. The CLI covers both basic and advanced usage of CloudAPI.

The triton CLI is currently in beta (effectively because it does not yet have complete coverage of all commands from node-smartdc) and will be expanded over time to support all CloudAPI commands, eventually replacing node-smartdc as both the API client library for Triton cloud and the command line tool.

Setup

User accounts, authentication, and security

Before you can use the CLI you'll need an account on the cloud to which you are connecting and an SSH key uploaded. The SSH key is used to identify and secure SSH access to containers and other resources in Triton.

API endpoint

Each data center has a single CloudAPI endpoint. For MNX Public Cloud, you can find the list of data centers here. For private cloud implementations, please consult the private cloud operator for the correct URL. Have the URL handy as you'll need it in the next step.

Installation

Install node.js, then:

npm install -g triton

Verify that it is installed and on your PATH:

$ triton --version
Triton CLI 4.15.0
https://github.com/TritonDataCenter/node-triton

To use triton, you'll need to configure it to talk to a Triton DataCenter API endpoint (called CloudAPI). Commonly that is done using a Triton profile:

$ triton profile create
A profile name. A short string to identify a CloudAPI endpoint to the
`triton` CLI.
name: central1

The CloudAPI endpoint URL.
url: https://us-central-1.api.mnx.io

Your account login name.
account: bob

Available SSH keys:
 1. 2048-bit RSA key with fingerprint 4e:e7:56:9a:b0:91:31:3e:23:8d:f8:62:12:58:a2:ec
  * [in homedir] bob-20160704 id_rsa

The fingerprint of the SSH key you want to use, or its index in the list
above. If the key you want to use is not listed, make sure it is either saved
in your SSH keys directory or loaded into the SSH agent.
keyId: 1

Saved profile "central1".

WARNING: Docker uses TLS-based authentication with a different security model
from SSH keys. As a result, the Docker client cannot currently support
encrypted (password protected) keys or SSH agents. If you continue, the
Triton CLI will attempt to format a copy of your SSH *private* key as an
unencrypted TLS cert and place the copy in ~/.triton/docker for use by the
Docker client.
Continue? [y/n] y
Setting up profile "central1" to use Docker.
Setup profile "central1" to use Docker (v1.12.3). Try this:
    eval "$(triton env --docker central1)"
    docker info

Set "central1" as current profile (because it is your only profile).

Or instead of using profiles, you can set the required environment variables (triton defaults to an "env" profile that uses these environment variables if no profile is set). For example:

TRITON_URL=https://us-central-1.api.mnx.io
TRITON_ACCOUNT=bob
TRITON_KEY_ID=SHA256:j2WoSeOWhFy69BQ0uCR3FAySp9qCZTSCEyT2vRKcL+s

For compatibility with the older sdc-* tools from node-smartdc, triton also supports SDC_URL, SDC_ACCOUNT, etc. environment variables.

Bash completion

Install Bash completion with

triton completion > /usr/local/etc/bash_completion.d/triton     # Mac
triton completion > /etc/bash_completion.d/triton               # Linux

Alternatively, if you don't have or don't want to use a "bash_completion.d" dir, then something like this would work:

triton completion > ~/.triton.completion
echo "source ~/.triton.completion" >> ~/.bashrc

Then open a new shell or manually source FILE that completion file, and play with the bash completions:

triton <TAB>

triton CLI Usage

Create and view instances

$ triton instance list
SHORTID  NAME  IMG  STATE  PRIMARYIP  AGO

We have no instances created yet, so let's create some. In order to create an instance we need to specify two things: an image and a package. An image represents what will be used as the root of the instances filesystem, and the package represents the size of the instance, eg. ram, disk size, cpu shares, etc. More information on images and packages below - for now we'll just use SmartOS 64bit and a small 128M ram package.

triton instance create base-64 t4-standard-128M

Without a name specified, the container created will have a generated ID. Now to create a container-native Ubuntu 14.04 container with 2GB of ram with the name "server-1"

triton instance create --name=server-1 ubuntu-14.04 t4-standard-2G

Now list your instances again

$ triton instance list
SHORTID   NAME      IMG                     STATE         PRIMARYIP        AGO
7db6c907  b851ba9   [email protected]          running       165.225.169.63   9m
9cf1f427  server-1  ubuntu-14.04@20150819   provisioning  -                0s

Get a quick overview of your account

$ triton info
login: [email protected]
name: Dave Eddy
email: [email protected]
url: https://us-central-1.api.mnx.io
totalDisk: 50.5 GiB
totalMemory: 2.0 MiB
instances: 2
    running: 1
    provisioning: 1

To obtain more detailed information of your instance

$ triton instance get server-1
{
    "id": "9cf1f427-9a40-c188-ce87-fd0c4a5a2c2c",
    "name": "251d4fd",
    "type": "smartmachine",
    "state": "running",
    "image": "c8d68a9e-4682-11e5-9450-4f4fadd0936d",
    "ips": [
        "165.225.169.54",
        "192.168.128.16"
    ],
    "memory": 2048,
    "disk": 51200,
    "metadata": {
        "root_authorized_keys": "(...ssh keys...)"
    },
    "tags": {},
    "created": "2015-09-08T04:56:27.734Z",
    "updated": "2015-09-08T04:56:43.000Z",
    "networks": [
        "feb7b2c5-0063-42f0-a4e6-b812917397f7",
        "726379ac-358b-4fb4-bb7c-8bc4548bac1e"
    ],
    "dataset": "c8d68a9e-4682-11e5-9450-4f4fadd0936d",
    "primaryIp": "165.225.169.54",
    "firewall_enabled": false,
    "compute_node": "44454c4c-5400-1034-8053-b5c04f383432",
    "package": "t4-standard-2G"
}

SSH to an instance

Connect to an instance over SSH

$ triton ssh b851ba9
Last login: Wed Aug 26 17:59:35 2015 from 208.184.5.170

  ,---.                   |     ,---. ,---.
  `---. ,-.-. ,---. ,---. |---  |   | `---.  base-64-lts
      | | | | ,---| |     |     |   |     |  21.4.1
  `---' ` ' ' `---' `     `---' `---' `---'


[root@7db6c907-2693-42bc-ea9b-f38678f2554b ~]# uptime
 20:08pm  up   2:27,  0 users,  load average: 0.00, 0.00, 0.01
[root@7db6c907-2693-42bc-ea9b-f38678f2554b ~]# logout
Connection to 165.225.169.63 closed.

Or non-interactively

$ triton ssh b851ba9 uname -v
joyent_20150826T120743Z

Manage an instance

Commonly used container operations are supported in the Triton CLI:

$ triton help instance
...
    list (ls)           List instances.
    get                 Get an instance.
    create              Create a new instance.
    delete (rm)         Delete one or more instances.

    start               Start one or more instances.
    stop                Stop one or more instances.
    reboot              Reboot one or more instances.

    ssh                 SSH to the primary IP of an instance
    wait                Wait on instances changing state.
    audit               List instance actions.

View packages and images

Package definitions and images available vary between different data centers and different Triton cloud implementations.

To see all the packages offered in the data center and specific package information, use

triton package list
triton package get ID|NAME

Similarly, to find out the available images and their details, do

triton image list
triton images ID|NAME

Note that docker images are not shown in triton images as they are maintained in Docker Hub and other third-party registries configured to be used with Triton clouds. In general, docker containers should be provisioned and managed with the regular docker CLI (Triton provides an endpoint that represents the entire datacenter as a single DOCKER_HOST. See the Triton Docker documentation for more information.)

TritonApi Module Usage

Node-triton can also be used as a node module for your own node.js tooling. A basic example appropriate for a command-line tool is:

var mod_bunyan = require('bunyan');
var mod_triton = require('triton');

var log = mod_bunyan.createLogger({name: 'my-tool'});

// See the `createClient` block comment for full usage details:
//      https://github.com/TritonDataCenter/node-triton/blob/master/lib/index.js
mod_triton.createClient({
    log: log,
    // Use 'env' to pick up 'TRITON_/SDC_' env vars. Or manually specify a
    // `profile` object.
    profileName: 'env',
    unlockKeyFn: mod_triton.promptPassphraseUnlockKey
}, function (err, client) {
    if (err) {
        // handle err
    }

    client.listImages(function (err, images) {
        client.close();   // Remember to close the client to close TCP conn.
        if (err) {
            console.error('listImages err:', err);
        } else {
            console.log(JSON.stringify(images, null, 4));
        }
    });
});

See the following for more details:

Configuration

This section defines all the vars in a TritonApi config. The baked in defaults are in "etc/defaults.json" and can be overriden for the CLI in "~/.triton/config.json" (on Windows: "%APPDATA%/Joyent/Triton/config.json").

Name Description
profile The name of the triton profile to use. The default with the CLI is "env", i.e. take config from SDC_* envvars.
cacheDir The path (relative to the config dir, "~/.triton") where cache data is stored. The default is "cache", i.e. the triton CLI caches at "~/.triton/cache".

node-triton differences with node-smartdc

  • There is a single triton command instead of a number of sdc-* commands.
  • TRITON_* environment variables are preferred to the SDC_* environment variables. However the SDC_* envvars are still supported.
  • Node-smartdc still has more complete coverage of the Triton CloudAPI. However, triton is catching up and is much more friendly to use.

Development Hooks

Before commiting be sure to, at least:

make check      # lint and style checks
make test-unit  # run unit tests

A good way to do that is to install the stock pre-commit hook in your clone via:

make git-hooks

Also please run the full (longer) test suite (make test). See the next section.

Testing

node-triton has both unit tests (make test-unit) and integration tests (make test-integration). Integration tests require a config file, by default at "test/config.json". For example:

$ cat test/config.json
{
    "profileName": "east3b",
    "allowWriteActions": true,
    "image": "minimal-64",
    "package": "g4-highcpu-128M",
    "resizePackage": "g4-highcpu-256M"
}

See "test/config.json.sample" for a description of all config vars. Minimally just a "profileName" or "profile" is required.

Warning: Running the integration tests will create resources and could incur costs if running against a public cloud.

Usage:

make test-unit [TEST-VARS]          # run unit tests
make test-integration [TEST-VARS]   # run integration tests
make test [TEST-VARS]               # run both sets

Test output is node-tap's default short-form output. Full TAP output is written to "test-unit.tap" and "test-integration.tap". You can use TAP=1 to have TAP output emited to stdout.

Test vars

There are a few TEST_... vars that can tweak how the tests are run.

  • TEST_CONFIG=<path to JSON config file> - By default the integration test suite uses "test/config.json". Use this flag to provide an alternative. This can be useful if you have test configs for a number of separate target DCs. E.g.:

      $ cat test/coal.json
      {
          "profileName": "coal",
          "allowWriteActions": true
      }
      $ make test TEST_CONFIG=test/coal.json
    

    where "coal" here refers to a development Triton (a.k.a SDC) "Cloud On A Laptop" standup.

  • TEST_GLOB=<glob for test file basename> - By default all "*.test.js" in the "test/unit/" and "test/integration" dirs are run. To run just those with "image" in the name, use make test TEST_GLOB=*image*, or to run a specific test file: make test TEST_GLOB=metadataFromOpts.

  • TEST_KNOWN_FAIL=1 - At any given time there may be some known failures in the test suite that are being worked on in specific tickets. Those tests may be excluded from the default test run. These will show up in test output like this:

    test/integration/cli-snapshots.test.js ................ 0/1 1s
      Skipped: 1
        triton instance snapshot known failure, see TRITON-1387

    Set the TEST_KNOWN_FAIL=1 environment variable to include these tests in the test run.

  • TEST_JOBS=<number of test files to run concurrently> - By default this is 10. Set to 1 to run tests serially. Note: Write tests must be run serially.

  • TEST_TIMEOUT_S=<number of seconds timeout for each test file> - By default this is 1200 (10 minutes). Ideally tests are written to take much less than 10 minutes.

  • TAP=1 to have the test suite emit TAP output. This is a node-tap envvar.

Testing Development Guide

  • Unit tests (i.e. not requiring the cloudapi endpoint) in "unit/*.test.js". Integration tests "integration/*.test.js".

  • We are using node-tap. Read RFD 139 for some guidelines for node-tap usage. The more common we can make some basic usage patterns in the many Triton repos, the easier the maintenance.

  • Use "test/lib/*.js" and "test/{unit,integration}/helpers.js" to help make ".test.js" code more expressive. Avoid excessive parameterization, however. Some cut 'n paste of boilerplate is fine if it makes an individual test clearer and easier to debug and maintain.

  • Node-tap supports running test files in parallel, and make test by default runs tests in parallel. Therefore:

    • Ensure that test files do not depend on each other and can run concurrently.
    • Prefer more and smaller and more targetted test files.

Release process

Here is how to cut a release:

  1. Make a commit to set the intended version in "package.json#version" and changing ## not yet released at the top of "CHANGES.md" to:

    ## not yet released
    
    ## $version
  2. Get that commit approved and merged via a pull request.

  3. Once that is merged and you've updated your local copy, run:

    make cutarelease

    This will run a couple checks (clean working copy, versions in package.json and CHANGES.md match), then will git tag and npm publish.

License

MPL 2.0

node-triton's People

Contributors

alyssais avatar andrew-wharton avatar arekinath avatar bahamas10 avatar bahamat avatar cburroughs avatar dependabot[bot] avatar dillona avatar dwlf avatar jasonbking avatar jclulow avatar joshwilsdon avatar joyent-automation avatar krisshannon avatar kusor avatar numericillustration avatar teutat3s avatar travispaul avatar trentm avatar twhiteman avatar yangyong3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-triton's Issues

"glob" module

do we need this module to simply find JSON files?

var files = glob.sync(path.resolve(opts.configDir, 'profiles.d', '*.json'));
for (var i = 0; i < files.length; i++) {
  ..
}

could become

var d = path.join(opts.configDir, 'profiles.d');
var files = fs.readdirSync(d);
files.forEach(function (file) {
  var ext = path.extname(file);
  if (ext !== 'json')
    return;
  var fullpath = path.join(d, file);
  ...
});

glob does a lot more than we really need it for

first cut of 'triton profiles'

This will implement 'triton profiles' and profile selection support. However, it doesn't yet support creating new profiles, editing them or deleting them. 'triton profiles' will be a "hidden" command until then.

triton ssh command not aware of "ubuntu" login for ubuntu-certified images

triton ssh INSTANCE_NAME will fail on an instance based on ubuntu-certified with the following error:

[christopher@JoyentMacBookPro ~/GitHub/node-triton]$ triton ssh ubuntu-certified-14.04-20150805
Warning: Permanently added '8.12.42.20' (ECDSA) to the list of known hosts.
Please login as the user "ubuntu" rather than the user "root".


Connection to 8.12.42.20 closed.

triton insts crashes if no primaryIP

If triton insts is run very early in the provisioning process, before an IP is assigned it'll throw an exception.

Phoenix:~] triton create base-64-lts g3-standard-0.25-smartos -n bmake-deploy
Creating instance bmake-deploy (c5d66161-5a7d-4ab0-e029-a4ddfc14c9ab, [email protected], g3-standard-0.25-smartos)
Phoenix:~] triton insts

/opt/pkg/lib/node_modules/joyent-triton/node_modules/tabula/lib/tabula.js:277
            throw new Error('no property ' + s.join(c) + ' found');
                  ^
Error: no property primaryIp found
    at dottedLookup (/opt/pkg/lib/node_modules/joyent-triton/node_modules/tabula/lib/tabula.js:277:19)
    at Array.4 (/opt/pkg/lib/node_modules/joyent-triton/node_modules/tabula/lib/tabula.js:181:24)
    at /opt/pkg/lib/node_modules/joyent-triton/node_modules/tabula/lib/tabula.js:206:35
    at Array.forEach (native)
    at tabulaFormat (/opt/pkg/lib/node_modules/joyent-triton/node_modules/tabula/lib/tabula.js:203:11)
    at tabulaPrint (/opt/pkg/lib/node_modules/joyent-triton/node_modules/tabula/lib/tabula.js:259:26)
    at done (/opt/pkg/lib/node_modules/joyent-triton/lib/do_instances.js:110:13)
    at /opt/pkg/lib/node_modules/joyent-triton/lib/do_instances.js:83:9
    at LOMStream.<anonymous> (/opt/pkg/lib/node_modules/joyent-triton/lib/cloudapi2.js:588:9)
    at LOMStream.emit (events.js:92:17)

These commands were run within about 3 seconds of each other.

`triton` commands blow up obtusely if getting HTML content back from cloudapi endpoints

I was hitting the following when I had a triton profile for talking to my COAL's cloudapi. What happened was that after building a new COAL, what had been the IP for cloudapi was now the IP for adminui. The result:

$ triton -v imgs 2>&1 | bunyan
...
[2015-09-23T19:15:25.689Z] TRACE: triton/39097 on danger0.local (/Users/trentm/joy/node-triton/node_modules/restify-clients/lib/JsonClient.js:55 in parseResponse): Invalid JSON in response
    SyntaxError: Unexpected token <
        at Object.parse (native)
        at parseResponse (/Users/trentm/joy/node-triton/node_modules/restify-clients/lib/JsonClient.js:50:28)
        at IncomingMessage.done (/Users/trentm/joy/node-triton/node_modules/restify-clients/lib/StringClient.js:180:13)
        at IncomingMessage.g (events.js:180:16)
        at IncomingMessage.emit (events.js:117:20)
        at _stream_readable.js:944:16
        at process._tickCallback (node.js:448:13)

/Users/trentm/joy/node-triton/node_modules/assert-plus/assert.js:87
                        throw new assert.AssertionError({
                              ^
AssertionError: items ([object]) required
    at tabulaFormat (/Users/trentm/joy/node-triton/node_modules/tabula/lib/tabula.js:123:12)
    at tabulaPrint (/Users/trentm/joy/node-triton/node_modules/tabula/lib/tabula.js:259:26)
    at onRes (/Users/trentm/joy/node-triton/lib/do_images.js:98:13)
    at /Users/trentm/joy/node-triton/lib/tritonapi.js:244:13
    at next (/Users/trentm/joy/node-triton/node_modules/vasync/lib/vasync.js:201:4)
    at /Users/trentm/joy/node-triton/lib/tritonapi.js:137:9
    at Object.oncomplete (fs.js:108:15)

Need to differentiate kvm vs lx in "triton images" output

Need to differentiate kvm vs lx in "triton images" output

$ triton images | grep -E 'SHORTID|ubuntu'
SHORTID   NAME                                 VERSION     STATE   FLAGS  OS       PUBDATE
e28711b3  ubuntu-certified-12.04               20140227    active  P      linux    2014-02-27
fe5aa6c0  ubuntu-certified-12.04               20140408    active  P      linux    2014-04-08
df165dad  ubuntu-certified-14.04               20140416    active  P      linux    2014-04-16
7735fbba  ubuntu-certified-14.04               20140519    active  P      linux    2014-05-19
0fd57f23  ubuntu-certified-12.04               20140519    active  P      linux    2014-05-19
f21af273  ubuntu-certified-12.04               20140608    active  P      linux    2014-06-08
286b0dc0  ubuntu-certified-14.04               20140608    active  P      linux    2014-06-08
202d0d26  ubuntu-certified-14.04               20140729    active  P      linux    2014-07-29
6c970fa8  ubuntu-certified-12.04               20140806    active  P      linux    2014-08-06
d0fb3c79  ubuntu-certified-12.04               20140926    active  P      linux    2014-09-26
c841e585  ubuntu-certified-14.04               20140926    active  P      linux    2014-09-26
01a24b88  ubuntu-certified-12.04               20140929    active  P      linux    2014-09-29
5f67e820  ubuntu-certified-14.04               20140929    active  P      linux    2014-09-29
47c62485  ubuntu-certified-14.10               20141022.3  active  P      linux    2014-10-22
be16f02b  ubuntu-certified-12.04               20150127    active  P      linux    2015-01-27
c864f104  ubuntu-certified-14.04               20150225.2  active  P      linux    2015-02-25
415e39e6  ubuntu-certified-12.04               20150225.1  active  P      linux    2015-02-25
430da066  ubuntu-14.04                         20150415    active  P      linux    2015-04-15
a21a64a0  ubuntu-14.04                         20150601    active  P      linux    2015-06-01
5a0145ee  ubuntu-14.04                         20150618    active  P      linux    2015-06-18
7a56eecc  ubuntu-14.04                         20150625    active  P      linux    2015-06-25
0bd891a8  ubuntu-14.04                         20150629    active  P      linux    2015-06-29
506bd05d  ubuntu-certified-12.04               20150709    active  P      linux    2015-07-09
143e254a  ubuntu-certified-14.04               20150708    active  P      linux    2015-07-09
a41ffcbc  ubuntu-certified-14.10               20150708    active  P      linux    2015-07-09
ead4ff68  ubuntu-14.04                         20150724    active  P      linux    2015-07-24
b33d4dec  ubuntu-certified-15.04               20150807    active  P      linux    2015-08-08
c8d68a9e  ubuntu-14.04                         20150819    active  P      linux    2015-08-19

I can't tell which of those are Lx-brand and which are kvm images.

Possible Solutions

For sdc-adminui listing, I'm going to prepend "kvm" to the OS of zvol ones. Alternatively, you could introduce another column.

error message emitted when images cache not found

$ rm -rf ~/.triton/
$ triton instances
{"name":"triton","hostname":"joyent-laptop.local","pid":45472,"level":40,"err":{"message":"ENOENT, open '/Users/dave.eddy/.triton/cache/dave_eddy_joyent_com@us-east-3b_api_joyent_com/images.json'","name":"Error","stack":"Error: ENOENT, open '/Users/dave.eddy/.triton/cache/dave_eddy_joyent_com@us-east-3b_api_joyent_com/images.json'","code":"ENOENT"},"cacheFile":"/Users/dave.eddy/.triton/cache/dave_eddy_joyent_com@us-east-3b_api_joyent_com/images.json","msg":"failed to read cache file","time":"2015-09-08T18:28:51.638Z","v":0}
SHORTID  NAME  IMG  STATE  PRIMARYIP  AGO

usage error could be friendlier

For example:

$ triton create
triton create: error (Usage): incorrect number of args (0):

This should probably also print the help message, or at least the usage synopsis.

Use http-signature for generating Authorization, not sprintf

(this is also PUBAPI-1166)

Currently there are sprintf calls in node-smartdc,manta,triton etc which generate the Authorization headers for HTTP signature auth in these tools. We should switch to using the new async RequestSigner API in http-signature 1.0 and centralize all this duplicated code.

get cloudapi error body details into Triton CLI error messages

...
[2015-09-08T18:24:50.339Z] TRACE: triton/14482 on danger0.local (/Users/trentm/joy/node-triton/node_modules/restify-clients/lib/StringClient.js:166 in done):
    body received:
    {"code":"ValidationFailed","message":"Invalid VM parameters","errors":[{"field":"cpu_cap","code":"Invalid","message":"Not a valid number: number must be >= 0"}]}
joyent-triton create: error (ValidationFailed): ValidationFailedError: Invalid VM parameters
    at parseResponse (/Users/trentm/joy/node-triton/node_modules/restify-clients/lib/JsonClient.js:72:26)
    at IncomingMessage.done (/Users/trentm/joy/node-triton/node_modules/restify-clients/lib/StringClient.js:180:13)
    at IncomingMessage.g (events.js:180:16)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:944:16
    at process._tickCallback (node.js:448:13)

Specifically, this error was due to a hacked up package (cpu_cap set to null), but that "error" response body should get into the error message in general. See possible example from 'sdc-imgapi-cli.git'.

Brew install support for Mac OS X

I'd love to be able to tell Mac users to install triton using a command like brew install triton and be done. Many of us are using brew to install node and npm, so the package dependencies are already there, and the win in convenience is huge.

`triton ssh INST COMMAND` missing stdout with node >=0.12 and ControlMaster

triton ssh <instance> appears to hang because there's no output from the command. Logging into the instance directly with ssh shows me that the triton nested session is in fact logged in, and that commands are being executed.

Typing exit, logout, or ^D returns me to my local shell.


Update (by @trentm 2016-03-11): adding a known issue for anyone hitting thise or curious about the workaround added in triton version 4.8.0.

known issue

triton instance ssh works by spawning ssh (with node's
child_process.spawn).

There is a known issue with SSH connection multiplexing (a.k.a.
ControlMaster, mux) where stdout/stderr is lost. As a workaround, ssh
is spawned with options disabling ControlMaster.

If you want to use ControlMaster here is an alternative:

ssh root@$(triton ip <inst>)

invalid machine name on duplicate

$ triton create -wn my-machine [email protected] t4-standard-128M
Creating instance my-machine (11e9c842-0546-c806-b6d3-aa71f5b18af8, [email protected], t4-standard-128M)
Created instance my-machine (11e9c842-0546-c806-b6d3-aa71f5b18af8) in 44s
$ triton create -wn my-machine [email protected] t4-standard-128M
triton create: error (ValidationFailed): Invalid VM parameters: Invalid machine name

"Invalid machine name", while correct, is not that descriptive for duplicates

consider changing test config var name away from 'destructiveAllowed'

It is a bit alarmist. A relavant discussion:

`destructiveAllowed`
meaning you can issue delete calls?

tRent
perhaps a bad name. That's the thing that says it can create and delete resources: instances, images, networks, etc.
we should change the name

angela
haha negative connotations - maybe it’s just me

tRent
the implication are:
- will take longer to run
- will use resources (which could result in cost on a public cloud)
- is deleting things, so has the *potential* to screw up

angela
if it’s false, we are just doing GETs?

triton bash completion not working

Not sure if I've missed something. All I got was this:

$ triton completion
joyent-triton completion: error: Object #<CLI> has no method 'bashCompletion'

triton images cache issue

Running trition insts resulted in output like this:

ravio:node-triton Michael.Zeller$ triton insts
SHORTID   NAME          STATE    TYPE          IMG                                   MEMORY  DISK    AGO
e237c065  btsync        running  smartmachine  818cc79e-ceb3-11e4-99ee-7bc8c674e754  512     25600   20w
dc4f8fd3  go            running  smartmachine  [email protected]                    128     10240   22w

Trent suggested running triton images > /dev/null and running again, which resulted in:

e237c065  btsync        running  smartmachine  lx-ubuntu-14.04@20150320              512     25600   20w
dc4f8fd3  go            running  smartmachine  [email protected]                    128     10240   22w

triton command fails with self-signed cert

Phoenix:~] triton -p home insts
triton insts: error: DEPTH_ZERO_SELF_SIGNED_CERT
Phoenix:~] triton -p home -i insts                                                       '-> 1

/opt/pkg/lib/node_modules/joyent-triton/lib/cloudapi2.js:556
            var resourcecount = res.headers['x-resource-count'];
                                   ^
TypeError: Cannot read property 'headers' of null
    at /opt/pkg/lib/node_modules/joyent-triton/lib/cloudapi2.js:556:36
    at parseResponse (/opt/pkg/lib/node_modules/joyent-triton/node_modules/restify-clients/lib/JsonClient.js:92:9)
    at ClientRequest.parseResponse (/opt/pkg/lib/node_modules/joyent-triton/node_modules/restify-clients/lib/StringClient.js:215:13)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.emit (events.js:98:17)
    at _emitResult (/opt/pkg/lib/node_modules/joyent-triton/node_modules/restify-clients/lib/HttpClient.js:151:14)
    at f (/opt/pkg/lib/node_modules/joyent-triton/node_modules/once/once.js:17:25)
    at /opt/pkg/lib/node_modules/joyent-triton/node_modules/restify-clients/lib/HttpClient.js:189:17
    at process._tickCallback (node.js:448:13)

But works with sdc-*

Phoenix:~] SDC_TESTING=1 sdc-listmachines -u https://cloudapi/ | json -Ha id state
9d6158b6-6175-41b3-f966-eddf1f7e3fc5 running
bec368ba-7e3b-6db1-923b-d3db8f92d9af running
8c4bf356-da3d-c074-f6d4-8758f85b8195 running
7020eeeb-969c-e1be-85ac-e19f155ea38e running
3734d6c4-8c2a-4798-8249-994a8641745c running
ee844fad-6d57-61fe-8f56-f5c39b0bf60e running
1126ffdf-08d1-cd46-d165-e4c7e554a9a9 running
8ab474d1-c420-ebf3-c187-82f9e1bea474 running
Phoenix:~] 

`triton info` improvements

$ triton info
trentm - undefined undefined <test+trentm@localhost>
https://10.88.88.5

0 instance(s)
- 0 B RAM Total
- 0 B Disk Total
  1. Note the 'undefined's if the user record doesn't have the name fields set.
  2. I'm inclined to change to a YAML-y type output (a la triton account and docker info)

Also, I'm wondering about changing the JSON output from triton info -j to just be the fields shown, i.e. just the counts and totals instead of the full list of instances so that we aren't stuck promising that. If triton info becomes heavily used we'd like to be able to make that quicker on the server side with an info endpoint that could be faster.

dtrace optional?

I didn't have mac xcode or mac command line tools installed, so the dtrace install portion understandably failed. triton --version didn't like not finding the dtrace module.

oyd:node-triton ll$ npm install -g .
|
> [email protected] install /usr/local/lib/node_modules/joyent-triton/node_modules/restify-clients/node_modules/dtrace-provider
> node scripts/install.js

---------------
Building dtrace-provider failed with exit code 1 and signal 0
re-run install with environment variable V set to see the build output
---------------

> [email protected] install /usr/local/lib/node_modules/joyent-triton/node_modules/bunyan/node_modules/dtrace-provider
> node scripts/install.js

---------------
Building dtrace-provider failed with exit code 1 and signal 0
re-run install with environment variable V set to see the build output
---------------
/usr/local/bin/triton -> /usr/local/lib/node_modules/joyent-triton/bin/triton
[email protected] /usr/local/lib/node_modules/joyent-triton
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected])
oyd:node-triton ll$ triton --version
{ [Error: Cannot find module './build/Release/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }
{ [Error: Cannot find module './build/default/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }
{ [Error: Cannot find module './build/Debug/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }
{ [Error: Cannot find module './build/Release/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }
{ [Error: Cannot find module './build/default/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }
{ [Error: Cannot find module './build/Debug/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }
triton 1.0.0

source <(triton completion) doesn't work on Mac 10.11.1 bash 3.2.57(1)

source <(triton completion) doesn't work on Mac 10.11.1 bash 3.2.57(1). It is documented in README.md .

It worked as expected on lx ubuntu-14.04@20150819 and when triton completion >> ~/.bashrc on Mac.

$ sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.11.1
BuildVersion:   15B17c
$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.

`getImg` should support the `name@version` syntax

Because if I look at current insts:

$ triton insts
SHORTID   NAME                         IMG                                STATE    PRIMARYIP    AGO
0227ae00  Achilles-20141003T051139Z-0  [email protected]                    running  172.26.3.29  50w
8e3aae37  test0                        [email protected]                        running  172.26.3.61  2h
4fa9e7e7  test1kvm                     [email protected]  running  172.26.3.62  2h

and want another of [email protected], I should be able to use that string for the image. But I get:

$ triton create -w -n test1 [email protected] t4-standard-256M
triton create: error: no image with name or short id "[email protected]" was found

ver info (hrm, that could be improved to show commit number or something):

$ triton --version
triton 1.0.0

"triton create" could better handle missing package argument

See, for example, pointing at staging-3:

jclulow@jmcbook ~ $ triton create -w base-32-lts

/Users/jclulow/proj/node-triton/node_modules/assert-plus/assert.js:45
                        throw new assert.AssertionError({
                              ^
AssertionError: options.package (string) is required
    at Object.uuid (/Users/jclulow/proj/node-triton/node_modules/assert-plus/assert.js:165:9)
    at CloudAPI.createMachine (/Users/jclulow/proj/node-triton/lib/cloudapi2.js:592:12)
    at Object.createInst [as func] (/Users/jclulow/proj/node-triton/lib/do_create_instance.js:90:22)
    at Immediate._onImmediate (/Users/jclulow/proj/node-triton/node_modules/vasync/lib/vasync.js:213:20)
    at processImmediate [as _immediateCallback] (timers.js:367:17)

Obviously I'm missing the second argument (PACKAGE). It's not clear if it is (as shown in the synopsis) optional or not. Either way, the message is not great.

-J flag stopped working

The -J flag to select the datacenter isn't working anymore.

I only have one profile.

Phoenix:~] triton profiles                                
NAME  CURR  ACCOUNT   URL
env   *     bbennett  https://us-west-1.api.joyent.com

List of instances in my default profile

Phoenix:~] triton insts           
SHORTID   NAME                 IMG                              STATE    PRIMARYIP        AGO
969c262c  gray.digitalelf.net  [email protected]                    running  165.225.150.182  1y
8d7e7bb5  docker-build         ubuntu-certified-14.10@20150708  running  165.225.151.57   2w
c5d66161  bmake-deploy         [email protected]               running  165.225.150.8    4d

Selecting us-sw-1 produces the same result as us-west-1.

Phoenix:~] triton -J us-sw-1 insts
SHORTID   NAME                 IMG                              STATE    PRIMARYIP        AGO
969c262c  gray.digitalelf.net  [email protected]                    running  165.225.150.182  1y
8d7e7bb5  docker-build         ubuntu-certified-14.10@20150708  running  165.225.151.57   2w
c5d66161  bmake-deploy         [email protected]               running  165.225.150.8    4d

But sdc-listmachines shows the real set.

Phoenix:~] sdc-listmachines -u https://us-sw-1.api.joyent.com/ | json -Ha name state primaryIp
pi-builder running 165.225.157.114
freebsd running 64.30.128.85
hopeful_hoover stopped 64.30.128.170

profiles name mismatch

$ cat ~/.triton/profiles.d/foo.json | json name
e3b
$ triton profiles
NAME  CURR  ACCOUNT               URL
env   *     [email protected]  https://us-east-3b.api.joyent.com
foo         [email protected]  https://us-east-3b.api.joyent.com

it uses the filename and not the name field... perhaps "name" is redundant?

two test failures when ./test/config.json and `TRITON_TEST_PROFILE` differ

# triton profiles (read only)
# triton profile env
# running: triton profile -j env
ok 47 no error running child process
ok 48 no stderr produced
ok 49 stdout produced
not ok 50 env account correct
  ---
    operator: equal
    expected: 'trent.mick'
    actual:   'trentm'
  ...
ok 51 env keyId correct
not ok 52 env url correct
  ---
    operator: equal
    expected: |-
      'https://us-east-3b.api.joyent.com'
    actual: |-
      'https://api.coal'
  ...

Triton help for setting up and using Docker against a Triton DC

Can we use triton to fill the gap we're facing without docker-machine support just now?

For example, how do we feel about setting up the proper docker environment vars using the current triton account by doing:

eval $(triton docker env)

Has this been discussed already and I missed it?

accidentally empty cache file and `triton` warns too loudly

$ triton insts
{"name":"triton","hostname":"danger0.local","pid":29163,"level":40,"err":{"message":"Unexpected end of input","name":"SyntaxError","stack":"SyntaxError: Unexpected end of input\n    at Object.parse (native)\n    at /Users/trentm/joy/node-triton/lib/tritonapi.js:161:28\n    at fs.js:272:14\n    at Object.oncomplete (fs.js:108:15)"},"keyPath":"/Users/trentm/.triton/cache/trentm@10_88_88_3/images.json","msg":"error parsing JSON cache file","time":"2015-09-18T23:51:12.731Z","v":0}

assert.js:93
  throw new assert.AssertionError({
        ^
AssertionError: false == true
    at Object.module.exports.(anonymous function) [as ok] (/Users/trentm/joy/node-triton/node_modules/assert-plus/assert.js:242:35)
    at lomValidData (/Users/trentm/joy/node-triton/node_modules/lomstream/lib/lomstream.js:278:13)
    at lomFetchDoneCallback (/Users/trentm/joy/node-triton/node_modules/lomstream/lib/lomstream.js:344:2)
    at donecb (/Users/trentm/joy/node-triton/node_modules/lomstream/lib/lomstream.js:399:3)
    at /Users/trentm/joy/node-triton/lib/cloudapi2.js:558:13
    at parseResponse (/Users/trentm/joy/node-triton/node_modules/restify-clients/lib/JsonClient.js:92:9)
    at IncomingMessage.done (/Users/trentm/joy/node-triton/node_modules/restify-clients/lib/StringClient.js:180:13)
    at IncomingMessage.g (events.js:180:16)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:944:16

`triton list` alias for instances

Feature request: triton list alias for triton instances as i is really crowded.

$ triton i
image           images          img             imgs            info            inst
instance        instance-audit  instances       insts

Ability to provision multiple instances of the same image/package

This corresponds to the request for cloudapi PUBAPI-1117. I don't know where the change is best implemented - cloudapi, cloudapi v2, or at the CLI level. We'll have to think about how it works with the -w flag if we allow user to specify some -n option to provision multiple.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.