Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 66 lines (50 sloc) 1.424 kB
#!/usr/bin/env node
// -*- mode: js -*-
// vim: set filetype=javascript :
// Copyright 2012 Joyent, Inc. All rights reserved.
var fs = require('fs');
var path = require('path');
var url = require('url');
var common = require('../lib/cli_common');
///--- Globals
var Options = {
"account": String,
"debug": Boolean,
"help": Boolean,
"identity": path,
"keyId": String,
"metadata": [String, Array],
"url": url
};
var ShortOptions = {
"a": ["--account"],
"d": ["--debug"],
"h": ["--help"],
"?": ["--help"],
"i": ["--identity"],
"k": ["--keyId"],
"m": ["--metadata"],
"u": ["--url"]
};
var usageStr = common.buildUsageString(Options);
usageStr += ' machine';
///--- Mainline
common.parseArguments(Options, ShortOptions, function(parsed) {
if (parsed.argv.remain.length < 1)
common.usage(usageStr, 1, 'machine required');
if (!parsed.metadata)
common.usage(usageStr, 1, '--metadata required');
var metadata = {};
for (var i = 0; i < parsed.metadata.length; i++) {
var tmp = parsed.metadata[i].split('=');
if (!tmp || tmp.length !== 2) {
console.error(parsed.metadata[i] + ' is invalid metadata; try foo=bar');
process.exit(1);
}
metadata[tmp[0]] = tmp[1];
}
var client = common.newClient(parsed);
parsed.argv.remain.forEach(function(machine) {
client.updateMachineMetadata(machine, metadata, common.callback);
});
}, usageStr);
Jump to Line
Something went wrong with that request. Please try again.