Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding limited nova network management support
- Loading branch information
1 parent
109c37e
commit 4cefdad
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var base = require("../../client/base"), | ||
error = require("../../client/error"); | ||
|
||
|
||
var NetworkManager = base.Manager.extend({ | ||
namespace: "os-networks", | ||
plural: "networks", | ||
|
||
create: function (params, callback) { | ||
// Nova will choke with an error trying to parse an int if MTU is sent | ||
// but anything other than an integer or null; | ||
if (!params.data.mtu) params.data.mtu = null; | ||
return this._super(params, callback); | ||
}, | ||
|
||
del: function (params, callback) { | ||
var manager = this, | ||
id = params.id || params.data.id; | ||
params.url = this.urljoin(this.get_base_url(params), id); | ||
// Always try to disassociate first; it's slightly inefficient, but it | ||
// ensures that delete won't fail because you forgot to do the disassocation | ||
// manually. This doesn't seem like a place where two steps are necessary. | ||
return this.disassociate({id: id}, function (err, result, xhr) { | ||
if (err) return manager.safe_complete(err, null, xhr, params, callback); | ||
manager.client.del(params, callback); | ||
}); | ||
}, | ||
|
||
disassociate: function (params, callback) { | ||
// Unlike novaclient, this method defaults to disassociating everything. | ||
var url = this.urljoin(this.get_base_url(params), params.id || params.data.id, "action"); | ||
params = this.prepare_params(params, url, "singular"); | ||
params.data = {disassociate: null}; | ||
return this.client.post(params, callback); | ||
} | ||
}); | ||
|
||
|
||
module.exports = NetworkManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters