-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
73 lines (63 loc) · 2.62 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var Cluster = require('./lib/cluster').Cluster;
/**
* Create a coreos cluster
*
* @param {object} options options for your new cluster
* @param {string} [options.basename] basename for the cluster, "cluster-" is default (e.g. cluster-1413933515-03)
* @param {string} [options.type] 'onMetal' or 'performance', performance is default
* @param {string} [options.flavor] cloud servers flavor, defaults to smallest for type
* @param {string} [options.release] coreos release, 'alpha', 'beta', 'stable', stable is default
* @param {number} [options.numNodes] number of nodes
* @param {string} [options.keyname] ssh keyname; if not provided will create a new key 'coreos-cluster'
* @param {string} [options.privateNetwork] optional private network guid to use for rackspace private network
* @param {string} [options.monitoringToken] optional monitoring token to configure cloud monitoring
* @param {string} [options.ephemeral] optional utilize data disk (ephemeral) for Docker storage
* @param {string} [options.discoverServiceUrl] url for an existing cluster's discover service
* @param {string} [options.keyname] ssh keyname; if not provided will create a new key 'coreos-cluster'
* @param {object} [options.update] options for CoreOS updates
* @param {string} [options.update.group] optional update group (e.g. stable, beta, UUID for a channel)
* @param {string} [options.update.server] optional omaha endpoint URL for updates
* @param {string} [options.update.rebootStrategy] optional reboot strategy
*
* @param callback callback with err, results
*/
exports.createCluster = function(options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
if (!callback) {
throw new Error('You must provide a callback to createCluster');
}
var cluster = Cluster(options);
try {
cluster = new Cluster(options);
}
catch (e) {
callback(e);
}
cluster.initialize(function(err) {
if (err) {
callback(err);
return;
}
cluster.validateNodeOptions(function(err, currentNodes) {
if (err) {
callback(err);
return;
}
if (currentNodes + options.numNodes < 3) {
callback('Total number of nodes must be at least 3');
return;
}
cluster.addNodes(options.numNodes, function(err) {
if (err) {
callback(err);
return;
}
callback(null, cluster.toJSON());
});
});
});
};
exports.Cluster = Cluster;