@yawetse/pkgcloud
Version:
An infrastructure-as-a-service agnostic cloud library for node.js
316 lines (232 loc) • 11.9 kB
Markdown
Creating a client is straight-forward:
``` js
var openstack = pkgcloud.network.createClient({
provider: 'openstack', // required
username: 'your-user-name', // required
password: 'your-password', // required
authUrl: 'your identity service url' // required
});
```
**Note:** *Due to variances between OpenStack deployments, you may or may not need a `region` option.*
**Networks**
Lists all networks that are available to use on your Openstack account
Callback returns `f(err, networks)` where `networks` is an `Array`
Gets specified network
Takes network or networkId as an argument and returns the network in the callback
`f(err, network)`
Creates a network with the options specified
Options are as follows:
```js
{
name: 'networkName', // optional
adminStateUp : true, // optional
shared : true, // optional, Admin only
tenantId : 'tenantId' // optional, Admin only
}
```
Returns the network in the callback `f(err, network)`
Updates a network with the options specified
Options are as follows:
```js
{
id : 'networkId', // required
name: 'networkName', // optional
adminStateUp : true, // optional
shared : true, // optional, Admin only
tenantId : 'tenantId' // optional, Admin only
}
```
Returns the network in the callback `f(err, network)`
Destroys the specified network
Takes network or networkId as an argument and returns the id of the destroyed network in the callback `f(err, networkId)`
**Subnets**
Lists all subnets that are available to use on your Openstack account
Callback returns `f(err, subnets)` where `subnets` is an `Array`
Gets specified subnet
Takes subnet or subnetId as an argument and returns the subnet in the callback
`f(err, subnet)`
Creates a subnet with the options specified
Options are as follows:
```js
{
name: 'subnetName', // optional
networkId : 'networkId', // required, The ID of the attached network.
shared : true, // optional, Admin only
tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only
gatewayIp : 'gateway ip address', // optional,The gateway IP address.
enableDhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled.
}
```
Returns the subnet in the callback `f(err, subnet)`
Updates a subnet with the options specified
Options are as follows:
```js
{
id : 'subnetId', // required
name: 'subnetName', // optional
networkId : 'networkId', // required, The ID of the attached network.
shared : true, // optional, Admin only
tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only
gatewayIp : 'gateway ip address', // optional,The gateway IP address.
enableDhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled.
}
```
Returns the subnet in the callback `f(err, subnet)`
Destroys the specified subnet
Takes subnet or subnetId as an argument and returns the id of the destroyed subnet in the callback `f(err, subnetId)`
**Ports**
Lists all ports that are available to use on your Openstack account
Callback returns `f(err, ports)` where `ports` is an `Array`
Gets specified port
Takes port or portId as an argument and returns the port in the callback
`f(err, port)`
Creates a port with the options specified
Options are as follows:
```js
{
name: 'portName', // optional
adminStateUp : true, // optional, The administrative status of the router. Admin-only
networkId : 'networkId', // required, The ID of the attached network.
status : 'text status', // optional, The status of the port.
tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only
macAddress: 'mac address' // optional
fixedIps : ['ip address1', 'ip address 2'], // optional.
securityGroups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs.
}
```
Returns the port in the callback `f(err, port)`
Updates a port with the options specified
Options are as follows:
```js
{
id : 'portId', // required
name: 'portName', // optional
adminStateUp : true, // optional, The administrative status of the router. Admin-only
networkId : 'networkId', // required, The ID of the attached network.
status : 'text status', // optional, The status of the port.
tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only
macAddress: 'mac address' // optional
fixedIps : ['ip address1', 'ip address 2'], // optional.
securityGroups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs.
}
```
Returns the port in the callback `f(err, port)`
Destroys the specified port
Takes port or portId as an argument and returns the id of the destroyed port in the callback `f(err, portId)`
**Security Groups**
Lists all security groups that are available to use on your Openstack account
Callback returns `f(err, securityGroups)` where `securityGroups` is an `Array`
Gets specified security group
Takes securityGroup or securityGroupId as an argument and returns the security group in the callback
`f(err, securityGroup)`
Creates a security group with the options specified
Options are as follows:
```js
{
name: 'securityGroupName', // required, name of security group
description : 'security group description', // optional, description of security group
tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group. Admin-only
}
```
Returns the created security group in the callback `f(err, securityGroup)`
Destroys the specified security group
Takes securityGroup or securityGroupId as an argument and returns the id of the destroyed security group in the callback `f(err, securityGroupId)`
**Security Group Rules**
Lists all security group rules that are available to use on your Openstack account
Callback returns `f(err, securityGroupRules)` where `securityGroupRules` is an `Array`
Gets specified security group rule
Takes securityGroupRule or securityGroupRuleId as an argument and returns the security group rule in the callback
`f(err, securityGroupRule)`
Creates a security group rule with the options specified
Options are as follows:
```js
{
securityGroupId: 'securityGroupId', // required, The security group ID to associate with this security group rule.
direction: 'ingress|egress', // required, The direction in which the security group rule is applied.
ethertype: 'IPv4|IPv6', // optional,
portRangeMin: portNumber, // optional, The minimum port number in the range that is matched by the security group rule.
portRangeMax: portNumber, // optional, The maximum port number in the range that is matched by the security group rule.
protocol: 'tcp|udp|icmp', // optional, The protocol that is matched by the security group rule
remoteGroupId: 'remote group id', // optional, The remote group ID to be associated with this security group rule. You can specify either this or remoteIpPrefix.
remoteIpPrefix: 'remote IP prefix', // optional, The remote IP prefix to be associated with this security group rule. You can specify either this or remoteGroupId.
tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group rule. Admin-only
}
```
Returns the created security group rule in the callback `f(err, securityGroupRule)`
Destroys the specified security group rule
Takes securityGroupRule or securityGroupRuleId as an argument and returns the id of the destroyed security group rule in the callback `f(err, securityGroupRuleId)`
**Security Groups**
Lists all security groups that are available to use on your Openstack account
Callback returns `f(err, securityGroups)` where `securityGroups` is an `Array`
Gets specified security group
Takes securityGroup or securityGroupId as an argument and returns the security group in the callback
`f(err, securityGroup)`
Creates a security group with the options specified
Options are as follows:
```js
{
name: 'securityGroupName', // required, name of security group
description : 'security group description', // optional, description of security group
tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group. Admin-only
}
```
Returns the created security group in the callback `f(err, securityGroup)`
Destroys the specified security group
Takes securityGroup or securityGroupId as an argument and returns the id of the destroyed security group in the callback `f(err, securityGroupId)`
**Security Group Rules**
Lists all security group rules that are available to use on your Openstack account
Callback returns `f(err, securityGroupRules)` where `securityGroupRules` is an `Array`
Gets specified security group rule
Takes securityGroupRule or securityGroupRuleId as an argument and returns the security group rule in the callback
`f(err, securityGroupRule)`
Creates a security group rule with the options specified
Options are as follows:
```js
{
securityGroupId: 'securityGroupId', // required, The security group ID to associate with this security group rule.
direction: 'ingress|egress', // required, The direction in which the security group rule is applied.
ethertype: 'IPv4|IPv6', // optional,
portRangeMin: portNumber, // optional, The minimum port number in the range that is matched by the security group rule.
portRangeMax: portNumber, // optional, The maximum port number in the range that is matched by the security group rule.
protocol: 'tcp|udp|icmp', // optional, The protocol that is matched by the security group rule
remoteGroupId: 'remote group id', // optional, The remote group ID to be associated with this security group rule. You can specify either this or remoteIpPrefix.
remoteIpPrefix: 'remote IP prefix', // optional, The remote IP prefix to be associated with this security group rule. You can specify either this or remoteGroupId.
tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group rule. Admin-only
}
```
Returns the created security group rule in the callback `f(err, securityGroupRule)`
Destroys the specified security group rule
Takes securityGroupRule or securityGroupRuleId as an argument and returns the id of the destroyed security group rule in the callback `f(err, securityGroupRuleId)`