├── test └── test.js ├── package.json ├── license ├── README.md └── lib └── proxmox.js /test/test.js: -------------------------------------------------------------------------------- 1 | var pmModule = require("../lib/proxmox")('user', 'password', 'server'); 2 | var assert = require("assert"); 3 | /* 4 | pmModule.network.get('proxmoxTestbak','eth0',function(err, response){ 5 | if (err) throw err; 6 | else { 7 | data = JSON.parse(response); 8 | console.log(data); 9 | } 10 | }); 11 | */ 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"proxmox", 3 | "preferGobal": "false", 4 | "version": "0.1.0", 5 | "author": "T. Tarvis", 6 | "description": "node.js, asynchronous, proxmox client", 7 | "repository": { 8 | "type":"git", 9 | "url":"https://github.com/ttarvis/node-proxmox" 10 | }, 11 | "engines": { 12 | "node": ">=0.10.9" 13 | }, 14 | "licenses": [ 15 | { 16 | "type":"Artistic 2.0" 17 | } 18 | ], 19 | "main":"./lib/proxmox.js" 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The Artistic License 2.0 2 | 3 | Copyright (c) 2000-2006, The Perl Foundation. 4 | 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | This license establishes the terms under which a given free software 11 | Package may be copied, modified, distributed, and/or redistributed. 12 | The intent is that the Copyright Holder maintains some artistic 13 | control over the development of that Package while still keeping the 14 | Package available as open source and free software. 15 | 16 | You are always permitted to make arrangements wholly outside of this 17 | license directly with the Copyright Holder of a given Package. If the 18 | terms of this license do not permit the full use that you propose to 19 | make of the Package, you should contact the Copyright Holder and seek 20 | a different licensing arrangement. 21 | 22 | Definitions 23 | 24 | "Copyright Holder" means the individual(s) or organization(s) 25 | named in the copyright notice for the entire Package. 26 | 27 | "Contributor" means any party that has contributed code or other 28 | material to the Package, in accordance with the Copyright Holder's 29 | procedures. 30 | 31 | "You" and "your" means any person who would like to copy, 32 | distribute, or modify the Package. 33 | 34 | "Package" means the collection of files distributed by the 35 | Copyright Holder, and derivatives of that collection and/or of 36 | those files. A given Package may consist of either the Standard 37 | Version, or a Modified Version. 38 | 39 | "Distribute" means providing a copy of the Package or making it 40 | accessible to anyone else, or in the case of a company or 41 | organization, to others outside of your company or organization. 42 | 43 | "Distributor Fee" means any fee that you charge for Distributing 44 | this Package or providing support for this Package to another 45 | party. It does not mean licensing fees. 46 | 47 | "Standard Version" refers to the Package if it has not been 48 | modified, or has been modified only in ways explicitly requested 49 | by the Copyright Holder. 50 | 51 | "Modified Version" means the Package, if it has been changed, and 52 | such changes were not explicitly requested by the Copyright 53 | Holder. 54 | 55 | "Original License" means this Artistic License as Distributed with 56 | the Standard Version of the Package, in its current version or as 57 | it may be modified by The Perl Foundation in the future. 58 | 59 | "Source" form means the source code, documentation source, and 60 | configuration files for the Package. 61 | 62 | "Compiled" form means the compiled bytecode, object code, binary, 63 | or any other form resulting from mechanical transformation or 64 | translation of the Source form. 65 | 66 | 67 | Permission for Use and Modification Without Distribution 68 | 69 | (1) You are permitted to use the Standard Version and create and use 70 | Modified Versions for any purpose without restriction, provided that 71 | you do not Distribute the Modified Version. 72 | 73 | 74 | Permissions for Redistribution of the Standard Version 75 | 76 | (2) You may Distribute verbatim copies of the Source form of the 77 | Standard Version of this Package in any medium without restriction, 78 | either gratis or for a Distributor Fee, provided that you duplicate 79 | all of the original copyright notices and associated disclaimers. At 80 | your discretion, such verbatim copies may or may not include a 81 | Compiled form of the Package. 82 | 83 | (3) You may apply any bug fixes, portability changes, and other 84 | modifications made available from the Copyright Holder. The resulting 85 | Package will still be considered the Standard Version, and as such 86 | will be subject to the Original License. 87 | 88 | 89 | Distribution of Modified Versions of the Package as Source 90 | 91 | (4) You may Distribute your Modified Version as Source (either gratis 92 | or for a Distributor Fee, and with or without a Compiled form of the 93 | Modified Version) provided that you clearly document how it differs 94 | from the Standard Version, including, but not limited to, documenting 95 | any non-standard features, executables, or modules, and provided that 96 | you do at least ONE of the following: 97 | 98 | (a) make the Modified Version available to the Copyright Holder 99 | of the Standard Version, under the Original License, so that the 100 | Copyright Holder may include your modifications in the Standard 101 | Version. 102 | 103 | (b) ensure that installation of your Modified Version does not 104 | prevent the user installing or running the Standard Version. In 105 | addition, the Modified Version must bear a name that is different 106 | from the name of the Standard Version. 107 | 108 | (c) allow anyone who receives a copy of the Modified Version to 109 | make the Source form of the Modified Version available to others 110 | under 111 | 112 | (i) the Original License or 113 | 114 | (ii) a license that permits the licensee to freely copy, 115 | modify and redistribute the Modified Version using the same 116 | licensing terms that apply to the copy that the licensee 117 | received, and requires that the Source form of the Modified 118 | Version, and of any works derived from it, be made freely 119 | available in that license fees are prohibited but Distributor 120 | Fees are allowed. 121 | 122 | 123 | Distribution of Compiled Forms of the Standard Version 124 | or Modified Versions without the Source 125 | 126 | (5) You may Distribute Compiled forms of the Standard Version without 127 | the Source, provided that you include complete instructions on how to 128 | get the Source of the Standard Version. Such instructions must be 129 | valid at the time of your distribution. If these instructions, at any 130 | time while you are carrying out such distribution, become invalid, you 131 | must provide new instructions on demand or cease further distribution. 132 | If you provide valid instructions or cease distribution within thirty 133 | days after you become aware that the instructions are invalid, then 134 | you do not forfeit any of your rights under this license. 135 | 136 | (6) You may Distribute a Modified Version in Compiled form without 137 | the Source, provided that you comply with Section 4 with respect to 138 | the Source of the Modified Version. 139 | 140 | 141 | Aggregating or Linking the Package 142 | 143 | (7) You may aggregate the Package (either the Standard Version or 144 | Modified Version) with other packages and Distribute the resulting 145 | aggregation provided that you do not charge a licensing fee for the 146 | Package. Distributor Fees are permitted, and licensing fees for other 147 | components in the aggregation are permitted. The terms of this license 148 | apply to the use and Distribution of the Standard or Modified Versions 149 | as included in the aggregation. 150 | 151 | (8) You are permitted to link Modified and Standard Versions with 152 | other works, to embed the Package in a larger work of your own, or to 153 | build stand-alone binary or bytecode versions of applications that 154 | include the Package, and Distribute the result without restriction, 155 | provided the result does not expose a direct interface to the Package. 156 | 157 | 158 | Items That are Not Considered Part of a Modified Version 159 | 160 | (9) Works (including, but not limited to, modules and scripts) that 161 | merely extend or make use of the Package, do not, by themselves, cause 162 | the Package to be a Modified Version. In addition, such works are not 163 | considered parts of the Package itself, and are not subject to the 164 | terms of this license. 165 | 166 | 167 | General Provisions 168 | 169 | (10) Any use, modification, and distribution of the Standard or 170 | Modified Versions is governed by this Artistic License. By using, 171 | modifying or distributing the Package, you accept this license. Do not 172 | use, modify, or distribute the Package, if you do not accept this 173 | license. 174 | 175 | (11) If your Modified Version has been derived from a Modified 176 | Version made by someone other than you, you are nevertheless required 177 | to ensure that your Modified Version complies with the requirements of 178 | this license. 179 | 180 | (12) This license does not grant you the right to use any trademark, 181 | service mark, tradename, or logo of the Copyright Holder. 182 | 183 | (13) This license includes the non-exclusive, worldwide, 184 | free-of-charge patent license to make, have made, use, offer to sell, 185 | sell, import and otherwise transfer the Package with respect to any 186 | patent claims licensable by the Copyright Holder that are necessarily 187 | infringed by the Package. If you institute patent litigation 188 | (including a cross-claim or counterclaim) against any party alleging 189 | that the Package constitutes direct or contributory patent 190 | infringement, then this Artistic License to you shall terminate on the 191 | date that such litigation is filed. 192 | 193 | (14) Disclaimer of Warranty: 194 | THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS 195 | IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED 196 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 197 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL 198 | LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL 199 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 200 | DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF 201 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Node Proxmox 2 | 3 | ## A node.js client for proxmox. See [Proxmox wiki](http://pve.proxmox.com/wiki/Main_Page) 4 | 5 | ###### [Proxmox API wiki](http://pve.proxmox.com/wiki/Proxmox_VE_API) 6 | ###### [Proxmox API referene](http://pve.proxmox.com/pve2-api-doc/) 7 | 8 | ##### Note: Requires cURL because node https module does not correctly transfer custom headers without a signed certificate even if you accept unauthorized 9 | 10 | ##### Installation 11 | 12 | ```npm install proxmox``` 13 | 14 | or install from here. 15 | 16 | ###### Example: 17 | 18 | proxmox = require("proxmox")('user', 'password', 'domain.com'); 19 | 20 | proxmox.getClusterStatus(function(err, response){ 21 | if(err) throw err; 22 | else{ 23 | data = JSON.parse(response); 24 | console.log(data); 25 | } 26 | }); 27 | 28 | Callback is a function of the form ```function(err, response){}``` 29 | data is an object, not a string. 30 | everything else is a string 31 | 32 | All returned responses are strings that can be parsed in to JSON as per the API reference. 33 | 34 | getNodes(callback); 35 | 36 | getQemu(node, callback); 37 | 38 | createQemu(node, data, callback) 39 | 40 | getStorage(callback); 41 | 42 | getClusterStatus(callback); 43 | 44 | getClusterBackupSchedule(callback); 45 | 46 | getNodeNetworks(node, callback); 47 | 48 | getNodeInterface(node, interface, callback); 49 | 50 | getNodeContainerIndex(node, callback); 51 | 52 | getNodeVirtualIndex(node, callback); 53 | 54 | getNodeServiceState(node, service, callback); 55 | 56 | getNodeStorage(node, callback); 57 | 58 | getNodeFinishedTasks(node, callback); 59 | 60 | getNodeDNS(node, callback); 61 | 62 | getNodeSyslog(node, callback); 63 | 64 | getNodeRRD(node, callback); 65 | 66 | getNodeRRDData(node, callback); 67 | 68 | getNodeBeans(node, callback); 69 | 70 | getNodeTaskByUPID(node, upid, callback); 71 | 72 | getNodeTaskStatusByUPID(node, upid, callback); 73 | 74 | getNodeTaskLogByUPID(node, upid, callback); 75 | 76 | getNodeTaskStatusByUPID(node, upid, callback); 77 | 78 | getNodeScanMethods(node, callback); 79 | 80 | getRemoteiSCSI(node, callback); 81 | 82 | getNodeLVMGroups(node, callback); 83 | 84 | getRemoteNFS(node, callback); 85 | 86 | getNodeUSB(node, callback); 87 | 88 | getStorageVolumeData(node, storage, volume, callback); 89 | 90 | getStorageConfig(storage, callback); 91 | 92 | getNodeStorageContent(node, storage, callback); 93 | 94 | getNodeStorageRRD(node, storage, callback); 95 | 96 | getNodeStorageRRDData(node, storage, callback); 97 | 98 | deleteNodeNetworkConfig(node, callback); 99 | 100 | deleteNodeInterface(node, interface, callback); 101 | 102 | deletePool(poolid, callback); 103 | 104 | setNodeDNSDomain(node, domain, callback); 105 | 106 | setNodeSubscriptionKey(node, key, callback); 107 | 108 | setNodeTimeZone(node, timezone, callback); 109 | 110 | setPoolData(poolid, data, callback); 111 | 112 | updateStorageConfiguration(storageid, data, callback); 113 | 114 | ### OpenVZ 115 | 116 | openvz.createOpenvzContainer(node, data, callback); 117 | 118 | openvz.mountOpenvzPrivate(node, vmid, callback); 119 | 120 | openvz.shutdownOpenvzContainer(node, vmid, callback); 121 | 122 | openvz.startOpenvzContainer(node, vmid, callback); 123 | 124 | openvz.stopOpenvzContainer(node, vmid, callback); 125 | 126 | openvz.unmountOpenvzContainer(node, vmid, callback); 127 | 128 | openvz.migrateOpenvzContainer(node, vmid, target, callback); 129 | 130 | openvz.getContainerIndex(node, vmid, callback); 131 | 132 | openvz.getContainerSTatus(node, vmid, callback); 133 | 134 | openvz.getContainerBeans(node, vmid, callback); 135 | 136 | openvz.getContainerConfig(node, vmid, callback); 137 | 138 | openvz.getContainerInitLog(node, vmid, callback); 139 | 140 | openvz.getContainerRRD(node, vmid, callback); 141 | 142 | openvz.getContainerRRDData(node, vmid, callback); 143 | 144 | openvz.deleteOpenvzContainer(node, vmid, callback); 145 | 146 | openvz.setOpenvzContainerOptions(node, vmid, data, callback); 147 | 148 | ### Qemu --- more info on permissions and data view the documentation.html 149 | 150 | qemu.getStatus (node, qemu, callback); 151 | 152 | qemu.getStatusCurrent (node, qemu, callback); 153 | 154 | qemu.start(node, qemu, callback); 155 | 156 | qemu.stop(node, qemu, callback); 157 | 158 | qemu.reset(node, qemu, callback); 159 | 160 | qemu.shutdown(node, qemu, callback); 161 | 162 | qemu.suspend(node, qemu, callback); 163 | 164 | qemu.resume(node, qemu, callback); 165 | 166 | qemu.rrd(node, qemu, callback); 167 | 168 | qemu.rrdData (node, qemu, callback); 169 | 170 | qemu.getConfig(node, qemu, callback); 171 | 172 | qemu.putConfig(node, qemu, data, callback); 173 | 174 | qemu.postConfig(node, qemu, data, callback); 175 | 176 | qemu.pending(node, qemu, callback); 177 | 178 | qemu.unlink(node, qemu, data, callback); 179 | 180 | qemu.vncproxy (node, qemu, callback); 181 | 182 | qemu.vncwebsocket(node, qemu, data, callback); 183 | 184 | qemu.sendkey(node, qemu, data, callback); 185 | 186 | qemu.feature (node, qemu, data, callback); 187 | 188 | qemu.clone (node, qemu, data, callback); 189 | 190 | qemu.moveDisk (node, qemu, data, callback); 191 | 192 | qemu.migrate (node, qemu, data, callback); 193 | 194 | qemu.monitor (node, qemu, data, callback); 195 | 196 | qemu.resize (node, qemu, data, callback); 197 | 198 | qemu.template (node, qemu, callback); 199 | 200 | ### snapshot 201 | 202 | qemu.snapshot.list(node, qemu, callback); 203 | 204 | qemu.snapshot.snapshot(node, qemu, snapname, callback); 205 | 206 | qemu.snapshot.getConfig(node, qemu, snapname, callback); 207 | 208 | qemu.snapshot.putConfig(node, qemu, snapname, data, callback); 209 | 210 | qemu.snapshot.rollback(node,qemu, snapname, callback); 211 | 212 | qemu.snapshot.delete(node, qemu, snapname, callback); 213 | 214 | qemu.snapshot.make(node, qemu, data, callback); 215 | 216 | ### firewall 217 | 218 | qemu.firewall.list(node, qemu, callback); 219 | 220 | qemu.firewall.listRules(node, qemu, callback); 221 | 222 | qemu.firewall.createRule(node, qemu, data, callback); 223 | 224 | qemu.firewall.getRule (node, qemu, pos, callback); 225 | 226 | qemu.firewall.listAlias(node, qemu, callback); 227 | 228 | qemu.firewall.createAlias(node, qemu, data, callback); 229 | 230 | qemu.firewall.getAlias(node, qemu, name, callback); 231 | 232 | qemu.firewall.updateAlias(node, qemu, name, data, callback); 233 | 234 | qemu.firewall.listIpset(node, qemu, callback); 235 | 236 | qemu.firewall.createIpset(node, qemu, data, callback); 237 | 238 | qemu.firewall.getIpsetContent(node, qemu, name, callback); 239 | 240 | qemu.firewall.addIpToIpset(node, qemu, name, data, callback); 241 | 242 | qemu.firewall.deleteIpset(node, qemu, name, callback); 243 | 244 | qemu.firewall.getIpfromIpset(node, qemu, name, cidr, callback); 245 | 246 | qemu.firewall.updateIpfromIpset(node, qemu, name, cidr, data, callback); 247 | 248 | qemu.firewall.deleteIpfromIpset(node, qemu, name, cidr, callback); 249 | 250 | qemu.firewall.getOptions(node, qemu, callback); 251 | 252 | qemu.firewall.setOptions(node, qemu, data, callback); 253 | 254 | qemu.firewall.getLog(node, qemu, callback); 255 | 256 | qemu.firewall.getRefs(node, qemu, callback); 257 | 258 | ### network 259 | 260 | network.list (node, callback); 261 | 262 | network.create(node, data, callback); 263 | 264 | network.get (node, iface, callback); 265 | 266 | network.update (node, iface, data, callback); 267 | 268 | network.delete (node, callback); 269 | 270 | network.deleteIface (node, iface, callback); 271 | 272 | ### access 273 | 274 | access.listUsers (callback); 275 | 276 | access.createUser (data, callback); 277 | 278 | access.getUser(user, callback); 279 | 280 | access.updateUser (user, data, callback); 281 | 282 | access.deleteUser (user, callback); 283 | 284 | access.listGroups (callback); 285 | 286 | access.createGroup (data, callback); 287 | 288 | access.getGroup (group, callback); 289 | 290 | access.updateGroup (group, data, callback); 291 | 292 | access.deleteGroup (group, callback); 293 | 294 | access.listRoles (callback); 295 | 296 | access.createRole (data, callback); 297 | 298 | access.getRole (role, callback); 299 | 300 | access.updateRole (role, data, callback); 301 | 302 | access.deleteRole (role, callback); 303 | 304 | access.listDomains (callback); 305 | 306 | access.createDomain (data, callback); 307 | 308 | access.getDomain (domain, callback); 309 | 310 | access.updateDomain (domain, data, callback); 311 | 312 | access.deleteDomain (domain, callback); 313 | 314 | access.getAcl (callback); 315 | 316 | access.updateAcl (data, callback); 317 | 318 | access.getTicket (callback); 319 | 320 | access.postTicket(data, callback); 321 | 322 | access.password(data, callback); 323 | 324 | ### pools 325 | 326 | pools.list (callback); 327 | 328 | pools.create (data, callback); 329 | 330 | pools.get (pool, callback); 331 | 332 | pools.update (pool, data, callback); 333 | 334 | pools.delete (pool, callback); 335 | 336 | ### storage 337 | 338 | storage.list (callback); 339 | 340 | storage.create (data, callback); 341 | 342 | storage.get (storageId, callback); 343 | 344 | storage.update (storageId, data, callback); 345 | 346 | storage.delete (storageId, callback); 347 | 348 | ### To Do: 349 | completed tests, examples, documentation, add methods for pool, node, KVM 350 | -------------------------------------------------------------------------------- /lib/proxmox.js: -------------------------------------------------------------------------------- 1 | var querystring = require("querystring"); 2 | var exec = require('child_process').exec; 3 | var events = require('events'); 4 | var eventEmitter = new events.EventEmitter(); 5 | 6 | module.exports = function(name, pwd, hostname) { 7 | 8 | var apiURL = 'https://' + hostname + ':8006/api2/json'; 9 | var authString = 'username=' + name + '&password=' + pwd; 10 | 11 | var token = {}; 12 | token.CSRF = ''; 13 | token.PVEAuth = ''; 14 | token.timeStamp = 0; 15 | 16 | function curlCom() { 17 | 18 | var command = ''; 19 | 20 | this.get = function(url) { 21 | command = 'curl -k '; 22 | command += ('-b ' + 'PVEAuthCookie='+token.PVEAuth); 23 | command += (' ' + apiURL + url); 24 | return this; 25 | }; 26 | this.post = function(url, data, header, cookie) { 27 | command = 'curl -X POST -k ' 28 | if (typeof cookie === 'string') command += ('-b '+ 'PVEAuthCookie='+cookie + ' '); 29 | if (typeof header === 'string') command += ('-H ' +'"'+'CSRFPreventionToken:' + header + '"'+' '); 30 | command += ('-d '+'"'+data+'"'+' '); 31 | command += (apiURL + url); 32 | return this; 33 | }; 34 | this.put = function(url, data, header, cookie) { 35 | command = 'curl -X PUT -k ' 36 | command += ('-b ' + 'PVEAuthCookie='+ cookie + ' '); 37 | command += ('-H ' +'"'+'CSRFPreventionToken:' + header + '"'+' '); 38 | command += ('-d ' + data); 39 | command += (' ' + apiURL + url); 40 | return this; 41 | }; 42 | this.del = function(url, data, header, cookie) { 43 | command = 'curl -X DELETE -k ' 44 | if (typeof cookie === 'string') command += ('-b '+ 'PVEAuthCookie='+ cookie + ' '); 45 | if (typeof header === 'string') command += ('-H ' +'"'+'CSRFPreventionToken:' + header + '"'+' '); 46 | command += (' ' + apiURL + url); 47 | return this; 48 | }; 49 | this.command = function() { 50 | return command; 51 | }; 52 | return this; 53 | }; 54 | 55 | function curl(command, callback) { 56 | exec(command, function(err, stdout, stderr) { 57 | var data = stdout; 58 | callback(err, data); 59 | }); 60 | }; 61 | 62 | function authorize(path, data, callback, cb) { 63 | command = curlCom().post('/access/ticket',authString).command(); 64 | 65 | curl(command, function(err, response) { 66 | if (err) throw err 67 | else { 68 | response = JSON.parse(response); 69 | token.CSRF = response.data.CSRFPreventionToken; 70 | token.PVEAuth = response.data.ticket; 71 | token.timeStamp = new Date().getTime(); 72 | if (typeof cb === 'function') cb(path, data, callback); 73 | } 74 | }); 75 | }; 76 | 77 | function makeRequest(method, path, data, callback){ 78 | if (method == 'GET') { 79 | command = curlCom().get(path).command(); 80 | } 81 | else if (method == 'POST') { 82 | command = curlCom().post(path, data, token.CSRF, token.PVEAuth).command(); 83 | } 84 | else if (method == 'DEL') { 85 | command = curlCom().del(path, data, token.CSRF, token.PVEAuth).command(); 86 | } 87 | else { 88 | command = curlCom().put(path, data, token.CSRF, token.PVEAuth).command(); 89 | } 90 | 91 | curl(command, callback); 92 | }; 93 | 94 | function get(path, data, callback) { 95 | if ( (token.timeStamp + 7200) < new Date().getTime() ) authorize(path, data, callback, get); 96 | else makeRequest('GET', path, data, callback); 97 | }; 98 | 99 | function post(path, data, callback) { 100 | if ( (token.timeStamp + 7200) < new Date().getTime() ) authorize(path, data, callback, post); 101 | else { 102 | data = querystring.stringify(data); 103 | makeRequest('POST', path, data, callback); 104 | }; 105 | }; 106 | 107 | function del(path, data, callback) { 108 | if ( (token.timeStamp + 7200) < new Date().getTime() ) authorize(path, data, callback, del); 109 | else makeRequest('DEL', path, data, callback); 110 | }; 111 | 112 | function put(path, data, callback) { 113 | if ( (token.timeStamp + 7200) < new Date().getTime() ) authorize(path, data, callback, put); 114 | else { 115 | data = querystring.stringify(data); 116 | makeRequest('PUT', path, data, callback); 117 | } 118 | }; 119 | 120 | return { 121 | getClusterStatus: function(callback) { 122 | data = {}; 123 | get('/cluster/status', data, callback); 124 | }, 125 | getClusterBackupSchedule: function(callback) { 126 | data = {}; 127 | get('/cluster/backup', data, callback); 128 | }, 129 | getNodeNetworks: function(node,callback) { 130 | data = {}; 131 | url = '/nodes/'+node+'/network'; 132 | get(url, data, callback); 133 | }, 134 | getNodeInterface: function(node, interface, callback) { 135 | data = {}; 136 | url = '/nodes/'+node+'/network/'+interface; 137 | get(url, data, callback); 138 | }, 139 | getNodeContainerIndex: function(node, callback) { 140 | data = {}; 141 | url = '/nodes/'+node+'/openvz/'; 142 | get(url, data, callback); 143 | }, 144 | getNodeVirtualIndex: function(node, callback) { 145 | data = {}; 146 | url = '/nodes/'+node+'/qemu'; 147 | get(url, data, callback); 148 | }, 149 | getNodeServiceState: function(node, service, callback) { 150 | data = {}; 151 | url = '/nodes/'+node+'/services/'+service+'/state'; 152 | get(url, data, callback); 153 | }, 154 | getNodeStorage: function(node, callback) { 155 | data = {}; 156 | url = '/nodes/'+node+'/storage'; 157 | get(url, data, callback); 158 | }, 159 | getNodeFinishedTasks: function(node, callback) { 160 | data = {}; 161 | url = '/nodes/'+node+'/tasks'; 162 | get(url, data, callback); 163 | }, 164 | getNodeDNS: function(node, callback) { 165 | data = {}; 166 | url = '/nodes/'+node+'/dns'; 167 | get(url, data, callback); 168 | }, 169 | getNodeSyslog: function(node, callback) { 170 | data = {}; 171 | url = '/nodes/'+node+'/syslog'; 172 | get(url, data, callback); 173 | }, 174 | getNodeRRD: function(node, callback) { 175 | data = {}; 176 | url = '/nodes/'+node+'/rrd'; 177 | get(url, data, callback); 178 | }, 179 | getNodeRRDData: function(node, callback) { 180 | data = {}; 181 | url = '/nodes/'+node+'/rrddata'; 182 | get(url, data, callback); 183 | }, 184 | getNodeBeans: function(node, callback) { 185 | data = {}; 186 | url = '/nodes/'+node+'/ubfailcnt'; 187 | get(url, data, callback); 188 | }, 189 | getNodeTaskByUPID: function(node, upid, callback) { 190 | data = {}; 191 | url = '/nodes/'+node+'/tasks/'+upid; 192 | get(url, data, callback); 193 | }, 194 | getNodeTaskLogByUPID: function(node, upid, callback) { 195 | data = {}; 196 | url = '/nodes/'+node+'/tasks/'+upid+'/log'; 197 | get(url, data, callback); 198 | }, 199 | getNodeTaskStatusByUPID: function(node, upid, callback) { 200 | data = {}; 201 | url = '/nodes/'+node+'/tasks/'+upid+'/status'; 202 | get(url, data, callback); 203 | }, 204 | getNodeScanMethods: function(node, callback) { 205 | data = {}; 206 | url = '/nodes/'+node+'/scan'; 207 | get(url, data, callback); 208 | }, 209 | getRemoteiSCSI: function(node, callback) { 210 | data = {}; 211 | url = '/nodes/'+node+'/scan/iscsi'; 212 | get(url, data, callback); 213 | }, 214 | getNodeLVMGroups: function(node, callback) { 215 | data = {}; 216 | url = '/nodes/'+node+'/scan/lvm'; 217 | get(url, data, callback); 218 | }, 219 | getRemoteNFS: function(node, callback) { 220 | data = {}; 221 | url = '/nodes/'+node+'/scan/nfs'; 222 | get(url, data, callback); 223 | }, 224 | getNodeUSB: function(node, callback) { 225 | data = {}; 226 | url = '/nodes/'+node+'/scan/usb'; 227 | }, 228 | getStorageVolumeData: function(node, storage, volume, callback) { 229 | data = {}; 230 | url = '/nodes/'+node+'/storage/'+storage+'/content/'+volume; 231 | get(url, data, callback); 232 | }, 233 | getStorageConfig: function(storage, callback) { 234 | data = {}; 235 | url = '/storage/'+storage; 236 | get(url, data, callback); 237 | }, 238 | getNodeStorageContent: function(node, storage, callback) { 239 | data = {}; 240 | url = '/nodes/'+node+'/storage/'+storage+'/content'; 241 | get(url, data, callback); 242 | }, 243 | getNodeStorageRRD: function(node, storage, callback) { 244 | data = {}; 245 | url = '/nodes/'+node+'/storage/'+storage+'/rrd'; 246 | get(url, data, callback); 247 | }, 248 | getNodeStorageRRDData: function(node, storage, callback) { 249 | data = {}; 250 | url = '/nodes/'+node+'/storage/'+storage+'/rrddata'; 251 | get(url, data, callback); 252 | }, 253 | //openvz functions 254 | openvz: { 255 | createOpenvzContainer: function(node, data, callback) { 256 | url = '/nodes/' + node + '/openvz' 257 | post(url, data, callback); 258 | }, 259 | mountOpenvzPrivate: function(node, vmid, callback) { 260 | data = {}; 261 | url = '/nodes/' + node + '/openvz/' + vmid + '/status/mount'; 262 | post(url, data, callback); 263 | }, 264 | shutdownOpenvzContainer: function(node, vmid, callback) { 265 | data = {}; 266 | url = '/nodes/' + node + '/openvz/' + vmid + '/status/shutdown'; 267 | post(url, data, callback); 268 | }, 269 | startOpenvzContainer: function(node, vmid, callback) { 270 | data = {}; 271 | url = '/nodes/' + node + '/openvz/' + vmid + '/status/start'; 272 | post(url, data, callback); 273 | }, 274 | stopOpenvzContainer: function(node, vmid, callback) { 275 | data = {}; 276 | url = '/nodes/' + node + '/openvz/' + vmid + '/status/stop'; 277 | post(url, data, callback); 278 | }, 279 | unmountOpenvzContainer: function(node, vmid, callback) { 280 | data = {}; 281 | url = '/nodes/' + node + '/openvz/' + vmid + '/status/unmount'; 282 | post(url, data, callback); 283 | }, 284 | migrateOpenvzContainer: function(node, vmid, target, callback) { 285 | data = {'target': target}; 286 | url = '/nodes/' + node + '/openvz/' + vmid + '/migrate'; 287 | post(url, data, callback); 288 | }, 289 | getContainerIndex: function(node, vmid, callback) { 290 | data = {}; 291 | url = '/nodes/'+node+'/openvz/'+vmid; 292 | get(url, data, callback); 293 | }, 294 | getContainerStatus: function(node, vmid, callback) { 295 | data = {}; 296 | url = '/nodes/'+node+'/openvz/'+node+'/status/current'; 297 | get(url, data, callback); 298 | }, 299 | getContainerBeans: function(node, vmid, callback) { 300 | data = {}; 301 | url = '/nodes/'+node+'/openvz/'+vmid+'/status/ubc'; 302 | get(url, data, callback); 303 | }, 304 | getContainerConfig: function(node, vmid, callback) { 305 | data = {}; 306 | url = '/nodes/'+node+'/openvz/'+vmid+'/config'; 307 | get(url, data, callback); 308 | }, 309 | getContainerInitLog: function(node, vmid, callback) { 310 | data = {}; 311 | url = '/nodes/'+node+'/openvz/'+vmid+'/initlog'; 312 | get(url, data, callback); 313 | }, 314 | getContainerRRD: function(node, vmid, callback) { 315 | data = {}; 316 | url = '/nodes/'+node+'/openvz/'+vmid+'/rrd'; 317 | get(url, data, callback); 318 | }, 319 | getContainerRRDData: function(node, vmid, callback) { 320 | data = {}; 321 | url = '/nodes/'+node+'/openvz/'+vmid+'/rrddata'; 322 | get(url, data, callback); 323 | }, 324 | deleteOpenvzContainer: function(node, vmid, callback) { 325 | data = {}; 326 | url = '/nodes/'+node+'/openvz/'+vmid; 327 | del(url, data, callback); 328 | }, 329 | setOpenvzContainerOptions: function(node, vmid, data, calback) { 330 | url = '/nodes/'+node+'/openvz/'+vmid+'/config'; 331 | put(url, data, callback); 332 | } 333 | }, 334 | 335 | deleteNodeNetworkConfig: function(node, callback) { 336 | data = {}; 337 | url = '/nodes/'+node+'/network'; 338 | del(url, data, callback); 339 | }, 340 | deleteNodeInterface: function(node, interface, callback) { 341 | data = {}; 342 | url = '/nodes/'+node+'/network/'+interface; 343 | del(url, data, callback); 344 | }, 345 | deletePool: function(poolid, callback){ 346 | data = {}; 347 | url = '/pools/'+poolid; 348 | del(url, data, callback); 349 | }, 350 | setNodeDNSDomain: function(node, domain, callback) { 351 | data = {'search': domain}; 352 | url = '/nodes/'+node+'/dns'; 353 | put(url, data, callback); 354 | }, 355 | setNodeSubscriptionKey: function(node, key, callback) { 356 | data = {'key': key}; 357 | url = '/nodes/'+node+'/subscription'; 358 | put(url, data, callback); 359 | }, 360 | setNodeTimeZone: function(node, timezone, callback) { 361 | data = {'timezone':timezone}; 362 | url = '/nodes/'+node+'/time'; 363 | put(url, data, callback); 364 | }, 365 | setPoolData: function(poolid, data, callback) { 366 | url = '/pools/'+poolid; 367 | put(url, data, callback); 368 | }, 369 | updateStorageConfiguration: function(storageid, data, callback) { 370 | url = '/storage/'+storageid; 371 | put(url, data, callback); 372 | }, 373 | //self added functions 374 | getNodes: function (callback) { 375 | data = {}; 376 | url = '/nodes/'; 377 | get(url,data,callback); 378 | }, 379 | getStorage: function (callback) { 380 | data = {}; 381 | url = '/storage/'; 382 | get(url,data,callback); 383 | }, 384 | getQemu: function (node, callback) { 385 | data = {}; 386 | url = '/nodes/' + node + '/qemu'; 387 | get(url,data,callback); 388 | }, 389 | createQemu: function (node, data, callback) { 390 | url = '/nodes/' + node + '/qemu'; 391 | post(url,data,callback); 392 | }, 393 | //vm functions 394 | qemu: { 395 | getStatus: function (node, qemu, callback) { 396 | data = {}; 397 | url = '/nodes/' + node + '/qemu/' + qemu + '/status/'; 398 | get (url,data,callback); 399 | }, 400 | get: function (node, qemu, callback) { 401 | data = {}; 402 | url = '/nodes/' + node + '/qemu/' + qemu; 403 | get(url,data,callback); 404 | }, 405 | del: function (node, qemu, callback) { 406 | data = {}; 407 | url = '/nodes/' + node + '/qemu/' + qemu; 408 | del(url,data,callback); 409 | }, 410 | getStatusCurrent: function (node, qemu, callback) { 411 | data = {}; 412 | url = '/nodes/' + node + '/qemu/' + qemu + '/status/current' 413 | get(url,data,callback); 414 | }, 415 | start: function (node, qemu, callback) { 416 | data = {}; 417 | url = '/nodes/' + node + '/qemu/' + qemu + '/status/start'; 418 | post(url,data,callback); 419 | }, 420 | stop: function (node, qemu, callback) { 421 | data = {}; 422 | url = '/nodes/' + node + '/qemu/' + qemu + '/status/stop'; 423 | post(url,data,callback); 424 | }, 425 | reset: function (node, qemu, callback) { 426 | data = {}; 427 | url = '/nodes/' + node + '/qemu/' + qemu + '/status/reset'; 428 | post(url,data,callback); 429 | }, 430 | shutdown: function (node, qemu, callback) { 431 | data = {}; 432 | url = '/nodes/' + node + '/qemu/' + qemu + '/status/shutdown'; 433 | post(url,data,callback); 434 | }, 435 | suspend: function (node, qemu, callback) { 436 | data = {}; 437 | url = '/nodes/' + node + '/qemu/' + qemu + '/status/suspend'; 438 | post(url,data,callback); 439 | }, 440 | resume: function (node, qemu, callback) { 441 | data = {}; 442 | url = '/nodes/' + node + '/qemu/' + qemu + '/status/resume'; 443 | post(url,data,callback); 444 | }, 445 | //snapshot functions 446 | snapshot: { 447 | list: function (node, qemu, callback) { 448 | data = {}; 449 | url = '/nodes/' + node + '/qemu/' + qemu + '/snapshot'; 450 | get(url,data,callback); 451 | }, 452 | get: function (node, qemu, snapname, callback) { 453 | data = {}; 454 | url = '/nodes/' + node + '/qemu/' + qemu + '/snapshot/' + snapname; 455 | get(url,data,callback); 456 | }, 457 | getConfig: function (node, qemu, snapname, callback) { 458 | data = {}; 459 | url = '/nodes/' + node + '/qemu/' + qemu + '/snapshot/' + snapname + '/config'; 460 | get(url,data,callback); 461 | }, 462 | putConfig: function (node, qemu, snapname, data, callback) { 463 | url = '/nodes/' + node + '/qemu/' + qemu + '/snapshot/' + snapname + '/config'; 464 | put(url,data,callback); 465 | }, 466 | rollback: function (node, qemu, snapname, callback) { 467 | data = {}; 468 | url = '/nodes/' + node + '/qemu/' + qemu + '/snapshot/' + snapname + '/rollback'; 469 | post(url,data,callback); 470 | }, 471 | delete: function (node, qemu, snapname, callback) { 472 | data = {}; 473 | url = '/nodes/' + node + '/qemu/' + qemu + '/snapshot/' + snapname; 474 | del(url,data,callback); 475 | }, 476 | make: function (node, qemu, data, callback) { 477 | url = '/nodes/' + node + '/qemu/' + qemu + '/snapshot'; 478 | post(url,data,callback); 479 | }, 480 | }, 481 | rrd: function (node, qemu, data, callback) { 482 | url = '/nodes/' + node + '/qemu/' + qemu + '/rrd'; 483 | get(url,data,callback); 484 | }, 485 | rrdData: function (node, qemu, data, callback) { 486 | url = '/nodes/' + node + '/qemu/' + qemu + '/rrddata'; 487 | get(url,data,callback); 488 | }, 489 | getConfig: function (node,qemu, callback) { 490 | data = {}; 491 | url = '/nodes/' + node + '/qemu/' + qemu + '/config'; 492 | get(url, data, callback); 493 | }, 494 | updateConfig: function (node, qemu, data, callback) { 495 | url = '/nodes/' + node + '/qemu/' + qemu + '/config'; 496 | put(url,data,callback); 497 | }, 498 | setConfig: function (node, qemu, data, callback) { 499 | url = '/nodes/' + node + '/qemu/' + qemu + '/config'; 500 | post(url,data,callback); 501 | }, 502 | pending: function (node, qemu, callback) { 503 | data = {}; 504 | url = '/nodes/' + node + '/qemu/' + qemu + '/pending'; 505 | get(url,data,callback); 506 | }, 507 | unlink: function (node, qemu, data, callback) { 508 | url = '/nodes/' + node + '/qemu/' + qemu + '/unlink'; 509 | put(url, data, callback); 510 | }, 511 | vncproxy: function (node, qemu, callback) { 512 | data = {}; 513 | url = '/nodes/' + node + '/qemu/' + qemu + '/vncproxy'; 514 | post (url,data,callback); 515 | }, 516 | vncwebsocket: function (node, qemu, data, callback) { 517 | url = '/nodes/' + node + '/qemu/' + qemu + '/vncwebsocket'; 518 | get(url,data,callback); 519 | }, 520 | spiceproxy: function (node, qemu, data, callback) { 521 | url = '/nodes/' + node + '/qemu/' + qemu + '/spiceproxy'; 522 | post(url,data,callback); 523 | }, 524 | sendkey: function (node, qemu, data, callback) { 525 | url = '/nodes/' + node + '/qemu/' + qemu + '/sendkey'; 526 | put (url,data,callback); 527 | }, 528 | feature: function (node, qemu, data, callback) { 529 | url = '/nodes/' + node + '/qemu/' + qemu + '/feature'; 530 | get(url,data, callback); 531 | }, 532 | clone: function (node, qemu, data, callback) { 533 | url = '/nodes/' + node + '/qemu/' + qemu + '/clone'; 534 | post(url, data, callback); 535 | }, 536 | moveDisk: function (node, qemu, data, callback) { 537 | url = '/nodes/' + node + '/qemu/' + qemu + '/move_disk'; 538 | post(url,data,callback); 539 | }, 540 | migrate: function (node, qemu, data, callback) { 541 | url = '/nodes/' + node + '/qemu/' + qemu + '/migrate'; 542 | post(url,data,callback); 543 | }, 544 | monitor: function (node, qemu, data, callback) { 545 | url = '/nodes/' + node + '/qemu/' + qemu + '/monitor'; 546 | post(url,data,callback); 547 | }, 548 | resize: function (node, qemu, data, callback) { 549 | url = '/nodes/' + node + '/qemu/' + qemu + '/resize'; 550 | put(url,data,callback); 551 | }, 552 | template: function (node, qemu, callback) { 553 | data = {}; 554 | url = '/nodes/' + node + '/qemu/' + qemu + '/template'; 555 | post(url,data,callback); 556 | }, 557 | //firewall functions 558 | firewall: { 559 | list: function (node, qemu, callback) { 560 | data = {}; 561 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall'; 562 | get(url,data,callback); 563 | }, 564 | listRules: function (node, qemu, callback) { 565 | data = {}; 566 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/rules'; 567 | get(url,data,callback); 568 | }, 569 | createRule: function (node, qemu, data, callback) { 570 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/rules'; 571 | post(url,data,callback); 572 | }, 573 | getRule: function (node, qemu, pos, callback) { 574 | data = {}; 575 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/rules/' + pos; 576 | get(url,data,callback); 577 | }, 578 | updateRule: function (node, qemu, pos, data, callback) { 579 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/rules/' + pos; 580 | put(url,data,callback); 581 | }, 582 | deleteRule: function (node, qemu, pos, callback) { 583 | data = {}; 584 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/rules/' + pos; 585 | del(url,data,callback); 586 | }, 587 | listAlias: function (node, qemu, callback) { 588 | data = {}; 589 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/aliases'; 590 | get(url,data,callback); 591 | }, 592 | createAlias: function (node, qemu, data, callback) { 593 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/aliases'; 594 | post(url,data,callback); 595 | }, 596 | getAlias: function (node, qemu, name, callback) { 597 | data = {}; 598 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/aliases/' + name; 599 | get(url,data,callback); 600 | }, 601 | updateAlias: function (node, qemu, name, data, callback) { 602 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/aliases/' + name; 603 | put(url,data,callback); 604 | }, 605 | deleteAlias: function (node, qemu, name, callback) { 606 | data = {}; 607 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/aliases/' + name; 608 | del(url,data,callback); 609 | }, 610 | listIpset: function (node, qemu, callback) { 611 | data = {}; 612 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/ipset'; 613 | get(url,data,callback); 614 | }, 615 | createIpset: function (node, qemu, data, callback) { 616 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/ipset'; 617 | post(url,data,callback); 618 | }, 619 | getIpsetContent: function (node, qemu, name, callback) { 620 | data = {}; 621 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/ipset/' + name; 622 | get(url,data,callback); 623 | }, 624 | addIpToIpset: function (node, qemu, name, data, callback) { 625 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/ipset/' + name; 626 | post(url,data,callback); 627 | }, 628 | deleteIpset: function (node, qemu, name, callback) { 629 | data = {}; 630 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/ipset/' + name; 631 | del(url,data,callback); 632 | }, 633 | getIpfromIpset: function (node, qemu, name, cidr, callback) { 634 | data = {}; 635 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/ipset/' + name + '/' + cidr; 636 | get(url,data,callback); 637 | }, 638 | updateIpfromIpset: function (node, qemu, name, cidr, data, callback) { 639 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/ipset/' + name + '/' + cidr; 640 | put(url,data,callback); 641 | }, 642 | deleteIpfromIpset: function (node, qemu, name, cidr, callback) { 643 | data = {}; 644 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/ipset/' + name + '/' + cidr; 645 | del(url,data,callback); 646 | }, 647 | getOptions: function (node, qemu, callback) { 648 | data = {}; 649 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/options'; 650 | get(url,data,callback); 651 | }, 652 | setOptions: function (node, qemu, data, callback) { 653 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/options'; 654 | put(url,data,callback); 655 | }, 656 | getLog: function (node, qemu, callback) { 657 | data = {}; 658 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/log'; 659 | get(url,data,callback); 660 | }, 661 | getRefs: function (node, qemu, callback) { 662 | data = {}; 663 | url = '/nodes/' + node + '/qemu/' + qemu + '/firewall/refs'; 664 | get(url,data,callback); 665 | }, 666 | }, 667 | }, 668 | network: { 669 | list: function (node, callback) { 670 | data = {}; 671 | url = '/nodes/' + node + '/network'; 672 | get(url,data,callback); 673 | }, 674 | create: function (node, data, callback) { 675 | url = '/nodes/' + node + '/network'; 676 | post(url,data,callback); 677 | }, 678 | get: function(node, iface, callback) { 679 | data = {}; 680 | url = '/nodes/' + node + '/network/' + iface; 681 | get(url,data,callback); 682 | }, 683 | update: function(node, iface, data, callback) { 684 | url = '/nodes/' + node + '/network/' + iface; 685 | put(url,data,callback); 686 | }, 687 | deleteIface: function(node, iface, callback) { 688 | data = {}; 689 | url = '/nodes/' + node + '/network/' + iface; 690 | del(url,data,callback); 691 | }, 692 | delete: function (node, callback) { 693 | data = {}; 694 | url = '/nodes/' + node + '/network'; 695 | del(url,data,callback); 696 | } 697 | }, 698 | //access functions 699 | access: { 700 | listUsers: function (callback) { 701 | data = {}; 702 | url = '/access/users'; 703 | get(url,data, callback); 704 | }, 705 | createUser: function (data, callback) { 706 | url = '/access/users'; 707 | post(url,data,callback); 708 | }, 709 | getUser: function(user, callback) { 710 | data = {}; 711 | url = '/access/users/' + user; 712 | get(url,data,callback); 713 | }, 714 | updateUser: function (user, data, callback) { 715 | url = '/access/users/' + user; 716 | put(url,data,callback); 717 | }, 718 | deleteUser: function (user, callback) { 719 | data = {}; 720 | url = '/access/users/' + user; 721 | del(url,data,callback); 722 | }, 723 | listGroups: function (callback) { 724 | data = {}; 725 | url = '/access/groups'; 726 | get(url,data,callback); 727 | }, 728 | createGroup: function (data, callback) { 729 | url = '/access/groups'; 730 | post(url,data,callback); 731 | }, 732 | getGroup: function (group, callback) { 733 | data = {}; 734 | url = '/access/groups/' + group; 735 | get(url,data,callback); 736 | }, 737 | updateGroup: function (group, data, callback) { 738 | url = '/access/groups/' + group; 739 | put(url,data,callback); 740 | }, 741 | deleteGroup: function (group, data, callback) { 742 | url = '/access/groups/' + group; 743 | del(url,data,callback); 744 | }, 745 | listRoles: function (callback) { 746 | data = {}; 747 | url = '/access/roles'; 748 | get(url,data,callback); 749 | }, 750 | createRole: function (data, callback) { 751 | url = '/access/roles'; 752 | post(url,data,callback); 753 | }, 754 | getRole: function (role, callback) { 755 | data = {}; 756 | url = '/access/roles/' + role; 757 | get(url,data,callback); 758 | }, 759 | updateRole: function (role, data, callback) { 760 | url = '/access/roles/' + role; 761 | put(url,data,callback); 762 | }, 763 | deleteRole: function(role,callback) { 764 | data = {}; 765 | url = '/access/roles/' + role; 766 | del(url,data,callback); 767 | }, 768 | listDomains: function(callback) { 769 | data = {}; 770 | url = '/access/domains'; 771 | get(url,data,callback); 772 | }, 773 | createDomain: function (data, callback) { 774 | url = '/access/domains'; 775 | post(url,data,callback); 776 | }, 777 | getDomain: function (domain, callback) { 778 | data = {}; 779 | url = '/access/domains/' + domain; 780 | get(url,data,callback); 781 | }, 782 | updateDomain: function(domain, data, callback) { 783 | url = '/access/domains/' + domain; 784 | put(url,data,callback); 785 | }, 786 | deleteDomain: function(domain, callback) { 787 | data = {}; 788 | url = '/access/domains/' + domain; 789 | del(url,data,callback); 790 | }, 791 | getAcl: function (callback) { 792 | data = {}; 793 | url = '/access/acl'; 794 | get(url,data,callback); 795 | }, 796 | updateAcl: function (data, callback) { 797 | url = '/access/acl'; 798 | put(url,data,callback); 799 | }, 800 | getTicket: function (callback) { 801 | data = {}; 802 | url = '/access/ticket'; 803 | get(url,data,callback); 804 | }, 805 | postTicket: function (data, callback) { 806 | url = '/access/ticket'; 807 | post(url,data,callback); 808 | }, 809 | password: function (data, callback) { 810 | url = '/access/password'; 811 | put(url,data,callback); 812 | }, 813 | }, 814 | //pool functions 815 | pools : { 816 | list: function (callback) { 817 | data = {}; 818 | url = '/pools'; 819 | get(url,data,callback); 820 | }, 821 | create: function (data, callback) { 822 | url = '/pools'; 823 | post(url,data,callback); 824 | }, 825 | get: function (pool, callback) { 826 | data = {}; 827 | url = '/pools/' + pool; 828 | get(url,data,callback); 829 | }, 830 | update: function(pool, data, callback) { 831 | url = '/pools/' + pool; 832 | put(url,data,callback); 833 | }, 834 | delete: function (pool, callback) { 835 | data = {}; 836 | url = '/pools/' + pool; 837 | del(url,data,callback); 838 | } 839 | }, 840 | //storage functions 841 | storage : { 842 | list: function (callback) { 843 | data = {}; 844 | url = '/storage'; 845 | get(url,data,callback); 846 | }, 847 | create: function (data, callback) { 848 | url = '/storage'; 849 | post(url,data,callback); 850 | }, 851 | get: function (storage, callback) { 852 | data = {}; 853 | url = '/storage/' + storage; 854 | get(url,data,callback); 855 | }, 856 | update: function (storage, data, callback) { 857 | url = '/storage/' + storage; 858 | put(url,data,callback); 859 | }, 860 | delete: function (storage, callback) { 861 | data = {}; 862 | url = '/storage/' + storage; 863 | del(url,data,callback); 864 | }, 865 | 866 | }, 867 | } 868 | }; 869 | --------------------------------------------------------------------------------