fog-fifo 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +9 -0
- data/README.md +3 -0
- data/examples/test.rb +16 -0
- data/fog-fifo.gemspec +19 -0
- data/lib/fog/fifo/compute.rb +215 -0
- data/lib/fog/fifo/models/compute/dataset.rb +17 -0
- data/lib/fog/fifo/models/compute/datasets.rb +25 -0
- data/lib/fog/fifo/models/compute/iprange.rb +20 -0
- data/lib/fog/fifo/models/compute/ipranges.rb +21 -0
- data/lib/fog/fifo/models/compute/keys.rb +33 -0
- data/lib/fog/fifo/models/compute/network.rb +14 -0
- data/lib/fog/fifo/models/compute/networks.rb +21 -0
- data/lib/fog/fifo/models/compute/package.rb +17 -0
- data/lib/fog/fifo/models/compute/packages.rb +25 -0
- data/lib/fog/fifo/models/compute/server.rb +67 -0
- data/lib/fog/fifo/models/compute/servers.rb +36 -0
- data/lib/fog/fifo/requests/compute/create_vm.rb +31 -0
- data/lib/fog/fifo/requests/compute/get_dataset.rb +28 -0
- data/lib/fog/fifo/requests/compute/get_iprange.rb +30 -0
- data/lib/fog/fifo/requests/compute/get_network.rb +30 -0
- data/lib/fog/fifo/requests/compute/get_package.rb +30 -0
- data/lib/fog/fifo/requests/compute/get_vm.rb +29 -0
- data/lib/fog/fifo/requests/compute/list_datasets.rb +24 -0
- data/lib/fog/fifo/requests/compute/list_ipranges.rb +25 -0
- data/lib/fog/fifo/requests/compute/list_networks.rb +25 -0
- data/lib/fog/fifo/requests/compute/list_packages.rb +27 -0
- data/lib/fog/fifo/requests/compute/list_vms.rb +26 -0
- data/lib/fog/fifo/requests/compute/reboot_vm.rb +29 -0
- data/lib/fog/fifo/requests/compute/start_vm.rb +30 -0
- data/lib/fog/fifo/requests/compute/stop_vm.rb +30 -0
- data/lib/fog/fifo.rb +10 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 36b4e9f87e2cdc5911f01bf44a857b45c9813c4f
|
4
|
+
data.tar.gz: e31dee1fa24928a148d47fb9cedc1a7253917dc5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db94411dd1046cca9039ed96bcd8ab40b3c340736a3f447c70ceec2d8dc606f96659e6597648f17bd7b938b925a8fbf569fa789607731d8bbec25670d50cc587
|
7
|
+
data.tar.gz: 0135958f45ee3760ea5e53823ce35768f2033a4ce49ba28ab4ebb32bab65644cfd76854cd5a4e48b9f840570014a9a94d524011ca958c3cbd580a4bd0ab04e33
|
data/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2012 bakins (Brian Akins)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/examples/test.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
|
2
|
+
require 'fog/fifo'
|
3
|
+
require 'pp'
|
4
|
+
connection = Fog::Compute.new(
|
5
|
+
:provider => 'Fifo',
|
6
|
+
:fifo_username => ENV['FIFO_USERNAME'],
|
7
|
+
:fifo_password => ENV['FIFO_PASSWORD'],
|
8
|
+
:fifo_url => ENV['FIFO_URL']
|
9
|
+
)
|
10
|
+
|
11
|
+
pp connection.datasets.all
|
12
|
+
pp connection.packages.all
|
13
|
+
pp connection.networks.all
|
14
|
+
pp connection.ipranges.all
|
15
|
+
pp connection.servers.all
|
16
|
+
|
data/fog-fifo.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "fog-fifo"
|
5
|
+
spec.version = '0.1.0'
|
6
|
+
spec.authors = [ "Brian Akins" ]
|
7
|
+
spec.email = [ "brian@akins.org" ]
|
8
|
+
spec.description = %q{fifo support for fog}
|
9
|
+
spec.summary = spec.description
|
10
|
+
spec.homepage = "https://github.com/bakins/fog-fifo"
|
11
|
+
spec.license = "Apache 2.0"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
spec.required_ruby_version = ">= 1.9.1"
|
18
|
+
spec.add_dependency("fog", "~> 1.17")
|
19
|
+
end
|
@@ -0,0 +1,215 @@
|
|
1
|
+
require 'fog/fifo'
|
2
|
+
#require 'fog/joyent/errors'
|
3
|
+
require 'fog/compute'
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
module Fog
|
7
|
+
module Compute
|
8
|
+
class Fifo < Fog::Service
|
9
|
+
requires :fifo_username
|
10
|
+
|
11
|
+
requires :fifo_password
|
12
|
+
requires :fifo_url
|
13
|
+
|
14
|
+
model_path 'fog/fifo/models/compute'
|
15
|
+
request_path 'fog/fifo/requests/compute'
|
16
|
+
|
17
|
+
# Datasets
|
18
|
+
collection :datasets
|
19
|
+
model :dataset
|
20
|
+
request :list_datasets
|
21
|
+
request :get_dataset
|
22
|
+
|
23
|
+
# packages
|
24
|
+
collection :packages
|
25
|
+
model :package
|
26
|
+
request :list_packages
|
27
|
+
request :get_package
|
28
|
+
|
29
|
+
# Servers
|
30
|
+
collection :servers
|
31
|
+
model :server
|
32
|
+
request :list_vms
|
33
|
+
request :get_vm
|
34
|
+
request :reboot_vm
|
35
|
+
request :stop_vm
|
36
|
+
request :start_vm
|
37
|
+
request :create_vm
|
38
|
+
|
39
|
+
if false
|
40
|
+
request :create_machine
|
41
|
+
request :start_machine
|
42
|
+
request :stop_machine
|
43
|
+
request :resize_machine
|
44
|
+
request :delete_machine
|
45
|
+
end
|
46
|
+
|
47
|
+
# Networks
|
48
|
+
collection :networks
|
49
|
+
model :network
|
50
|
+
request :list_networks
|
51
|
+
request :get_network
|
52
|
+
|
53
|
+
# Ipranges
|
54
|
+
collection :ipranges
|
55
|
+
model :iprange
|
56
|
+
request :list_ipranges
|
57
|
+
request :get_iprange
|
58
|
+
|
59
|
+
class Mock
|
60
|
+
def self.data
|
61
|
+
@data ||= Hash.new do |hash, key|
|
62
|
+
hash[key] = {}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def data
|
67
|
+
self.class.data
|
68
|
+
end
|
69
|
+
|
70
|
+
def initialize(options = {})
|
71
|
+
@fifo_username = options[:fifo_username] || Fog.credentials[:fifo_username]
|
72
|
+
@fifo_password = options[:fifo_password] || Fog.credentials[:fifo_password]
|
73
|
+
end
|
74
|
+
|
75
|
+
def request(opts)
|
76
|
+
raise "Not Implemented"
|
77
|
+
end
|
78
|
+
end # Mock
|
79
|
+
|
80
|
+
class Real
|
81
|
+
def initialize(options = {})
|
82
|
+
|
83
|
+
@connection_options = options[:connection_options] || {}
|
84
|
+
@persistent = options[:persistent] || false
|
85
|
+
|
86
|
+
@fifo_username = options[:fifo_username]
|
87
|
+
|
88
|
+
unless @fifo_username
|
89
|
+
raise ArgumentError, "options[:fifo_username] required"
|
90
|
+
end
|
91
|
+
|
92
|
+
@fifo_url = options[:fifo_url]
|
93
|
+
|
94
|
+
unless @fifo_url
|
95
|
+
raise ArgumentError, "options[:fifo_url] required"
|
96
|
+
end
|
97
|
+
|
98
|
+
@fifo_password = options[:fifo_password]
|
99
|
+
|
100
|
+
unless @fifo_password
|
101
|
+
raise ArgumentError, "options[:fifo_password] required"
|
102
|
+
end
|
103
|
+
|
104
|
+
@fifo_password = options[:fifo_password]
|
105
|
+
|
106
|
+
@fifo_token = nil
|
107
|
+
|
108
|
+
@fifo_uri = ::URI.parse(@fifo_url)
|
109
|
+
|
110
|
+
@connection = Fog::Connection.new(
|
111
|
+
@fifo_url,
|
112
|
+
@persistent,
|
113
|
+
@connection_options
|
114
|
+
)
|
115
|
+
authenticate
|
116
|
+
end
|
117
|
+
|
118
|
+
def authenticate
|
119
|
+
response = @connection.request({
|
120
|
+
:expects => [200, 204, 303],
|
121
|
+
#:host => @fifo_uri.host,
|
122
|
+
:method => 'POST',
|
123
|
+
:path => create_path('sessions'),
|
124
|
+
:headers => {
|
125
|
+
"Content-Type" => "application/json",
|
126
|
+
"Accept" => "application/json"
|
127
|
+
},
|
128
|
+
:body => Fog::JSON.encode({
|
129
|
+
"user" => @fifo_username,
|
130
|
+
"password" => @fifo_password
|
131
|
+
})
|
132
|
+
})
|
133
|
+
|
134
|
+
@fifo_token = response.headers["x-snarl-token"] || File.basename(response.headers["location"])
|
135
|
+
end
|
136
|
+
|
137
|
+
def request(opts = {})
|
138
|
+
opts[:headers] = {
|
139
|
+
"X-Api-Version" => @fifo_version,
|
140
|
+
"Content-Type" => "application/json",
|
141
|
+
"Accept" => "application/json",
|
142
|
+
"x-Snarl-Token" => @fifo_token
|
143
|
+
}.merge(opts[:headers] || {})
|
144
|
+
|
145
|
+
if opts[:body]
|
146
|
+
opts[:body] = Fog::JSON.encode(opts[:body])
|
147
|
+
end
|
148
|
+
|
149
|
+
opts[:path] = create_path(opts[:path])
|
150
|
+
response = @connection.request(opts)
|
151
|
+
if response.headers["Content-Type"] == "application/json"
|
152
|
+
response.body = json_decode(response.body)
|
153
|
+
end
|
154
|
+
|
155
|
+
#pp response
|
156
|
+
response
|
157
|
+
rescue Excon::Errors::HTTPStatusError => e
|
158
|
+
raise_if_error!(e.request, e.response)
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def create_path(path)
|
164
|
+
::File.join(@fifo_uri.path, path)
|
165
|
+
end
|
166
|
+
|
167
|
+
def json_decode(body)
|
168
|
+
parsed = Fog::JSON.decode(body)
|
169
|
+
decode_time_attrs(parsed)
|
170
|
+
end
|
171
|
+
|
172
|
+
def decode_time_attrs(obj)
|
173
|
+
if obj.kind_of?(Hash)
|
174
|
+
obj["created"] = Time.parse(obj["created"]) unless obj["created"].nil? or obj["created"] == ''
|
175
|
+
obj["updated"] = Time.parse(obj["updated"]) unless obj["updated"].nil? or obj["updated"] == ''
|
176
|
+
elsif obj.kind_of?(Array)
|
177
|
+
obj.map do |o|
|
178
|
+
decode_time_attrs(o)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
obj
|
183
|
+
end
|
184
|
+
|
185
|
+
def raise_if_error!(request, response)
|
186
|
+
case response.status
|
187
|
+
when 401 then
|
188
|
+
raise Fifo::Errors::Unauthorized.new('Invalid credentials were used', request, response)
|
189
|
+
when 403 then
|
190
|
+
raise Fifo::Errors::Forbidden.new('No permissions to the specified resource', request, response)
|
191
|
+
when 404 then
|
192
|
+
raise Fifo::Errors::NotFound.new('Requested resource was not found', request, response)
|
193
|
+
when 405 then
|
194
|
+
raise Fifo::Errors::MethodNotAllowed.new('Method not supported for the given resource', request, response)
|
195
|
+
when 406 then
|
196
|
+
raise Fifo::Errors::NotAcceptable.new('Try sending a different Accept header', request, response)
|
197
|
+
when 409 then
|
198
|
+
raise Fifo::Errors::Conflict.new('Most likely invalid or missing parameters', request, response)
|
199
|
+
when 414 then
|
200
|
+
raise Fifo::Errors::RequestEntityTooLarge.new('You sent too much data', request, response)
|
201
|
+
when 415 then
|
202
|
+
raise Fifo::Errors::UnsupportedMediaType.new('You encoded your request in a format we don\'t understand', request, response)
|
203
|
+
when 420 then
|
204
|
+
raise Fifo::Errors::PolicyNotForfilled.new('You are sending too many requests', request, response)
|
205
|
+
when 449 then
|
206
|
+
raise Fifo::Errors::RetryWith.new('Invalid API Version requested; try with a different API Version', request, response)
|
207
|
+
when 503 then
|
208
|
+
raise Fifo::Errors::ServiceUnavailable.new('Either there\'s no capacity in this datacenter, or we\'re in a maintenance window', request, response)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
end # Real
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/fifo/models/compute/dataset'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
|
7
|
+
class Fifo
|
8
|
+
class Datasets < Fog::Collection
|
9
|
+
|
10
|
+
model Fog::Compute::Fifo::Datasets
|
11
|
+
|
12
|
+
def all
|
13
|
+
service.list_datasets().body
|
14
|
+
end
|
15
|
+
|
16
|
+
def get(id)
|
17
|
+
data = service.get_dataset(id).body
|
18
|
+
new(data)
|
19
|
+
end
|
20
|
+
|
21
|
+
end # Images
|
22
|
+
end # Fifo
|
23
|
+
|
24
|
+
end # Compute
|
25
|
+
end # Fog
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
class Iprange < Fog::Model
|
5
|
+
identity :uuid
|
6
|
+
|
7
|
+
attribute :name
|
8
|
+
attribute :version
|
9
|
+
attribute :first
|
10
|
+
attribute :last
|
11
|
+
attribute :gateway
|
12
|
+
attribute :netmask
|
13
|
+
attribute :network
|
14
|
+
attribute :tag
|
15
|
+
attribute :vlan
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'fog/fifo/models/compute/iprange'
|
2
|
+
module Fog
|
3
|
+
module Compute
|
4
|
+
class Fifo
|
5
|
+
class Ipranges < Fog::Collection
|
6
|
+
|
7
|
+
model Fog::Compute::Fifo::Iprange
|
8
|
+
|
9
|
+
def all
|
10
|
+
service.list_ipranges().body.map{|id| get(id) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(id)
|
14
|
+
data = service.get_iprange(id).body
|
15
|
+
new(data)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#require 'fog/joyent/models/compute/key'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class Fifo
|
6
|
+
class Keys < Fog::Collection
|
7
|
+
|
8
|
+
model Fog::Compute::Fifo::Key
|
9
|
+
|
10
|
+
def all
|
11
|
+
data = service.list_keys.body
|
12
|
+
load(data)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(keyname)
|
16
|
+
data = service.get_key(keyname).body
|
17
|
+
if data
|
18
|
+
new(data)
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def create(params = {})
|
25
|
+
raise ArgumentError, "option [name] required" unless params.key?(:name)
|
26
|
+
raise ArgumentError, "option [key] required" unless params.key?(:key)
|
27
|
+
|
28
|
+
service.create_key(params)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'fog/fifo/models/compute/network'
|
2
|
+
module Fog
|
3
|
+
module Compute
|
4
|
+
class Fifo
|
5
|
+
class Networks < Fog::Collection
|
6
|
+
|
7
|
+
model Fog::Compute::Fifo::Network
|
8
|
+
|
9
|
+
def all
|
10
|
+
service.list_networks().body.map{|id| get(id) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(id)
|
14
|
+
data = service.get_network(id).body
|
15
|
+
new(data)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/fifo/models/compute/package'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
|
7
|
+
class Fifo
|
8
|
+
class Packages < Fog::Collection
|
9
|
+
|
10
|
+
model Fog::Compute::Fifo::Package
|
11
|
+
|
12
|
+
def all
|
13
|
+
service.list_packages().body.map{|id| get(id) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def get(id)
|
17
|
+
data = service.get_package(id).body
|
18
|
+
new(data)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end # Fifo
|
23
|
+
|
24
|
+
end # Compute
|
25
|
+
end # Fog
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'fog/compute/models/server'
|
2
|
+
module Fog
|
3
|
+
module Compute
|
4
|
+
class Fifo
|
5
|
+
|
6
|
+
class Server < Fog::Compute::Server
|
7
|
+
identity :uuid
|
8
|
+
|
9
|
+
attribute :state
|
10
|
+
attribute :hypervisor
|
11
|
+
attribute :config
|
12
|
+
attribute :package
|
13
|
+
attribute :network
|
14
|
+
|
15
|
+
def dataset
|
16
|
+
requires :uuid
|
17
|
+
config["dataset"]
|
18
|
+
end
|
19
|
+
|
20
|
+
#def package
|
21
|
+
# requires :uuid
|
22
|
+
# config["package"]
|
23
|
+
#end
|
24
|
+
|
25
|
+
def ips
|
26
|
+
requires :uuid
|
27
|
+
config["networks"].map{|n| n["ip"]}
|
28
|
+
end
|
29
|
+
|
30
|
+
def memory
|
31
|
+
requires :uuid
|
32
|
+
config["ram"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def reboot
|
36
|
+
requires :uuid
|
37
|
+
service.reboot_vm(uuid)
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
41
|
+
def stopped?
|
42
|
+
requires :uuid
|
43
|
+
self.state == 'stopped'
|
44
|
+
end
|
45
|
+
|
46
|
+
def stop
|
47
|
+
requires :uuid
|
48
|
+
service.stop_vm(uuid)
|
49
|
+
self.wait_for { stopped? }
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
def ready?
|
54
|
+
self.state == 'running'
|
55
|
+
end
|
56
|
+
|
57
|
+
def start
|
58
|
+
requires :uuid
|
59
|
+
service.start_vm(uuid)
|
60
|
+
self.wait_for { ready? }
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/fifo/models/compute/server'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
|
7
|
+
class Fifo
|
8
|
+
class Servers < Fog::Collection
|
9
|
+
model Fog::Compute::Fifo::Server
|
10
|
+
|
11
|
+
def all
|
12
|
+
service.list_vms().body.map{|id| get(id) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(params = {})
|
16
|
+
data = service.create_vm(params).body
|
17
|
+
server = new(data)
|
18
|
+
server
|
19
|
+
end
|
20
|
+
|
21
|
+
def bootstrap(new_attributes = {})
|
22
|
+
server = create(new_attributes)
|
23
|
+
server.wait_for { ready? }
|
24
|
+
server
|
25
|
+
end
|
26
|
+
|
27
|
+
def get(machine_id)
|
28
|
+
data = service.get_vm(machine_id).body
|
29
|
+
new(data)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end # Fifo
|
34
|
+
|
35
|
+
end # Compute
|
36
|
+
end # Fog
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def start_vm(uuid)
|
7
|
+
if vm = self.data[:vms][uuid]
|
8
|
+
res = Excon::Response.new
|
9
|
+
res.status = 200
|
10
|
+
res.body = vm
|
11
|
+
res
|
12
|
+
else
|
13
|
+
raise Excon::Errors::NotFound, "Not Found"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Real
|
19
|
+
def create_vm(params)
|
20
|
+
pp params
|
21
|
+
request(
|
22
|
+
:method => "POST",
|
23
|
+
:path => "vms",
|
24
|
+
:expects => [200],
|
25
|
+
:body => params
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def get_dataset(id)
|
7
|
+
if ds = self.data[:datasets][id]
|
8
|
+
res = Excon::Response.new
|
9
|
+
res.status = 200
|
10
|
+
res.body = ds
|
11
|
+
else
|
12
|
+
raise Excon::Errors::NotFound
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Real
|
18
|
+
def get_dataset(id)
|
19
|
+
request(
|
20
|
+
:method => "GET",
|
21
|
+
:path => "datasets/#{id}"
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
class Mock
|
5
|
+
|
6
|
+
def get_iprange(id)
|
7
|
+
if pkg = self.data[:iprange][id]
|
8
|
+
response = Excon::Response.new
|
9
|
+
response.body = pkg
|
10
|
+
response.status = 200
|
11
|
+
response
|
12
|
+
else
|
13
|
+
raise Excon::Errors::NotFound
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Real
|
19
|
+
def get_iprange(id)
|
20
|
+
request(
|
21
|
+
:method => "GET",
|
22
|
+
:path => "ipranges/#{id}",
|
23
|
+
:expects => 200
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
class Mock
|
5
|
+
|
6
|
+
def get_network(id)
|
7
|
+
if pkg = self.data[:networks][id]
|
8
|
+
response = Excon::Response.new
|
9
|
+
response.body = pkg
|
10
|
+
response.status = 200
|
11
|
+
response
|
12
|
+
else
|
13
|
+
raise Excon::Errors::NotFound
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Real
|
19
|
+
def get_network(id)
|
20
|
+
request(
|
21
|
+
:method => "GET",
|
22
|
+
:path => "networks/#{id}",
|
23
|
+
:expects => 200
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
class Mock
|
5
|
+
|
6
|
+
def get_package(id)
|
7
|
+
if pkg = self.data[:packages][id]
|
8
|
+
response = Excon::Response.new
|
9
|
+
response.body = pkg
|
10
|
+
response.status = 200
|
11
|
+
response
|
12
|
+
else
|
13
|
+
raise Excon::Errors::NotFound
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Real
|
19
|
+
def get_package(id)
|
20
|
+
request(
|
21
|
+
:method => "GET",
|
22
|
+
:path => "packages/#{id}",
|
23
|
+
:expects => 200
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def get_vm(uuid)
|
7
|
+
if vm = self.data[:vms][uuid]
|
8
|
+
res = Excon::Response.new
|
9
|
+
res.status = 200
|
10
|
+
res.body = vm
|
11
|
+
res
|
12
|
+
else
|
13
|
+
raise Excon::Errors::NotFound, "Not Found"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Real
|
19
|
+
def get_vm(id)
|
20
|
+
request(
|
21
|
+
:method => "GET",
|
22
|
+
:path => "vms/#{id}",
|
23
|
+
:expects => [200]
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def list_datasets
|
7
|
+
res = Excon::Response.new
|
8
|
+
res.status = 200
|
9
|
+
res.body = self.data[:datasets].values
|
10
|
+
res
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Real
|
15
|
+
def list_datasets
|
16
|
+
request(
|
17
|
+
:method => "GET",
|
18
|
+
:path => "datasets"
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def list_ipranges
|
7
|
+
res = Excon::Response.new
|
8
|
+
res.status = 200
|
9
|
+
res.body = self.data[:ipranges].values
|
10
|
+
res
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Real
|
15
|
+
def list_ipranges
|
16
|
+
request(
|
17
|
+
:path => "ipranges",
|
18
|
+
:method => "GET",
|
19
|
+
:expects => 200
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def list_networks
|
7
|
+
res = Excon::Response.new
|
8
|
+
res.status = 200
|
9
|
+
res.body = self.data[:networks].values
|
10
|
+
res
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Real
|
15
|
+
def list_networks
|
16
|
+
request(
|
17
|
+
:path => "networks",
|
18
|
+
:method => "GET",
|
19
|
+
:expects => 200
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def list_packages
|
7
|
+
response = Excon::Response.new()
|
8
|
+
response.status = 200
|
9
|
+
response.body = self.data[:packages].values
|
10
|
+
response
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Real
|
15
|
+
def list_packages
|
16
|
+
request(
|
17
|
+
:path => "packages",
|
18
|
+
:method => "GET",
|
19
|
+
:expects => 200
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def list_vm
|
7
|
+
res = Excon::Response.new
|
8
|
+
res.status = 200
|
9
|
+
res.body = self.data[:machines].values
|
10
|
+
res
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Real
|
15
|
+
def list_vms(options={})
|
16
|
+
request(
|
17
|
+
:path => "vms",
|
18
|
+
:method => "GET",
|
19
|
+
:query => options,
|
20
|
+
:expects => 200
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def remoot_vm(uuid)
|
7
|
+
if vm = self.data[:vms][uuid]
|
8
|
+
res = Excon::Response.new
|
9
|
+
res.status = 200
|
10
|
+
res
|
11
|
+
else
|
12
|
+
raise Excon::Errors::NotFound, "Not Found"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Real
|
18
|
+
def reboot_vm(id)
|
19
|
+
request(
|
20
|
+
:method => "PUT",
|
21
|
+
:path => "vms/#{id}",
|
22
|
+
:expects => [200],
|
23
|
+
:body => {"action" => "reboot"},
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def start_vm(uuid)
|
7
|
+
if vm = self.data[:vms][uuid]
|
8
|
+
res = Excon::Response.new
|
9
|
+
res.status = 200
|
10
|
+
res.body = vm
|
11
|
+
res
|
12
|
+
else
|
13
|
+
raise Excon::Errors::NotFound, "Not Found"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Real
|
19
|
+
def start_vm(id)
|
20
|
+
request(
|
21
|
+
:method => "PUT",
|
22
|
+
:path => "vms/#{id}",
|
23
|
+
:expects => [200],
|
24
|
+
:body => {"action" => "start"},
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Fifo
|
4
|
+
|
5
|
+
class Mock
|
6
|
+
def stop_vm(uuid)
|
7
|
+
if vm = self.data[:vms][uuid]
|
8
|
+
res = Excon::Response.new
|
9
|
+
res.status = 200
|
10
|
+
res.body = vm
|
11
|
+
res
|
12
|
+
else
|
13
|
+
raise Excon::Errors::NotFound, "Not Found"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Real
|
19
|
+
def stop_vm(id)
|
20
|
+
request(
|
21
|
+
:method => "PUT",
|
22
|
+
:path => "vms/#{id}",
|
23
|
+
:expects => [200],
|
24
|
+
:body => {"action" => "stop"},
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/fog/fifo.rb
ADDED
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fog-fifo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Akins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fog
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
description: fifo support for fog
|
28
|
+
email:
|
29
|
+
- brian@akins.org
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- examples/test.rb
|
37
|
+
- fog-fifo.gemspec
|
38
|
+
- lib/fog/fifo.rb
|
39
|
+
- lib/fog/fifo/compute.rb
|
40
|
+
- lib/fog/fifo/models/compute/dataset.rb
|
41
|
+
- lib/fog/fifo/models/compute/datasets.rb
|
42
|
+
- lib/fog/fifo/models/compute/iprange.rb
|
43
|
+
- lib/fog/fifo/models/compute/ipranges.rb
|
44
|
+
- lib/fog/fifo/models/compute/keys.rb
|
45
|
+
- lib/fog/fifo/models/compute/network.rb
|
46
|
+
- lib/fog/fifo/models/compute/networks.rb
|
47
|
+
- lib/fog/fifo/models/compute/package.rb
|
48
|
+
- lib/fog/fifo/models/compute/packages.rb
|
49
|
+
- lib/fog/fifo/models/compute/server.rb
|
50
|
+
- lib/fog/fifo/models/compute/servers.rb
|
51
|
+
- lib/fog/fifo/requests/compute/create_vm.rb
|
52
|
+
- lib/fog/fifo/requests/compute/get_dataset.rb
|
53
|
+
- lib/fog/fifo/requests/compute/get_iprange.rb
|
54
|
+
- lib/fog/fifo/requests/compute/get_network.rb
|
55
|
+
- lib/fog/fifo/requests/compute/get_package.rb
|
56
|
+
- lib/fog/fifo/requests/compute/get_vm.rb
|
57
|
+
- lib/fog/fifo/requests/compute/list_datasets.rb
|
58
|
+
- lib/fog/fifo/requests/compute/list_ipranges.rb
|
59
|
+
- lib/fog/fifo/requests/compute/list_networks.rb
|
60
|
+
- lib/fog/fifo/requests/compute/list_packages.rb
|
61
|
+
- lib/fog/fifo/requests/compute/list_vms.rb
|
62
|
+
- lib/fog/fifo/requests/compute/reboot_vm.rb
|
63
|
+
- lib/fog/fifo/requests/compute/start_vm.rb
|
64
|
+
- lib/fog/fifo/requests/compute/stop_vm.rb
|
65
|
+
homepage: https://github.com/bakins/fog-fifo
|
66
|
+
licenses:
|
67
|
+
- Apache 2.0
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.9.1
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.0.14
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: fifo support for fog
|
89
|
+
test_files: []
|
90
|
+
has_rdoc:
|