fog-profitbricks 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/Rakefile +1 -1
- data/examples/pb_demo.rb +2 -8
- data/lib/fog/profitbricks/compute.rb +249 -105
- data/lib/fog/profitbricks/models/compute/datacenter.rb +63 -9
- data/lib/fog/profitbricks/models/compute/firewall_rule.rb +3 -1
- data/lib/fog/profitbricks/models/compute/group.rb +7 -4
- data/lib/fog/profitbricks/models/compute/image.rb +3 -0
- data/lib/fog/profitbricks/models/compute/ip_block.rb +2 -0
- data/lib/fog/profitbricks/models/compute/lan.rb +2 -1
- data/lib/fog/profitbricks/models/compute/load_balancer.rb +2 -0
- data/lib/fog/profitbricks/models/compute/location.rb +1 -0
- data/lib/fog/profitbricks/models/compute/nic.rb +2 -0
- data/lib/fog/profitbricks/models/compute/request.rb +1 -0
- data/lib/fog/profitbricks/models/compute/resource.rb +1 -0
- data/lib/fog/profitbricks/models/compute/server.rb +5 -1
- data/lib/fog/profitbricks/models/compute/share.rb +4 -2
- data/lib/fog/profitbricks/models/compute/snapshot.rb +2 -0
- data/lib/fog/profitbricks/models/compute/user.rb +4 -1
- data/lib/fog/profitbricks/requests/compute/add_share.rb +2 -2
- data/lib/fog/profitbricks/requests/compute/add_user_to_group.rb +4 -4
- data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +1 -3
- data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +18 -17
- data/lib/fog/profitbricks/requests/compute/attach_volume.rb +9 -2
- data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +71 -25
- data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +11 -4
- data/lib/fog/profitbricks/requests/compute/create_group.rb +22 -4
- data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/create_lan.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +4 -43
- data/lib/fog/profitbricks/requests/compute/create_nic.rb +4 -0
- data/lib/fog/profitbricks/requests/compute/create_server.rb +6 -1
- data/lib/fog/profitbricks/requests/compute/create_user.rb +20 -1
- data/lib/fog/profitbricks/requests/compute/create_volume.rb +5 -1
- data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/delete_group.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/delete_share.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/delete_user.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +3 -3
- data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +3 -3
- data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_group.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_image.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_lan.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +7 -1
- data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_location.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_nic.rb +2 -2
- data/lib/fog/profitbricks/requests/compute/get_request.rb +8 -1
- data/lib/fog/profitbricks/requests/compute/get_resource_by_type.rb +8 -1
- data/lib/fog/profitbricks/requests/compute/get_resources_by_type.rb +9 -3
- data/lib/fog/profitbricks/requests/compute/get_server.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_share.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_user.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_volume.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +3 -1
- data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +3 -3
- data/lib/fog/profitbricks/requests/compute/remove_user_from_group.rb +2 -2
- data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +3 -8
- data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/update_group.rb +5 -5
- data/lib/fog/profitbricks/requests/compute/update_nic.rb +2 -4
- data/lib/fog/profitbricks/requests/compute/update_server.rb +3 -4
- data/lib/fog/profitbricks/requests/compute/update_share.rb +3 -3
- data/lib/fog/profitbricks/requests/compute/update_user.rb +2 -2
- data/lib/fog/profitbricks/version.rb +1 -1
- data/tests/profitbricks/models/compute/compute_tests.rb +1071 -267
- metadata +26 -33
- data/gemfiles/Gemfile.1.8.7 +0 -6
- data/tests/profitbricks/requests/compute/composite_create_tests.rb +0 -174
- data/tests/profitbricks/requests/compute/flavor_tests.rb +0 -40
- data/tests/profitbricks/requests/compute/location_tests.rb +0 -42
- data/tests/profitbricks/requests/compute/nic_tests.rb +0 -268
- data/tests/profitbricks/requests/compute/request_tests.rb +0 -50
- data/tests/profitbricks/requests/compute/server_tests.rb +0 -462
@@ -6,7 +6,9 @@ module Fog
|
|
6
6
|
class Datacenter < Fog::Models::ProfitBricks::Base
|
7
7
|
include Fog::Helpers::ProfitBricks::DataHelper
|
8
8
|
|
9
|
-
identity
|
9
|
+
identity :id
|
10
|
+
|
11
|
+
attribute :type
|
10
12
|
|
11
13
|
# properties
|
12
14
|
attribute :name
|
@@ -16,13 +18,19 @@ module Fog
|
|
16
18
|
attribute :features
|
17
19
|
|
18
20
|
# metadata
|
19
|
-
attribute :created_date,
|
20
|
-
attribute :created_by,
|
21
|
-
attribute :last_modified_date,
|
22
|
-
attribute :last_modified_by,
|
23
|
-
attribute :request_id,
|
21
|
+
attribute :created_date, :aliases => 'createdDate', :type => :time
|
22
|
+
attribute :created_by, :aliases => 'createdBy'
|
23
|
+
attribute :last_modified_date, :aliases => 'lastModifiedDate', :type => :time
|
24
|
+
attribute :last_modified_by, :aliases => 'lastModifiedBy'
|
25
|
+
attribute :request_id, :aliases => 'requestId'
|
24
26
|
attribute :state
|
25
27
|
|
28
|
+
#entities
|
29
|
+
attribute :servers
|
30
|
+
attribute :volumes
|
31
|
+
attribute :loadbalancers
|
32
|
+
attribute :lans
|
33
|
+
|
26
34
|
attr_accessor :options
|
27
35
|
|
28
36
|
def initialize(attributes = {})
|
@@ -33,11 +41,37 @@ module Fog
|
|
33
41
|
requires :name, :location
|
34
42
|
|
35
43
|
options = {}
|
36
|
-
options[:name]
|
37
|
-
options[:location]
|
44
|
+
options[:name] = name
|
45
|
+
options[:location] = location
|
38
46
|
options[:description] = description if description
|
47
|
+
options[:servers] = servers if servers
|
48
|
+
options[:volumes] = volumes if volumes
|
49
|
+
options[:loadbalancers] = loadbalancers if loadbalancers
|
50
|
+
options[:lans] = lans if lans
|
51
|
+
|
52
|
+
entities = {}
|
53
|
+
|
54
|
+
# Retrieve servers collection if present and generate appropriate JSON.
|
55
|
+
if options.key?(:servers)
|
56
|
+
entities[:servers] = collect_entities(options.delete(:servers))
|
57
|
+
end
|
58
|
+
|
59
|
+
# Retrieve volumes collection if present and generate appropriate JSON.
|
60
|
+
if options.key?(:volumes)
|
61
|
+
entities[:volumes] = collect_entities(options.delete(:volumes))
|
62
|
+
end
|
39
63
|
|
40
|
-
|
64
|
+
# Retrieve volumes collection if present and generate appropriate JSON.
|
65
|
+
if options.key?(:loadbalancers)
|
66
|
+
entities[:loadbalancers] = collect_entities(options.delete(:loadbalancers))
|
67
|
+
end
|
68
|
+
|
69
|
+
# Retrieve volumes collection if present and generate appropriate JSON.
|
70
|
+
if options.key?(:lans)
|
71
|
+
entities[:lans] = collect_entities(options.delete(:lans))
|
72
|
+
end
|
73
|
+
|
74
|
+
data = service.create_datacenter(options, entities)
|
41
75
|
merge_attributes(flatten(data.body))
|
42
76
|
true
|
43
77
|
end
|
@@ -58,6 +92,26 @@ module Fog
|
|
58
92
|
data = service.delete_datacenter(id)
|
59
93
|
true
|
60
94
|
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def collect_entities(entities)
|
99
|
+
if entities.is_a?(Array) && entities.length > 0
|
100
|
+
items = []
|
101
|
+
entities.each do |entity|
|
102
|
+
if entity.key?(:volumes)
|
103
|
+
subentities = collect_entities(entity.delete(:volumes))
|
104
|
+
items << {
|
105
|
+
properties: entity,
|
106
|
+
entities: {volumes: subentities}
|
107
|
+
}
|
108
|
+
else
|
109
|
+
items << {properties: entity}
|
110
|
+
end
|
111
|
+
end
|
112
|
+
{items: items}
|
113
|
+
end
|
114
|
+
end
|
61
115
|
end
|
62
116
|
end
|
63
117
|
end
|
@@ -8,10 +8,12 @@ module Fog
|
|
8
8
|
|
9
9
|
identity :id
|
10
10
|
|
11
|
+
attribute :type
|
12
|
+
|
11
13
|
# properties
|
12
14
|
attribute :name
|
13
15
|
attribute :protocol
|
14
|
-
attribute :source_mac,
|
16
|
+
attribute :source_mac, :aliases => 'sourceMac'
|
15
17
|
attribute :source_ip, :aliases => 'sourceIp'
|
16
18
|
attribute :target_ip, :aliases => 'targetIp'
|
17
19
|
attribute :icmp_code, :aliases => 'icmpCode'
|
@@ -8,6 +8,9 @@ module Fog
|
|
8
8
|
|
9
9
|
identity :id
|
10
10
|
|
11
|
+
attribute :type
|
12
|
+
attribute :request_id
|
13
|
+
|
11
14
|
# properties
|
12
15
|
attribute :name
|
13
16
|
attribute :create_datacenter, :aliases => 'createDataCenter'
|
@@ -45,10 +48,10 @@ module Fog
|
|
45
48
|
|
46
49
|
options = {}
|
47
50
|
options[:name] = name
|
48
|
-
options[:createDataCenter] = create_datacenter if create_datacenter
|
49
|
-
options[:createSnapshot] = create_snapshot if create_snapshot
|
50
|
-
options[:reserveIp] = reserve_ip if reserve_ip
|
51
|
-
options[:accessActivityLog] = access_activity_log if access_activity_log
|
51
|
+
options[:createDataCenter] = create_datacenter if [true, false].include?(create_datacenter)
|
52
|
+
options[:createSnapshot] = create_snapshot if [true, false].include?(create_snapshot)
|
53
|
+
options[:reserveIp] = reserve_ip if [true, false].include?(reserve_ip)
|
54
|
+
options[:accessActivityLog] = access_activity_log if [true, false].include?(access_activity_log)
|
52
55
|
|
53
56
|
data = service.update_group(id, options)
|
54
57
|
merge_attributes(flatten(data.body))
|
@@ -8,6 +8,8 @@ module Fog
|
|
8
8
|
|
9
9
|
identity :id
|
10
10
|
|
11
|
+
attribute :type
|
12
|
+
|
11
13
|
# properties
|
12
14
|
attribute :name
|
13
15
|
attribute :description
|
@@ -26,6 +28,7 @@ module Fog
|
|
26
28
|
attribute :licence_type, :aliases => 'licenceType'
|
27
29
|
attribute :image_type, :aliases => 'imageType'
|
28
30
|
attribute :public
|
31
|
+
attribute :image_aliases, :aliases => 'imageAliases'
|
29
32
|
|
30
33
|
# metadata
|
31
34
|
attribute :created_date, :aliases => 'createdDate', :type => :time
|
@@ -7,6 +7,7 @@ module Fog
|
|
7
7
|
include Fog::Helpers::ProfitBricks::DataHelper
|
8
8
|
|
9
9
|
identity :id
|
10
|
+
attribute :type
|
10
11
|
|
11
12
|
# properties
|
12
13
|
attribute :name
|
@@ -24,7 +25,7 @@ module Fog
|
|
24
25
|
# entities
|
25
26
|
attribute :nics
|
26
27
|
|
27
|
-
attribute :datacenter_id
|
28
|
+
attribute :datacenter_id, :aliases => 'datacenterId'
|
28
29
|
|
29
30
|
attr_accessor :options
|
30
31
|
|
@@ -9,6 +9,8 @@ module Fog
|
|
9
9
|
|
10
10
|
identity :id
|
11
11
|
|
12
|
+
attribute :type
|
13
|
+
|
12
14
|
# properties
|
13
15
|
attribute :name
|
14
16
|
attribute :cores
|
@@ -29,7 +31,7 @@ module Fog
|
|
29
31
|
attribute :state
|
30
32
|
|
31
33
|
# entities
|
32
|
-
|
34
|
+
attribute :cdroms
|
33
35
|
attribute :volumes
|
34
36
|
attribute :nics
|
35
37
|
|
@@ -203,6 +205,7 @@ module Fog
|
|
203
205
|
|
204
206
|
def get_volumes(volumes)
|
205
207
|
items = []
|
208
|
+
|
206
209
|
for volume in volumes do
|
207
210
|
item = {}
|
208
211
|
item[:name] = volume[:name]
|
@@ -210,6 +213,7 @@ module Fog
|
|
210
213
|
item[:type] = volume[:type]
|
211
214
|
item[:bus] = volume[:bus] || 'VIRTIO'
|
212
215
|
item[:image] = volume[:image]
|
216
|
+
item[:imageAlias] = volume[:image_alias]
|
213
217
|
item[:imagePassword] = volume[:image_password]
|
214
218
|
item[:sshKeys] = volume[:ssh_keys]
|
215
219
|
item[:licenceType] = volume[:licence_type]
|
@@ -8,6 +8,8 @@ module Fog
|
|
8
8
|
|
9
9
|
identity :id
|
10
10
|
|
11
|
+
attribute :type
|
12
|
+
|
11
13
|
# properties
|
12
14
|
attribute :edit_privilege, :aliases => 'editPrivilege'
|
13
15
|
attribute :share_privilege, :aliases => 'sharePrivilege'
|
@@ -40,8 +42,8 @@ module Fog
|
|
40
42
|
requires :group_id, :resource_id
|
41
43
|
|
42
44
|
options = {}
|
43
|
-
options[:editPrivilege] = edit_privilege if edit_privilege
|
44
|
-
options[:sharePrivilege] = share_privilege if share_privilege
|
45
|
+
options[:editPrivilege] = edit_privilege if [true, false].include?(edit_privilege)
|
46
|
+
options[:sharePrivilege] = share_privilege if [true, false].include?(share_privilege)
|
45
47
|
|
46
48
|
data = service.update_share(group_id, resource_id, options)
|
47
49
|
merge_attributes(flatten(data.body))
|
@@ -8,6 +8,9 @@ module Fog
|
|
8
8
|
|
9
9
|
identity :id
|
10
10
|
|
11
|
+
attribute :type
|
12
|
+
attribute :request_id
|
13
|
+
|
11
14
|
# metadata
|
12
15
|
attribute :etag
|
13
16
|
attribute :creation_date, :aliases => 'creationDate'
|
@@ -22,7 +25,7 @@ module Fog
|
|
22
25
|
attribute :force_sec_auth, :aliases => 'forceSecAuth'
|
23
26
|
attribute :sec_auth_active, :aliases => 'secAuthActive'
|
24
27
|
|
25
|
-
#
|
28
|
+
# entities
|
26
29
|
attribute :owns
|
27
30
|
attribute :groups
|
28
31
|
|
@@ -48,8 +48,8 @@ module Fog
|
|
48
48
|
'type' => 'resource',
|
49
49
|
'href' => "https=>//api.profitbricks.com/rest/v4/um/groups/#{group_id}/shares/#{resource_id}",
|
50
50
|
'properties' => {
|
51
|
-
'editPrivilege' => options[:
|
52
|
-
'sharePrivilege' => options[:
|
51
|
+
'editPrivilege' => options[:editPrivilege],
|
52
|
+
'sharePrivilege' => options[:sharePrivilege]
|
53
53
|
}
|
54
54
|
}
|
55
55
|
|
@@ -67,18 +67,18 @@ module Fog
|
|
67
67
|
grp["id"] == group_id
|
68
68
|
end
|
69
69
|
else
|
70
|
-
raise Excon::Error::HTTPStatus, "
|
70
|
+
raise Excon::Error::HTTPStatus, "Resource does not exist"
|
71
71
|
end
|
72
72
|
|
73
73
|
if user = data[:users]['items'].find do |usr|
|
74
74
|
usr["id"] == user_id
|
75
75
|
end
|
76
76
|
else
|
77
|
-
raise Excon::Error::HTTPStatus, "
|
77
|
+
raise Excon::Error::HTTPStatus, "Resource does not exist"
|
78
78
|
end
|
79
79
|
|
80
|
-
group['users'] << user
|
81
|
-
user['groups'] << group
|
80
|
+
group['users']['items'] << user
|
81
|
+
user['groups']['items'] << group
|
82
82
|
|
83
83
|
response.body = user
|
84
84
|
response
|
@@ -48,10 +48,10 @@ module Fog
|
|
48
48
|
}
|
49
49
|
|
50
50
|
request(
|
51
|
-
:expects
|
52
|
-
:method
|
53
|
-
:path
|
54
|
-
:body
|
51
|
+
:expects => [202],
|
52
|
+
:method => 'POST',
|
53
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms",
|
54
|
+
:body => Fog::JSON.encode(volume)
|
55
55
|
)
|
56
56
|
end
|
57
57
|
end
|
@@ -62,32 +62,33 @@ module Fog
|
|
62
62
|
cd["id"] == cdrom_image_id
|
63
63
|
end
|
64
64
|
else
|
65
|
-
raise
|
65
|
+
raise Excon::Error::HTTPStatus, "Resource does not exist"
|
66
66
|
end
|
67
67
|
|
68
68
|
if server = data[:servers]['items'].find do |serv|
|
69
69
|
serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
|
70
70
|
end
|
71
71
|
else
|
72
|
-
raise
|
72
|
+
raise Excon::Error::HTTPStatus, "Resource does not exist"
|
73
73
|
end
|
74
74
|
|
75
|
-
|
76
|
-
|
75
|
+
cdrom['properties'] = {}
|
76
|
+
cdrom['properties']['name'] = cdrom['name']
|
77
|
+
|
78
|
+
if server['cdroms'] && server['cdroms']['items']
|
79
|
+
server['cdroms']['items'] << cdrom
|
77
80
|
else
|
78
|
-
server['
|
79
|
-
'
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
'items' => [cdrom]
|
84
|
-
}
|
81
|
+
server['cdroms'] = {
|
82
|
+
'id' => "#{server['id']}/cdroms",
|
83
|
+
'type' => 'collection',
|
84
|
+
'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{server['datacenter_id']}/servers/#{server['id']}/cdroms",
|
85
|
+
'items' => [cdrom]
|
85
86
|
}
|
86
87
|
end
|
87
88
|
|
88
|
-
response
|
89
|
+
response = Excon::Response.new
|
89
90
|
response.status = 202
|
90
|
-
response.body
|
91
|
+
response.body = cdrom
|
91
92
|
|
92
93
|
response
|
93
94
|
end
|
@@ -63,16 +63,23 @@ module Fog
|
|
63
63
|
vlm["id"] == storage_id && vlm["datacenter_id"] == datacenter_id
|
64
64
|
end
|
65
65
|
else
|
66
|
-
raise
|
66
|
+
raise Excon::Error::HTTPStatus, "Resource does not exist"
|
67
67
|
end
|
68
68
|
|
69
69
|
if server = data[:servers]['items'].find do |serv|
|
70
70
|
serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
|
71
71
|
end
|
72
72
|
else
|
73
|
-
raise
|
73
|
+
raise Excon::Error::HTTPStatus, "Resource does not exist"
|
74
74
|
end
|
75
75
|
|
76
|
+
volume['properties'] = {}
|
77
|
+
volume['properties']['name'] = volume['name']
|
78
|
+
volume['properties']['size'] = volume['size']
|
79
|
+
volume['properties']['bus'] = volume['bus']
|
80
|
+
volume['properties']['type'] = volume['type']
|
81
|
+
volume['properties']['licenceType'] = 'LINUX'
|
82
|
+
|
76
83
|
if server['entities'] && server['entities']['volumes'] && server['entities']['volumes']['items']
|
77
84
|
server['entities']['volumes']['items'] << volume
|
78
85
|
else
|