Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# node-smartdc Changelog

## 8.1.1
- PUBAPI-1378 Provide UpdateFabricNetwork endpoint

## 8.1.0

- PUBAPI-1219 - add --cns-enable and --cns-disable options to
Expand Down
55 changes: 55 additions & 0 deletions bin/sdc-fabric
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,61 @@ FabricNetwork.prototype.do_get.help = (
);


FabricNetwork.prototype.do_update = function (subcmd, opts, args, callback) {
var self = this;

if (opts.help) {
return this.do_help('help', {}, [subcmd], callback);
}

if (args.length !== 1) {
return callback(new Error('network_id must be specified'));
}

// to match up with the behavior of other node-smartdc commands, we also
// want to be able to accept CSV and JSON here
if (opts.resolvers && opts.resolvers.length === 1) {
try {
opts.resolvers = JSON.parse(opts.resolvers[0]);
} catch (e) {
opts.resolvers = opts.resolvers[0].split(',');
}
}

if (opts.routes) {
opts.routes = JSON.parse(opts.routes);
}

return this.cloudapi.getFabricNetwork(args[0],
function _afterGet(err, net) {
if (err) {
return commonCb(err);
}

return self.cloudapi.updateFabricNetwork(net.vlan_id, args[0], opts,
commonCb);
});
};

FabricNetwork.prototype.do_update.options = [
OPTIONAL.name,
OPTIONAL.resolvers,
OPTIONAL.no_internet_nat,
OPTIONAL.gateway,
OPTIONAL.description,
OPTIONAL.routes,
HELP_OPT
];

FabricNetwork.prototype.do_update.help = (
'Update an existing fabric network.\n' +
'\n' +
'Usage:\n' +
' {{name}} update [OPTIONS]\n' +
'\n' +
'{{options}}'
);

FabricNetwork.prototype.do_create = function (subcmd, opts, args, callback) {
var self = this;
if (opts.help) {
Expand Down
45 changes: 45 additions & 0 deletions lib/cli/fabric-nets.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,50 @@ function createFabricNetwork(account, options, callback) {
});
}

/**
* Update a fabric network.
*
* Returns a JS object (the created network).
*
* @param {String} account (optional) the login name of the account.
* @param {Number} vlanId the ID of the VLAN the network is on.
* @param {String} network the ID of the network.
* @param {Object} options object to be passed to the API
* @param {Function} callback of the form f(err, network).
* @param {Boolean} noCache optional flag to force skipping the cache.
* @throws {TypeError} on bad input.
*/
function updateFabricNetwork(account, vlanId, network, options,
callback, noCache) {
var self = this;
var opts;

if (typeof (options) === 'function') {
noCache = callback;
callback = options;
options = network;
network = vlanId;
vlanId = account;
account = this.account;
}

if (typeof (network) === 'function') {
noCache = callback;
callback = network;
network = vlanId;
vlanId = account;
account = this.account;
}
account = validate.account(account);
validate.network(network);
opts = validate.networkOptions(options);
validate.callback(callback);

return self._request(sprintf(paths.fabricNetwork, account, vlanId,
network), opts, function (req) {
return self._put(req, callback, noCache);
});
}

/**
* Deletes a fabric network.
Expand Down Expand Up @@ -160,6 +204,7 @@ function listFabricNetworks(account, options, callback, noCache) {

module.exports = {
createFabricNetwork: createFabricNetwork,
updateFabricNetwork: updateFabricNetwork,
deleteFabricNetwork: deleteFabricNetwork,
getFabricNetwork: getFabricNetwork,
listFabricNetworks: listFabricNetworks
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Joyent, Inc. http://www.joyent.com",
"name": "smartdc",
"description": "Client SDK and CLI for the Joyent SmartDataCenter API",
"version": "8.1.0",
"version": "8.1.1",
"repository": {
"type": "git",
"url": "git://github.com/joyent/node-smartdc.git"
Expand Down