fog-profitbricks 0.0.5 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1465 -4
- data/Rakefile +3 -0
- data/examples/pb_demo.rb +83 -35
- data/fog-profitbricks.gemspec +10 -10
- data/gemfiles/Gemfile.1.8.7 +0 -1
- data/lib/fog/profitbricks.rb +4 -23
- data/lib/fog/profitbricks/compute.rb +1082 -1
- data/lib/fog/profitbricks/helpers/compute/data_helper.rb +12 -0
- data/lib/fog/profitbricks/models/base.rb +37 -0
- data/lib/fog/profitbricks/models/compute/datacenter.rb +64 -0
- data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/datacenters.rb +9 -4
- data/lib/fog/profitbricks/models/compute/firewall_rule.rb +101 -0
- data/lib/fog/profitbricks/models/compute/firewall_rules.rb +40 -0
- data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/flavor.rb +0 -0
- data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/flavors.rb +0 -0
- data/lib/fog/profitbricks/models/compute/image.rb +72 -0
- data/lib/fog/profitbricks/models/compute/images.rb +28 -0
- data/lib/fog/profitbricks/models/compute/ip_block.rb +58 -0
- data/lib/fog/profitbricks/models/compute/ip_blocks.rb +30 -0
- data/lib/fog/profitbricks/models/compute/lan.rb +89 -0
- data/lib/fog/profitbricks/models/compute/lans.rb +36 -0
- data/lib/fog/profitbricks/models/compute/load_balancer.rb +126 -0
- data/lib/fog/profitbricks/models/compute/load_balancers.rb +34 -0
- data/lib/fog/profitbricks/models/compute/location.rb +18 -0
- data/lib/fog/profitbricks/models/compute/locations.rb +28 -0
- data/lib/fog/profitbricks/models/compute/nic.rb +111 -0
- data/lib/fog/profitbricks/models/compute/nics.rb +38 -0
- data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/region.rb +0 -0
- data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/regions.rb +0 -0
- data/lib/fog/profitbricks/models/compute/request.rb +24 -0
- data/lib/fog/profitbricks/models/compute/requests.rb +37 -0
- data/lib/fog/profitbricks/models/compute/server.rb +263 -0
- data/lib/fog/profitbricks/models/compute/servers.rb +32 -0
- data/lib/fog/profitbricks/models/compute/snapshot.rb +81 -0
- data/lib/fog/profitbricks/models/compute/snapshots.rb +28 -0
- data/lib/fog/profitbricks/models/compute/volume.rb +123 -0
- data/lib/fog/profitbricks/models/compute/volumes.rb +33 -0
- data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +104 -0
- data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +88 -0
- data/lib/fog/profitbricks/requests/compute/attach_volume.rb +89 -0
- data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +89 -0
- data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +103 -0
- data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/create_flavor.rb +0 -0
- data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +81 -0
- data/lib/fog/profitbricks/requests/compute/create_lan.rb +160 -0
- data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +87 -0
- data/lib/fog/profitbricks/requests/compute/create_nic.rb +124 -0
- data/lib/fog/profitbricks/requests/compute/create_server.rb +257 -0
- data/lib/fog/profitbricks/requests/compute/create_volume.rb +133 -0
- data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +113 -0
- data/lib/fog/profitbricks/requests/compute/delete_datacenter.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb +47 -0
- data/lib/fog/profitbricks/requests/compute/delete_image.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/delete_ip_block.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/delete_lan.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/delete_nic.rb +46 -0
- data/lib/fog/profitbricks/requests/compute/delete_server.rb +48 -0
- data/lib/fog/profitbricks/requests/compute/delete_snapshot.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/delete_volume.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +52 -0
- data/lib/fog/profitbricks/requests/compute/detach_volume.rb +53 -0
- data/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb +59 -0
- data/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb +76 -0
- data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/get_all_flavors.rb +0 -0
- data/lib/fog/profitbricks/requests/compute/get_all_images.rb +66 -0
- data/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb +56 -0
- data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +120 -0
- data/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb +100 -0
- data/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb +117 -0
- data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +102 -0
- data/lib/fog/profitbricks/requests/compute/get_all_requests.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +134 -0
- data/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb +66 -0
- data/lib/fog/profitbricks/requests/compute/get_all_volumes.rb +78 -0
- data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +78 -0
- data/lib/fog/profitbricks/requests/compute/get_attached_volume.rb +79 -0
- data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +65 -0
- data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +71 -0
- data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/get_flavor.rb +0 -0
- data/lib/fog/profitbricks/requests/compute/get_image.rb +71 -0
- data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +58 -0
- data/lib/fog/profitbricks/requests/compute/get_lan.rb +120 -0
- data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +99 -0
- data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +116 -0
- data/lib/fog/profitbricks/requests/compute/get_location.rb +49 -0
- data/lib/fog/profitbricks/requests/compute/get_nic.rb +98 -0
- data/lib/fog/profitbricks/requests/compute/get_request.rb +61 -0
- data/lib/fog/profitbricks/requests/compute/get_request_status.rb +50 -0
- data/lib/fog/profitbricks/requests/compute/get_server.rb +133 -0
- data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +70 -0
- data/lib/fog/profitbricks/requests/compute/get_volume.rb +73 -0
- data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +74 -0
- data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +75 -0
- data/lib/fog/profitbricks/requests/compute/reboot_server.rb +47 -0
- data/lib/fog/profitbricks/requests/compute/remove_nic_association.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb +61 -0
- data/lib/fog/profitbricks/requests/compute/start_server.rb +49 -0
- data/lib/fog/profitbricks/requests/compute/stop_server.rb +50 -0
- data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +73 -0
- data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +87 -0
- data/lib/fog/profitbricks/requests/compute/update_image.rb +90 -0
- data/lib/fog/profitbricks/requests/compute/update_lan.rb +126 -0
- data/lib/fog/profitbricks/requests/compute/update_load_balancer.rb +70 -0
- data/lib/fog/profitbricks/requests/compute/update_nic.rb +107 -0
- data/lib/fog/profitbricks/requests/compute/update_server.rb +147 -0
- data/lib/fog/profitbricks/requests/compute/update_snapshot.rb +90 -0
- data/lib/fog/profitbricks/requests/compute/update_volume.rb +82 -0
- data/lib/fog/profitbricks/version.rb +1 -1
- data/tests/profitbricks/requests/compute/composite_create_tests.rb +241 -0
- data/tests/profitbricks/requests/compute/location_tests.rb +24 -12
- data/tests/profitbricks/requests/compute/nic_tests.rb +290 -0
- data/tests/profitbricks/requests/compute/request_tests.rb +52 -0
- data/tests/profitbricks/requests/compute/server_tests.rb +398 -175
- metadata +140 -133
- data/lib/fog/compute/profit_bricks.rb +0 -217
- data/lib/fog/compute/profit_bricks/models/datacenter.rb +0 -60
- data/lib/fog/compute/profit_bricks/models/image.rb +0 -27
- data/lib/fog/compute/profit_bricks/models/images.rb +0 -22
- data/lib/fog/compute/profit_bricks/models/interface.rb +0 -61
- data/lib/fog/compute/profit_bricks/models/interfaces.rb +0 -23
- data/lib/fog/compute/profit_bricks/models/server.rb +0 -104
- data/lib/fog/compute/profit_bricks/models/servers.rb +0 -22
- data/lib/fog/compute/profit_bricks/models/volume.rb +0 -71
- data/lib/fog/compute/profit_bricks/models/volumes.rb +0 -23
- data/lib/fog/compute/profit_bricks/requests/clear_data_center.rb +0 -51
- data/lib/fog/compute/profit_bricks/requests/connect_storage_to_server.rb +0 -83
- data/lib/fog/compute/profit_bricks/requests/create_data_center.rb +0 -62
- data/lib/fog/compute/profit_bricks/requests/create_nic.rb +0 -79
- data/lib/fog/compute/profit_bricks/requests/create_server.rb +0 -105
- data/lib/fog/compute/profit_bricks/requests/create_storage.rb +0 -96
- data/lib/fog/compute/profit_bricks/requests/delete_data_center.rb +0 -60
- data/lib/fog/compute/profit_bricks/requests/delete_nic.rb +0 -64
- data/lib/fog/compute/profit_bricks/requests/delete_server.rb +0 -64
- data/lib/fog/compute/profit_bricks/requests/delete_storage.rb +0 -64
- data/lib/fog/compute/profit_bricks/requests/disconnect_storage_from_server.rb +0 -76
- data/lib/fog/compute/profit_bricks/requests/get_all_data_centers.rb +0 -31
- data/lib/fog/compute/profit_bricks/requests/get_all_images.rb +0 -65
- data/lib/fog/compute/profit_bricks/requests/get_all_locations.rb +0 -44
- data/lib/fog/compute/profit_bricks/requests/get_all_nic.rb +0 -53
- data/lib/fog/compute/profit_bricks/requests/get_all_servers.rb +0 -57
- data/lib/fog/compute/profit_bricks/requests/get_all_storages.rb +0 -56
- data/lib/fog/compute/profit_bricks/requests/get_data_center.rb +0 -38
- data/lib/fog/compute/profit_bricks/requests/get_data_center_state.rb +0 -42
- data/lib/fog/compute/profit_bricks/requests/get_image.rb +0 -69
- data/lib/fog/compute/profit_bricks/requests/get_location.rb +0 -48
- data/lib/fog/compute/profit_bricks/requests/get_nic.rb +0 -63
- data/lib/fog/compute/profit_bricks/requests/get_server.rb +0 -98
- data/lib/fog/compute/profit_bricks/requests/get_storage.rb +0 -63
- data/lib/fog/compute/profit_bricks/requests/reset_server.rb +0 -49
- data/lib/fog/compute/profit_bricks/requests/set_internet_access.rb +0 -59
- data/lib/fog/compute/profit_bricks/requests/start_server.rb +0 -58
- data/lib/fog/compute/profit_bricks/requests/stop_server.rb +0 -58
- data/lib/fog/compute/profit_bricks/requests/update_data_center.rb +0 -54
- data/lib/fog/compute/profit_bricks/requests/update_nic.rb +0 -74
- data/lib/fog/compute/profit_bricks/requests/update_server.rb +0 -79
- data/lib/fog/compute/profit_bricks/requests/update_storage.rb +0 -73
- data/lib/fog/models/profit_bricks/base.rb +0 -11
- data/lib/fog/parsers/compute.rb +0 -37
- data/lib/fog/parsers/compute/profit_bricks/base.rb +0 -51
- data/lib/fog/parsers/compute/profit_bricks/clear_data_center.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/connect_storage_to_server.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/create_data_center.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/create_nic.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/create_server.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/create_storage.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/delete_data_center.rb +0 -20
- data/lib/fog/parsers/compute/profit_bricks/delete_nic.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/delete_server.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/delete_storage.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/disconnect_storage_from_server.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/get_all_data_centers.rb +0 -26
- data/lib/fog/parsers/compute/profit_bricks/get_all_images.rb +0 -30
- data/lib/fog/parsers/compute/profit_bricks/get_all_nic.rb +0 -30
- data/lib/fog/parsers/compute/profit_bricks/get_all_servers.rb +0 -57
- data/lib/fog/parsers/compute/profit_bricks/get_all_storages.rb +0 -33
- data/lib/fog/parsers/compute/profit_bricks/get_data_center.rb +0 -23
- data/lib/fog/parsers/compute/profit_bricks/get_data_center_state.rb +0 -20
- data/lib/fog/parsers/compute/profit_bricks/get_image.rb +0 -26
- data/lib/fog/parsers/compute/profit_bricks/get_nic.rb +0 -27
- data/lib/fog/parsers/compute/profit_bricks/get_server.rb +0 -57
- data/lib/fog/parsers/compute/profit_bricks/get_storage.rb +0 -30
- data/lib/fog/parsers/compute/profit_bricks/reset_server.rb +0 -20
- data/lib/fog/parsers/compute/profit_bricks/set_internet_access.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/update_data_center.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/update_nic.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/update_server.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/update_storage.rb +0 -22
- data/lib/fog/profitbricks/storage.rb +0 -1
- data/tests/profitbricks/requests/compute/image_tests.rb +0 -50
- data/tests/profitbricks/requests/compute/interface_tests.rb +0 -101
@@ -1,60 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Compute
|
3
|
-
class ProfitBricks
|
4
|
-
class Datacenter < Fog::Models::ProfitBricks::Base
|
5
|
-
identity :id, :aliases => "dataCenterId"
|
6
|
-
|
7
|
-
attribute :name, :aliases => "dataCenterName"
|
8
|
-
attribute :version, :aliases => "dataCenterVersion"
|
9
|
-
attribute :state, :aliases => "provisioningState"
|
10
|
-
attribute :request_id, :aliases => "requestId"
|
11
|
-
attribute :region, :aliases => "location"
|
12
|
-
|
13
|
-
attr_accessor :options
|
14
|
-
|
15
|
-
def initialize(attributes = {})
|
16
|
-
super
|
17
|
-
end
|
18
|
-
|
19
|
-
def save
|
20
|
-
requires :name, :region
|
21
|
-
|
22
|
-
data = service.create_data_center(name, region)
|
23
|
-
merge_attributes(data.body["createDataCenterResponse"])
|
24
|
-
true
|
25
|
-
end
|
26
|
-
|
27
|
-
def update
|
28
|
-
requires :id
|
29
|
-
data = service.update_data_center(id, options)
|
30
|
-
merge_attributes(data.body["updateDataCenterResponse"])
|
31
|
-
true
|
32
|
-
end
|
33
|
-
|
34
|
-
def destroy
|
35
|
-
requires :id
|
36
|
-
service.delete_data_center(id)
|
37
|
-
true
|
38
|
-
end
|
39
|
-
|
40
|
-
def clear(confirm = false)
|
41
|
-
requires :id
|
42
|
-
if confirm == true
|
43
|
-
service.clear_data_center(id)
|
44
|
-
true
|
45
|
-
else
|
46
|
-
raise ArgumentError.new("Confirm with true boolean to clear datacenter")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def ready?
|
51
|
-
state == "AVAILABLE"
|
52
|
-
end
|
53
|
-
|
54
|
-
def failed?
|
55
|
-
state == "ERROR"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Compute
|
3
|
-
class ProfitBricks
|
4
|
-
class Image < Fog::Models::ProfitBricks::Base
|
5
|
-
identity :id, :aliases => "imageId"
|
6
|
-
|
7
|
-
attribute :name, :aliases => "imageName"
|
8
|
-
attribute :type, :aliases => "imageType"
|
9
|
-
attribute :size, :aliases => "imageSize"
|
10
|
-
attribute :cpu_hotplug, :aliases => "cpuHotPlug"
|
11
|
-
attribute :cpu_hotunplug, :aliases => "cpuHotUnplug"
|
12
|
-
attribute :ram_hotplug, :aliases => "memoryHotPlug"
|
13
|
-
attribute :ram_hotunplug, :aliases => "memoryHotUnPlug"
|
14
|
-
attribute :disc_hotplug, :aliases => "discVirtioHotPlug"
|
15
|
-
attribute :disc_hotunplug, :aliases => "discVirtioUnHotPlug"
|
16
|
-
attribute :nic_hotplug, :aliases => "nicHotPlug"
|
17
|
-
attribute :nic_hotunplug, :aliases => "nicHotUnPlug"
|
18
|
-
attribute :server_ids, :aliases => "serverIds"
|
19
|
-
attribute :os_type, :aliases => "osType"
|
20
|
-
attribute :region, :aliases => "location"
|
21
|
-
attribute :bootable
|
22
|
-
attribute :writeable
|
23
|
-
attribute :public
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.expand_path('../image', __FILE__)
|
2
|
-
|
3
|
-
module Fog
|
4
|
-
module Compute
|
5
|
-
class ProfitBricks
|
6
|
-
class Images < Fog::Collection
|
7
|
-
model Fog::Compute::ProfitBricks::Image
|
8
|
-
|
9
|
-
def all
|
10
|
-
load(service.get_all_images.body["getAllImagesResponse"])
|
11
|
-
end
|
12
|
-
|
13
|
-
def get(id)
|
14
|
-
image = service.get_image(id).body["getImageResponse"]
|
15
|
-
new(image)
|
16
|
-
rescue Fog::Errors::NotFound
|
17
|
-
nil
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Compute
|
3
|
-
class ProfitBricks
|
4
|
-
class Interface < Fog::Models::ProfitBricks::Base
|
5
|
-
identity :id, :aliases => "nicId"
|
6
|
-
|
7
|
-
attribute :name, :aliases => "nicName"
|
8
|
-
attribute :mac_address, :aliases => "macAddress"
|
9
|
-
attribute :lan_id, :aliases => "lanId"
|
10
|
-
attribute :dhcp_active, :aliases => "dhcpActive"
|
11
|
-
attribute :ips, :aliases => "ips"
|
12
|
-
attribute :server_id, :aliases => "serverId"
|
13
|
-
attribute :internet_access, :aliases => "internetAccess"
|
14
|
-
attribute :state, :aliases => "provisioningState"
|
15
|
-
attribute :firewall
|
16
|
-
attribute :data_center_id, :aliases => "dataCenterId"
|
17
|
-
attribute :data_center_version, :aliases => "dataCenterVersion"
|
18
|
-
attribute :request_id, :aliases => "requestId"
|
19
|
-
|
20
|
-
attr_accessor :options
|
21
|
-
|
22
|
-
def save
|
23
|
-
requires :server_id, :lan_id
|
24
|
-
|
25
|
-
data = service.create_nic(server_id, lan_id, options = {})
|
26
|
-
merge_attributes(data.body["createNicResponse"])
|
27
|
-
true
|
28
|
-
end
|
29
|
-
|
30
|
-
def update
|
31
|
-
requires :id
|
32
|
-
|
33
|
-
data = service.update_nic(id, options)
|
34
|
-
merge_attributes(data.body["updateNicResponse"])
|
35
|
-
true
|
36
|
-
end
|
37
|
-
|
38
|
-
def destroy
|
39
|
-
requires :id
|
40
|
-
service.delete_nic(id)
|
41
|
-
true
|
42
|
-
end
|
43
|
-
|
44
|
-
def set_internet_access(options = {})
|
45
|
-
service.set_internet_access(
|
46
|
-
options[:data_center_id], options[:lan_id], options[:internet_access]
|
47
|
-
)
|
48
|
-
true
|
49
|
-
end
|
50
|
-
|
51
|
-
def ready?
|
52
|
-
state == "AVAILABLE"
|
53
|
-
end
|
54
|
-
|
55
|
-
def failed?
|
56
|
-
state == "ERROR"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path('../interface', __FILE__)
|
2
|
-
|
3
|
-
module Fog
|
4
|
-
module Compute
|
5
|
-
class ProfitBricks
|
6
|
-
class Interfaces < Fog::Collection
|
7
|
-
model Fog::Compute::ProfitBricks::Interface
|
8
|
-
|
9
|
-
def all
|
10
|
-
load(service.get_all_nic.body["getAllNicResponse"])
|
11
|
-
end
|
12
|
-
|
13
|
-
def get(id)
|
14
|
-
interface = service.get_nic(id).body["getNicResponse"]
|
15
|
-
Excon::Errors
|
16
|
-
new(interface)
|
17
|
-
rescue Excon::Errors::NotFound
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
require "fog/compute/models/server"
|
2
|
-
|
3
|
-
module Fog
|
4
|
-
module Compute
|
5
|
-
class ProfitBricks
|
6
|
-
class Server < Fog::Compute::Server
|
7
|
-
identity :id, :aliases => "serverId"
|
8
|
-
|
9
|
-
attribute :name, :aliases => "serverName"
|
10
|
-
attribute :cores
|
11
|
-
attribute :ram
|
12
|
-
attribute :attached_volumes, :aliases => "connectedStorages"
|
13
|
-
attribute :interfaces, :aliases => "nics"
|
14
|
-
attribute :internet_access, :aliases => "internetAccess"
|
15
|
-
attribute :zone, :aliases => "availabilityZone"
|
16
|
-
attribute :creation_time, :aliases => "creationTime"
|
17
|
-
attribute :modification_time, :aliases => "lastModificationTime"
|
18
|
-
attribute :machine_state, :aliases => "virtualMachineState"
|
19
|
-
attribute :state, :aliases => "provisioningState"
|
20
|
-
attribute :os_type, :aliases => "osType"
|
21
|
-
attribute :cpu_hotplug, :aliases => "cpuHotPlug"
|
22
|
-
attribute :ram_hotplug, :aliases => "ramHotPlug"
|
23
|
-
attribute :nic_hotplug, :aliases => "nicHotPlug"
|
24
|
-
attribute :nic_hotunplug, :aliases => "nicHotUnPlug"
|
25
|
-
attribute :disc_hotplug, :aliases => "discVirtioHotPlug"
|
26
|
-
attribute :disc_hotunplug, :aliases => "discVirtioHotUnPlug"
|
27
|
-
attribute :data_center_id, :aliases => "dataCenterId"
|
28
|
-
attribute :data_center_version, :aliases => "dataCenterVersion"
|
29
|
-
attribute :request_id, :aliases => "requestId"
|
30
|
-
|
31
|
-
attr_accessor :options
|
32
|
-
attr_accessor :flavor_id
|
33
|
-
|
34
|
-
def save
|
35
|
-
requires :data_center_id
|
36
|
-
|
37
|
-
if (cores and ram)
|
38
|
-
data = service.create_server(data_center_id, cores, ram, options || {})
|
39
|
-
elsif flavor_id
|
40
|
-
flavor = service.flavors.get(flavor_id)
|
41
|
-
data = service.create_server(data_center_id, flavor.cores, flavor.ram, options || {})
|
42
|
-
else
|
43
|
-
raise ArgumentError, "cores/ram or flavor_id is required for this operation"
|
44
|
-
end
|
45
|
-
|
46
|
-
merge_attributes(data.body["createServerResponse"])
|
47
|
-
true
|
48
|
-
end
|
49
|
-
|
50
|
-
def update
|
51
|
-
requires :id
|
52
|
-
|
53
|
-
data = service.update_server(id, options)
|
54
|
-
merge_attributes(data.body["updateServerResponse"])
|
55
|
-
true
|
56
|
-
end
|
57
|
-
|
58
|
-
def reset
|
59
|
-
requires :id
|
60
|
-
service.reset_server(id)
|
61
|
-
true
|
62
|
-
end
|
63
|
-
|
64
|
-
def start
|
65
|
-
requires :id
|
66
|
-
service.start_server(id)
|
67
|
-
true
|
68
|
-
end
|
69
|
-
|
70
|
-
def stop
|
71
|
-
requires :id
|
72
|
-
service.stop_server(id)
|
73
|
-
true
|
74
|
-
end
|
75
|
-
|
76
|
-
def destroy
|
77
|
-
requires :id
|
78
|
-
service.delete_server(id)
|
79
|
-
true
|
80
|
-
end
|
81
|
-
|
82
|
-
def volumes
|
83
|
-
service.volumes.find_all do |volume|
|
84
|
-
volume.server_ids =~ /#{id}/
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def interfaces
|
89
|
-
service.interfaces.find_all do |nic|
|
90
|
-
nic.server_id == id
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def ready?
|
95
|
-
state == "AVAILABLE"
|
96
|
-
end
|
97
|
-
|
98
|
-
def failed?
|
99
|
-
state == "ERROR"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.expand_path('../server', __FILE__)
|
2
|
-
|
3
|
-
module Fog
|
4
|
-
module Compute
|
5
|
-
class ProfitBricks
|
6
|
-
class Servers < Fog::Collection
|
7
|
-
model Fog::Compute::ProfitBricks::Server
|
8
|
-
|
9
|
-
def all
|
10
|
-
load(service.get_all_servers.body["getAllServersResponse"])
|
11
|
-
end
|
12
|
-
|
13
|
-
def get(id)
|
14
|
-
server = service.get_server(id).body["getServerResponse"]
|
15
|
-
new(server)
|
16
|
-
rescue Excon::Errors::NotFound
|
17
|
-
nil
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Compute
|
3
|
-
class ProfitBricks
|
4
|
-
class Volume < Fog::Models::ProfitBricks::Base
|
5
|
-
identity :id, :aliases => "storageId"
|
6
|
-
|
7
|
-
attribute :name, :aliases => "storageName"
|
8
|
-
attribute :size
|
9
|
-
attribute :creation_time, :aliases => "creationTime"
|
10
|
-
attribute :modification_time, :aliases => "lastModificationTime"
|
11
|
-
attribute :server_ids, :aliases => "serverIds"
|
12
|
-
attribute :mount_image, :aliases => "mountImage"
|
13
|
-
attribute :state, :aliases => "provisioningState"
|
14
|
-
attribute :data_center_id, :aliases => "dataCenterId"
|
15
|
-
attribute :data_center_version, :aliases => "dataCenterVersion"
|
16
|
-
attribute :request_id, :aliases => "requestId"
|
17
|
-
|
18
|
-
attr_accessor :options
|
19
|
-
|
20
|
-
def save
|
21
|
-
requires :data_center_id, :size
|
22
|
-
|
23
|
-
data = service.create_storage(data_center_id, size, options)
|
24
|
-
merge_attributes(data.body["createStorageResponse"])
|
25
|
-
true
|
26
|
-
end
|
27
|
-
|
28
|
-
def update
|
29
|
-
requires :id
|
30
|
-
|
31
|
-
data = service.update_storage(id, options)
|
32
|
-
merge_attributes(data.body["updateStorageResponse"])
|
33
|
-
true
|
34
|
-
end
|
35
|
-
|
36
|
-
def attach(server_id, options = {})
|
37
|
-
requires :id
|
38
|
-
|
39
|
-
options = {
|
40
|
-
"busType" => options[:bus_type],
|
41
|
-
"deviceNumber" => options[:device_number]
|
42
|
-
}
|
43
|
-
|
44
|
-
data = service.connect_storage_to_server(id, server_id, options)
|
45
|
-
reload
|
46
|
-
end
|
47
|
-
|
48
|
-
def detach(server_id)
|
49
|
-
requires :id
|
50
|
-
|
51
|
-
data = service.disconnect_storage_from_server(id, server_id)
|
52
|
-
reload
|
53
|
-
end
|
54
|
-
|
55
|
-
def destroy
|
56
|
-
requires :id
|
57
|
-
service.delete_storage(id)
|
58
|
-
true
|
59
|
-
end
|
60
|
-
|
61
|
-
def ready?
|
62
|
-
state == "AVAILABLE"
|
63
|
-
end
|
64
|
-
|
65
|
-
def failed?
|
66
|
-
state == "ERROR"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path('../volume', __FILE__)
|
2
|
-
|
3
|
-
module Fog
|
4
|
-
module Compute
|
5
|
-
class ProfitBricks
|
6
|
-
class Volumes < Fog::Collection
|
7
|
-
model Fog::Compute::ProfitBricks::Volume
|
8
|
-
|
9
|
-
def all
|
10
|
-
load(service.get_all_storages.body["getAllStoragesResponse"])
|
11
|
-
end
|
12
|
-
|
13
|
-
def get(id)
|
14
|
-
volume = service.get_storage(id).body["getStorageResponse"]
|
15
|
-
Excon::Errors
|
16
|
-
new(volume)
|
17
|
-
rescue Excon::Errors::NotFound
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Compute
|
3
|
-
class ProfitBricks
|
4
|
-
class Real
|
5
|
-
# Clear all objects within a virtual data center
|
6
|
-
#
|
7
|
-
# ==== Parameters
|
8
|
-
# * dataCenterId<~String> - Required, UUID of virtual data center
|
9
|
-
#
|
10
|
-
# ==== Returns
|
11
|
-
# * response<~Excon::Response>:
|
12
|
-
# * body<~Hash>:
|
13
|
-
# * clearDataCenterResponse<~Hash>:
|
14
|
-
# * requestId<~String> - ID of request
|
15
|
-
# * dataCenterId<~String> - UUID of virtual data center
|
16
|
-
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
17
|
-
#
|
18
|
-
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/ClearDataCenter.html]
|
19
|
-
def clear_data_center(data_center_id)
|
20
|
-
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
21
|
-
|xml| xml[:ws].clearDataCenter {
|
22
|
-
xml.dataCenterId(data_center_id)
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
request(
|
27
|
-
:expects => [200],
|
28
|
-
:method => "POST",
|
29
|
-
:body => soap_envelope.to_xml,
|
30
|
-
:parser => Fog::Parsers::Compute::ProfitBricks::ClearDataCenter.new
|
31
|
-
)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Mock
|
36
|
-
def clear_data_center(data_center_id)
|
37
|
-
response = Excon::Response.new
|
38
|
-
response.status = 200
|
39
|
-
response.body = {
|
40
|
-
"clearDataCenterResponse" => {
|
41
|
-
"requestId" => Fog::Mock::random_numbers(7),
|
42
|
-
"dataCenterId" => Fog::UUID.uuid,
|
43
|
-
"dataCenterVersion" => 1,
|
44
|
-
}
|
45
|
-
}
|
46
|
-
response
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|