fog-softlayer 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +8 -8
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.md +25 -9
  4. data/CONTRIBUTING.md +13 -25
  5. data/CONTRIBUTORS.md +1 -1
  6. data/Rakefile +3 -3
  7. data/examples/compute.md +114 -3
  8. data/examples/network.md +285 -0
  9. data/examples/tags.md +76 -1
  10. data/fog-softlayer.gemspec +2 -3
  11. data/lib/fog/softlayer.rb +2 -0
  12. data/lib/fog/softlayer/compute.rb +16 -73
  13. data/lib/fog/softlayer/core.rb +105 -1
  14. data/lib/fog/softlayer/models/compute/flavor.rb +1 -0
  15. data/lib/fog/softlayer/models/compute/flavors.rb +1 -0
  16. data/lib/fog/softlayer/models/compute/image.rb +1 -0
  17. data/lib/fog/softlayer/models/compute/images.rb +1 -0
  18. data/lib/fog/softlayer/models/compute/server.rb +71 -12
  19. data/lib/fog/softlayer/models/compute/servers.rb +9 -5
  20. data/lib/fog/softlayer/models/compute/tag.rb +5 -6
  21. data/lib/fog/softlayer/models/compute/tags.rb +1 -0
  22. data/lib/fog/softlayer/models/network/datacenter.rb +52 -0
  23. data/lib/fog/softlayer/models/network/datacenters.rb +42 -0
  24. data/lib/fog/softlayer/models/network/ip.rb +67 -0
  25. data/lib/fog/softlayer/models/network/ips.rb +39 -0
  26. data/lib/fog/softlayer/models/network/network.rb +121 -0
  27. data/lib/fog/softlayer/models/network/networks.rb +47 -0
  28. data/lib/fog/softlayer/models/network/subnet.rb +62 -0
  29. data/lib/fog/softlayer/models/network/subnets.rb +33 -0
  30. data/lib/fog/softlayer/models/network/tag.rb +54 -0
  31. data/lib/fog/softlayer/models/network/tags.rb +40 -0
  32. data/lib/fog/softlayer/models/storage/directories.rb +7 -0
  33. data/lib/fog/softlayer/models/storage/directory.rb +7 -0
  34. data/lib/fog/softlayer/models/storage/file.rb +7 -0
  35. data/lib/fog/softlayer/models/storage/files.rb +7 -0
  36. data/lib/fog/softlayer/network.rb +139 -0
  37. data/lib/fog/softlayer/requests/compute/create_bare_metal_server.rb +1 -1
  38. data/lib/fog/softlayer/requests/compute/get_vms.rb +1 -1
  39. data/lib/fog/softlayer/requests/network/create_network.rb +488 -0
  40. data/lib/fog/softlayer/requests/network/create_network_tags.rb +50 -0
  41. data/lib/fog/softlayer/requests/network/delete_network.rb +37 -0
  42. data/lib/fog/softlayer/requests/network/delete_network_tags.rb +46 -0
  43. data/lib/fog/softlayer/requests/network/get_datacenter_routers.rb +41 -0
  44. data/lib/fog/softlayer/requests/network/get_datacenters.rb +30 -0
  45. data/lib/fog/softlayer/requests/network/get_ip_address.rb +28 -0
  46. data/lib/fog/softlayer/requests/network/get_network.rb +34 -0
  47. data/lib/fog/softlayer/requests/network/get_network_tags.rb +47 -0
  48. data/lib/fog/softlayer/requests/network/get_private_vlan_price_code.rb +27 -0
  49. data/lib/fog/softlayer/requests/network/get_public_vlan_price_code.rb +27 -0
  50. data/lib/fog/softlayer/requests/network/get_references_by_tag_name.rb +42 -0
  51. data/lib/fog/softlayer/requests/network/get_subnet.rb +28 -0
  52. data/lib/fog/softlayer/requests/network/get_subnet_package_id.rb +29 -0
  53. data/lib/fog/softlayer/requests/network/get_subnet_price_code.rb +30 -0
  54. data/lib/fog/softlayer/requests/network/list_networks.rb +30 -0
  55. data/lib/fog/softlayer/requests/network/list_subnets.rb +28 -0
  56. data/lib/fog/softlayer/storage.rb +7 -0
  57. data/lib/fog/softlayer/version.rb +2 -1
  58. data/tests/compute/flavors_helper.rb +1 -0
  59. data/tests/compute/server_helper.rb +1 -0
  60. data/tests/compute/servers_helper.rb +1 -0
  61. data/tests/helper.rb +7 -0
  62. data/tests/helpers/collection_helper.rb +7 -0
  63. data/tests/helpers/compute/flavors_helper.rb +7 -0
  64. data/tests/helpers/compute/server_helper.rb +7 -0
  65. data/tests/helpers/compute/servers_helper.rb +7 -0
  66. data/tests/helpers/formats_helper.rb +7 -0
  67. data/tests/helpers/formats_helper_tests.rb +7 -0
  68. data/tests/helpers/mock_helper.rb +7 -0
  69. data/tests/helpers/model_helper.rb +7 -0
  70. data/tests/helpers/responds_to_helper.rb +7 -0
  71. data/tests/helpers/schema_validator_tests.rb +7 -0
  72. data/tests/helpers/succeeds_helper.rb +7 -0
  73. data/tests/softlayer/compute/helper.rb +1 -0
  74. data/tests/softlayer/compute/schema.rb +1 -0
  75. data/tests/softlayer/models/compute/server_tests.rb +31 -4
  76. data/tests/softlayer/requests/compute/bmc_tests.rb +4 -3
  77. data/tests/softlayer/requests/compute/tag_tests.rb +1 -1
  78. data/tests/softlayer/requests/network/network_tests.rb +129 -0
  79. metadata +35 -25
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODBkZjA5MDMwN2UzM2FlOGJiMmNkYjhmZTkxMGRkNGYwNmFkNDllYg==
4
+ MTM2MDFlYmQ0NjNhMDI0NjZhM2FmNWRjNjVmNzdhMmRhNDE0YjMzYw==
5
5
  data.tar.gz: !binary |-
6
- ZDk5ZjI0ZDE2YTA5OWQyN2RhYzNkNDY5OTYzMDFiYWQ2MzJmNWIxOA==
6
+ MmE5ZjAzZTYzMGVjOGY4YTU5MjQ0OGZkNjkxYTNhMzg4NDYwNThhYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODA5NzljZTFlNDZmMjUxYTJiZjI5ZjIzYjViZGY0YmE4M2RjMzRhNmE4MGQ1
10
- NGVjY2E3ZTc2YzI0YjQxMWJkNjgxNDc4ODRjMWYwN2Y0NzE4MjM3Zjg2YWEx
11
- NGE0OTNhYmVmOTI4MzkwMTNhZTk4NGZkMTdmZjJjNjgzMTBkM2E=
9
+ NmNlZDRhMDYwZDAwNWExZmZhN2UyMzAyNGExMDU0ZDJmMjJjODMwMWIyMGYx
10
+ YjY0ZmJjMzgzNTg4YTRiMmY1M2UyYzNiYzI5ZDczOTVmMTVlYTUxNzMyNzMz
11
+ MDJmNjdhYzZmMzQ0MTc4MmMyNTNlNGRlYzFlMmFjNTJlMzQ3OGM=
12
12
  data.tar.gz: !binary |-
13
- NmYyN2ZhOGI2Mjg4YjQ5ZTdmOGNjMWViYzgxZWY0ZWM1Y2FmZmI0NGJiNWVk
14
- YmI1ZTc5NjUxMDcxODM0ZWU0OWQzYTQwNWJkMjc2OGY3YmI5MjUwM2I0MGYw
15
- YjBmYWE2MzBiNDIxOTk2MzZjMzRjZmYyMTExOWIzM2RhNzQxODA=
13
+ ZTg3YTBiZjI3ZjdiYzBjYWRmN2Q0YTcxNDkxODgzNWZhMzU1ZmJmMjQ1YjAx
14
+ ODc0YzEzZGEwYjU5ZWIyYTlhMmZhNmRhZGZjY2U5OWYxNzAxNDI0ODU3Zjc0
15
+ NDRiMWM2MzIyZGQ1ZTU2MTVlODBhNDA5YzU1MTE5MTViOWIxNjU=
data/.travis.yml CHANGED
@@ -27,7 +27,6 @@ matrix:
27
27
 
28
28
  allow_failures:
29
29
  - rvm: jruby-head
30
- - rvm: 1.8.7
31
30
 
32
31
  notifications:
33
32
  email:
data/CHANGELOG.md CHANGED
@@ -1,26 +1,42 @@
1
+ ## 0.3.0 2014-06-26
2
+
3
+ * Added Network service.
4
+ * Network model.
5
+ * Subnet model.
6
+ * Ip model.
7
+ * Tag model.
8
+ * Added vlan and private_vlan properties to Server model.
9
+ * Fixed up bare_metal? on Server so it's not a hack. *thanks fernandes*
10
+ * Fixed Bundler/dep issues with Ruby 1.8.7. (Thx @fernandes!)
11
+ * Added some missing license headers.
12
+ * Updated Compute examples and Tag examples to reflect new Network service.
13
+ * Moved shared logic from `lib/fog/softlayer/compute.rb` to `lib/fog/softlayer/core.rb`
14
+
15
+ ## 0.2.1 2014-06-17
16
+ * Add support for SoftLayer Tags on Compute resources.
17
+
1
18
  ## 0.1.1 2014-06-10
2
19
 
3
- * Fix Compute model after breaking change to SLAPI. :datecenter is no longer optional.
20
+ * Fix Compute model after breaking change to SLAPI. :datacenter is no longer optional.
21
+
4
22
  ## 0.1.0 2014-06-10
5
23
 
6
- * Add missing get method to Fog::DNS::Softlayer::Record.
7
- * Add OS attribute and ssh_password method to Compute model.
24
+ * Add missing get method to Fog::DNS::Softlayer::Record.
25
+ * Add OS attribute and ssh_password method to Compute model.
8
26
 
9
27
  ### 0.0.9 2014-06-10
10
28
 
11
- * Initial support for DNS.
29
+ * Initial support for DNS.
12
30
 
13
31
  ### 0.0.8 2014-06-05
14
32
 
15
- * Released support for Object Storage.
33
+ * Released support for Object Storage.
16
34
 
17
35
  ### 0.0.7 2014-05-29
18
36
 
19
- * Compute requests and models initial development complete. Supports both VMs and BMC.
20
- * Storage requests and models initial development complete.
37
+ * Compute requests and models initial development complete. Supports both VMs and BMC.
38
+ * Storage requests and models initial development complete.
21
39
 
22
40
  ### 0.0.1 / 2014-04-18
23
41
 
24
- Enhancements:
25
-
26
42
  * Initial release of `fog-softlayer` module.
data/CONTRIBUTING.md CHANGED
@@ -1,30 +1,18 @@
1
- # Contributing to fog-softlayer
1
+ ## Getting Involved
2
2
 
3
- We are happy to accept contributions to fog-softlayer. Please follow the guidelines below.
3
+ New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
4
4
 
5
- * Sign our contributor agreement (CLA) You can find the [CLA here](./docs/cla-individual.pdf).
5
+ ### Coding
6
6
 
7
- * If you're contributing on behalf of your employer we'll need a signed copy of our corporate contributor agreement (CCLA) as well. You can find the [CCLA here](./docs/cla-corporate.pdf).
8
-
9
- * Fork the repo, make your changes, and open a pull request.
7
+ * Pick a task:
8
+ * Offer feedback on open [pull requests](https://github.com/softlayer/fog/pulls).
9
+ * Review open [issues](https://github.com/softlayer/fog/issues) for things to help on.
10
+ * [Create an issue](https://github.com/softlayer/fog/issues/new) to start a discussion on additions or features.
11
+ * Fork the project, add your changes and tests to cover them in a topic branch.
12
+ * Commit your changes and rebase against `softlayer/fog` to ensure everything is up to date.
13
+ * [Submit a pull request](https://github.com/softlayer/fog/compare/).
10
14
 
11
- ## Issue Tracking
12
-
13
- You can file tickets to describe the bug you'd like to fix or feature you'd
14
- like to add on the [fog-softlayer project](https://github.com/softlayer/fog-softlayer/issues) on github.
15
-
16
- ## Testing Instructions
17
-
18
- To run tests, run the following Ruby tool commands from the root of your local copy of
19
- fog-softlayer:
20
-
21
- bundle install
22
- bundle exec rake travis
23
-
24
- **All tests must pass** before your contribution can be merged. Thus it's a good idea
25
- to execute the tests without your change to be sure you understand how to run
26
- them, as well as after to validate that you've avoided regressions.
27
-
28
- All but the most trivial changes should include **at least one unit test case** to exercise the
29
- new / changed code; please add tests to your pull request in this common case.
15
+ ### Non-Coding
30
16
 
17
+ * Offer feedback on open [issues](https://github.com/softlayer/fog/issues).
18
+ * Organize or volunteer at events.
data/CONTRIBUTORS.md CHANGED
@@ -1,2 +1,2 @@
1
1
  * Celso Fernandes <fernandes@zertico.com>
2
- * Matt Eldridge <matt.eldridge@us.ibm.com>
2
+ * Matt Eldridge <matt.eldridge@us.ibm.com>
data/Rakefile CHANGED
@@ -34,7 +34,7 @@ def name
34
34
  end
35
35
 
36
36
  def version
37
- Fog::VERSION
37
+ Fog::Softlayer::VERSION
38
38
  end
39
39
 
40
40
  def date
@@ -198,7 +198,7 @@ task :gemspec => :validate do
198
198
  replace_header(spec, :version)
199
199
  replace_header(spec, :date)
200
200
  #comment this out if your rubyforge_project has a different name
201
- replace_header(spec, :rubyforge_project)
201
+ #replace_header(spec, :rubyforge_project)
202
202
 
203
203
  File.open(gemspec_file, 'w') { |io| io.write(spec) }
204
204
  puts "Updated #{gemspec_file}"
@@ -209,7 +209,7 @@ task :validate do
209
209
  libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}", "lib/tasks"]
210
210
  unless libfiles.empty?
211
211
  puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
212
- exit!
212
+ #exit!
213
213
  end
214
214
  unless Dir['VERSION*'].empty?
215
215
  puts "A `VERSION` file at root level violates Gem best practices."
data/examples/compute.md CHANGED
@@ -32,6 +32,94 @@ These examples all assume you have `~/.fog` which contains the following
32
32
  server.state # => 'Running', 'Stopped', 'Terminated', etc.
33
33
  ```
34
34
 
35
+ 1. Get all servers tagged with certain tags.
36
+
37
+ ```ruby
38
+ prod_fe_servers = @sl.servers.tagged_with(['production', 'frontend'])
39
+ # => [ <Fog::Compute::Softlayer::Server>,
40
+ # <Fog::Compute::Softlayer::Server>,
41
+ # <Fog::Compute::Softlayer::Server>,
42
+ # <Fog::Compute::Softlayer::Server>,
43
+ # <Fog::Compute::Softlayer::Server>,]
44
+ ```
45
+
46
+ 1. Get a server's public/frontend VLAN
47
+
48
+ ```ruby
49
+ server = @sl.servers.get(12345)
50
+ server.vlan
51
+ # => <Fog::Network::Softlayer::Network
52
+ # id=123456,
53
+ # name='frontend-staging-vlan',
54
+ # modify_date="2014-02-22T12:42:31-06:00",
55
+ # note=nil,
56
+ # tags=['sparkle', 'motion'],
57
+ # type="STANDARD",
58
+ # datacenter= <Fog::Network::Softlayer::Datacenter
59
+ # id=168642,
60
+ # long_name="San Jose 1",
61
+ # name="sjc01"
62
+ # >,
63
+ # network_space="PUBLIC",
64
+ # router={"hostname"=>"fcr01a.sjc01", "id"=>82412, "datacenter"=>{"id"=>168642, "longName"=>"San Jose 1", "name"=>"sjc01"}}
65
+ # >
66
+ ```
67
+
68
+ 1. Get a server's private/backend VLAN
69
+
70
+ ```ruby
71
+ server = @sl.servers.get(12345)
72
+ server.private_vlan
73
+ # => <Fog::Network::Softlayer::Network
74
+ # id=123456,
75
+ # name='backend-staging-vlan',
76
+ # modify_date="2014-02-22T12:42:33-06:00",
77
+ # note=nil,
78
+ # tags=[],
79
+ # type="STANDARD",
80
+ # datacenter= <Fog::Network::Softlayer::Datacenter
81
+ # id=168642,
82
+ # long_name="San Jose 1",
83
+ # name="sjc01"
84
+ # >,
85
+ # network_space="PRIVATE",
86
+ # router={"hostname"=>"bcr01a.sjc01", "id"=>82461, "datacenter"=>{"id"=>168642, "longName"=>"San Jose 1", "name"=>"sjc01"}}
87
+ # >
88
+
89
+ ```
90
+
91
+ 1. Get a server's tags
92
+
93
+ ```ruby
94
+ server = @sl.servers.get(12345)
95
+ server.tags
96
+ # => ['production', 'frontend']
97
+ ```
98
+
99
+ 1. Add tags to a server
100
+
101
+ ```ruby
102
+ server = @sl.servers.get(12345)
103
+ server.tags
104
+ # => ['production', 'frontend']
105
+ server.add_tags(['sparkle', 'motion']
106
+ # => true
107
+ server.tags
108
+ # => ['production', 'frontend', 'sparkle', 'motion']
109
+ ```
110
+
111
+ 1. Delete tags from a server
112
+
113
+ ```ruby
114
+ server = @sl.servers.get(12345)
115
+ server.tags
116
+ # => ['production', 'frontend', 'sparkle', 'motion']
117
+ server.delete_tags(['sparkle', 'motion']
118
+ # => true
119
+ server.tags
120
+ # => ['production', 'frontend']
121
+ ```
122
+
35
123
  1. Provision a new VM with flavor (simple).
36
124
 
37
125
  ```ruby
@@ -45,7 +133,7 @@ These examples all assume you have `~/.fog` which contains the following
45
133
  new_server.id # => 1337
46
134
  ```
47
135
 
48
- 1. Provision a new BMC instance with flavor (simple).
136
+ 1. Provision a new Bare Metal instance with flavor (simple).
49
137
 
50
138
  ```ruby
51
139
  opts = {
@@ -75,7 +163,7 @@ These examples all assume you have `~/.fog` which contains the following
75
163
  }
76
164
  ```
77
165
 
78
- 1. Provision a BMC Instance without a flavor
166
+ 1. Provision a Bare Metal Instance without a flavor
79
167
 
80
168
  ```ruby
81
169
  opts = {
@@ -92,9 +180,32 @@ These examples all assume you have `~/.fog` which contains the following
92
180
  }
93
181
  ```
94
182
 
95
- 1. Delete a VM or BMC instance.
183
+ 1. Delete a VM or Bare Metal instance.
96
184
 
97
185
  ```ruby
98
186
  @sl.servers.get(<server id>).destroy
99
187
  ```
188
+
189
+ 1. Provision a Server (works the same for VM and Bare Metal) into a specific VLAN
190
+
191
+ ```ruby
192
+ # I want to launch another server to hold docker containers into my existing staging VLANs
193
+ # I'll start by getting a staging server so I can use its vlans as a reference.
194
+ staging_server = @sl.servers.tagged_with(['staging', 'docker']).first # => <Fog::Compute::Softlayer::Server>
195
+
196
+ opts = {
197
+ :flavor_id => 'm1.large',
198
+ :image_id => '23f7f05f-3657-4330-8772-329ed2e816bc', # Ubuntu Docker Image
199
+ :domain => 'staging.example.com',
200
+ :datacenter => 'ams01', # This needs to be the same datacenter as the target VLAN of course.
201
+ :name => 'additional-docker-host',
202
+ :vlan => staging.server.vlan, # Passing in a <Fog::Network::Softlayer::Network> object.
203
+ :private_vlan => staging.server.private_vlan.id, # Passing in an Integer (the id of a network/vlan) works too.
204
+ }
205
+
206
+ new_staging_server = @sl.servers.create(opts)
207
+ # => <Fog::Compute::Softlayer::Server>
208
+
209
+
210
+ ```
100
211
 
@@ -0,0 +1,285 @@
1
+ ### Network Examples
2
+
3
+ Note that SoftLayer uses the term `VLAN`. The Fog project tries to keep things provider independent, and we'll be referring to them as `networks`.
4
+
5
+
6
+ These examples all assume you have `~/.fog` which contains the following
7
+
8
+
9
+ ```yaml
10
+ :softlayer_username: example-username
11
+ :softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
12
+ ```
13
+
14
+ #### Create a connection to SoftLayer Network
15
+
16
+ ```ruby
17
+ require 'fog/softlayer'
18
+ @sl = Fog::Network[:softlayer]
19
+ ```
20
+
21
+ #### Use the Models
22
+ 1. List existing networks.
23
+
24
+ ```ruby
25
+ nets = @sl.networks
26
+ # => [ <Fog::Network::Softlayer::Network
27
+ # id=123456,
28
+ # name="some-optional-name",
29
+ # modify_date="2014-06-25T17:10:57-05:00",
30
+ # note=nil,
31
+ # tags=["sparkle", "motion", "public"],
32
+ # type="STANDARD",
33
+ # datacenter= <Fog::Network::Softlayer::Datacenter
34
+ # id=12345,
35
+ # long_name="Washington, DC 1",
36
+ # name="wdc01"
37
+ # >,
38
+ # network_space="PUBLIC"
39
+ # router={"hostname"=>"fcr02.wdc01", "id"=>40378, "datacenter"=>{"id"=>37473, "longName"=>"Washington, DC 1", "name"=>"wdc01"}}
40
+ # >,
41
+ # <Fog::Network::Softlayer::Network
42
+ # id=123457,
43
+ # name="some-other-optional-name",
44
+ # modify_date="2014-06-25T17:11:57-05:00",
45
+ # note=nil,
46
+ # tags=["sparkle", "motion", "private"],
47
+ # type="STANDARD",
48
+ # datacenter= <Fog::Network::Softlayer::Datacenter
49
+ # id=12345,
50
+ # long_name="Washington, DC 1",
51
+ # name="wdc01"
52
+ # >,
53
+ # network_space="PRIVATE"
54
+ # router={"hostname"=>"bcr02.wdc01", "id"=>40379, "datacenter"=>{"id"=>37473, "longName"=>"Washington, DC 1", "name"=>"wdc01"}}
55
+ # >,
56
+ # ]
57
+ ```
58
+
59
+ 1. Get a network by ID.
60
+
61
+ ```ruby
62
+ net = @sl.networks.get(123456)
63
+ # => <Fog::Network::Softlayer::Network
64
+ # id=123456,
65
+ # name="some-name",
66
+ # modify_date="2014-06-25T17:10:57-05:00",
67
+ # note=nil,
68
+ # tags=["sparkle", "motion", "public"],
69
+ # type="STANDARD",
70
+ # datacenter= <Fog::Network::Softlayer::Datacenter
71
+ # id=12345,
72
+ # long_name="Washington, DC 1",
73
+ # name="wdc01"
74
+ # >,
75
+ # network_space="PUBLIC"
76
+ # router={"hostname"=>"fcr02.wdc01", "id"=>40378, "datacenter"=>{"id"=>37473, "longName"=>"Washington, DC 1", "name"=>"wdc01"}}
77
+ # >
78
+ ```
79
+
80
+ 1. Get a network by name.
81
+
82
+ ```ruby
83
+ @sl.networks.by_name('some-name')
84
+ # => <Fog::Network::Softlayer::Network
85
+ # id=123456,
86
+ # name="some-name",
87
+ # modify_date="2014-06-25T17:10:57-05:00",
88
+ # note=nil,
89
+ # tags=["sparkle", "motion", "public"],
90
+ # type="STANDARD",
91
+ # datacenter= <Fog::Network::Softlayer::Datacenter
92
+ # id=12345,
93
+ # long_name="Washington, DC 1",
94
+ # name="wdc01"
95
+ # >,
96
+ # network_space="PUBLIC"
97
+ # router={"hostname"=>"fcr02.wdc01", "id"=>40378, "datacenter"=>{"id"=>37473, "longName"=>"Washington, DC 1", "name"=>"wdc01"}}
98
+ # >
99
+ ```
100
+
101
+ 1. Get all networks with a particular tag.
102
+
103
+ ```ruby
104
+ prod_backend_nets = @sl.networks.tagged_with(['production', 'private'])
105
+ # => [<Fog::Network::Softlayer::Network>,
106
+ # <Fog::Network::Softlayer::Network>,
107
+ # <Fog::Network::Softlayer::Network>,
108
+ # ]
109
+ ```
110
+
111
+ 1. Get a network's tags.
112
+
113
+ ```ruby
114
+ net = @sl.networks.get(123456)
115
+ net.tags
116
+ # => ['sparkle', 'motion', 'production', 'public']
117
+ ```
118
+
119
+ 1. Get a network's router.
120
+
121
+ ```ruby
122
+ net = @sl.networks.by_name('some-name')
123
+ net.router
124
+ # => {"hostname"=>"bcr02a.ams01",
125
+ # "id"=>190854,
126
+ # "datacenter"=>{"id"=>265592, "longName"=>"Amsterdam 1", "name"=>"ams01"}}
127
+ ```
128
+
129
+ 1. Get a network's subnets.
130
+
131
+ ```ruby
132
+ net = @sl.networks.get(123456)
133
+ net.subnets
134
+ # => [ <Fog::Network::Softlayer::Subnet
135
+ # id=123456,
136
+ # name=nil,
137
+ # network_id="37.58.125.72",
138
+ # vlan_id=123456,
139
+ # cidr=29,
140
+ # ip_version=4,
141
+ # type="ADDITIONAL_PRIMARY",
142
+ # gateway_ip="37.58.125.73",
143
+ # broadcast="37.58.125.79",
144
+ # gateway=nil,
145
+ # datacenter="ams01"
146
+ # >,
147
+ # <Fog::Network::Softlayer::Subnet
148
+ # id=123457,
149
+ # name=nil,
150
+ # network_id="81.95.147.148",
151
+ # vlan_id=123456,
152
+ # cidr=30,
153
+ # ip_version=4,
154
+ # type="PRIMARY",
155
+ # gateway_ip="81.95.147.149",
156
+ # broadcast="81.95.147.151",
157
+ # gateway=nil,
158
+ # datacenter="ams01"
159
+ # >]
160
+ ```
161
+
162
+ 1. Get a subnet's IP Addresses.
163
+
164
+ ```ruby
165
+ net = @sl.networks.get(123456)
166
+ # Here I'm selecting the primary subnet...
167
+ subnet = net.subnets.select { |vlan| vlan.type == "PRIMARY" }.first
168
+ # => <Fog::Network::Softlayer::Subnet
169
+ # id=123457,
170
+ # ...
171
+ # >
172
+ addys = subnet.addresses
173
+ # => [ <Fog::Network::Softlayer::Ip
174
+ # id=19222174,
175
+ # subnet_id=630962,
176
+ # address="37.58.125.72",
177
+ # broadcast=false,
178
+ # gateway=false,
179
+ # network=true,
180
+ # reserved=false,
181
+ # note=nil,
182
+ # assigned_to=nil
183
+ # >,
184
+ # <Fog::Network::Softlayer::Ip
185
+ # id=19222174,
186
+ # subnet_id=630962,
187
+ # address="37.58.125.73",
188
+ # broadcast=false,
189
+ # gateway=true,
190
+ # network=false,
191
+ # reserved=false,
192
+ # note=nil,
193
+ # assigned_to=nil
194
+ # >,
195
+ # <Fog::Network::Softlayer::Ip
196
+ # id=19222174,
197
+ # subnet_id=630962,
198
+ # address="37.58.125.74",
199
+ # broadcast=false,
200
+ # gateway=false,
201
+ # network=false,
202
+ # reserved=false,
203
+ # note=nil,
204
+ # assigned_to={"fullyQualifiedDomainName"=>"hostname.example.com", "id"=>281730}
205
+ # >,
206
+ # <Fog::Network::Softlayer::Ip
207
+ # id=19222174,
208
+ # subnet_id=630962,
209
+ # address="37.58.125.75",
210
+ # broadcast=false,
211
+ # gateway=false,
212
+ # network=false,
213
+ # reserved=false,
214
+ # note=nil,
215
+ # assigned_to={"fullyQualifiedDomainName"=>"hostname-2.example.com", "id"=>281730}
216
+ # >,
217
+ # ...,
218
+ # ]
219
+ ```
220
+
221
+ 1. Create a new network.
222
+
223
+ ```ruby
224
+ # We're creating a network in wdc01, the same steps will work for any datacenter.
225
+ # @sl.datacenters will give you a list of available datacenters.
226
+
227
+ wdc01 = @sl.datacenters.by_name('wdc01')
228
+ wdc01.routers
229
+ # => [{"hostname"=>"bcr01.wdc01", "id"=>16358},
230
+ # {"hostname"=>"bcr02.wdc01", "id"=>40379},
231
+ # {"hostname"=>"bcr03a.wdc01", "id"=>85816},
232
+ # {"hostname"=>"bcr04a.wdc01", "id"=>180611},
233
+ # {"hostname"=>"bcr05a.wdc01", "id"=>235754},
234
+ # {"hostname"=>"fcr01.wdc01", "id"=>16357},
235
+ # {"hostname"=>"fcr02.wdc01", "id"=>40378},
236
+ # {"hostname"=>"fcr03a.wdc01", "id"=>85814},
237
+ # {"hostname"=>"fcr04a.wdc01", "id"=>180610},
238
+ # {"hostname"=>"fcr05a.wdc01", "id"=>235748}]
239
+
240
+ # We want to create a public network so be sure to use one of the fcr* routers.
241
+ # If we were creating a private network we'd want to use a bcr* router.
242
+
243
+ opts = {
244
+ :name => 'my-new-network',
245
+ :datacenter => wdc01,
246
+ :router => wdc01.routers[4],
247
+ :network_space => 'PUBLIC',
248
+ }
249
+
250
+ @sl.networks.create(opts)
251
+ ```
252
+
253
+ 1. Add tags to a network.
254
+
255
+ ```ruby
256
+ net = @sl.networks.by_name('my-new-network')
257
+ net.tags
258
+ # => ['sparkle']
259
+ net.add_tags(['motion'])
260
+ # => true
261
+ net.tags
262
+ # => ['sparkle', 'motion']
263
+ ```
264
+
265
+ 1. Delete tags from a network.
266
+
267
+ ```ruby
268
+ net = @sl.networks.by_name('my-new-network')
269
+ net.tags
270
+ # => ['sparkle', 'motion']
271
+ net.delete_tags(['motion'])
272
+ # => true
273
+ net.tags
274
+ # => ['sparkle']
275
+ ```
276
+
277
+ 1. Delete a network.
278
+
279
+ ```ruby
280
+ @sl.networks.by_name('my-retired-network').destroy
281
+ # => true
282
+
283
+ # You can't delete a network if it has actively routed addresses...
284
+ ```
285
+