1.5.0 • Published 4 years ago
triton-netconfig v1.5.0
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 ## TBDUsage
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>): returntrueif the NIC is an admin NIC, andfalseotherwise.isNicExternal(<NIC Ojbect>): returntrueif the NIC is an external NIC, andfalseotherwise.isNetAdmin(<NAPI Net Ojbect>): returntrueif the network is an admin network, andfalseotherwise.isNetExternal(<NAPI Net Ojbect>): returntrueif the network is an external network, andfalseotherwise.isNetInternal(<NAPI Net Ojbect>): returntrueif the network is an internal network, andfalseotherwise.
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-unitOptional coverage information is generated by:
make test-coverage-unitCommiting
Before commit, ensure that the following passes:
make fmt checkYou can setup a local git pre-commit hook that'll do that by running
make git-hooksReleasing
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 cutareleaseTo list to npm accounts that have publish access:
npm owner ls $packageName