fog-profitbricks 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/fog-profitbricks.gemspec +12 -11
- data/lib/fog/compute/profit_bricks.rb +217 -0
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/datacenter.rb +0 -2
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/datacenters.rb +1 -2
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/flavor.rb +0 -6
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/flavors.rb +1 -2
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/image.rb +0 -6
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/images.rb +1 -2
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/interface.rb +0 -6
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/interfaces.rb +1 -2
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/region.rb +0 -6
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/regions.rb +1 -2
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/server.rb +0 -8
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/servers.rb +1 -2
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/volume.rb +0 -6
- data/lib/fog/{profitbricks/models/compute → compute/profit_bricks/models}/volumes.rb +1 -2
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/clear_data_center.rb +0 -2
- data/lib/fog/compute/profit_bricks/requests/connect_storage_to_server.rb +83 -0
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/create_data_center.rb +1 -3
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/create_flavor.rb +2 -2
- data/lib/fog/compute/profit_bricks/requests/create_nic.rb +79 -0
- data/lib/fog/compute/profit_bricks/requests/create_server.rb +105 -0
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/create_storage.rb +4 -6
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/delete_data_center.rb +3 -5
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/delete_nic.rb +3 -5
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/delete_server.rb +2 -4
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/delete_storage.rb +2 -4
- data/lib/fog/compute/profit_bricks/requests/disconnect_storage_from_server.rb +76 -0
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_all_data_centers.rb +0 -1
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_all_flavors.rb +0 -0
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_all_images.rb +0 -2
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_all_locations.rb +0 -0
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_all_nic.rb +2 -4
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_all_servers.rb +0 -1
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_all_storages.rb +2 -4
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_data_center.rb +0 -2
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_data_center_state.rb +2 -3
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_flavor.rb +0 -0
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_image.rb +0 -2
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_location.rb +0 -0
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_nic.rb +0 -2
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_server.rb +0 -2
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/get_storage.rb +0 -2
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/reset_server.rb +0 -2
- data/lib/fog/compute/profit_bricks/requests/set_internet_access.rb +59 -0
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/start_server.rb +0 -1
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/stop_server.rb +0 -1
- data/lib/fog/{profitbricks/requests/compute → compute/profit_bricks/requests}/update_data_center.rb +3 -4
- data/lib/fog/compute/profit_bricks/requests/update_nic.rb +74 -0
- data/lib/fog/compute/profit_bricks/requests/update_server.rb +79 -0
- data/lib/fog/compute/profit_bricks/requests/update_storage.rb +73 -0
- data/lib/fog/{profitbricks/models → models/profit_bricks}/base.rb +0 -0
- data/lib/fog/parsers/compute.rb +37 -0
- data/lib/fog/parsers/compute/profit_bricks/base.rb +51 -0
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/clear_data_center.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/connect_storage_to_server.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/create_data_center.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/create_nic.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/create_server.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/create_storage.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/delete_data_center.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/delete_nic.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/delete_server.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/delete_storage.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/disconnect_storage_from_server.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_all_data_centers.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_all_images.rb +2 -2
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_all_nic.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_all_servers.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_all_storages.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_data_center.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_data_center_state.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_image.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_nic.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_server.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_storage.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/reset_server.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/set_internet_access.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/update_data_center.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/update_nic.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/update_server.rb +1 -1
- data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/update_storage.rb +1 -1
- data/lib/fog/profitbricks.rb +32 -4
- data/lib/fog/profitbricks/compute.rb +1 -215
- data/lib/fog/profitbricks/storage.rb +1 -0
- data/lib/fog/profitbricks/version.rb +1 -1
- metadata +107 -103
- data/lib/fog/profitbricks/core.rb +0 -18
- data/lib/fog/profitbricks/parsers/base.rb +0 -49
- data/lib/fog/profitbricks/requests/compute/connect_storage_to_server.rb +0 -85
- data/lib/fog/profitbricks/requests/compute/create_nic.rb +0 -81
- data/lib/fog/profitbricks/requests/compute/create_server.rb +0 -107
- data/lib/fog/profitbricks/requests/compute/disconnect_storage_from_server.rb +0 -78
- data/lib/fog/profitbricks/requests/compute/set_internet_access.rb +0 -61
- data/lib/fog/profitbricks/requests/compute/update_nic.rb +0 -76
- data/lib/fog/profitbricks/requests/compute/update_server.rb +0 -81
- data/lib/fog/profitbricks/requests/compute/update_storage.rb +0 -75
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Compute
|
4
|
+
module ProfitBricks
|
5
|
+
autoload :Base, File.expand_path('../compute/profit_bricks/base', __FILE__)
|
6
|
+
autoload :ClearDataCenter, File.expand_path('../compute/profit_bricks/clear_data_center', __FILE__)
|
7
|
+
autoload :ConnectStorageToServer, File.expand_path('../compute/profit_bricks/connect_storage_to_server', __FILE__)
|
8
|
+
autoload :CreateDataCenter, File.expand_path('../compute/profit_bricks/create_data_center', __FILE__)
|
9
|
+
autoload :CreateNic, File.expand_path('../compute/profit_bricks/create_nic', __FILE__)
|
10
|
+
autoload :CreateServer, File.expand_path('../compute/profit_bricks/create_server', __FILE__)
|
11
|
+
autoload :CreateStorage, File.expand_path('../compute/profit_bricks/create_storage', __FILE__)
|
12
|
+
autoload :DeleteDataCenter, File.expand_path('../compute/profit_bricks/delete_data_center', __FILE__)
|
13
|
+
autoload :DeleteNic, File.expand_path('../compute/profit_bricks/delete_nic', __FILE__)
|
14
|
+
autoload :DeleteServer, File.expand_path('../compute/profit_bricks/delete_server', __FILE__)
|
15
|
+
autoload :DeleteStorage, File.expand_path('../compute/profit_bricks/DeleteStorage', __FILE__)
|
16
|
+
autoload :DisconnectStorageFromServer, File.expand_path('../compute/profit_bricks/disconnect_storage_from_server', __FILE__)
|
17
|
+
autoload :GetAllDataCenters, File.expand_path('../compute/profit_bricks/get_all_data_centers', __FILE__)
|
18
|
+
autoload :GetAllImages, File.expand_path('../compute/profit_bricks/get_all_images', __FILE__)
|
19
|
+
autoload :GetAllNic, File.expand_path('../compute/profit_bricks/get_all_nic', __FILE__)
|
20
|
+
autoload :GetAllServers, File.expand_path('../compute/profit_bricks/get_all_servers', __FILE__)
|
21
|
+
autoload :GetAllStorages, File.expand_path('../compute/profit_bricks/get_all_storages', __FILE__)
|
22
|
+
autoload :GetDataCenter, File.expand_path('../compute/profit_bricks/get_data_center', __FILE__)
|
23
|
+
autoload :GetDataCenterState, File.expand_path('../compute/profit_bricks/get_data_center_state', __FILE__)
|
24
|
+
autoload :GetImage, File.expand_path('../compute/profit_bricks/get_image', __FILE__)
|
25
|
+
autoload :GetNic, File.expand_path('../compute/profit_bricks/get_nic', __FILE__)
|
26
|
+
autoload :GetServer, File.expand_path('../compute/profit_bricks/get_server', __FILE__)
|
27
|
+
autoload :GetStorage, File.expand_path('../compute/profit_bricks/get_storage', __FILE__)
|
28
|
+
autoload :ResetServer, File.expand_path('../compute/profit_bricks/reset_server', __FILE__)
|
29
|
+
autoload :SetInternetAccess, File.expand_path('../compute/profit_bricks/set_internet_access', __FILE__)
|
30
|
+
autoload :UpdateDataCenter, File.expand_path('../compute/profit_bricks/update_data_center', __FILE__)
|
31
|
+
autoload :UpdateNic, File.expand_path('../compute/profit_bricks/update_nic', __FILE__)
|
32
|
+
autoload :UpdateServer, File.expand_path('../compute/profit_bricks/update_server', __FILE__)
|
33
|
+
autoload :UpdateStorage, File.expand_path('../compute/profit_bricks/update_storage', __FILE__)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Parsers
|
5
|
+
module Compute
|
6
|
+
module ProfitBricks
|
7
|
+
class Base < Nokogiri::XML::SAX::Document
|
8
|
+
attr_reader :response
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
reset
|
12
|
+
end
|
13
|
+
|
14
|
+
def attr_value(name, attrs)
|
15
|
+
(entry = attrs.find {|a, v| a == name }) && entry.last
|
16
|
+
end
|
17
|
+
|
18
|
+
def reset
|
19
|
+
@response = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def characters(string)
|
23
|
+
@value ||= ''
|
24
|
+
@value << string
|
25
|
+
end
|
26
|
+
|
27
|
+
# ###############################################################################
|
28
|
+
# This is a workaround. Original implementation from Nokogiri is overwritten with
|
29
|
+
# one that does not join namespace prefix with local name.
|
30
|
+
def start_element_namespace name, attrs = [], prefix = nil, uri = nil, ns = []
|
31
|
+
start_element name, attrs
|
32
|
+
end
|
33
|
+
|
34
|
+
def end_element_namespace name, prefix = nil, uri = nil
|
35
|
+
end_element name
|
36
|
+
end
|
37
|
+
|
38
|
+
# ###############################################################################
|
39
|
+
|
40
|
+
def start_element(name, attrs = [])
|
41
|
+
@value = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def value
|
45
|
+
@value && @value.dup
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module Parsers
|
3
3
|
module Compute
|
4
4
|
module ProfitBricks
|
5
|
-
class ConnectStorageToServer < Fog::Parsers::ProfitBricks::Base
|
5
|
+
class ConnectStorageToServer < Fog::Parsers::Compute::ProfitBricks::Base
|
6
6
|
def reset
|
7
7
|
@response = { 'connectStorageToServerResponse' => {} }
|
8
8
|
end
|
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module Parsers
|
3
3
|
module Compute
|
4
4
|
module ProfitBricks
|
5
|
-
class DisconnectStorageFromServer < Fog::Parsers::ProfitBricks::Base
|
5
|
+
class DisconnectStorageFromServer < Fog::Parsers::Compute::ProfitBricks::Base
|
6
6
|
def reset
|
7
7
|
@response = { 'disconnectStorageFromServerResponse' => {} }
|
8
8
|
end
|
data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_all_data_centers.rb
RENAMED
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module Parsers
|
3
3
|
module Compute
|
4
4
|
module ProfitBricks
|
5
|
-
class GetAllDataCenters < Fog::Parsers::ProfitBricks::Base
|
5
|
+
class GetAllDataCenters < Fog::Parsers::Compute::ProfitBricks::Base
|
6
6
|
def reset
|
7
7
|
@datacenter = {}
|
8
8
|
@response = { 'getAllDataCentersResponse' => [] }
|
data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_all_images.rb
RENAMED
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module Parsers
|
3
3
|
module Compute
|
4
4
|
module ProfitBricks
|
5
|
-
class GetAllImages < Fog::Parsers::ProfitBricks::Base
|
5
|
+
class GetAllImages < Fog::Parsers::Compute::ProfitBricks::Base
|
6
6
|
def reset
|
7
7
|
@image = {}
|
8
8
|
@response = { 'getAllImagesResponse' => [] }
|
@@ -15,7 +15,7 @@ module Fog
|
|
15
15
|
'cpuHotUnPlug', 'ramHotPlug', 'ramHotUnPlug',
|
16
16
|
'discVirtioHotPlug', 'discVirtioHotUnPlug', 'public',
|
17
17
|
'nicHotPlug', 'nicHotUnPlug', 'bootable', 'location'
|
18
|
-
|
18
|
+
@image[name] = value
|
19
19
|
when 'imageSize'
|
20
20
|
@image[name] = value.to_i
|
21
21
|
when 'return'
|
data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_all_servers.rb
RENAMED
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module Parsers
|
3
3
|
module Compute
|
4
4
|
module ProfitBricks
|
5
|
-
class GetAllServers < Fog::Parsers::ProfitBricks::Base
|
5
|
+
class GetAllServers < Fog::Parsers::Compute::ProfitBricks::Base
|
6
6
|
def reset
|
7
7
|
@response = { 'getAllServersResponse' => [] }
|
8
8
|
@server = { 'connectedStorages' => [], 'nics' => [] }
|
data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_all_storages.rb
RENAMED
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module Parsers
|
3
3
|
module Compute
|
4
4
|
module ProfitBricks
|
5
|
-
class GetAllStorages < Fog::Parsers::ProfitBricks::Base
|
5
|
+
class GetAllStorages < Fog::Parsers::Compute::ProfitBricks::Base
|
6
6
|
def reset
|
7
7
|
@storage = { 'mountImage' => {} }
|
8
8
|
@response = { 'getAllStoragesResponse' => [] }
|
data/lib/fog/{profitbricks/parsers/compute → parsers/compute/profit_bricks}/get_data_center_state.rb
RENAMED
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module Parsers
|
3
3
|
module Compute
|
4
4
|
module ProfitBricks
|
5
|
-
class GetDataCenterState < Fog::Parsers::ProfitBricks::Base
|
5
|
+
class GetDataCenterState < Fog::Parsers::Compute::ProfitBricks::Base
|
6
6
|
def reset
|
7
7
|
@response = { 'getDataCenterStateResponse' => {} }
|
8
8
|
end
|
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module Parsers
|
3
3
|
module Compute
|
4
4
|
module ProfitBricks
|
5
|
-
class GetNic < Fog::Parsers::ProfitBricks::Base
|
5
|
+
class GetNic < Fog::Parsers::Compute::ProfitBricks::Base
|
6
6
|
def reset
|
7
7
|
@response = { 'getNicResponse' => {} }
|
8
8
|
@response['getNicResponse']['firewall'] = {}
|
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module Parsers
|
3
3
|
module Compute
|
4
4
|
module ProfitBricks
|
5
|
-
class GetServer < Fog::Parsers::ProfitBricks::Base
|
5
|
+
class GetServer < Fog::Parsers::Compute::ProfitBricks::Base
|
6
6
|
def reset
|
7
7
|
@response = { 'getServerResponse' => {} }
|
8
8
|
@response['getServerResponse'] = {
|
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module Parsers
|
3
3
|
module Compute
|
4
4
|
module ProfitBricks
|
5
|
-
class GetStorage < Fog::Parsers::ProfitBricks::Base
|
5
|
+
class GetStorage < Fog::Parsers::Compute::ProfitBricks::Base
|
6
6
|
def reset
|
7
7
|
@response = { 'getStorageResponse' => {} }
|
8
8
|
@response['getStorageResponse']['mountImage'] = {}
|
data/lib/fog/profitbricks.rb
CHANGED
@@ -1,13 +1,41 @@
|
|
1
1
|
require "fog/core"
|
2
2
|
require "fog/xml"
|
3
|
-
|
4
|
-
require
|
5
|
-
require "fog/profitbricks/compute"
|
6
|
-
require "fog/profitbricks/parsers/base"
|
3
|
+
|
4
|
+
require File.expand_path('../profitbricks/version', __FILE__)
|
7
5
|
|
8
6
|
module Fog
|
7
|
+
module Compute
|
8
|
+
autoload :ProfitBricks, File.expand_path('../compute/profit_bricks', __FILE__)
|
9
|
+
end
|
10
|
+
|
11
|
+
module Models
|
12
|
+
module ProfitBricks
|
13
|
+
autoload :Base, File.expand_path('../models/profit_bricks/base', __FILE__)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Parsers
|
18
|
+
autoload :Compute, File.expand_path('../parsers/compute', __FILE__)
|
19
|
+
end
|
20
|
+
|
9
21
|
module ProfitBricks
|
10
22
|
extend Fog::Provider
|
23
|
+
|
11
24
|
service(:compute, "Compute")
|
25
|
+
|
26
|
+
def self.construct_envelope(&block)
|
27
|
+
namespaces = {
|
28
|
+
"xmlns" => "",
|
29
|
+
"xmlns:soapenv" => "http://schemas.xmlsoap.org/soap/envelope/",
|
30
|
+
"xmlns:ws" => "http://ws.api.profitbricks.com/"
|
31
|
+
}
|
32
|
+
|
33
|
+
Nokogiri::XML::Builder.new do |xml|
|
34
|
+
xml[:soapenv].Envelope(namespaces) do
|
35
|
+
xml[:soapenv].Header
|
36
|
+
xml[:soapenv].Body(&block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
12
40
|
end
|
13
41
|
end
|
@@ -1,215 +1 @@
|
|
1
|
-
|
2
|
-
module Compute
|
3
|
-
class ProfitBricks < Fog::Service
|
4
|
-
API_VERSION = '1.3'
|
5
|
-
|
6
|
-
requires :profitbricks_username, :profitbricks_password
|
7
|
-
recognizes :profitbricks_url
|
8
|
-
|
9
|
-
# Models
|
10
|
-
model_path 'fog/profitbricks/models/compute'
|
11
|
-
model :server
|
12
|
-
collection :servers
|
13
|
-
model :datacenter
|
14
|
-
collection :datacenters
|
15
|
-
model :region
|
16
|
-
collection :regions
|
17
|
-
model :image
|
18
|
-
collection :images
|
19
|
-
model :flavor
|
20
|
-
collection :flavors
|
21
|
-
model :volume
|
22
|
-
collection :volumes
|
23
|
-
model :interface
|
24
|
-
collection :interfaces
|
25
|
-
|
26
|
-
# Requests
|
27
|
-
request_path 'fog/profitbricks/requests/compute'
|
28
|
-
request :create_server # createServer
|
29
|
-
request :delete_server # deleteServer
|
30
|
-
request :update_server # updateServer
|
31
|
-
request :get_all_servers # getAllServers
|
32
|
-
request :get_server # getServer
|
33
|
-
request :reset_server # resetServer
|
34
|
-
request :start_server # startServer
|
35
|
-
request :stop_server # stopServer
|
36
|
-
|
37
|
-
request :clear_data_center # clearDataCenter
|
38
|
-
request :create_data_center # createDataCenter
|
39
|
-
request :delete_data_center # deleteDataCenter
|
40
|
-
request :update_data_center # updateDataCenter
|
41
|
-
request :get_all_data_centers # getAllDataCenters
|
42
|
-
request :get_data_center # getDataCenter
|
43
|
-
request :get_data_center_state # getDataCenterState
|
44
|
-
|
45
|
-
request :get_all_locations # getAllLocations
|
46
|
-
request :get_location # getLocation
|
47
|
-
|
48
|
-
request :get_all_images # getAllImages
|
49
|
-
request :get_image # getImage
|
50
|
-
|
51
|
-
request :get_all_flavors # getAllFlavors
|
52
|
-
request :get_flavor # getFlavor
|
53
|
-
request :create_flavor # createFlavor
|
54
|
-
|
55
|
-
request :create_storage # createStorage
|
56
|
-
request :delete_storage # deleteStorage
|
57
|
-
request :update_storage # updateStorage
|
58
|
-
request :get_all_storages # getAllStorages
|
59
|
-
request :get_storage # getStorage
|
60
|
-
request :connect_storage_to_server # connectStorageToServer
|
61
|
-
request :disconnect_storage_from_server # disconnectStorageFromServer
|
62
|
-
|
63
|
-
request :create_nic # createNic
|
64
|
-
request :delete_nic # deleteNic
|
65
|
-
request :update_nic # updateNic
|
66
|
-
request :get_all_nic # getAllNic
|
67
|
-
request :get_nic # getNic
|
68
|
-
request :set_internet_access # setInternetAccess
|
69
|
-
|
70
|
-
class Real
|
71
|
-
def initialize(options={})
|
72
|
-
@profitbricks_username = options[:profitbricks_username]
|
73
|
-
@profitbricks_password = options[:profitbricks_password]
|
74
|
-
@profitbricks_url = options[:profitbricks_url] ||
|
75
|
-
"https://api.profitbricks.com/#{API_VERSION}"
|
76
|
-
|
77
|
-
@connection = Fog::XML::Connection.new(@profitbricks_url, false)
|
78
|
-
end
|
79
|
-
|
80
|
-
def request(params)
|
81
|
-
begin
|
82
|
-
response = @connection.request(params.merge({
|
83
|
-
:headers => {
|
84
|
-
'Authorization' => "Basic #{auth_header}"
|
85
|
-
}.merge!(params[:headers] || {})
|
86
|
-
}))
|
87
|
-
rescue Excon::Errors::Unauthorized => error
|
88
|
-
raise error
|
89
|
-
rescue Excon::Errors::HTTPStatusError => error
|
90
|
-
raise error
|
91
|
-
rescue Excon::Errors::InternalServerError => error
|
92
|
-
raise error
|
93
|
-
end
|
94
|
-
response
|
95
|
-
end
|
96
|
-
|
97
|
-
private
|
98
|
-
|
99
|
-
def auth_header
|
100
|
-
return Base64.encode64(
|
101
|
-
"#{@profitbricks_username}:#{@profitbricks_password}"
|
102
|
-
).delete("\r\n")
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
class Mock
|
107
|
-
def self.data
|
108
|
-
@data ||= Hash.new do |hash, key|
|
109
|
-
hash[key] = {
|
110
|
-
:servers => [],
|
111
|
-
:datacenters => [],
|
112
|
-
:regions =>
|
113
|
-
[
|
114
|
-
{
|
115
|
-
'locationId' => 'c0420cc0-90e8-4f4b-8860-df0a07d18047',
|
116
|
-
'locationName' => 'de/fkb',
|
117
|
-
'country' => 'DEU'
|
118
|
-
},
|
119
|
-
{
|
120
|
-
'locationId' => '68c4099a-d9d8-4683-bdc2-12789aacfa2a',
|
121
|
-
'locationName' => 'de/fra',
|
122
|
-
'country' => 'DEU'
|
123
|
-
},
|
124
|
-
{
|
125
|
-
'locationId' => 'e102ba74-6764-47f3-8896-246141da8ada',
|
126
|
-
'locationName' => 'us/las',
|
127
|
-
'country' => 'USA'
|
128
|
-
}
|
129
|
-
],
|
130
|
-
:images =>
|
131
|
-
[
|
132
|
-
{
|
133
|
-
'imageId' => 'ece948c0-14f8-4d49-8bdc-b966b746b6f9',
|
134
|
-
'imageName' => 'CentOS-6.5-x86_64-netinstall.iso',
|
135
|
-
'imageType' => 'CDROM',
|
136
|
-
'imageSize' => 244,
|
137
|
-
'bootable' => 'true',
|
138
|
-
'cpuHotPlug' => 'false',
|
139
|
-
'cpuHotUnPlug' => 'false',
|
140
|
-
'ramHotPlug' => 'false',
|
141
|
-
'ramHotUnPlug' => 'false',
|
142
|
-
'discVirtioHotPlug' => 'false',
|
143
|
-
'discVirtioHotUnPlug' => 'false',
|
144
|
-
'nicHotPlug' => 'false',
|
145
|
-
'nicHotUnPlug' => 'false',
|
146
|
-
'osType' => 'LINUX',
|
147
|
-
'serverIds' => nil,
|
148
|
-
'writeable' => 'true',
|
149
|
-
'location' => 'us/las',
|
150
|
-
'public' => 'true'
|
151
|
-
},
|
152
|
-
{
|
153
|
-
'imageId' => 'cc43d811-c423-402c-8bd0-6a04073a65ca',
|
154
|
-
'imageName' => 'CentOS-6-server',
|
155
|
-
'imageType' => 'HDD',
|
156
|
-
'imageSize' => 11264,
|
157
|
-
'bootable' => 'true',
|
158
|
-
'cpuHotPlug' => 'false',
|
159
|
-
'cpuHotUnPlug' => 'false',
|
160
|
-
'ramHotPlug' => 'false',
|
161
|
-
'ramHotUnPlug' => 'false',
|
162
|
-
'discVirtioHotPlug' => 'false',
|
163
|
-
'discVirtioHotUnPlug' => 'false',
|
164
|
-
'nicHotPlug' => 'false',
|
165
|
-
'nicHotUnPlug' => 'false',
|
166
|
-
'osType' => 'LINUX',
|
167
|
-
'serverIds' => nil,
|
168
|
-
'writeable' => 'true',
|
169
|
-
'location' => 'us/las',
|
170
|
-
'public' => 'true'
|
171
|
-
}
|
172
|
-
],
|
173
|
-
:flavors =>
|
174
|
-
[
|
175
|
-
{
|
176
|
-
'flavorId' => Fog::UUID.uuid,
|
177
|
-
'flavorName' => 'Micro',
|
178
|
-
'ram' => 1024,
|
179
|
-
'disk' => 50,
|
180
|
-
'cores' => 1
|
181
|
-
},
|
182
|
-
{
|
183
|
-
'flavorId' => Fog::UUID.uuid,
|
184
|
-
'flavorName' => 'Small',
|
185
|
-
'ram' => 2048,
|
186
|
-
'disk' => 50,
|
187
|
-
'cores' => 1
|
188
|
-
}
|
189
|
-
],
|
190
|
-
:volumes => [],
|
191
|
-
:interfaces => []
|
192
|
-
}
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
def self.reset
|
197
|
-
@data = nil
|
198
|
-
end
|
199
|
-
|
200
|
-
def initialize(options={})
|
201
|
-
@profitbricks_username = options[:profitbricks_username]
|
202
|
-
@profitbricks_password = options[:profitbricks_password]
|
203
|
-
end
|
204
|
-
|
205
|
-
def data
|
206
|
-
self.class.data[@profitbricks_username]
|
207
|
-
end
|
208
|
-
|
209
|
-
def reset_data
|
210
|
-
self.class.data.delete(@profitbricks_username)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
1
|
+
# This file is intentionally left blank
|