Skip to content

Commit fb45db2

Browse files
committed
Vdc support
1 parent e599a7f commit fb45db2

File tree

4 files changed

+155
-2
lines changed

4 files changed

+155
-2
lines changed

lib/group.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ Group.prototype.quota = function(template, callback) {
3131
});
3232
};
3333

34+
Group.prototype.addAdmin = function(group, user, callback) {
35+
this.modem.call('group.addadmin', [this.id, group, user], function(err, data) {
36+
if(err) return callback(err);
37+
callback(null, data);
38+
});
39+
};
40+
41+
Group.prototype.delAdmin = function(group, user, callback) {
42+
this.modem.call('group.deladmin', [this.id, group, user], function(err, data) {
43+
if(err) return callback(err);
44+
callback(null, data);
45+
});
46+
};
47+
3448
Group.prototype.addProvider = function(group, zone, cluster, callback) {
3549
this.modem.call('group.addprovider', [this.id, group, zone, cluster], function(err, data) {
3650
if(err) return callback(err);

lib/opennebula.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ var Modem = require('./modem'),
99
Datastore = require('./datastore'),
1010
Image = require('./image'),
1111
Zone = require('./zone'),
12-
Document = require('./document');
12+
Document = require('./document'),
13+
Vdc = require('./vdc');
1314

1415
var OpenNebula = function(auth, hostname) {
1516
this.auth = auth;
@@ -60,6 +61,32 @@ OpenNebula.prototype.getVMs = function(callback, userFilter, startID, endID, sta
6061
});
6162
};
6263

64+
//VDC
65+
OpenNebula.prototype.getVdc = function(id) {
66+
return new Vdc(this.modem, id);
67+
};
68+
69+
OpenNebula.prototype.createVdc = function(template, cluster, callback) {
70+
this.modem.call('vdc.allocate', [template, cluster || -1], function(err, data) {
71+
if(err) return callback(err);
72+
callback(null, new Vdc(this.modem, data));
73+
});
74+
};
75+
76+
OpenNebula.prototype.getVdcs = function(callback) {
77+
this.modem.call('vdcpool.info', [], function(err, data) {
78+
if (err) return callback(err);
79+
80+
if (Array.isArray(data.VDC_POOL)) {
81+
callback(null, data.VDC_POOL);
82+
} else if(Array.isArray(data.VDC_POOL.HOST)) {
83+
callback(null, data.VDC_POOL.HOST);
84+
} else {
85+
callback(null, [data.VDC_POOL.HOST]);
86+
}
87+
});
88+
};
89+
6390
//HOST
6491
OpenNebula.prototype.getHost = function(id) {
6592
return new Host(this.modem, id);

lib/vdc.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
var Vdc = function(modem, id) {
2+
this.modem = modem;
3+
this.id = id;
4+
};
5+
6+
Vdc.prototype.allocate = function(template, cluster, callback) {
7+
this.modem.call('vdc.allocate', [template, cluster], function(err, data) {
8+
if(err) return callback(err);
9+
callback(null, data);
10+
});
11+
};
12+
13+
Vdc.prototype.delete = function(callback) {
14+
this.modem.call('vdc.delete', [this.id], function(err, data) {
15+
if(err) return callback(err);
16+
callback(null, data);
17+
});
18+
};
19+
20+
Vdc.prototype.rename = function(name, callback) {
21+
this.modem.call('vdc.rename', [this.id, name], function(err, data) {
22+
if(err) return callback(err);
23+
callback(null, data);
24+
});
25+
};
26+
27+
Vdc.prototype.update = function(template, merge, callback) {
28+
this.modem.call('vdc.update', [this.id, template, merge], function(err, data) {
29+
if(err) return callback(err);
30+
callback(null, data);
31+
});
32+
};
33+
34+
Vdc.prototype.info = function(callback) {
35+
this.modem.call('vdc.info', [this.id], function(err, data) {
36+
if(err) return callback(err);
37+
callback(null, data);
38+
});
39+
};
40+
41+
Vdc.prototype.addGroup = function(groupid, callback) {
42+
this.modem.call('vdc.addgroup', [this.id, groupid], function(err, data) {
43+
if(err) return callback(err);
44+
callback(null, data);
45+
});
46+
};
47+
48+
Vdc.prototype.delGroup = function(groupid, callback) {
49+
this.modem.call('vdc.delgroup', [this.id, groupid], function(err, data) {
50+
if(err) return callback(err);
51+
callback(null, data);
52+
});
53+
};
54+
55+
Vdc.prototype.addCluster = function(zoneid, clusterid, callback) {
56+
this.modem.call('vdc.addcluster', [this.id, zoneid, clusterid], function(err, data) {
57+
if(err) return callback(err);
58+
callback(null, data);
59+
});
60+
};
61+
62+
Vdc.prototype.delCluster = function(zoneid, clusterid, callback) {
63+
this.modem.call('vdc.delcluster', [this.id, zoneid, clusterid], function(err, data) {
64+
if(err) return callback(err);
65+
callback(null, data);
66+
});
67+
};
68+
69+
Vdc.prototype.addHost = function(zoneid, hostid, callback) {
70+
this.modem.call('vdc.delcluster', [this.id, zoneid, clusterid], function(err, data) {
71+
if(err) return callback(err);
72+
callback(null, data);
73+
});
74+
};
75+
76+
Vdc.prototype.delHost = function(zoneid, hostid, callback) {
77+
this.modem.call('vdc.delhost', [this.id, zoneid, clusterid], function(err, data) {
78+
if(err) return callback(err);
79+
callback(null, data);
80+
});
81+
};
82+
83+
Vdc.prototype.addDatastore = function(zoneid, datastoreid, callback) {
84+
this.modem.call('vdc.adddatastore', [this.id, zoneid, datastoreid], function(err, data) {
85+
if(err) return callback(err);
86+
callback(null, data);
87+
});
88+
};
89+
90+
Vdc.prototype.delDatastore = function(zoneid, datastoreid, callback) {
91+
this.modem.call('vdc.deldatastore', [this.id, zoneid, datastoreid], function(err, data) {
92+
if(err) return callback(err);
93+
callback(null, data);
94+
});
95+
};
96+
97+
Vdc.prototype.addVnet = function(zoneid, venetid, callback) {
98+
this.modem.call('vdc.addvnet', [this.id, zoneid, venetid], function(err, data) {
99+
if(err) return callback(err);
100+
callback(null, data);
101+
});
102+
};
103+
104+
Vdc.prototype.delVnet = function(zoneid, venetid, callback) {
105+
this.modem.call('vdc.delvnet', [this.id, zoneid, venetid], function(err, data) {
106+
if(err) return callback(err);
107+
callback(null, data);
108+
});
109+
};
110+
111+
112+
module.exports = Vdc;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "opennebula",
33
"description": "OpenNebula XML-RPC API client.",
4-
"version": "1.0.7",
4+
"version": "1.0.8",
55
"author": "Pedro Dias <petermdias@gmail.com>",
66
"maintainers": [
77
"apocas <petermdias@gmail.com>"

0 commit comments

Comments
 (0)