@yawetse/pkgcloud
Version:
An infrastructure-as-a-service agnostic cloud library for node.js
169 lines (123 loc) • 4.93 kB
Markdown
Creating a block-storage client is straight-forward:
``` js
var rackspace = pkgcloud.blockstorage.createClient({
provider: 'rackspace', // required
username: 'your-user-name', // required
apiKey: 'your-api-key', // required
region: 'IAD', // required, regions can be found at
// http://www.rackspace.com/knowledge_center/article/about-regions
useInternal: false // optional, use to talk to serviceNet from a Rackspace machine
});
```
[](README.md)
Note: For **attaching volumes to compute instances**, please see the [compute volume attachments](compute.md
* Volume
* [Model](
* [APIs](
* Snapshot
* [Model](
* [APIs](
* VolumeType
* [Model](
* [APIs](
A Volume for BlockStorage has following properties:
```Javascript
{
id: '12345678-1111-2222-3333-123456789012', // id of the volume
name: 'foo3',
description: 'my volume',
status: 'available', // status of the volume
size: 100, // in GB
volumeType: 'SATA',
attachments: [], // array of the attachments for this volume
snapshotId: null, // snapshotId, if any, for this volume
createdAt: '2013-07-26T15:54:04.000000'
}
```
A Snapshot for BlockStorage has the following properties:
```Javascript
{
id: '12345678-1111-2222-3333-123456789012', // id of the snapshot
name: 'foo3',
description: 'my snapshot',
status: 'available', // status of the snapshot
size: 100, // in GB
volumeId: '12345678-1111-2222-3333-123456789012',
createdAt: '2013-07-26T15:54:04.000000'
}
```
A VolumeType for BlockStorage has the following properties:
```Javascript
{
id: '12345678-1111-2222-3333-123456789012', // id of the snapshot
name: 'SSD',
extra_specs: {} // not used presently
}
```
Lists all volumes that are available to use on your Rackspace account
Callback returns `f(err, volumes)` where `volumes` is an `Array`. `options` is an optional `boolean` which will return the full volume details if true.
Gets specified volume.
Takes volume or volumeId as an argument and returns the volume in the callback
`f(err, volume)`
Creates a volume with the details specified
Options are as follows:
```js
{
name: 'volumeName', // required
description: 'my volume', // required
size: 100, // 100-1000 gb
volumeType: 'SSD' // optional, defaults to spindles
snapshotId: '1234567890' // optional, the snapshotId to use when creating the volume
}
```
Returns the new volume in the callback `f(err, volume)`
Deletes the specified volume
Takes volume or volumeId as an argument and returns an error if unsuccessful `f(err)`
Updates the name & description on the provided volume. Does not support resize.
Returns callback with a confirmation
Lists all snapshots that are available to use on your Rackspace account
Callback returns `f(err, snapshots)` where `snapshots` is an `Array`. `options` is an optional `boolean` which will return the full snapshot details if true.
Gets specified snapshot.
Takes snapshot or snapshotId as an argument and returns the snapshot in the callback
`f(err, snapshot)`
Creates a snapshot with the details specified
Options are as follows:
```js
{
name: 'volumeName', // required
description: 'my volume', // required
volumeId: 'asdf1234', // required, volume id of the new snapshot
force: true // optional, defaults to false. force creation of the snapshot
}
```
Returns the new snapshot in the callback `f(err, snapshot)`
Deletes the specified snapshot
Takes snapshot or snapshotId as an argument and returns an error if unsuccessful `f(err)`
Updates the name & description on the provided snapshot.
Returns callback with a confirmation
Volume types are used to define which kind of new volume to create.
Lists all volumeTypes that are available to use on your Rackspace account
Callback returns `f(err, volumeTypes)` where `volumeTypes` is an `Array`.
Gets specified volumeType.
Takes volumeType or volumeTypeId as an argument and returns the volumeType in the callback
`f(err, volumeType)`