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
@@ -0,0 +1,12 @@
|
|
1
|
+
module Fog
|
2
|
+
module Helpers
|
3
|
+
module ProfitBricks
|
4
|
+
module DataHelper
|
5
|
+
def flatten(response_json)
|
6
|
+
['properties', 'metadata', 'entities'].each {|k| response_json.merge!(response_json.delete(k)) if response_json.has_key?(k)}
|
7
|
+
response_json
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Fog
|
2
|
+
module Models
|
3
|
+
module ProfitBricks
|
4
|
+
class Base < Fog::Model
|
5
|
+
def wait_for(timeout = Fog.timeout, interval = Fog.interval, &block)
|
6
|
+
reload_has_succeeded = false
|
7
|
+
duration = Fog.wait_for(timeout, interval) do # Note that duration = false if it times out
|
8
|
+
if ready?
|
9
|
+
reload_has_succeeded = true
|
10
|
+
instance_eval(&block)
|
11
|
+
else
|
12
|
+
false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
if reload_has_succeeded
|
16
|
+
return duration # false if timeout; otherwise {:duration => elapsed time }
|
17
|
+
else
|
18
|
+
raise Fog::Errors::Error, "Reload failed, #{self.class} #{identity} not present."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def request_status(request_id)
|
23
|
+
request = service.requests.get_status(request_id)
|
24
|
+
request.status
|
25
|
+
end
|
26
|
+
|
27
|
+
def ready?
|
28
|
+
request_status(request_id) == 'DONE'
|
29
|
+
end
|
30
|
+
|
31
|
+
def failed?
|
32
|
+
request_status(request_id) == 'FAILED'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require File.expand_path('../../helpers/compute/data_helper', __dir__)
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class ProfitBricks
|
6
|
+
class Datacenter < Fog::Models::ProfitBricks::Base
|
7
|
+
include Fog::Helpers::ProfitBricks::DataHelper
|
8
|
+
|
9
|
+
identity :id
|
10
|
+
|
11
|
+
# properties
|
12
|
+
attribute :name
|
13
|
+
attribute :description
|
14
|
+
attribute :location
|
15
|
+
attribute :version
|
16
|
+
attribute :features
|
17
|
+
|
18
|
+
# metadata
|
19
|
+
attribute :created_date, :aliases => 'createdDate', :type => :time
|
20
|
+
attribute :created_by, :aliases => 'createdBy'
|
21
|
+
attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time
|
22
|
+
attribute :last_modified_by, :aliases => 'lastModifiedBy'
|
23
|
+
attribute :request_id, :aliases => 'requestId'
|
24
|
+
attribute :state
|
25
|
+
|
26
|
+
attr_accessor :options
|
27
|
+
|
28
|
+
def initialize(attributes = {})
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def save
|
33
|
+
requires :name, :location
|
34
|
+
|
35
|
+
options = {}
|
36
|
+
options[:name] = name
|
37
|
+
options[:location] = location
|
38
|
+
options[:description] = description if description
|
39
|
+
|
40
|
+
data = service.create_datacenter(options)
|
41
|
+
merge_attributes(flatten(data.body))
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
def update
|
46
|
+
requires :id
|
47
|
+
|
48
|
+
options = {}
|
49
|
+
options[:name] = name if name
|
50
|
+
options[:description] = description if description
|
51
|
+
data = service.update_datacenter(id, options)
|
52
|
+
merge_attributes(flatten(data.body))
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
def delete
|
57
|
+
requires :id
|
58
|
+
data = service.delete_datacenter(id)
|
59
|
+
true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -1,23 +1,28 @@
|
|
1
1
|
require File.expand_path('../datacenter', __FILE__)
|
2
|
+
require File.expand_path('../../helpers/compute/data_helper', __dir__)
|
2
3
|
|
3
4
|
module Fog
|
4
5
|
module Compute
|
5
6
|
class ProfitBricks
|
6
7
|
class Datacenters < Fog::Collection
|
8
|
+
include Fog::Helpers::ProfitBricks::DataHelper
|
7
9
|
model Fog::Compute::ProfitBricks::Datacenter
|
8
10
|
|
9
11
|
def all
|
10
|
-
|
12
|
+
result = service.get_all_datacenters
|
13
|
+
|
14
|
+
load(result.body['items'].each {|dc| flatten(dc)})
|
11
15
|
end
|
12
16
|
|
13
17
|
def get(id)
|
14
|
-
datacenter = service.
|
18
|
+
datacenter = service.get_datacenter(id).body
|
19
|
+
|
15
20
|
Excon::Errors
|
16
|
-
new(datacenter)
|
21
|
+
new(flatten(datacenter))
|
17
22
|
rescue Excon::Errors::NotFound
|
18
23
|
nil
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
end
|
23
|
-
end
|
28
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require File.expand_path('../../helpers/compute/data_helper', __dir__)
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class ProfitBricks
|
6
|
+
class FirewallRule < Fog::Models::ProfitBricks::Base
|
7
|
+
include Fog::Helpers::ProfitBricks::DataHelper
|
8
|
+
|
9
|
+
identity :id
|
10
|
+
|
11
|
+
# properties
|
12
|
+
attribute :name
|
13
|
+
attribute :protocol
|
14
|
+
attribute :source_mac, :aliases => 'sourceMac'
|
15
|
+
attribute :source_ip, :aliases => 'sourceIp'
|
16
|
+
attribute :target_ip, :aliases => 'targetIp'
|
17
|
+
attribute :icmp_code, :aliases => 'icmpCode'
|
18
|
+
attribute :icmp_type, :aliases => 'icmpType'
|
19
|
+
attribute :port_range_start, :aliases => 'portRangeStart'
|
20
|
+
attribute :port_range_end, :aliases => 'portRangeEnd'
|
21
|
+
|
22
|
+
# metadata
|
23
|
+
attribute :created_date, :aliases => 'createdDate', :type => :time
|
24
|
+
attribute :created_by, :aliases => 'createdBy'
|
25
|
+
attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time
|
26
|
+
attribute :last_modified_by, :aliases => 'lastModifiedBy'
|
27
|
+
attribute :request_id, :aliases => 'requestId'
|
28
|
+
attribute :state
|
29
|
+
|
30
|
+
attribute :datacenter_id
|
31
|
+
attribute :server_id
|
32
|
+
attribute :nic_id
|
33
|
+
|
34
|
+
def save
|
35
|
+
requires :datacenter_id, :server_id, :nic_id, :protocol
|
36
|
+
|
37
|
+
properties = {}
|
38
|
+
properties[:name] = name if name
|
39
|
+
properties[:protocol] = protocol if protocol
|
40
|
+
properties[:sourceMac] = source_mac if source_mac
|
41
|
+
properties[:sourceIp] = source_ip if source_ip
|
42
|
+
properties[:targetIp] = target_ip if target_ip
|
43
|
+
properties[:portRangeStart] = port_range_start if port_range_start
|
44
|
+
properties[:portRangeEnd] = port_range_end if port_range_end
|
45
|
+
properties[:icmpType] = icmp_type if icmp_type
|
46
|
+
properties[:icmpCode] = icmp_code if icmp_code
|
47
|
+
|
48
|
+
data = service.create_firewall_rule(datacenter_id, server_id, nic_id, properties)
|
49
|
+
merge_attributes(flatten(data.body))
|
50
|
+
end
|
51
|
+
|
52
|
+
def update
|
53
|
+
requires :datacenter_id, :server_id, :nic_id, :id
|
54
|
+
|
55
|
+
properties = {}
|
56
|
+
properties[:name] = name if name
|
57
|
+
properties[:sourceMac] = source_mac if source_mac
|
58
|
+
properties[:sourceIp] = source_ip if source_ip
|
59
|
+
properties[:targetIp] = target_ip if target_ip
|
60
|
+
properties[:portRangeStart] = port_range_start if port_range_start
|
61
|
+
properties[:portRangeEnd] = port_range_end if port_range_end
|
62
|
+
properties[:icmpType] = icmp_type if icmp_type
|
63
|
+
properties[:icmpCode] = icmp_code if icmp_code
|
64
|
+
|
65
|
+
data = service.update_firewall_rule(datacenter_id, server_id, nic_id, id, properties)
|
66
|
+
merge_attributes(flatten(data.body))
|
67
|
+
end
|
68
|
+
|
69
|
+
def delete
|
70
|
+
requires :datacenter_id, :server_id, :nic_id, :id
|
71
|
+
service.delete_firewall_rule(datacenter_id, server_id, nic_id, id)
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
75
|
+
def reload
|
76
|
+
requires :datacenter_id, :server_id, :nic_id, :id
|
77
|
+
|
78
|
+
data = begin
|
79
|
+
collection.get(datacenter_id, server_id, nic_id, id)
|
80
|
+
rescue Excon::Errors::SocketError
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
|
84
|
+
return unless data
|
85
|
+
|
86
|
+
new_attributes = data.attributes
|
87
|
+
merge_attributes(new_attributes)
|
88
|
+
self
|
89
|
+
end
|
90
|
+
|
91
|
+
def ready?
|
92
|
+
state == 'AVAILABLE'
|
93
|
+
end
|
94
|
+
|
95
|
+
def failed?
|
96
|
+
state == 'ERROR'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.expand_path('../firewall_rule', __FILE__)
|
2
|
+
require File.expand_path('../../helpers/compute/data_helper', __dir__)
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class ProfitBricks
|
7
|
+
class FirewallRules < Fog::Collection
|
8
|
+
include Fog::Helpers::ProfitBricks::DataHelper
|
9
|
+
model Fog::Compute::ProfitBricks::FirewallRule
|
10
|
+
|
11
|
+
def all(datacenter_id, server_id, nic_id)
|
12
|
+
result = service.get_all_firewall_rules(datacenter_id, server_id, nic_id)
|
13
|
+
|
14
|
+
firewall_rules = result.body['items'].each {|fwr|
|
15
|
+
fwr['datacenter_id'] = datacenter_id
|
16
|
+
fwr['server_id'] = server_id
|
17
|
+
fwr['nic_id'] = nic_id
|
18
|
+
}
|
19
|
+
|
20
|
+
result.body['items'] = firewall_rules
|
21
|
+
|
22
|
+
load(result.body['items'].each {|fwr| flatten(fwr)})
|
23
|
+
end
|
24
|
+
|
25
|
+
def get(datacenter_id, server_id, nic_id, firewall_rule_id)
|
26
|
+
firewall_rule = service.get_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id).body
|
27
|
+
|
28
|
+
Excon::Errors
|
29
|
+
firewall_rule['datacenter_id'] = datacenter_id
|
30
|
+
firewall_rule['server_id'] = server_id
|
31
|
+
firewall_rule['nic_id'] = nic_id
|
32
|
+
|
33
|
+
new(flatten(firewall_rule))
|
34
|
+
rescue Excon::Errors::NotFound
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Image < Fog::Models::ProfitBricks::Base
|
5
|
+
identity :id
|
6
|
+
|
7
|
+
# properties
|
8
|
+
attribute :name
|
9
|
+
attribute :description
|
10
|
+
attribute :location
|
11
|
+
attribute :size
|
12
|
+
attribute :cpu_hot_plug, :aliases => 'cpuHotPlug'
|
13
|
+
attribute :cpu_hot_unplug, :aliases => 'cpuHotUnplug'
|
14
|
+
attribute :ram_hot_plug, :aliases => 'ramHotPlug'
|
15
|
+
attribute :ram_hot_unplug, :aliases => 'ramHotUnplug'
|
16
|
+
attribute :nic_hot_plug, :aliases => 'nicHotPlug'
|
17
|
+
attribute :nic_hot_unplug, :aliases => 'nicHotUnplug'
|
18
|
+
attribute :disc_virtio_hot_plug, :aliases => 'discVirtioHotPlug'
|
19
|
+
attribute :disc_virtio_hot_unplug, :aliases => 'discVirtioHotUnplug'
|
20
|
+
attribute :disc_scsi_hot_plug, :aliases => 'discScsiHotPlug'
|
21
|
+
attribute :disc_scsi_hot_unplug, :aliases => 'discScsiHotUnplug'
|
22
|
+
attribute :licence_type, :aliases => 'licenceType'
|
23
|
+
attribute :image_type, :aliases => 'imageType'
|
24
|
+
attribute :public
|
25
|
+
|
26
|
+
# metadata
|
27
|
+
attribute :created_date, :aliases => 'createdDate', :type => :time
|
28
|
+
attribute :created_by, :aliases => 'createdBy'
|
29
|
+
attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time
|
30
|
+
attribute :last_modified_by, :aliases => 'lastModifiedBy'
|
31
|
+
attribute :state
|
32
|
+
|
33
|
+
def update
|
34
|
+
requires :id
|
35
|
+
|
36
|
+
options = {}
|
37
|
+
options[:name] = name if name
|
38
|
+
options[:description] = description if description
|
39
|
+
options[:licenceType] = licence_type if licence_type
|
40
|
+
options[:cpuHotPlug] = cpu_hot_plug if cpu_hot_plug
|
41
|
+
options[:cpuHotUnplug] = cpu_hot_unplug if cpu_hot_unplug
|
42
|
+
options[:ramHotPlug] = ram_hot_plug if ram_hot_plug
|
43
|
+
options[:ramHotUnplug] = ram_hot_unplug if ram_hot_unplug
|
44
|
+
options[:nicHotPlug] = nic_hot_plug if nic_hot_plug
|
45
|
+
options[:nicHotUnplug] = nic_hot_unplug if nic_hot_unplug
|
46
|
+
options[:discVirtioHotPlug] = disc_virtio_hot_plug if disc_virtio_hot_plug
|
47
|
+
options[:discVirtioHotUnplug] = disc_virtio_hot_unplug if disc_virtio_hot_unplug
|
48
|
+
options[:discScsiHotPlug] = disc_scsi_hot_plug if disc_scsi_hot_plug
|
49
|
+
options[:discScsiHotUnplug] = disc_scsi_hot_unplug if disc_scsi_hot_unplug
|
50
|
+
|
51
|
+
data = service.update_image(id, options)
|
52
|
+
merge_attributes(flatten(data.body))
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
def delete
|
57
|
+
requires :id
|
58
|
+
service.delete_image(id)
|
59
|
+
true
|
60
|
+
end
|
61
|
+
|
62
|
+
def ready?
|
63
|
+
state == 'AVAILABLE'
|
64
|
+
end
|
65
|
+
|
66
|
+
def failed?
|
67
|
+
state == 'ERROR'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path('../image', __FILE__)
|
2
|
+
require File.expand_path('../../helpers/compute/data_helper', __dir__)
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class ProfitBricks
|
7
|
+
class Images < Fog::Collection
|
8
|
+
include Fog::Helpers::ProfitBricks::DataHelper
|
9
|
+
model Fog::Compute::ProfitBricks::Image
|
10
|
+
|
11
|
+
def all
|
12
|
+
result = service.get_all_images
|
13
|
+
|
14
|
+
load(result.body['items'].each {|img| flatten(img)})
|
15
|
+
end
|
16
|
+
|
17
|
+
def get(id)
|
18
|
+
image = service.get_image(id).body
|
19
|
+
|
20
|
+
Excon::Errors
|
21
|
+
new(flatten(image))
|
22
|
+
rescue Excon::Errors::NotFound
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.expand_path('../../helpers/compute/data_helper', __dir__)
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class ProfitBricks
|
6
|
+
class IpBlock < Fog::Models::ProfitBricks::Base
|
7
|
+
include Fog::Helpers::ProfitBricks::DataHelper
|
8
|
+
|
9
|
+
identity :id
|
10
|
+
|
11
|
+
# properties
|
12
|
+
attribute :ips
|
13
|
+
attribute :location
|
14
|
+
attribute :size
|
15
|
+
attribute :name
|
16
|
+
|
17
|
+
# metadata
|
18
|
+
attribute :created_date, :aliases => 'createdDate', :type => :time
|
19
|
+
attribute :created_by, :aliases => 'createdBy'
|
20
|
+
attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time
|
21
|
+
attribute :last_modified_by, :aliases => 'lastModifiedBy'
|
22
|
+
attribute :request_id, :aliases => 'requestId'
|
23
|
+
attribute :state
|
24
|
+
|
25
|
+
def initialize(attributes = {})
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def save
|
30
|
+
requires :location, :size
|
31
|
+
|
32
|
+
properties = {}
|
33
|
+
properties[:location] = location if location
|
34
|
+
properties[:size] = size if size
|
35
|
+
properties[:name] = name if name
|
36
|
+
|
37
|
+
data = service.create_ip_block(properties)
|
38
|
+
merge_attributes(flatten(data.body))
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete
|
43
|
+
requires :id
|
44
|
+
service.delete_ip_block(id)
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def ready?
|
49
|
+
state == 'AVAILABLE'
|
50
|
+
end
|
51
|
+
|
52
|
+
def failed?
|
53
|
+
state == 'ERROR'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|