fog-softlayer 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +15 -7
  2. data/.gitignore +28 -0
  3. data/Gemfile +7 -0
  4. data/Rakefile +225 -1
  5. data/fog-softlayer.gemspec +15 -5
  6. data/lib/fog.rb +29 -0
  7. data/lib/fog/softlayer.rb +8 -0
  8. data/lib/fog/softlayer/compute.rb +0 -15
  9. data/lib/fog/softlayer/core.rb +6 -8
  10. data/lib/fog/softlayer/version.rb +7 -1
  11. data/spec/fog/compute/softlayer_spec.rb +6 -0
  12. data/tests/compute/flavors_helper.rb +40 -0
  13. data/tests/compute/server_helper.rb +33 -0
  14. data/tests/compute/servers_helper.rb +18 -0
  15. data/tests/helper.rb +68 -0
  16. data/tests/helpers/collection_helper.rb +102 -0
  17. data/tests/helpers/compute/flavors_helper.rb +34 -0
  18. data/tests/helpers/compute/server_helper.rb +27 -0
  19. data/tests/helpers/compute/servers_helper.rb +12 -0
  20. data/tests/helpers/formats_helper.rb +99 -0
  21. data/tests/helpers/formats_helper_tests.rb +111 -0
  22. data/tests/helpers/mock_helper.rb +111 -0
  23. data/tests/helpers/model_helper.rb +35 -0
  24. data/tests/helpers/responds_to_helper.rb +13 -0
  25. data/tests/helpers/schema_validator_tests.rb +107 -0
  26. data/tests/helpers/succeeds_helper.rb +11 -0
  27. data/tests/lorem.txt +1 -0
  28. data/tests/softlayer/compute/helper.rb +7 -0
  29. data/tests/softlayer/compute/schema.rb +133 -0
  30. data/tests/softlayer/compute_tests.rb +34 -0
  31. data/tests/softlayer/helper.rb +9 -0
  32. data/tests/softlayer/models/compute/flavor_tests.rb +24 -0
  33. data/tests/softlayer/models/compute/image_tests.rb +25 -0
  34. data/tests/softlayer/models/compute/server_tests.rb +80 -0
  35. data/tests/softlayer/requests/compute/bmc_tests.rb +62 -0
  36. data/tests/softlayer/requests/compute/vm_tests.rb +90 -0
  37. metadata +254 -59
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
- ---
2
- SHA1:
3
- data.tar.gz: 603a92b8df5d52e401e355800b18e9bd8212a1ad
4
- metadata.gz: c04b468d48832beb929584ebffaf958c2e4511d3
5
- SHA512:
6
- data.tar.gz: 1482ca7a4cbfb56189127d900541218c343b3eb0f93063e72f52fa9b526bbe0d66f78e8ca033ecc8b59d41d2d78bb2c796f928e5beb0692d0513cbd7f59a76b8
7
- metadata.gz: 06f30a5d29b281c089729822bcaf6cc734bdc37012349e47507863920ebb7a6c98da013c33b7fd1b28f24fdf53bdfc2bda5ad15a24f69536aeb4e2bd2666b45e
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjY5ZGRiZWQ0NGZlNTRjMTJmZjNjYTU5ODU4MGI3ZTA4NjQxM2M5Mg==
5
+ data.tar.gz: !binary |-
6
+ ODkzYmYxMWZjODc1OWViZjdiMjNiMjgyMjk0ZWZjYTVkOTcwMzE4MQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OGYyYTkxMTMwOWMzMGY1ZWQyMDZiMDVjM2JlZGY2ZGFkMDQ2NDA2ZWY0Njk4
10
+ YTFjNDFhMDYxMzMxMjdjZTM3MmZiNzY4NTliMTg0NjFlYzMyZjM3ZDQ3MzM3
11
+ ZDI0YWI5ODBmNDZkNWI4MzJjMzY5OGE4MmFhNGE0Nzg3MWQyZTc=
12
+ data.tar.gz: !binary |-
13
+ MDE5OWJmNTQ3YjQyZGNlMTljYTFlMzcwNWEyODJkYmFmOTI3MmI2NzVkMjNi
14
+ ZjgzMDhlMGQzMmJmNzc0N2ZjOGQ0YWI0NjAyOTVkZDdhM2Y5NWJkMGRhMGRk
15
+ MmIyNDI2YzQyMjIyYzNkNjU4NTg3MTdiYjQ5MzcwN2EzOWI3NGU=
data/.gitignore CHANGED
@@ -1 +1,29 @@
1
+ .idea*
2
+ *~
3
+ *.gem
4
+ *.rbc
5
+ *.sw?
6
+ .rbenv
7
+ .rvmrc
8
+ .ruby-gemset
9
+ .ruby-version
10
+ .bundle
11
+ .DS_Store
12
+ .idea
13
+ .yardoc
14
+ /tests/.fog
15
+ bin/*
16
+ !bin/fog
17
+ .fog
18
+ coverage
19
+ doc/*
20
+ docs/_site/*
21
+ docs/about/supported_services.markdown
1
22
  Gemfile.lock
23
+ gemfiles/*.lock
24
+ yardoc
25
+ pkg
26
+ spec/credentials.yml
27
+ vendor/*
28
+ tags
29
+
data/Gemfile CHANGED
@@ -1,3 +1,10 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ group :development, :test do
4
+ # This is here because gemspec doesn't support require: false
5
+ gem 'coveralls', :require => false
6
+ gem 'netrc', :require => false
7
+ gem 'octokit', :require => false
8
+ end
9
+
3
10
  gemspec
data/Rakefile CHANGED
@@ -9,8 +9,232 @@
9
9
  require "bundler/gem_tasks"
10
10
  require "rake/testtask"
11
11
 
12
+ #task :default => :test
13
+ #
14
+ #Rake::TestTask.new do |t|
15
+ # t.pattern = File.join("spec", "**", "*_spec.rb")
16
+ #end
17
+
18
+ require 'bundler/setup'
19
+ require 'rake/testtask'
20
+ require 'date'
21
+ require 'rubygems'
22
+ require 'rubygems/package_task'
23
+ require 'yard'
24
+ require File.dirname(__FILE__) + '/lib/fog'
25
+
26
+ #############################################################################
27
+ #
28
+ # Helper functions
29
+ #
30
+ #############################################################################
31
+
32
+ def name
33
+ @name ||= Dir['*.gemspec'].first.split('.').first
34
+ end
35
+
36
+ def version
37
+ Fog::VERSION
38
+ end
39
+
40
+ def date
41
+ Date.today.to_s
42
+ end
43
+
44
+ def rubyforge_project
45
+ name
46
+ end
47
+
48
+ def gemspec_file
49
+ "#{name}.gemspec"
50
+ end
51
+
52
+ def gem_file
53
+ "#{name}-#{version}.gem"
54
+ end
55
+
56
+ def replace_header(head, header_name)
57
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
58
+ end
59
+
60
+ #############################################################################
61
+ #
62
+ # Standard tasks
63
+ #
64
+ #############################################################################
65
+
66
+ GEM_NAME = "#{name}"
12
67
  task :default => :test
68
+ task :travis => ['test', 'test:travis', 'coveralls_push_workaround']
13
69
 
14
70
  Rake::TestTask.new do |t|
15
- t.pattern = File.join("spec", "**", "*_spec.rb")
71
+ t.pattern = File.join("**", "spec", "**", "*_spec.rb")
72
+ end
73
+
74
+ namespace :test do
75
+ mock = 'true' || ENV['FOG_MOCK']
76
+ task :travis do
77
+ # jruby coveralls causes an OOM in travis
78
+ ENV['COVERAGE'] = 'false' if RUBY_PLATFORM == 'java'
79
+ sh("export FOG_MOCK=#{mock} && bundle exec shindont")
80
+ end
81
+ task :vsphere do
82
+ sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/vsphere")
83
+ end
84
+ task :openvz do
85
+ sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/openvz")
86
+ end
87
+ end
88
+
89
+ desc 'Run mocked tests for a specific provider'
90
+ task :mock, :provider do |t, args|
91
+ if args.to_a.size != 1
92
+ fail 'USAGE: rake mock[<provider>]'
93
+ end
94
+ provider = args[:provider]
95
+ sh("export FOG_MOCK=true && bundle exec shindont tests/#{provider}")
96
+ end
97
+
98
+ desc 'Run live tests against a specific provider'
99
+ task :live, :provider do |t, args|
100
+ if args.to_a.size != 1
101
+ fail 'USAGE: rake live[<provider>]'
102
+ end
103
+ provider = args[:provider]
104
+ sh("export FOG_MOCK=false PROVIDER=#{provider} && bundle exec shindont tests/#{provider}")
105
+ end
106
+
107
+ task :nuke do
108
+ Fog.providers.each do |provider|
109
+ next if ['Vmfusion'].include?(provider)
110
+ begin
111
+ compute = Fog::Compute.new(:provider => provider)
112
+ for server in compute.servers
113
+ Formatador.display_line("[#{provider}] destroying server #{server.identity}")
114
+ server.destroy rescue nil
115
+ end
116
+ rescue
117
+ end
118
+ begin
119
+ dns = Fog::DNS.new(:provider => provider)
120
+ for zone in dns.zones
121
+ for record in zone.records
122
+ record.destroy rescue nil
123
+ end
124
+ Formatador.display_line("[#{provider}] destroying zone #{zone.identity}")
125
+ zone.destroy rescue nil
126
+ end
127
+ rescue
128
+ end
129
+ end
130
+ end
131
+
132
+ desc "Open an irb session preloaded with this library"
133
+ task :console do
134
+ sh "irb -rubygems -r ./lib/#{name}.rb"
135
+ end
136
+
137
+ #############################################################################
138
+ #
139
+ # Packaging tasks
140
+ #
141
+ #############################################################################
142
+
143
+ task :release => ["release:prepare", "release:publish"]
144
+
145
+ namespace :release do
146
+ task :preflight do
147
+ unless `git branch` =~ /^\* master$/
148
+ puts "You must be on the master branch to release!"
149
+ exit!
150
+ end
151
+ if `git tag` =~ /^\* v#{version}$/
152
+ puts "Tag v#{version} already exists!"
153
+ exit!
154
+ end
155
+ end
156
+
157
+ task :prepare => :preflight do
158
+ Rake::Task[:build].invoke
159
+ sh "gem install pkg/#{name}-#{version}.gem"
160
+ Rake::Task[:git_mark_release].invoke
161
+ end
162
+
163
+ task :publish do
164
+ Rake::Task[:git_push_release].invoke
165
+ Rake::Task[:gem_push].invoke
166
+ end
167
+ end
168
+
169
+ task :git_mark_release do
170
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
171
+ sh "git tag v#{version}"
172
+ end
173
+
174
+ task :git_push_release do
175
+ sh "git push origin master"
176
+ sh "git push origin v#{version}"
177
+ end
178
+
179
+ task :gem_push do
180
+ sh "gem push pkg/#{name}-#{version}.gem"
181
+ end
182
+
183
+ desc "Build fog-#{version}.gem"
184
+ task :build => :gemspec do
185
+ sh "mkdir -p pkg"
186
+ sh "gem build #{gemspec_file}"
187
+ sh "mv #{gem_file} pkg"
188
+ end
189
+ task :gem => :build
190
+
191
+ desc "Updates the gemspec and runs 'validate'"
192
+ task :gemspec => :validate do
193
+ # read spec file and split out manifest section
194
+ spec = File.read(gemspec_file)
195
+
196
+ # replace name version and date
197
+ replace_header(spec, :name)
198
+ replace_header(spec, :version)
199
+ replace_header(spec, :date)
200
+ #comment this out if your rubyforge_project has a different name
201
+ replace_header(spec, :rubyforge_project)
202
+
203
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
204
+ puts "Updated #{gemspec_file}"
205
+ end
206
+
207
+ desc "Run before pushing out the code"
208
+ task :validate do
209
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}", "lib/tasks"]
210
+ unless libfiles.empty?
211
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
212
+ exit!
213
+ end
214
+ unless Dir['VERSION*'].empty?
215
+ puts "A `VERSION` file at root level violates Gem best practices."
216
+ exit!
217
+ end
218
+ end
219
+
220
+ # Include Yard tasks for rake yard
221
+ YARDOC_LOCATION = "doc"
222
+ YARD::Rake::YardocTask.new do |t|
223
+ t.files = ['lib/**/*.rb', "README"]
224
+ t.options = ["--output-dir", YARDOC_LOCATION, "--title", "#{name} #{version}"]
225
+ end
226
+
227
+ require "tasks/changelog_task"
228
+ Fog::Rake::ChangelogTask.new
229
+
230
+ require "tasks/github_release_task"
231
+ Fog::Rake::GithubReleaseTask.new
232
+
233
+ task :coveralls_push_workaround do
234
+ use_coveralls = (Gem::Version.new(RUBY_VERSION) > Gem::Version.new('1.9.2'))
235
+ if (ENV['COVERAGE'] != 'false') && use_coveralls
236
+ require 'coveralls/rake/task'
237
+ Coveralls::RakeTask.new
238
+ Rake::Task["coveralls:push"].invoke
239
+ end
16
240
  end
@@ -19,10 +19,20 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "fog-core"
23
- spec.add_dependency "fog-json"
22
+ spec.add_dependency 'fog'
23
+ spec.add_dependency 'fog-core'
24
+ spec.add_dependency 'fog-json'
24
25
 
25
- spec.add_development_dependency "bundler", "~> 1.3"
26
- spec.add_development_dependency "rake"
27
- spec.add_development_dependency "minitest"
26
+ spec.add_development_dependency 'bundler', '~> 1.3'
27
+ spec.add_development_dependency('minitest')
28
+ spec.add_development_dependency('jekyll') unless RUBY_PLATFORM == 'java'
29
+ spec.add_development_dependency('rake')
30
+ spec.add_development_dependency('rbvmomi')
31
+ spec.add_development_dependency('yard')
32
+ spec.add_development_dependency('thor')
33
+ spec.add_development_dependency('rbovirt', '0.0.24')
34
+ spec.add_development_dependency('shindo', '~> 0.3.4')
35
+ spec.add_development_dependency('fission')
36
+ spec.add_development_dependency('pry')
37
+ spec.add_development_dependency('google-api-client', '~> 0.6', '>= 0.6.2')
28
38
  end
data/lib/fog.rb ADDED
@@ -0,0 +1,29 @@
1
+ #
2
+ # Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
3
+ # © Copyright IBM Corporation 2014.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
7
+
8
+ # necessary when requiring fog without rubygems while also
9
+ # maintaining ruby 1.8.7 support (can't use require_relative)
10
+ __LIB_DIR__ = File.expand_path(File.dirname(__FILE__))
11
+ $LOAD_PATH.unshift __LIB_DIR__ unless $LOAD_PATH.include?(__LIB_DIR__)
12
+
13
+ # Use fog and core
14
+ require 'fog/core'
15
+ require 'fog'
16
+
17
+ # Previously treated as "core"
18
+ # data exchange specific (to be extracted and used on a per provider basis)
19
+ require 'fog/xml'
20
+ require 'fog/json'
21
+ require 'fog/core/parser'
22
+
23
+ # deprecation wrappers (XML wrapped version)
24
+ require 'fog/core/deprecated/connection'
25
+ require 'fog/core/deprecated_connection_accessors'
26
+
27
+ # any one of these can be required separately.
28
+ # they all depend on fog/core for shared functionality.
29
+ require 'fog/softlayer'
data/lib/fog/softlayer.rb CHANGED
@@ -1 +1,9 @@
1
+ #
2
+ # Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
3
+ # © Copyright IBM Corporation 2014.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
7
+ require 'fog'
8
+ require 'fog/softlayer'
1
9
  require 'fog/softlayer/compute'
@@ -21,8 +21,6 @@ module Fog
21
21
  recognizes :softlayer_default_domain
22
22
 
23
23
 
24
- #service = File.basename(__FILE__, '.rb')
25
-
26
24
  model_path 'fog/softlayer/models/compute'
27
25
  collection :flavors
28
26
  model :flavor
@@ -31,15 +29,6 @@ module Fog
31
29
  collection :servers
32
30
  model :server
33
31
 
34
- #Fog::Softlayer.loader("models/#{service}") do |basename|
35
- # if basename =~ /s$/
36
- # collection basename
37
- # else
38
- # model basename
39
- # end
40
- #
41
- #end
42
-
43
32
  request_path 'fog/softlayer/requests/compute'
44
33
  request :create_bare_metal_server
45
34
  request :create_vm
@@ -51,10 +40,6 @@ module Fog
51
40
  request :get_vm
52
41
  request :get_vms
53
42
 
54
- #Fog::Softlayer.loader("requests/#{service}") do |basename|
55
- # request basename
56
- #end
57
-
58
43
  # The Mock Service allows you to run a fake instance of the Service
59
44
  # which makes no real connections.
60
45
  #
@@ -1,3 +1,9 @@
1
+ #
2
+ # Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
3
+ # © Copyright IBM Corporation 2014.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
1
7
  require 'fog/core'
2
8
  require 'fog/json'
3
9
  require 'time'
@@ -10,14 +16,6 @@ module Fog
10
16
 
11
17
  service(:compute, 'Compute')
12
18
 
13
- def self.loader(service)
14
- path = "providers/softlayer/lib/fog/softlayer/#{service}"
15
- Dir.entries(path).reject{|e| e =~ /^\./}.each do |file|
16
- _request = File.basename(file, '.rb')
17
- yield _request.to_sym
18
- end
19
- end
20
-
21
19
  def self.mock_account_id
22
20
  Fog.mocking? and @sl_account_id ||= Fog::Mock.random_numbers(7)
23
21
  end
@@ -1,5 +1,11 @@
1
+ #
2
+ # Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
3
+ # © Copyright IBM Corporation 2014.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
1
7
  module Fog
2
8
  module Softlayer
3
- VERSION = "0.0.4"
9
+ VERSION = "0.0.5"
4
10
  end
5
11
  end
@@ -1,3 +1,9 @@
1
+ #
2
+ # Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
3
+ # © Copyright IBM Corporation 2014.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
1
7
  require "minitest/autorun"
2
8
  require "fog/softlayer"
3
9