triton-netconfig

1.5.0 • Public • Published

node-triton-netconfig

This library provides common utility methods to aid in managing network configuration in a Triton Datacenter.

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

Install

npm install triton-netconfig ## TBD

Usage

  • adminNicFromSysinfo(<CN Sysinfo>): return the admin NIC object from the sysinfo JSON object.
  • adminIpFromSysinfo(<CN Sysinfo>): return admin IP address from sysinfo JSON object.
  • adminIpFromVmMetadata(<VM Metadata Object>): return the admin IP address from VM Metadta JSON object.
  • externalIpFromVmMetadata(<VM Metadata Object>): return the external IP address from VM Metadta JSON object.
  • mantaIpFromVmMetadata(<VM Metadata Object>): return the manta IP address from VM Metadta JSON object.
  • adminMacFromVmMetadata(<VM Metadata Object>): return the admin MAC address from VM Metadta JSON object.
  • isNicAdmin(<NIC Ojbect>): return true if the NIC is an admin NIC, and false otherwise.
  • isNicExternal(<NIC Ojbect>): return true if the NIC is an external NIC, and false otherwise.
  • isNetAdmin(<NAPI Net Ojbect>): return true if the network is an admin network, and false otherwise.
  • isNetExternal(<NAPI Net Ojbect>): return true if the network is an external network, and false otherwise.
  • isNetInternal(<NAPI Net Ojbect>): return true if the network is an internal network, and false otherwise.

Example

var netconf = require('triton-netconfig');

var serverOpts = {
    extras: 'sysinfo,agents'
};

cnapi.listServers(serverOpts, function (serversErr, servers) {
    if (serversErr) {
        next(new errors.SDCClientError(serversErr, 'cnapi'));
        return;
    }
    for (var i = 0; i < servers.length; i++) {
        var server = servers[i];

        if (!server.sysinfo) {
            serverIps[server.uuid] = 'unknown';
            continue;
        }

        serverIps[server.uuid] = netconf.adminIpFromSysinfo(server.sysinfo);
    }
});

Development

The following sections are about developing this module.

Testing

To run all of the unit tests:

make test-unit

Optional coverage information is generated by:

make test-coverage-unit

Commiting

Before commit, ensure that the following passes:

make fmt check

You can setup a local git pre-commit hook that'll do that by running

make git-hooks

Releasing

Changes with possible user impact should:

  1. Add a note to the changelog.

  2. Bump the package version appropriately (major for breaking changes, minor for new features, patch for bug fixes).

  3. Once merged to master, the new version should be tagged and published to npm via:

     make cutarelease
    

    To list to npm accounts that have publish access:

     npm owner ls $packageName
    

Readme

Keywords

Package Sidebar

Install

npm i triton-netconfig

Weekly Downloads

1

Version

1.5.0

License

MPL-2.0

Unpacked Size

26.8 kB

Total Files

5

Last publish

Collaborators

  • bahamat
  • todd.whiteman
  • kusor
  • michael.hicks
  • trentm
  • melloc
  • rjloura