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.
npm install triton-netconfig ## TBD
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>)
: returntrue
if the NIC is an admin NIC, andfalse
otherwise.isNicExternal(<NIC Ojbect>)
: returntrue
if the NIC is an external NIC, andfalse
otherwise.isNetAdmin(<NAPI Net Ojbect>)
: returntrue
if the network is an admin network, andfalse
otherwise.isNetExternal(<NAPI Net Ojbect>)
: returntrue
if the network is an external network, andfalse
otherwise.isNetInternal(<NAPI Net Ojbect>)
: returntrue
if the network is an internal network, andfalse
otherwise.
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);
}
});
The following sections are about developing this module.
To run all of the unit tests:
make test-unit
Optional coverage information is generated by:
make test-coverage-unit
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
Changes with possible user impact should:
-
Add a note to the changelog.
-
Bump the package version appropriately (major for breaking changes, minor for new features, patch for bug fixes).
-
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