Skip to content

Commit fe04a34

Browse files
Phani RajPhani Raj
authored andcommitted
Merge branch 'master' into pkgcloudgh-280
2 parents 46f7bb7 + 0f27b4d commit fe04a34

38 files changed

Lines changed: 2464 additions & 12 deletions

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pkgcloud is a standard library for node.js that abstracts away differences among
1414
* [DNS](#dns----beta) *(beta)*
1515
* [Block Storage](#block-storage----beta) *(beta)*
1616
* [Load Balancers](#load-balancers----beta) *(beta)*
17+
* [Network](#network----beta) *(beta)*
1718
* _Fine Print_
1819
* [Installation](#installation)
1920
* [Tests](#tests)
@@ -39,6 +40,7 @@ Currently there are six service types which are handled by pkgcloud:
3940
* [DNS](#dns----beta) *(beta)*
4041
* [Block Storage](#block-storage----beta) *(beta)*
4142
* [Load Balancers](#load-balancers----beta) *(beta)*
43+
* [Network](#dns----beta) *(beta)*
4244

4345
In our [Roadmap](#roadmap), we plan to add support for more services, such as Queueing, Monitoring, and more. Additionally, we plan to implement more providers for the *beta* services, thus moving them out of *beta*.
4446

@@ -118,6 +120,8 @@ If a service does not have at least two providers, it is considered a *beta* int
118120
* [Rackspace](docs/providers/rackspace/blockstorage.md)
119121
* **[Load Balancers](#load-balancers----beta)** *(beta)*
120122
* [Rackspace](docs/providers/rackspace/loadbalancer.md)
123+
* **[Network](#network----beta)** *(beta)*
124+
* [Openstack](docs/providers/openstack/network.md)
121125

122126
## Compute
123127

@@ -397,6 +401,55 @@ Each instance of `pkgcloud.loadbalancer.Client` returned from `pkgcloud.loadbala
397401
* `client.updateNode(loadBalancer, node, function (err) { })`
398402
* `client.removeNode(loadBalancer, node, function (err) { })`
399403

404+
## Network -- Beta
405+
406+
##### Note: Network is considered Beta until there are multiple providers; presently only Openstack providers are supported.
407+
408+
The `pkgcloud.network` service is designed to make it easy to create and manage networks.
409+
410+
To get started with a `pkgcloud.network` client just create one:
411+
412+
``` js
413+
var client = require('pkgcloud').network.createClient({
414+
//
415+
// The name of the provider (e.g. "openstack")
416+
//
417+
provider: 'provider-name',
418+
419+
//
420+
// ... Provider specific credentials
421+
//
422+
});
423+
```
424+
425+
#### Providers
426+
427+
* [Openstack](docs/providers/openstack/network.md)
428+
429+
Each instance of `pkgcloud.network.Client` returned from `pkgcloud.network.createClient` has a set of uniform APIs:
430+
431+
### Networks
432+
* `client.getNetworks(options, function (err, networks) { })`
433+
* `client.getNetwork(network, function (err, network) { })`
434+
* `client.createNetwork(options, function (err, network) { })`
435+
* `client.updateNetwork(network, function (err, network) { })`
436+
* `client.deleteNetwork(network, function (err, networkId) { })`
437+
438+
439+
### Subnets
440+
* `client.getSubnets(options, function (err, subnets) { })`
441+
* `client.getSubnet(subnet, function (err, subnet) { })`
442+
* `client.createSubnet(options, function (err, subnet) { })`
443+
* `client.updateSubnet(subnet, function (err, subnet) { })`
444+
* `client.deleteSubnet(subnet, function (err, subnetId) { })`
445+
446+
### Ports
447+
* `client.getPorts(options, function (err, ports) { })`
448+
* `client.getPort(port, function (err, port) { })`
449+
* `client.createPort(options, function (err, port) { })`
450+
* `client.updatePort(port, function (err, port) { })`
451+
* `client.deletePort(port, function (err, portId) { })`
452+
400453
## Installation
401454

402455
``` bash

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ If a service does not have at least two providers, it is considered a *beta* int
4040
* [Rackspace](providers/rackspace/blockstorage.md)
4141
* **Load Balancers** *(beta)*
4242
* [Rackspace](providers/rackspace/loadbalancer.md)
43+
* **Networking** *(beta)*
44+
* [Openstack](providers/openstack/network.md)

docs/providers/openstack/compute.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,4 @@ Attaches the provided `volume` to the `server`. `volume` may either be the `volu
138138

139139
Detaches the provided `attachment` from the server. `attachment` may either be the `attachmentId` or an object with `attachmentId` as a property. If the `volume` is mounted this call will return an err.
140140

141-
`f(err)`
141+
`f(err)`
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
##Using the Openstack Network provider
2+
3+
Creating a client is straight-forward:
4+
5+
``` js
6+
var openstack = pkgcloud.network.createClient({
7+
provider: 'openstack',
8+
username: 'your-user-name',
9+
password: 'your-password',
10+
authUrl: 'https://yourIdentity-service'
11+
});
12+
```
13+
### API Methods
14+
15+
**Networks**
16+
17+
#### client.getNetworks(callback)
18+
Lists all networks that are available to use on your Openstack account
19+
20+
Callback returns `f(err, networks)` where `networks` is an `Array`
21+
22+
#### client.getNetwork(network, callback)
23+
Gets specified network
24+
25+
Takes network or networkId as an argument and returns the network in the callback
26+
`f(err, network)`
27+
28+
#### client.createNetwork(options, callback)
29+
Creates a network with the options specified
30+
31+
Options are as follows:
32+
33+
```js
34+
{
35+
name: 'networkName', // optional
36+
adminStateUp : true, // optional
37+
shared : true, // optional, Admin only
38+
tenantId : 'tenantId' // optional, Admin only
39+
}
40+
```
41+
Returns the network in the callback `f(err, network)`
42+
43+
#### client.updateNetwork(options, callback)
44+
Updates a network with the options specified
45+
46+
Options are as follows:
47+
48+
```js
49+
{
50+
id : 'networkId', // required
51+
name: 'networkName', // optional
52+
adminStateUp : true, // optional
53+
shared : true, // optional, Admin only
54+
tenantId : 'tenantId' // optional, Admin only
55+
}
56+
```
57+
Returns the network in the callback `f(err, network)`
58+
59+
#### client.destroyNetwork(network, callback)
60+
Destroys the specified network
61+
62+
Takes network or networkId as an argument and returns the id of the destroyed network in the callback `f(err, networkId)`
63+
64+
**Subnets**
65+
66+
#### client.getSubnets(callback)
67+
Lists all subnets that are available to use on your Openstack account
68+
69+
Callback returns `f(err, subnets)` where `subnets` is an `Array`
70+
71+
#### client.getSubnet(subnet, callback)
72+
Gets specified subnet
73+
74+
Takes subnet or subnetId as an argument and returns the subnet in the callback
75+
`f(err, subnet)`
76+
77+
#### client.createSubnet(options, callback)
78+
Creates a subnet with the options specified
79+
80+
Options are as follows:
81+
82+
```js
83+
{
84+
name: 'subnetName', // optional
85+
networkId : 'networkId', // required, The ID of the attached network.
86+
shared : true, // optional, Admin only
87+
tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only
88+
gatewayIp : 'gateway ip address', // optional,The gateway IP address.
89+
enableDhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled.
90+
}
91+
```
92+
Returns the subnet in the callback `f(err, subnet)`
93+
94+
#### client.updateSubnet(options, callback)
95+
Updates a subnet with the options specified
96+
97+
Options are as follows:
98+
99+
```js
100+
{
101+
id : 'subnetId', // required
102+
name: 'subnetName', // optional
103+
networkId : 'networkId', // required, The ID of the attached network.
104+
shared : true, // optional, Admin only
105+
tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only
106+
gatewayIp : 'gateway ip address', // optional,The gateway IP address.
107+
enableDhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled.
108+
}
109+
```
110+
Returns the subnet in the callback `f(err, subnet)`
111+
112+
#### client.destroySubnet(subnet, callback)
113+
Destroys the specified subnet
114+
115+
Takes subnet or subnetId as an argument and returns the id of the destroyed subnet in the callback `f(err, subnetId)`
116+
117+
**Ports**
118+
119+
#### client.getPorts(callback)
120+
Lists all ports that are available to use on your Openstack account
121+
122+
Callback returns `f(err, ports)` where `ports` is an `Array`
123+
124+
#### client.getPort(port, callback)
125+
Gets specified port
126+
127+
Takes port or portId as an argument and returns the port in the callback
128+
`f(err, port)`
129+
130+
#### client.createPort(options, callback)
131+
Creates a port with the options specified
132+
133+
Options are as follows:
134+
135+
```js
136+
{
137+
name: 'portName', // optional
138+
adminStateUp : true, // optional, The administrative status of the router. Admin-only
139+
networkId : 'networkId', // required, The ID of the attached network.
140+
status : 'text status', // optional, The status of the port.
141+
tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only
142+
macAddress: 'mac address' // optional
143+
fixedIps : ['ip address1', 'ip address 2'], // optional.
144+
securityGroups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs.
145+
}
146+
```
147+
Returns the port in the callback `f(err, port)`
148+
149+
#### client.updatePort(options, callback)
150+
Updates a port with the options specified
151+
152+
Options are as follows:
153+
154+
```js
155+
{
156+
id : 'portId', // required
157+
name: 'portName', // optional
158+
adminStateUp : true, // optional, The administrative status of the router. Admin-only
159+
networkId : 'networkId', // required, The ID of the attached network.
160+
status : 'text status', // optional, The status of the port.
161+
tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only
162+
macAddress: 'mac address' // optional
163+
fixedIps : ['ip address1', 'ip address 2'], // optional.
164+
securityGroups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs.
165+
}
166+
```
167+
Returns the port in the callback `f(err, port)`
168+
169+
#### client.destroyPort(port, callback)
170+
Destroys the specified port
171+
172+
Takes port or portId as an argument and returns the id of the destroyed port in the callback `f(err, portId)`

docs/providers/openstack/storage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Removes the provided [`file`](#file-model) from the provided [`container`](#cont
282282

283283
Updates the [`file`](#file-model) metadata in the the provided [`container`](#container-model).
284284

285-
File metadata is completely replaced with each callt o updateFileMetadata. This is different than container metadata. To delete a property, just remove it from the metadata attribute on the `File` and call `updateFileMetadata`.
285+
File metadata is completely replaced with each call to updateFileMetadata. This is different than container metadata. To delete a property, just remove it from the metadata attribute on the `File` and call `updateFileMetadata`.
286286
```javascript
287287
file.metadata = {
288288
campaign = '2011 website'

docs/providers/rackspace/storage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ Removes the provided [`file`](#file-model) from the provided [`container`](#cont
293293

294294
Updates the [`file`](#file-model) metadata in the the provided [`container`](#container-model).
295295

296-
File metadata is completely replaced with each callt o updateFileMetadata. This is different than container metadata. To delete a property, just remove it from the metadata attribute on the `File` and call `updateFileMetadata`.
296+
File metadata is completely replaced with each call to updateFileMetadata. This is different than container metadata. To delete a property, just remove it from the metadata attribute on the `File` and call `updateFileMetadata`.
297297
```javascript
298298
file.metadata = {
299299
campaign = '2011 website'

lib/pkgcloud.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var services = [
4040
'database',
4141
'dns',
4242
'loadbalancer',
43+
'network',
4344
'storage'
4445
];
4546

lib/pkgcloud/core/base/client.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ utile.inherits(Client, events.EventEmitter2);
4242
*/
4343
Client.prototype._request = function (options, callback) {
4444
var self = this;
45-
4645
var requestOptions = {};
4746

4847
requestOptions.method = options.method || 'GET';
@@ -70,7 +69,7 @@ Client.prototype._request = function (options, callback) {
7069
requestOptions.signingUrl += '?' + qs.stringify(options.qs);
7170
}
7271
}
73-
72+
7473
function sendRequest(opts) {
7574

7675
//
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* network.js: Base network from which all pkgcloud networks inherit.
3+
*
4+
* (C) 2014 Hewlett-Packard Development Company, L.P.
5+
*
6+
*/
7+
8+
var utile = require('utile'),
9+
model = require('../base/model');
10+
11+
var Network = exports.Network = function (client, details) {
12+
model.Model.call(this, client, details);
13+
};
14+
15+
utile.inherits(Network, model.Model);
16+
17+
Network.prototype.create = function (callback) {
18+
this.client.createNetwork(this.name, callback);
19+
};
20+
21+
Network.prototype.refresh = function (callback) {
22+
this.client.getNetwork(this.id, callback);
23+
};
24+
25+
Network.prototype.update = function (callback) {
26+
this.client.updateNetwork(this, callback);
27+
};
28+
29+
Network.prototype.destroy = function (callback) {
30+
this.client.destroyNetwork(this.id, callback);
31+
};

lib/pkgcloud/core/network/port.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* port.js: Base network from which all pkgcloud ports inherit.
3+
*
4+
* (C) 2014 Hewlett-Packard Development Company, L.P.
5+
*
6+
*/
7+
8+
var utile = require('utile'),
9+
model = require('../base/model');
10+
11+
var Port = exports.Port = function (client, details) {
12+
model.Model.call(this, client, details);
13+
};
14+
15+
utile.inherits(Port, model.Model);
16+
17+
Port.prototype.create = function (callback) {
18+
this.client.createPort(this.name, callback);
19+
};
20+
21+
Port.prototype.refresh = function (callback) {
22+
this.client.getPort(this.id, callback);
23+
};
24+
25+
Port.prototype.update = function (callback) {
26+
this.client.updatePort(this, callback);
27+
};
28+
29+
Port.prototype.destroy = function (callback) {
30+
this.client.destroyPort(this.id, callback);
31+
};

0 commit comments

Comments
 (0)