fog-speedyrails 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +8 -0
- data/README.md +533 -0
- data/Rakefile +6 -0
- data/bin/console +17 -0
- data/bin/setup +9 -0
- data/config.yml.example +6 -0
- data/exe/fog-speedyrails +3 -0
- data/fog-speedyrails.gemspec +26 -0
- data/lib/fog/speedyrails/version.rb +5 -0
- data/lib/fog/speedyrails.rb +35 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 389b9d938c228349d3f4e801846dab34436327f9
|
4
|
+
data.tar.gz: 18a944388fc93223ee7669ae293f84c595b1bb67
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64fb3215761f0125a5600a31493ca87cafdb8b364c9131e4b93ad36340f66d22a6e9f9472654d810665515377fbd2e9a223a8e623b33bb935bc5ae664c653b34
|
7
|
+
data.tar.gz: b4a3a6ab6a28df59c70d97162f92ad021187546d43f089d1c5eb64834851eecddb5a43e103179baaf3b49a68e7bb8ac4a8e46255d3765b300997b4afac6f55ca
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,533 @@
|
|
1
|
+
# Fog::Speedyrails
|
2
|
+
|
3
|
+
This is the plugin Gem to talk to [OpenStack](http://openstack.org) clouds via fog.
|
4
|
+
|
5
|
+
The main maintainers for the OpenStack sections are @dhague, @Ladas, @seanhandley, @mdarby and @jjasghar. Please send CC them on pull requests.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'fog-openstack'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install fog-openstack
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Initial Setup
|
26
|
+
|
27
|
+
Require the gem:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require "fog/openstack"
|
31
|
+
```
|
32
|
+
|
33
|
+
Checklist:
|
34
|
+
|
35
|
+
* Before you can do anything with an OpenStack cloud, you need to authenticate yourself with the identity service, "Keystone".
|
36
|
+
* All following examples assume that `@connection_params` is a hash of valid connection information for an OpenStack cloud.
|
37
|
+
* The `:openstack_username` and `:openstack_api_key` keys must map to a valid user/password combination in Keystone.
|
38
|
+
* If you don't know what domain your user belongs to, chances are it's the `default` domain. By default, all users are a member of the `default` domain unless otherwise specified.
|
39
|
+
|
40
|
+
Connection parameters:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
@connection_params = {
|
44
|
+
openstack_auth_url: "http://devstack.test:5000/v3/auth/tokens",
|
45
|
+
openstack_username: "admin",
|
46
|
+
openstack_api_key: "password",
|
47
|
+
openstack_project_name: "admin",
|
48
|
+
openstack_domain_id: "default"
|
49
|
+
}
|
50
|
+
```
|
51
|
+
|
52
|
+
If you're using Keystone V2, you don't need to supply domain details but ensure the `openstack_auth_url` parameter references the correct endpoint.
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
@connection_params = {
|
56
|
+
openstack_auth_url: "http://devstack.test:5000/v2.0/tokens"
|
57
|
+
openstack_username: "admin",
|
58
|
+
openstack_api_key: "password",
|
59
|
+
openstack_project_name: "admin"
|
60
|
+
}
|
61
|
+
```
|
62
|
+
|
63
|
+
If you're not sure whether your OpenStack cloud uses Keystone V2 or V3 then you can find out by logging into the dashboard (Horizon) and navigating to "Access & Security" under the "Project" section. Select "API Access" and find the line for the Identity Service. If the endpoint has "v3" in it, you're on Keystone V3, if it has "v2" then (surprise) you're on Keystone V2.
|
64
|
+
|
65
|
+
If you need a version of OpenStack to test against, get youself a copy of [DevStack](http://docs.openstack.org/developer/devstack/).
|
66
|
+
|
67
|
+
### Networking Gotcha
|
68
|
+
|
69
|
+
Note that tenants (aka projects) in OpenStack usually require that you create a default gateway router in order to allow external access to your instances.
|
70
|
+
|
71
|
+
The exception is if you're using Nova (and not Neutron) for your instance networking. If you're using Neutron, you'll want to [set up your default gateway](https://github.com/fog/fog-openstack/blob/usage_doc/README.md#networking-neutron) before you try to give instances public addresses (aka floating IPs).
|
72
|
+
|
73
|
+
### Compute (Nova)
|
74
|
+
|
75
|
+
Initialise a connection to the compute service:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
compute = Fog::Compute::OpenStack.new(@connection_params)
|
79
|
+
```
|
80
|
+
|
81
|
+
Get a list of available images for use with booting new instances:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
p compute.images
|
85
|
+
# => <Fog::Compute::OpenStack::Images
|
86
|
+
# filters={},
|
87
|
+
# server=nil
|
88
|
+
# [
|
89
|
+
# <Fog::Compute::OpenStack::Image
|
90
|
+
# id="57a67f8a-7bae-4578-b684-b9b4dcd48d7f",
|
91
|
+
# ...
|
92
|
+
# >
|
93
|
+
# ]
|
94
|
+
# >
|
95
|
+
```
|
96
|
+
|
97
|
+
List available flavors so we can decide how powerful to make this instance:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
p compute.flavors
|
101
|
+
# => <Fog::Compute::OpenStack::Flavors
|
102
|
+
# [
|
103
|
+
# <Fog::Compute::OpenStack::Flavor
|
104
|
+
# id="1",
|
105
|
+
# name="m1.tiny",
|
106
|
+
# ram=512,
|
107
|
+
# disk=1,
|
108
|
+
# vcpus=1,
|
109
|
+
# ...
|
110
|
+
# >,
|
111
|
+
# <Fog::Compute::OpenStack::Flavor
|
112
|
+
# id="2",
|
113
|
+
# name="m1.small",
|
114
|
+
# ram=2048,
|
115
|
+
# disk=20,
|
116
|
+
# vcpus=1,
|
117
|
+
# ...
|
118
|
+
# >,
|
119
|
+
# ...
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
Now we know the `id` numbers of a valid image and a valid flavor, we can instantiate an instance:
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
flavor = compute.flavors[0]
|
127
|
+
image = compute.images[0]
|
128
|
+
instance = compute.servers.create name: 'test',
|
129
|
+
image_ref: image.id,
|
130
|
+
flavor_ref: flavor.id
|
131
|
+
|
132
|
+
# Optionally, wait for the instance to provision before continuing
|
133
|
+
instance.wait_for { ready? }
|
134
|
+
# => {:duration=>17.359134}
|
135
|
+
|
136
|
+
p instance
|
137
|
+
# => <Fog::Compute::OpenStack::Server
|
138
|
+
# id="63633125-26b5-4fe1-a909-0f44d1ab3337",
|
139
|
+
# instance_name=nil,
|
140
|
+
# addresses={"public"=>[{"OS-EXT-IPS-MAC:mac_addr"=>"fa:16:3e:f4:75:ab", "version"=>4, "addr"=>"1.2.3.4", "OS-EXT-IPS:type"=>"fixed"}]},
|
141
|
+
# flavor={"id"=>"2"},
|
142
|
+
# host_id="f5ea01262720d02e886508bc4fa994782c516557d232c72aeb79638e",
|
143
|
+
# image={"id"=>"57a67f8a-7bae-4578-b684-b9b4dcd48d7f"},
|
144
|
+
# name="test",
|
145
|
+
# personality=nil,
|
146
|
+
# progress=0,
|
147
|
+
# accessIPv4="",
|
148
|
+
# accessIPv6="",
|
149
|
+
# availability_zone="nova",
|
150
|
+
# user_data_encoded=nil,
|
151
|
+
# state="ACTIVE",
|
152
|
+
# created=2016-03-07 08:07:36 UTC,
|
153
|
+
# updated=2016-03-07 08:07:52 UTC,
|
154
|
+
# tenant_id="06a9a90c60074cdeae5f7fdd0048d9ac"
|
155
|
+
# ...
|
156
|
+
# >
|
157
|
+
```
|
158
|
+
|
159
|
+
And destroy it when we're done:
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
instance.destroy
|
163
|
+
# => true
|
164
|
+
```
|
165
|
+
|
166
|
+
You'll probably need your instances to be accessible via SSH. [Learn more about SSH keypairs](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/).
|
167
|
+
|
168
|
+
Allow TCP traffic through port 22:
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
security_group = compute.security_groups.create name: "Test SSH",
|
172
|
+
description: "Allow access to port 22"
|
173
|
+
# => <Fog::Compute::OpenStack::SecurityGroup
|
174
|
+
# id="e5d53d00-b3f9-471a-b90f-985694b966ed",
|
175
|
+
# name="Test SSH",
|
176
|
+
# description="Allow access to port 22",
|
177
|
+
# security_group_rules= <Fog::Compute::OpenStack::SecurityGroupRules
|
178
|
+
# [
|
179
|
+
|
180
|
+
# ]
|
181
|
+
# >,
|
182
|
+
# tenant_id="06a9a90c60074cdeae5f7fdd0048d9ac"
|
183
|
+
# >
|
184
|
+
|
185
|
+
compute.security_group_rules.create parent_group_id: security_group.id,
|
186
|
+
ip_protocol: "tcp",
|
187
|
+
from_port: 22,
|
188
|
+
to_port: 22
|
189
|
+
|
190
|
+
key_pair = compute.key_pairs.create name: "My Public Key",
|
191
|
+
public_key: "/full/path/to/ssh.pub"
|
192
|
+
# => <Fog::Compute::OpenStack::KeyPair
|
193
|
+
# name="My Public Key",
|
194
|
+
# ...
|
195
|
+
# user_id="20746f49211e4037a91269df6a3fbf7b",
|
196
|
+
# id=nil
|
197
|
+
# >
|
198
|
+
```
|
199
|
+
|
200
|
+
Now create a new server using the security group and keypair we created:
|
201
|
+
|
202
|
+
```ruby
|
203
|
+
instance = compute.servers.create name: "Test 2",
|
204
|
+
image_ref: image.id,
|
205
|
+
flavor_ref: flavor.id,
|
206
|
+
key_name: key_pair.name,
|
207
|
+
security_groups: security_group
|
208
|
+
# => <Fog::Compute::OpenStack::Server
|
209
|
+
# id="e18ebdfb-e5f5-4a45-929f-4cc9926dc2c7",
|
210
|
+
# name="Test 2",
|
211
|
+
# state="ACTIVE",
|
212
|
+
# tenant_id="06a9a90c60074cdeae5f7fdd0048d9ac",
|
213
|
+
# key_name="My Public Key",
|
214
|
+
# >
|
215
|
+
# (some data omitted for brevity)
|
216
|
+
```
|
217
|
+
|
218
|
+
Finally, assign a floating IP address to make this instance sit under a world-visible public IP address:
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
pool_name = compute.addresses.get_address_pools[0]['name']
|
222
|
+
floating_ip_address = compute.addresses.create pool: pool_name
|
223
|
+
instance.associate_address floating_ip_address.ip
|
224
|
+
|
225
|
+
p floating_ip_address
|
226
|
+
# => <Fog::Compute::OpenStack::Address
|
227
|
+
# id="54064324-ce7d-448d-9753-94497b29dc91",
|
228
|
+
# ip="1.2.3.4",
|
229
|
+
# pool="external",
|
230
|
+
# fixed_ip="192.168.0.96",
|
231
|
+
# instance_id="e18ebdfb-e5f5-4a45-929f-4cc9926dc2c7"
|
232
|
+
# >
|
233
|
+
```
|
234
|
+
|
235
|
+
Now you can SSH into the instance:
|
236
|
+
|
237
|
+
```
|
238
|
+
$ ssh cirros@1.2.3.4
|
239
|
+
The authenticity of host '1.2.3.4 (1.2.3.4)' can't be established.
|
240
|
+
RSA key fingerprint is SHA256:cB0L/owUtcHsMhFhsuSZXxK4oRg/uqP/6IriUomQnQQ.
|
241
|
+
Are you sure you want to continue connecting (yes/no)? yes
|
242
|
+
Warning: Permanently added '1.2.3.4' (RSA) to the list of known hosts.
|
243
|
+
$ pwd
|
244
|
+
/home/cirros
|
245
|
+
```
|
246
|
+
|
247
|
+
### Volume (Cinder)
|
248
|
+
|
249
|
+
Create and attach a volume to a running instance:
|
250
|
+
|
251
|
+
```ruby
|
252
|
+
compute = Fog::Compute::OpenStack.new(@connection_params)
|
253
|
+
|
254
|
+
volume = compute.volumes.create name: "Test",
|
255
|
+
description: "Testing",
|
256
|
+
size: 1
|
257
|
+
# => <Fog::Compute::OpenStack::Volume
|
258
|
+
# id="4a212986-c6b6-4a93-8319-c6a98e347750",
|
259
|
+
# name="Test",
|
260
|
+
# description="Testing",
|
261
|
+
# size=1,
|
262
|
+
# availability_zone="Production",
|
263
|
+
# created_at="2016-03-07T13:40:43.914063",
|
264
|
+
# attachments=[{}]
|
265
|
+
# >
|
266
|
+
|
267
|
+
flavor = compute.flavors[3]
|
268
|
+
image = compute.images[0]
|
269
|
+
instance = compute.servers.create name: "test",
|
270
|
+
image_ref: image.id,
|
271
|
+
flavor_ref: flavor.id
|
272
|
+
instance.wait_for { ready? }
|
273
|
+
|
274
|
+
volume.reload
|
275
|
+
|
276
|
+
instance.attach_volume(volume.id, "/dev/vdb")
|
277
|
+
```
|
278
|
+
|
279
|
+
Detach volume and create a snapshot:
|
280
|
+
|
281
|
+
```ruby
|
282
|
+
instance.detach_volume(volume.id)
|
283
|
+
volume.reload
|
284
|
+
|
285
|
+
compute.snapshots.create volume_id: volume.id,
|
286
|
+
name: "test",
|
287
|
+
description: "test"
|
288
|
+
# => <Fog::Compute::OpenStack::Snapshot
|
289
|
+
# id="7a8c9192-25ee-4364-be91-070b7a6d9855",
|
290
|
+
# name="test",
|
291
|
+
# description="test",
|
292
|
+
# volume_id="4a212986-c6b6-4a93-8319-c6a98e347750",
|
293
|
+
# status="creating",
|
294
|
+
# size=1,
|
295
|
+
# created_at="2016-03-07T13:47:11.543814"
|
296
|
+
# >
|
297
|
+
```
|
298
|
+
|
299
|
+
Destroy a volume:
|
300
|
+
```ruby
|
301
|
+
volume.destroy
|
302
|
+
# => true
|
303
|
+
```
|
304
|
+
|
305
|
+
### Image (Glance)
|
306
|
+
|
307
|
+
Create Glance image from URL:
|
308
|
+
|
309
|
+
```ruby
|
310
|
+
|
311
|
+
image = Fog::Image::OpenStack.new(@connection_params)
|
312
|
+
|
313
|
+
cirros_location = "http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img"
|
314
|
+
|
315
|
+
image.images.create name: "cirros",
|
316
|
+
disk_format: "qcow2",
|
317
|
+
container_format: "bare",
|
318
|
+
location: cirros_location
|
319
|
+
# => <Fog::Image::OpenStack::V2::Image
|
320
|
+
# id="4beedb46-e32f-4ef3-a87b-7f1234294dc1",
|
321
|
+
# name="cirros",
|
322
|
+
# visibility="private",
|
323
|
+
# tags=[],
|
324
|
+
# self="/v2/images/4beedb46-e32f-4ef3-a87b-7f1234294dc1",
|
325
|
+
# size=nil,
|
326
|
+
# disk_format="qcow2",
|
327
|
+
# container_format="bare",
|
328
|
+
# id="4beedb46-e32f-4ef3-a87b-7f1234294dc1",
|
329
|
+
# checksum=nil,
|
330
|
+
# self="/v2/images/4beedb46-e32f-4ef3-a87b-7f1234294dc1",
|
331
|
+
# file="/v2/images/4beedb46-e32f-4ef3-a87b-7f1234294dc1/file",
|
332
|
+
# min_disk=0,
|
333
|
+
# created_at="2016-03-07T14:28:10Z",
|
334
|
+
# updated_at="2016-03-07T14:28:10Z",
|
335
|
+
# protected=false,
|
336
|
+
# status="queued",
|
337
|
+
# >
|
338
|
+
|
339
|
+
```
|
340
|
+
|
341
|
+
Create Glance image from file:
|
342
|
+
|
343
|
+
```ruby
|
344
|
+
cirros_location = "http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img"
|
345
|
+
image_out = File.open("/tmp/cirros-image-#{SecureRandom.hex}", 'wb')
|
346
|
+
|
347
|
+
streamer = lambda do |chunk, _, _|
|
348
|
+
image_out.write chunk
|
349
|
+
end
|
350
|
+
|
351
|
+
Excon.get cirros_location, response_block: streamer
|
352
|
+
image_out.close
|
353
|
+
|
354
|
+
image.images.create name: "cirros",
|
355
|
+
disk_format: "qcow2",
|
356
|
+
container_format: "bare",
|
357
|
+
location: image_out.path
|
358
|
+
|
359
|
+
```
|
360
|
+
|
361
|
+
Destroy image:
|
362
|
+
|
363
|
+
```ruby
|
364
|
+
cirros = image.images.get("4beedb46-e32f-4ef3-a87b-7f1234294dc1")
|
365
|
+
cirros.destroy
|
366
|
+
```
|
367
|
+
|
368
|
+
### Identity (Keystone)
|
369
|
+
|
370
|
+
List domains (Keystone V3 only):
|
371
|
+
|
372
|
+
```ruby
|
373
|
+
identity = Fog::Identity::OpenStack.new(@connection_params)
|
374
|
+
|
375
|
+
identity.domains
|
376
|
+
# => <Fog::Identity::OpenStack::V3::Domains
|
377
|
+
# [
|
378
|
+
# <Fog::Identity::OpenStack::V3::Domain
|
379
|
+
# id="default",
|
380
|
+
# description="",
|
381
|
+
# enabled=true,
|
382
|
+
# name="Default",
|
383
|
+
# >
|
384
|
+
# ]
|
385
|
+
# >
|
386
|
+
```
|
387
|
+
|
388
|
+
List projects (aka tenants):
|
389
|
+
|
390
|
+
```ruby
|
391
|
+
identity.projects
|
392
|
+
# => <Fog::Identity::OpenStack::V3::Projects
|
393
|
+
# [
|
394
|
+
# <Fog::Identity::OpenStack::V3::Project
|
395
|
+
# id="008e5537d3424295a03560abc923693c",
|
396
|
+
# domain_id="default",
|
397
|
+
# description="Project 1",
|
398
|
+
# enabled=true,
|
399
|
+
# name="project_1",
|
400
|
+
# >,
|
401
|
+
# ...
|
402
|
+
# ]
|
403
|
+
|
404
|
+
# On Keystone V2
|
405
|
+
identity.tenants
|
406
|
+
# => <Fog::Identity::OpenStack::V2::Tenants
|
407
|
+
# [ ... ]
|
408
|
+
```
|
409
|
+
|
410
|
+
List users:
|
411
|
+
|
412
|
+
```ruby
|
413
|
+
identity.users
|
414
|
+
# => <Fog::Identity::OpenStack::V3::Users
|
415
|
+
# [ ... ]
|
416
|
+
```
|
417
|
+
|
418
|
+
Create/destroy new user:
|
419
|
+
|
420
|
+
```ruby
|
421
|
+
project_id = identity.projects[0].id
|
422
|
+
|
423
|
+
user = identity.users.create name: "test",
|
424
|
+
project_id: project_id,
|
425
|
+
email: "test@test.com",
|
426
|
+
password: "test"
|
427
|
+
# => <Fog::Identity::OpenStack::V3::User
|
428
|
+
# id="474a59153ebd4e709938e5e9b614dc57",
|
429
|
+
# default_project_id=nil,
|
430
|
+
# description=nil,
|
431
|
+
# domain_id="default",
|
432
|
+
# email="test@test.com",
|
433
|
+
# enabled=true,
|
434
|
+
# name="test",
|
435
|
+
# password="test"
|
436
|
+
# >
|
437
|
+
|
438
|
+
user.destroy
|
439
|
+
# => true
|
440
|
+
```
|
441
|
+
|
442
|
+
Create/destroy new tenant:
|
443
|
+
|
444
|
+
```ruby
|
445
|
+
|
446
|
+
project = identity.projects.create name: "test",
|
447
|
+
description: "test"
|
448
|
+
# => <Fog::Identity::OpenStack::V3::Project
|
449
|
+
# id="423559128a7249f2973cdb7d5d581c4d",
|
450
|
+
# domain_id="default",
|
451
|
+
# description="test",
|
452
|
+
# enabled=true,
|
453
|
+
# name="test",
|
454
|
+
# parent_id=nil,
|
455
|
+
# subtree=nil,
|
456
|
+
# parents=nil
|
457
|
+
# >
|
458
|
+
|
459
|
+
project.destroy
|
460
|
+
# => true
|
461
|
+
```
|
462
|
+
|
463
|
+
Grant user role on tenant and revoke it:
|
464
|
+
|
465
|
+
```ruby
|
466
|
+
role = identity.roles.select{|role| role.name == "_member_"}[0]
|
467
|
+
# => <Fog::Identity::OpenStack::V3::Role
|
468
|
+
# id="9fe2ff9ee4384b1894a90878d3e92bab",
|
469
|
+
# name="_member_",
|
470
|
+
# >
|
471
|
+
|
472
|
+
project.grant_role_to_user(role.id, user.id)
|
473
|
+
|
474
|
+
project.revoke_role_from_user(role.id, user.id)
|
475
|
+
```
|
476
|
+
|
477
|
+
### Networking (Neutron)
|
478
|
+
|
479
|
+
Set up a project's public gateway (needed for external access):
|
480
|
+
|
481
|
+
```ruby
|
482
|
+
|
483
|
+
identity = Fog::Identity::OpenStack.new(@connection_params)
|
484
|
+
|
485
|
+
tenants = identity.projects.select do |project|
|
486
|
+
project.name == @connection_params[:openstack_project_name]
|
487
|
+
end
|
488
|
+
|
489
|
+
tenant_id = tenants[0].id
|
490
|
+
|
491
|
+
neutron = Fog::Network::OpenStack.new(@connection_params)
|
492
|
+
|
493
|
+
network = neutron.networks.create name: "default",
|
494
|
+
tenant_id: tenant_id
|
495
|
+
|
496
|
+
subnet = network.subnets.create name: "default",
|
497
|
+
cidr: "192.168.0.0/24",
|
498
|
+
network_id: network.id,
|
499
|
+
ip_version: 4,
|
500
|
+
dns_nameservers: ["8.8.8.8", "8.8.4.4"],
|
501
|
+
tenant_id: tenant_id
|
502
|
+
|
503
|
+
external_network = neutron.networks.select(&:router_external)[0]
|
504
|
+
|
505
|
+
router = neutron.routers.create name: 'default',
|
506
|
+
tenant_id: tenant_id,
|
507
|
+
external_gateway_info: external_network.id
|
508
|
+
|
509
|
+
neutron.add_router_interface router.id, subnet.id
|
510
|
+
|
511
|
+
```
|
512
|
+
|
513
|
+
### Further Reading
|
514
|
+
|
515
|
+
* See [the documentation directory](https://github.com/fog/fog-openstack/tree/master/lib/fog/openstack/docs) for more examples.
|
516
|
+
* Read the [OpenStack API documentation](http://developer.openstack.org/api-ref.html).
|
517
|
+
* Also, remember that reading the code itself is the best way to educate yourself on how best to interact with this gem.
|
518
|
+
|
519
|
+
## Development
|
520
|
+
|
521
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
522
|
+
|
523
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
524
|
+
|
525
|
+
## Contributing
|
526
|
+
|
527
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fog-openstack. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
528
|
+
|
529
|
+
|
530
|
+
## License
|
531
|
+
|
532
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
533
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fog/speedyrails"
|
5
|
+
require 'active_support/all'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
CONNECTION_PARAMS = YAML::load_file(File.expand_path('../../config.yml', __FILE__)).to_options!
|
11
|
+
|
12
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
13
|
+
require "pry"
|
14
|
+
Pry.start
|
15
|
+
|
16
|
+
# require "irb"
|
17
|
+
# IRB.start
|
data/bin/setup
ADDED
data/config.yml.example
ADDED
data/exe/fog-speedyrails
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fog/speedyrails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fog-speedyrails"
|
8
|
+
spec.version = Fog::Speedyrails::VERSION
|
9
|
+
spec.authors = ["Jorge Calás Lozano"]
|
10
|
+
spec.email = ["calas@speedyrails.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Fog plugin for Speedyrails cloud.}
|
13
|
+
spec.description = %q{Fog plugin for Speedyrails cloud.}
|
14
|
+
spec.homepage = "https://speedyrails.com"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "fog-openstack"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "fog/speedyrails/version"
|
2
|
+
require "fog/openstack"
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Speedyrails < OpenStack;
|
7
|
+
recognizes :openstack_auth_token, :openstack_management_url,
|
8
|
+
:persistent, :openstack_service_type, :openstack_service_name,
|
9
|
+
:openstack_tenant, :openstack_tenant_id,
|
10
|
+
:openstack_api_key, :openstack_username, :openstack_identity_endpoint,
|
11
|
+
:current_user, :current_tenant, :openstack_region,
|
12
|
+
:openstack_endpoint_type,
|
13
|
+
:openstack_project_name, :openstack_project_id,
|
14
|
+
:openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
|
15
|
+
:openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
|
16
|
+
:openstack_identity_prefix
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Image
|
21
|
+
class Speedyrails < OpenStack; end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Network
|
25
|
+
class Speedyrails < OpenStack; end
|
26
|
+
end
|
27
|
+
|
28
|
+
module Speedyrails
|
29
|
+
extend Fog::Provider
|
30
|
+
|
31
|
+
service(:compute, 'Compute')
|
32
|
+
service(:image, 'Image')
|
33
|
+
service(:network, 'Network')
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fog-speedyrails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jorge Calás Lozano
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fog-openstack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Fog plugin for Speedyrails cloud.
|
70
|
+
email:
|
71
|
+
- calas@speedyrails.com
|
72
|
+
executables:
|
73
|
+
- fog-speedyrails
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- config.yml.example
|
86
|
+
- exe/fog-speedyrails
|
87
|
+
- fog-speedyrails.gemspec
|
88
|
+
- lib/fog/speedyrails.rb
|
89
|
+
- lib/fog/speedyrails/version.rb
|
90
|
+
homepage: https://speedyrails.com
|
91
|
+
licenses: []
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.4.5
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Fog plugin for Speedyrails cloud.
|
113
|
+
test_files: []
|
114
|
+
has_rdoc:
|