fog-voxel 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +20 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +19 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +5 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +34 -0
- data/Rakefile +18 -0
- data/fog-voxel.gemspec +35 -0
- data/gemfiles/Gemfile.1.9.2- +8 -0
- data/gemfiles/Gemfile.1.9.3+ +7 -0
- data/lib/fog/bin/voxel.rb +29 -0
- data/lib/fog/compute/voxel.rb +127 -0
- data/lib/fog/compute/voxel/image.rb +11 -0
- data/lib/fog/compute/voxel/images.rb +24 -0
- data/lib/fog/compute/voxel/real.rb +6 -0
- data/lib/fog/compute/voxel/real/devices_list.rb +22 -0
- data/lib/fog/compute/voxel/real/devices_power.rb +20 -0
- data/lib/fog/compute/voxel/real/images_list.rb +29 -0
- data/lib/fog/compute/voxel/real/voxcloud_create.rb +20 -0
- data/lib/fog/compute/voxel/real/voxcloud_delete.rb +18 -0
- data/lib/fog/compute/voxel/real/voxcloud_status.rb +22 -0
- data/lib/fog/compute/voxel/server.rb +71 -0
- data/lib/fog/compute/voxel/servers.rb +26 -0
- data/lib/fog/parsers/compute.rb +7 -0
- data/lib/fog/parsers/compute/voxel.rb +14 -0
- data/lib/fog/parsers/compute/voxel/basic.rb +27 -0
- data/lib/fog/parsers/compute/voxel/devices_list.rb +107 -0
- data/lib/fog/parsers/compute/voxel/images_list.rb +55 -0
- data/lib/fog/parsers/compute/voxel/voxcloud_create.rb +36 -0
- data/lib/fog/parsers/compute/voxel/voxcloud_delete.rb +27 -0
- data/lib/fog/parsers/compute/voxel/voxcloud_status.rb +42 -0
- data/lib/fog/voxel.rb +25 -0
- data/lib/fog/voxel/compute.rb +0 -0
- data/lib/fog/voxel/version.rb +5 -0
- data/spec/minitest_helper.rb +31 -0
- data/tests/helper.rb +37 -0
- data/tests/helpers/collection_helper.rb +97 -0
- data/tests/helpers/compute/flavors_helper.rb +32 -0
- data/tests/helpers/compute/server_helper.rb +25 -0
- data/tests/helpers/compute/servers_helper.rb +10 -0
- data/tests/helpers/formats_helper.rb +98 -0
- data/tests/helpers/formats_helper_tests.rb +110 -0
- data/tests/helpers/mock_helper.rb +117 -0
- data/tests/helpers/model_helper.rb +31 -0
- data/tests/helpers/responds_to_helper.rb +11 -0
- data/tests/helpers/schema_validator_tests.rb +107 -0
- data/tests/helpers/succeeds_helper.rb +9 -0
- data/tests/requests/compute/image_tests.rb +52 -0
- data/tests/requests/compute/server_tests.rb +123 -0
- metadata +225 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0886f6d85070e02c66b08dd9f372866f14341012
|
4
|
+
data.tar.gz: 075842f1860bc1a9445d59b84b9bcca0dfb19616
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d3e76e22b5213afee66900b3dbfd9bd09e70bf5ec003daa46bb5de01bcbb8c4107938480583e32ae321a224cbf2b0b17b840fcbb092d9f6cc352f5686f85a637
|
7
|
+
data.tar.gz: 0b8653bc807973c757c6ad0ca3f39379e70d2dc5d20ee29abacc623cb2c860c3fca93156a766233be1337e2d78b00f3ebdb25b27c81c779bfe197cd34997ea44
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
gemfiles/*.lock
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Metrics/LineLength:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Style/EachWithObject:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Style/Encoding:
|
8
|
+
EnforcedStyle: when_needed
|
9
|
+
|
10
|
+
Style/FormatString:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/HashSyntax:
|
14
|
+
EnforcedStyle: hash_rockets
|
15
|
+
|
16
|
+
Style/SignalException:
|
17
|
+
EnforcedStyle: only_raise
|
18
|
+
|
19
|
+
Style/StringLiterals:
|
20
|
+
EnforcedStyle: double_quotes
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
fog-voxel
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.4
|
data/.travis.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
matrix:
|
2
|
+
include:
|
3
|
+
- rvm: 1.8.7
|
4
|
+
gemfile: gemfiles/Gemfile.1.9.2-
|
5
|
+
- rvm: 1.9.2
|
6
|
+
gemfile: gemfiles/Gemfile.1.9.2-
|
7
|
+
- rvm: 1.9.3
|
8
|
+
gemfile: gemfiles/Gemfile.1.9.3+
|
9
|
+
- rvm: 2.0.0
|
10
|
+
gemfile: gemfiles/Gemfile.1.9.3+
|
11
|
+
env: COVERAGE=true
|
12
|
+
- rvm: 2.1.1
|
13
|
+
gemfile: gemfiles/Gemfile.1.9.3+
|
14
|
+
env: COVERAGE=true
|
15
|
+
- rvm: ree
|
16
|
+
gemfile: gemfiles/Gemfile.1.9.2-
|
17
|
+
- rvm: jruby
|
18
|
+
gemfile: gemfiles/Gemfile.1.9.3+
|
19
|
+
env: COVERAGE=true
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## Getting Involved
|
2
|
+
|
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
|
+
|
5
|
+
### Coding
|
6
|
+
|
7
|
+
* Pick a task:
|
8
|
+
* Offer feedback on open [pull requests](https://github.com/fog/fog-exoscale/pulls).
|
9
|
+
* Review open [issues](https://github.com/fog/fog-exoscale/issues) for things to help on.
|
10
|
+
* [Create an issue](https://github.com/fog/fog-exoscale/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 `fog/fog-exoscale` to ensure everything is up to date.
|
13
|
+
* [Submit a pull request](https://github.com/fog/fog-exoscale/compare/)
|
14
|
+
|
15
|
+
### Non-Coding
|
16
|
+
|
17
|
+
* Offer feedback on open [issues](https://github.com/fog/fog-exoscale/issues).
|
18
|
+
* Organize or volunteer at events.
|
data/CONTRIBUTORS.md
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014-2014 [CONTRIBUTORS.md](https://github.com/fog/fog-voxel/blob/master/CONTRIBUTORS.md)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Fog::Voxel
|
2
|
+
|
3
|
+
[](https://travis-ci.org/fog/fog-voxel) [](https://gemnasium.com/fog/fog-voxel) [](https://coveralls.io/r/fog/fog-voxel) [](https://codeclimate.com/github/fog/fog-voxel)
|
4
|
+
|
5
|
+
Module for the 'fog' gem to support Voxel
|
6
|
+
|
7
|
+
## Help Needed
|
8
|
+
|
9
|
+
This gem needs a maintainer. If you want to work on it, please contact
|
10
|
+
[@geemus](mailto:geemus@gmail.com) or [@plribeiro3000](mailto:plribeiro3000@gmail.com)
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'fog-voxel'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install fog-voxel
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it ( https://github.com/fog/fog-voxel/fork )
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs.push %w(spec)
|
6
|
+
t.test_files = FileList['spec/**/*_spec.rb']
|
7
|
+
t.verbose = true
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Default Task'
|
11
|
+
task :default => [ :test, 'test:travis' ]
|
12
|
+
|
13
|
+
namespace :test do
|
14
|
+
mock = ENV['FOG_MOCK'] || 'true'
|
15
|
+
task :travis do
|
16
|
+
sh("export FOG_MOCK=#{mock} && bundle exec shindont")
|
17
|
+
end
|
18
|
+
end
|
data/fog-voxel.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "fog/voxel/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fog-voxel"
|
8
|
+
spec.version = Fog::Voxel::VERSION
|
9
|
+
spec.authors = %q(Paulo Henrique Lopes Ribeiro)
|
10
|
+
spec.email = %q(plribeiro3000@gmail.com)
|
11
|
+
spec.summary = %q{Module for the 'fog' gem to support Voxel.}
|
12
|
+
spec.description = %q{This library can be used as a module for `fog` or as standalone provider
|
13
|
+
to use the Voxel in applications.}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "fog-core"
|
23
|
+
spec.add_dependency "fog-xml"
|
24
|
+
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "minitest"
|
27
|
+
spec.add_development_dependency "shindo"
|
28
|
+
spec.add_development_dependency "turn"
|
29
|
+
spec.add_development_dependency "pry"
|
30
|
+
|
31
|
+
if RUBY_VERSION.to_f > 1.9
|
32
|
+
spec.add_development_dependency "coveralls"
|
33
|
+
spec.add_development_dependency "rubocop"
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Voxel < Fog::Bin
|
2
|
+
class << self
|
3
|
+
def class_for(key)
|
4
|
+
case key
|
5
|
+
when :compute
|
6
|
+
Fog::Compute::Voxel
|
7
|
+
else
|
8
|
+
raise ArgumentError, "Unrecognized service: #{key}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def [](service)
|
13
|
+
@@connections ||= Hash.new do |hash, key|
|
14
|
+
hash[key] = case key
|
15
|
+
when :compute
|
16
|
+
Fog::Logger.warning("Voxel[:compute] is not recommended, use Compute[:voxel] for portability")
|
17
|
+
Fog::Compute.new(:provider => 'Voxel')
|
18
|
+
else
|
19
|
+
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
@@connections[service]
|
23
|
+
end
|
24
|
+
|
25
|
+
def services
|
26
|
+
Fog::Voxel.services
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'fog/voxel'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class Voxel < Fog::Service
|
6
|
+
autoload :Image, 'fog/compute/voxel/image'
|
7
|
+
autoload :Images, 'fog/compute/voxel/images'
|
8
|
+
autoload :Server, 'fog/compute/voxel/server'
|
9
|
+
autoload :Servers, 'fog/compute/voxel/servers'
|
10
|
+
|
11
|
+
requires :voxel_api_key, :voxel_api_secret
|
12
|
+
recognizes :host, :port, :scheme, :persistent
|
13
|
+
|
14
|
+
model_path 'fog/compute/voxel'
|
15
|
+
model :image
|
16
|
+
collection :images
|
17
|
+
model :server
|
18
|
+
collection :servers
|
19
|
+
|
20
|
+
request_path 'fog/compute/voxel/real'
|
21
|
+
request :images_list
|
22
|
+
request :devices_list
|
23
|
+
request :devices_power
|
24
|
+
request :voxcloud_create
|
25
|
+
request :voxcloud_status
|
26
|
+
request :voxcloud_delete
|
27
|
+
|
28
|
+
class Mock
|
29
|
+
include Collections
|
30
|
+
|
31
|
+
def self.data
|
32
|
+
@data ||= Hash.new do |hash, key|
|
33
|
+
hash[key] = {
|
34
|
+
:last_modified => { :servers => {}, :statuses => {}, :images => {} },
|
35
|
+
:servers => [],
|
36
|
+
:statuses => {},
|
37
|
+
:images => [
|
38
|
+
{'id' => 1, 'name' => "CentOS 4, 32-bit, base install"},
|
39
|
+
{'id' => 2, 'name' => "CentOS 4, 64-bit, base install"},
|
40
|
+
{'id' => 3, 'name' => "CentOS 5, 32-bit, base install"},
|
41
|
+
{'id' => 4, 'name' => "CentOS 5, 64-bit, base install"},
|
42
|
+
{'id' => 7, 'name' => "Fedora 10, 32-bit, base install"},
|
43
|
+
{'id' => 8, 'name' => "Fedora 10, 64-bit, base install"},
|
44
|
+
{'id' => 10, 'name' => "OpenSUSE 11, 64-bit, base install"},
|
45
|
+
{'id' => 11, 'name' => "Debian 5.0 \"lenny\", 32-bit, base install"},
|
46
|
+
{'id' => 12, 'name' => "Debian 5.0 \"lenny\", 64-bit, base install"},
|
47
|
+
{'id' => 13, 'name' => "Ubuntu 8.04 \"Hardy\", 32-bit, base install"},
|
48
|
+
{'id' => 14, 'name' => "Ubuntu 8.04 \"Hardy\", 64-bit, base install"},
|
49
|
+
{'id' => 15, 'name' => "Voxel Server Environment (VSE), 32-bit, base install"},
|
50
|
+
{'id' => 16, 'name' => "Voxel Server Environment (VSE), 64-bit, base install"},
|
51
|
+
{'id' => 32, 'name' => "Pantheon Official Mercury Stack for Drupal (based on VSE/64)"},
|
52
|
+
{'id' => 55, 'name' => "Ubuntu 10.04 \"Lucid\", 64-bit, base install"} ]
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.reset
|
58
|
+
@data = nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def initialize(options={})
|
62
|
+
@voxel_api_key = options[:voxel_api_key]
|
63
|
+
end
|
64
|
+
|
65
|
+
def data
|
66
|
+
self.class.data[@voxel_api_key]
|
67
|
+
end
|
68
|
+
|
69
|
+
def reset_data
|
70
|
+
self.class.data.delete(@voxel_api_key)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class Real
|
75
|
+
include Collections
|
76
|
+
|
77
|
+
def initialize(options = {})
|
78
|
+
require 'time'
|
79
|
+
require 'digest/md5'
|
80
|
+
|
81
|
+
@voxel_api_key = options[:voxel_api_key]
|
82
|
+
@voxel_api_secret = options[:voxel_api_secret]
|
83
|
+
|
84
|
+
@connection_options = options[:connection_options] || {}
|
85
|
+
@host = options[:host] || "api.voxel.net"
|
86
|
+
@port = options[:port] || 443
|
87
|
+
@scheme = options[:scheme] || 'https'
|
88
|
+
@persistent = options[:persistent] || false
|
89
|
+
|
90
|
+
@connection_options[:ssl_verify_peer] = false
|
91
|
+
|
92
|
+
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
93
|
+
end
|
94
|
+
|
95
|
+
def request(method_name, options = {})
|
96
|
+
begin
|
97
|
+
parser = options.delete(:parser)
|
98
|
+
options.merge!({ :method => method_name, :timestamp => Time.now.xmlschema, :key => @voxel_api_key })
|
99
|
+
options[:api_sig] = create_signature(@voxel_api_secret, options)
|
100
|
+
data = @connection.request(
|
101
|
+
:method => "POST",
|
102
|
+
:query => options,
|
103
|
+
:parser => parser,
|
104
|
+
:path => "/version/1.0/"
|
105
|
+
)
|
106
|
+
unless data.body['stat'] == 'ok'
|
107
|
+
raise Fog::Compute::Voxel::Error, "#{data.body['err']['msg']}"
|
108
|
+
end
|
109
|
+
data
|
110
|
+
rescue Excon::Errors::HTTPStatusError => error
|
111
|
+
raise case error
|
112
|
+
when Excon::Errors::NotFound
|
113
|
+
Fog::Compute::Voxel::NotFound.slurp(error)
|
114
|
+
else
|
115
|
+
error
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def create_signature(secret, options)
|
121
|
+
to_sign = options.keys.map { |k| k.to_s }.sort.map { |k| "#{k}#{options[k.to_sym]}" }.join("")
|
122
|
+
Digest::MD5.hexdigest( secret + to_sign )
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Voxel
|
4
|
+
class Images < Fog::Collection
|
5
|
+
model Fog::Compute::Voxel::Image
|
6
|
+
|
7
|
+
def all
|
8
|
+
data = service.images_list.body['images']
|
9
|
+
load(data)
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(image_id)
|
13
|
+
data = service.images_list(image_id).body['images']
|
14
|
+
|
15
|
+
if data.empty?
|
16
|
+
nil
|
17
|
+
else
|
18
|
+
new(data.first)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
require 'fog/compute/voxel/real/devices_list'
|
2
|
+
require 'fog/compute/voxel/real/devices_power'
|
3
|
+
require 'fog/compute/voxel/real/images_list'
|
4
|
+
require 'fog/compute/voxel/real/voxcloud_create'
|
5
|
+
require 'fog/compute/voxel/real/voxcloud_delete'
|
6
|
+
require 'fog/compute/voxel/real/voxcloud_status'
|