fog-voxel 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,22 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Voxel
|
4
|
+
class Real
|
5
|
+
require 'fog/voxel/parsers/voxel/devices_list'
|
6
|
+
|
7
|
+
def devices_list(device_id = nil)
|
8
|
+
options = {
|
9
|
+
:parser => Fog::Parsers::Compute::Voxel::DevicesList.new,
|
10
|
+
:verbosity => 'normal'
|
11
|
+
}
|
12
|
+
|
13
|
+
unless device_id.nil?
|
14
|
+
options[:device_id] = device_id
|
15
|
+
end
|
16
|
+
|
17
|
+
request("voxel.devices.list", options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Voxel
|
4
|
+
class Real
|
5
|
+
require 'fog/voxel/parsers/voxel/basic'
|
6
|
+
|
7
|
+
def devices_power(device_id, power_action)
|
8
|
+
options = {
|
9
|
+
:device_id => device_id,
|
10
|
+
:parser => Fog::Parsers::Compute::Voxel::Basic.new,
|
11
|
+
:power_action => power_action,
|
12
|
+
:verbosity => 'normal'
|
13
|
+
}
|
14
|
+
|
15
|
+
request("voxel.devices.power", options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Voxel
|
4
|
+
class Real
|
5
|
+
require 'fog/voxel/parsers/voxel/images_list'
|
6
|
+
|
7
|
+
def images_list(image_id = nil)
|
8
|
+
options = {
|
9
|
+
:parser => Fog::Parsers::Compute::Voxel::ImagesList.new,
|
10
|
+
:verbosity => 'compact'
|
11
|
+
}
|
12
|
+
|
13
|
+
unless image_id.nil?
|
14
|
+
options[:verbosity] = 'extended'
|
15
|
+
options[:image_id] = image_id
|
16
|
+
end
|
17
|
+
|
18
|
+
data = request("voxel.images.list", options)
|
19
|
+
|
20
|
+
if data.body['stat'] == "ok"
|
21
|
+
data
|
22
|
+
else
|
23
|
+
raise Fog::Compute::Voxel::NotFound
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Voxel
|
4
|
+
class Real
|
5
|
+
require 'fog/voxel/parsers/voxel/voxcloud_create'
|
6
|
+
|
7
|
+
def voxcloud_create(options)
|
8
|
+
options[:parser] = Fog::Parsers::Compute::Voxel::VoxcloudCreate.new
|
9
|
+
|
10
|
+
if options.key?(:password)
|
11
|
+
options[:admin_password] = options[:password]
|
12
|
+
options.delete(:password)
|
13
|
+
end
|
14
|
+
|
15
|
+
request("voxel.voxcloud.create", options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Voxel
|
4
|
+
class Real
|
5
|
+
require 'fog/voxel/parsers/voxel/voxcloud_delete'
|
6
|
+
|
7
|
+
def voxcloud_delete(device_id)
|
8
|
+
options = {
|
9
|
+
:device_id => device_id,
|
10
|
+
:parser => Fog::Parsers::Compute::Voxel::VoxcloudDelete.new
|
11
|
+
}
|
12
|
+
|
13
|
+
request("voxel.voxcloud.delete", options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Voxel
|
4
|
+
class Real
|
5
|
+
require 'fog/voxel/parsers/voxel/voxcloud_status'
|
6
|
+
|
7
|
+
def voxcloud_status(device_id = nil)
|
8
|
+
options = {
|
9
|
+
:parser => Fog::Parsers::Compute::Voxel::VoxcloudStatus.new,
|
10
|
+
:verbosity => 'compact'
|
11
|
+
}
|
12
|
+
|
13
|
+
unless device_id.nil?
|
14
|
+
options[:device_id] = device_id
|
15
|
+
end
|
16
|
+
|
17
|
+
request("voxel.voxcloud.status", options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Voxel
|
4
|
+
class Server < Fog::Compute::Server
|
5
|
+
identity :id
|
6
|
+
|
7
|
+
attribute :name
|
8
|
+
attribute :processing_cores
|
9
|
+
attribute :image_id
|
10
|
+
attribute :facility
|
11
|
+
attribute :disk_size
|
12
|
+
attribute :ip_assignments, :aliases => 'ipassignments'
|
13
|
+
|
14
|
+
def initialize(attributes={})
|
15
|
+
self.image_id ||= '55' # Ubuntu 10.04 LTS 64bit
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy
|
20
|
+
requires :id
|
21
|
+
service.voxcloud_delete(id)
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def image
|
26
|
+
requires :image_id
|
27
|
+
service.images.get(image_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def ready?
|
31
|
+
self.state == 'SUCCEEDED'
|
32
|
+
end
|
33
|
+
|
34
|
+
def private_ip_address
|
35
|
+
ip_assignments.select {|ip_assignment| ip_assignment['type'] == 'internal'}.first
|
36
|
+
end
|
37
|
+
|
38
|
+
def public_ip_address
|
39
|
+
ip_assignments.select {|ip_assignment| ip_assignment['type'] == 'external'}.first
|
40
|
+
end
|
41
|
+
|
42
|
+
def reboot
|
43
|
+
requires :id
|
44
|
+
service.devices_power(id, :reboot)
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def state
|
49
|
+
@state ||= service.voxcloud_status(id).body['devices'].first['status']
|
50
|
+
end
|
51
|
+
|
52
|
+
def save
|
53
|
+
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
54
|
+
requires :name, :image_id, :processing_cores, :facility, :disk_size
|
55
|
+
|
56
|
+
data = service.voxcloud_create({
|
57
|
+
:disk_size => disk_size,
|
58
|
+
:facility => facility,
|
59
|
+
:hostname => name,
|
60
|
+
:image_id => image_id,
|
61
|
+
:processing_cores => processing_cores
|
62
|
+
}).body
|
63
|
+
|
64
|
+
merge_attributes(data['device'])
|
65
|
+
|
66
|
+
true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Voxel
|
4
|
+
class Servers < Fog::Collection
|
5
|
+
model Fog::Compute::Voxel::Server
|
6
|
+
|
7
|
+
def all
|
8
|
+
data = service.devices_list.body['devices'].select {|device| device['type']['id'] == '3'}
|
9
|
+
load(data)
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(device_id)
|
13
|
+
if device_id && server = service.devices_list(device_id).body['devices']
|
14
|
+
new(server.first)
|
15
|
+
end
|
16
|
+
rescue Fog::Service::Error => error
|
17
|
+
if error.message == "The device_id passed in can't be matched to a valid device."
|
18
|
+
nil
|
19
|
+
else
|
20
|
+
raise error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Compute
|
4
|
+
module Voxel
|
5
|
+
autoload :Basic, 'fog/parsers/compute/voxel/basic'
|
6
|
+
autoload :DevicesList, 'fog/parsers/compute/voxel/devices_list'
|
7
|
+
autoload :ImagesList, 'fog/parsers/compute/voxel/images_list'
|
8
|
+
autoload :VoxcloudCreate, 'fog/parsers/compute/voxel/voxcloud_create'
|
9
|
+
autoload :VoxcloudDelete, 'fog/parsers/compute/voxel/voxcloud_delete'
|
10
|
+
autoload :Voxcloudstatus, 'fog/parsers/compute/voxel/voxcloud_status'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Compute
|
4
|
+
module Voxel
|
5
|
+
class Basic < Fog::Parsers::Base
|
6
|
+
def reset
|
7
|
+
@response = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def start_element(name, attrs = [])
|
11
|
+
super
|
12
|
+
|
13
|
+
case name
|
14
|
+
when 'err'
|
15
|
+
@response['err'] = {
|
16
|
+
'code' => attr_value('code', attrs),
|
17
|
+
'msg' => attr_value('msg', attrs)
|
18
|
+
}
|
19
|
+
when 'rsp'
|
20
|
+
@response['stat'] = attr_value('stat', attrs)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Compute
|
4
|
+
module Voxel
|
5
|
+
class DevicesList < Fog::Parsers::Base
|
6
|
+
def reset
|
7
|
+
@device = {}
|
8
|
+
@response = { 'devices' => [] }
|
9
|
+
@in_storage = false
|
10
|
+
end
|
11
|
+
|
12
|
+
def start_element(name, attrs = [])
|
13
|
+
super
|
14
|
+
|
15
|
+
case name
|
16
|
+
when 'accessmethod'
|
17
|
+
@access_method = { 'type' => attr_value('type', attrs) }
|
18
|
+
when 'accessmethods'
|
19
|
+
@device['access_methods'] = []
|
20
|
+
when 'device'
|
21
|
+
@device = {
|
22
|
+
'id' => attr_value('id', attrs),
|
23
|
+
'label' => attr_value('label', attrs),
|
24
|
+
'status' => attr_value('status', attrs)
|
25
|
+
}
|
26
|
+
when 'err'
|
27
|
+
@response['err'] = {
|
28
|
+
'code' => attr_value('code', attrs),
|
29
|
+
'msg' => attr_value('msg', attrs)
|
30
|
+
}
|
31
|
+
when 'cage', 'facility', 'rack', 'row', 'zone'
|
32
|
+
@device['location'][name] = { 'id' => attr_value('id', attrs) }
|
33
|
+
if code = attr_value('code', attrs)
|
34
|
+
@device['location'][name]['code'] = code
|
35
|
+
end
|
36
|
+
when 'drive'
|
37
|
+
@drive = { 'position' => attr_value('position', attrs) }
|
38
|
+
when 'ipassignment'
|
39
|
+
type = attr_value('type', attrs)
|
40
|
+
@device['ipassignments'] = []
|
41
|
+
@device['ipassignments'] << {
|
42
|
+
'id' => attr_value('id', attrs),
|
43
|
+
'type' => attr_value('type', attrs),
|
44
|
+
'description' => attr_value('description', attrs),
|
45
|
+
}
|
46
|
+
when 'ipassignments'
|
47
|
+
@device['ipassignments'] = {}
|
48
|
+
when 'location'
|
49
|
+
@device['location'] = {}
|
50
|
+
when 'memory'
|
51
|
+
@device['memory'] = { 'size' => attr_value('size', attrs).to_i }
|
52
|
+
when 'model', 'type'
|
53
|
+
@device[name] = { 'id' => attr_value('id', attrs) }
|
54
|
+
when 'operating_system'
|
55
|
+
@device['operating_system'] = {}
|
56
|
+
when 'power_consumption'
|
57
|
+
@device[name] = attr_value('unit', attrs)
|
58
|
+
when 'processor'
|
59
|
+
@device['processor'] = {}
|
60
|
+
when 'rsp'
|
61
|
+
@response['stat'] = attr_value('stat', attrs)
|
62
|
+
when 'storage'
|
63
|
+
@device['drives'] = []
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def end_element(name)
|
68
|
+
case name
|
69
|
+
when 'access_method'
|
70
|
+
@device['access_methods'] << @access_method
|
71
|
+
when 'architecture'
|
72
|
+
@device['operating_system'][name] = value.to_i
|
73
|
+
when 'cage', 'facility', 'rack', 'row', 'zone'
|
74
|
+
@device['location'][name]['value'] = value
|
75
|
+
when 'cores'
|
76
|
+
@device['processor'][name] = value.to_i
|
77
|
+
when 'description'
|
78
|
+
@device[name] = value
|
79
|
+
when 'device'
|
80
|
+
@response['devices'] << @device
|
81
|
+
@device = {}
|
82
|
+
when 'drive'
|
83
|
+
@device['drives'] << @drive
|
84
|
+
@drive = {}
|
85
|
+
when 'cores'
|
86
|
+
@device['processing_cores'] = value.to_i
|
87
|
+
when 'ipassignment'
|
88
|
+
@device['ipassignments'].last['value'] = value
|
89
|
+
when 'model', 'type'
|
90
|
+
@device[name]['value'] = value
|
91
|
+
when 'name'
|
92
|
+
@device['operating_system'][name] = value
|
93
|
+
when 'position'
|
94
|
+
@device['location'][name] = value
|
95
|
+
when 'power_consumption'
|
96
|
+
@device[name] = [value, @device[name]].join(' ')
|
97
|
+
when 'size'
|
98
|
+
@drive[name] = value.to_i
|
99
|
+
when 'host', 'password', 'protocol', 'username'
|
100
|
+
@access_method[name] = value
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Compute
|
4
|
+
module Voxel
|
5
|
+
class ImagesList < Fog::Parsers::Base
|
6
|
+
def reset
|
7
|
+
@image = {}
|
8
|
+
@response = { 'images' => [] }
|
9
|
+
end
|
10
|
+
|
11
|
+
def start_element(name, attrs = [])
|
12
|
+
super
|
13
|
+
|
14
|
+
case name
|
15
|
+
when 'err'
|
16
|
+
@response['err'] = {
|
17
|
+
'code' => attr_value('code', attrs),
|
18
|
+
'msg' => attr_value('msg', attrs)
|
19
|
+
}
|
20
|
+
when 'size'
|
21
|
+
@image['filesystem']['units'] = attr_value('units', attrs)
|
22
|
+
when 'image'
|
23
|
+
@image = {
|
24
|
+
'id' => attr_value('id', attrs).to_i,
|
25
|
+
'summary' => attr_value('summary', attrs)
|
26
|
+
}
|
27
|
+
when 'filesystem', 'operating_system'
|
28
|
+
@image[name] = {}
|
29
|
+
when 'rsp'
|
30
|
+
@response['stat'] = attr_value('stat', attrs)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def end_element(name)
|
35
|
+
case name
|
36
|
+
when 'architecture'
|
37
|
+
@image['operating_system'][name] = value.to_i
|
38
|
+
when 'admin_username', 'family', 'product_family', 'product_version', 'version'
|
39
|
+
@image['operating_system'][name] = value
|
40
|
+
when 'description'
|
41
|
+
@image[name] = value
|
42
|
+
when 'image'
|
43
|
+
@response['images'] << @image
|
44
|
+
@image = {}
|
45
|
+
when 'size'
|
46
|
+
@image['filesystem'][name] = value.to_i
|
47
|
+
when 'type'
|
48
|
+
@image['filesystem'][name] = value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|