|
| 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)` |
0 commit comments