fog-profitbricks 2.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +11 -4
- data/README.md +8 -5
- data/Rakefile +1 -1
- data/examples/pb_demo.rb +49 -49
- data/fog-profitbricks.gemspec +4 -5
- data/gemfiles/Gemfile.1.9.2+ +1 -0
- data/lib/fog/bin/profitbricks.rb +5 -5
- data/lib/fog/profitbricks.rb +3 -3
- data/lib/fog/profitbricks/compute.rb +209 -204
- data/lib/fog/profitbricks/helpers/compute/data_helper.rb +1 -1
- data/lib/fog/profitbricks/models/compute/datacenter.rb +1 -1
- data/lib/fog/profitbricks/models/compute/datacenters.rb +6 -7
- data/lib/fog/profitbricks/models/compute/firewall_rule.rb +2 -2
- data/lib/fog/profitbricks/models/compute/firewall_rules.rb +5 -8
- data/lib/fog/profitbricks/models/compute/flavors.rb +1 -4
- data/lib/fog/profitbricks/models/compute/image.rb +4 -0
- data/lib/fog/profitbricks/models/compute/images.rb +2 -5
- data/lib/fog/profitbricks/models/compute/ip_block.rb +1 -1
- data/lib/fog/profitbricks/models/compute/ip_blocks.rb +3 -8
- data/lib/fog/profitbricks/models/compute/lan.rb +1 -1
- data/lib/fog/profitbricks/models/compute/lans.rb +4 -7
- data/lib/fog/profitbricks/models/compute/load_balancer.rb +6 -7
- data/lib/fog/profitbricks/models/compute/load_balancers.rb +5 -9
- data/lib/fog/profitbricks/models/compute/locations.rb +2 -5
- data/lib/fog/profitbricks/models/compute/nic.rb +6 -3
- data/lib/fog/profitbricks/models/compute/nics.rb +2 -5
- data/lib/fog/profitbricks/models/compute/regions.rb +1 -4
- data/lib/fog/profitbricks/models/compute/request.rb +0 -1
- data/lib/fog/profitbricks/models/compute/requests.rb +2 -4
- data/lib/fog/profitbricks/models/compute/server.rb +10 -13
- data/lib/fog/profitbricks/models/compute/servers.rb +3 -6
- data/lib/fog/profitbricks/models/compute/snapshot.rb +2 -2
- data/lib/fog/profitbricks/models/compute/snapshots.rb +3 -6
- data/lib/fog/profitbricks/models/compute/volume.rb +11 -9
- data/lib/fog/profitbricks/models/compute/volumes.rb +3 -6
- data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +26 -13
- data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +25 -16
- data/lib/fog/profitbricks/requests/compute/attach_volume.rb +25 -16
- data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +22 -23
- data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +24 -26
- data/lib/fog/profitbricks/requests/compute/create_flavor.rb +34 -34
- data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +18 -20
- data/lib/fog/profitbricks/requests/compute/create_lan.rb +151 -150
- data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +67 -26
- data/lib/fog/profitbricks/requests/compute/create_nic.rb +24 -26
- data/lib/fog/profitbricks/requests/compute/create_server.rb +70 -61
- data/lib/fog/profitbricks/requests/compute/create_volume.rb +122 -122
- data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +42 -45
- data/lib/fog/profitbricks/requests/compute/delete_datacenter.rb +34 -36
- data/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb +8 -11
- data/lib/fog/profitbricks/requests/compute/delete_image.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/delete_ip_block.rb +8 -10
- data/lib/fog/profitbricks/requests/compute/delete_lan.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb +8 -10
- data/lib/fog/profitbricks/requests/compute/delete_nic.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/delete_server.rb +6 -10
- data/lib/fog/profitbricks/requests/compute/delete_snapshot.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/delete_volume.rb +36 -38
- data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +11 -13
- data/lib/fog/profitbricks/requests/compute/detach_volume.rb +16 -13
- data/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb +6 -7
- data/lib/fog/profitbricks/requests/compute/get_all_flavors.rb +72 -72
- data/lib/fog/profitbricks/requests/compute/get_all_images.rb +62 -62
- data/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb +5 -5
- data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +113 -113
- data/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb +15 -9
- data/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb +9 -9
- data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +6 -6
- data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +94 -94
- data/lib/fog/profitbricks/requests/compute/get_all_requests.rb +38 -38
- data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +8 -9
- data/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb +4 -4
- data/lib/fog/profitbricks/requests/compute/get_all_volumes.rb +71 -71
- data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +11 -11
- data/lib/fog/profitbricks/requests/compute/get_attached_volume.rb +16 -11
- data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +4 -6
- data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +8 -11
- data/lib/fog/profitbricks/requests/compute/get_flavor.rb +9 -9
- data/lib/fog/profitbricks/requests/compute/get_image.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +8 -10
- data/lib/fog/profitbricks/requests/compute/get_lan.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +16 -12
- data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_location.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_nic.rb +8 -11
- data/lib/fog/profitbricks/requests/compute/get_request.rb +55 -57
- data/lib/fog/profitbricks/requests/compute/get_request_status.rb +44 -46
- data/lib/fog/profitbricks/requests/compute/get_server.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_volume.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +8 -8
- data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +18 -8
- data/lib/fog/profitbricks/requests/compute/reboot_server.rb +7 -11
- data/lib/fog/profitbricks/requests/compute/remove_nic_association.rb +9 -11
- data/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb +15 -17
- data/lib/fog/profitbricks/requests/compute/start_server.rb +7 -11
- data/lib/fog/profitbricks/requests/compute/stop_server.rb +7 -11
- data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +20 -15
- data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +9 -11
- data/lib/fog/profitbricks/requests/compute/update_image.rb +15 -15
- data/lib/fog/profitbricks/requests/compute/update_lan.rb +6 -8
- data/lib/fog/profitbricks/requests/compute/update_load_balancer.rb +10 -12
- data/lib/fog/profitbricks/requests/compute/update_nic.rb +10 -12
- data/lib/fog/profitbricks/requests/compute/update_server.rb +10 -13
- data/lib/fog/profitbricks/requests/compute/update_snapshot.rb +10 -13
- data/lib/fog/profitbricks/requests/compute/update_volume.rb +10 -13
- data/lib/fog/profitbricks/version.rb +1 -1
- data/spec/minitest_helper.rb +1 -3
- data/tests/helpers/formats_helper.rb +8 -8
- data/tests/profitbricks/models/compute/compute_tests.rb +529 -0
- data/tests/profitbricks/requests/compute/composite_create_tests.rb +16 -83
- data/tests/profitbricks/requests/compute/flavor_tests.rb +1 -4
- data/tests/profitbricks/requests/compute/location_tests.rb +14 -17
- data/tests/profitbricks/requests/compute/nic_tests.rb +60 -70
- data/tests/profitbricks/requests/compute/request_tests.rb +1 -3
- data/tests/profitbricks/requests/compute/server_tests.rb +163 -161
- metadata +5 -18
@@ -52,47 +52,45 @@ module Fog
|
|
52
52
|
# Leave portRangeStart and portRangeEnd null to allow all ports
|
53
53
|
#
|
54
54
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-firewall-rule]
|
55
|
-
def create_firewall_rule(datacenter_id, server_id, nic_id, options={})
|
55
|
+
def create_firewall_rule(datacenter_id, server_id, nic_id, options = {})
|
56
56
|
firewall_rule = {
|
57
|
-
|
57
|
+
:properties => options
|
58
58
|
}
|
59
59
|
|
60
60
|
request(
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
:expects => [202],
|
62
|
+
:method => 'POST',
|
63
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules",
|
64
|
+
:body => Fog::JSON.encode(firewall_rule)
|
65
65
|
)
|
66
|
-
rescue => error
|
67
|
-
Fog::Errors::NotFound.new(error)
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
71
69
|
class Mock
|
72
|
-
def create_firewall_rule(datacenter_id, server_id, nic_id, options={})
|
70
|
+
def create_firewall_rule(datacenter_id, server_id, nic_id, options = {})
|
73
71
|
response = Excon::Response.new
|
74
72
|
response.status = 202
|
75
73
|
|
76
74
|
firewall_rule_id = Fog::UUID.uuid
|
77
75
|
firewall_rule = {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
76
|
+
'id' => firewall_rule_id,
|
77
|
+
'type' => 'nic',
|
78
|
+
'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}",
|
79
|
+
'metadata' => {
|
80
|
+
'createdDate' => '2015-03-18T19:00:51Z',
|
81
|
+
'createdBy' => 'test@stackpointcloud.com',
|
82
|
+
'etag' => 'faa67fbacb1c0e2e02cf9650657251f2',
|
83
|
+
'lastModifiedDate' => '2015-03-18T19:00:51Z',
|
84
|
+
'lastModifiedBy' => 'test@stackpointcloud.com',
|
85
|
+
'state' => 'AVAILABLE'
|
86
|
+
},
|
87
|
+
'properties' => options,
|
88
|
+
'datacenter_id' => datacenter_id,
|
89
|
+
'server_id' => server_id,
|
90
|
+
'nic_id' => nic_id
|
93
91
|
}
|
94
92
|
|
95
|
-
|
93
|
+
data[:firewall_rules]['items'] << firewall_rule
|
96
94
|
response.body = firewall_rule
|
97
95
|
|
98
96
|
response
|
@@ -100,4 +98,4 @@ module Fog
|
|
100
98
|
end
|
101
99
|
end
|
102
100
|
end
|
103
|
-
end
|
101
|
+
end
|
@@ -1,40 +1,40 @@
|
|
1
1
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
# Not a real API method; will only return flavor object.
|
6
|
+
def create_flavor(flavor_name, cores, ram)
|
7
|
+
response = Excon::Response.new
|
8
|
+
response.status = 200
|
9
|
+
response.body = {
|
10
|
+
'createFlavorResponse' => {
|
11
|
+
'id' => Fog::UUID.uuid,
|
12
|
+
'name' => flavor_name,
|
13
|
+
'cores' => cores,
|
14
|
+
'ram' => ram
|
15
|
+
}
|
16
|
+
}
|
17
|
+
response
|
18
|
+
end
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
class Mock
|
22
|
+
def create_flavor(flavor_name, ram, cores)
|
23
|
+
response = Excon::Response.new
|
24
|
+
response.status = 200
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
flavor = {
|
27
|
+
'id' => Fog::UUID.uuid,
|
28
|
+
'name' => flavor_name,
|
29
|
+
'ram' => ram,
|
30
|
+
'cores' => cores
|
31
|
+
}
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
33
|
+
data[:flavors] << flavor
|
34
|
+
response.body = { 'createFlavorResponse' => flavor }
|
35
|
+
response
|
38
36
|
end
|
37
|
+
end
|
39
38
|
end
|
40
|
-
end
|
39
|
+
end
|
40
|
+
end
|
@@ -32,17 +32,15 @@ module Fog
|
|
32
32
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-ip-block]
|
33
33
|
def create_ip_block(options = {})
|
34
34
|
ip_block = {
|
35
|
-
|
35
|
+
:properties => options
|
36
36
|
}
|
37
37
|
|
38
38
|
request(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
:expects => [202],
|
40
|
+
:method => 'POST',
|
41
|
+
:path => "/ipblocks",
|
42
|
+
:body => Fog::JSON.encode(ip_block)
|
43
43
|
)
|
44
|
-
rescue => error
|
45
|
-
Fog::Errors::NotFound.new(error)
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
@@ -53,23 +51,23 @@ module Fog
|
|
53
51
|
'id' => ipb_3_id,
|
54
52
|
'type' => 'ipblock',
|
55
53
|
'href' => "https://api.profitbricks.com/rest/v2/ipblocks/#{ipb_3_id}",
|
56
|
-
'metadata'
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
'metadata' => {
|
55
|
+
'createdDate' => '2016-07-31T15:41:27Z',
|
56
|
+
'createdBy' => 'test@stackpointcloud.com',
|
57
|
+
'etag' => '5b91832ee85a758568d4523a86bd8702',
|
58
|
+
'lastModifiedDate' => '2016-07-31T15:41:27Z',
|
59
|
+
'lastModifiedBy' => 'test@stackpointcloud.com',
|
60
|
+
'state' => 'AVAILABLE'
|
63
61
|
},
|
64
62
|
'properties' => {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
'ips' => ["777.777.777.777", "888.888.888.888", "999.999.999.999"],
|
64
|
+
'location' => options[:location],
|
65
|
+
'size' => options[:size],
|
66
|
+
'name' => options[:name]
|
69
67
|
}
|
70
68
|
}
|
71
69
|
|
72
|
-
|
70
|
+
data[:ip_blocks]['items'] << ip_block
|
73
71
|
response = Excon::Response.new
|
74
72
|
response.status = 202
|
75
73
|
response.body = ip_block
|
@@ -78,4 +76,4 @@ module Fog
|
|
78
76
|
end
|
79
77
|
end
|
80
78
|
end
|
81
|
-
end
|
79
|
+
end
|
@@ -1,160 +1,161 @@
|
|
1
1
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
# Creates a LAN within a data center
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * datacenter_id<~String> - Required - UUID of virtual data center
|
9
|
+
# * properties<~Hash>:
|
10
|
+
# * name<~String> - The name of the LAN
|
11
|
+
# * public<~Integer> - Boolean indicating if the LAN faces the public Internet or not
|
12
|
+
# * entities<~Hash>:
|
13
|
+
# * nics<~Array> - A collection of NICs associated with the LAN
|
14
|
+
#
|
15
|
+
# ==== Returns
|
16
|
+
# * response<~Excon::Response>:
|
17
|
+
# * body<~Hash>:
|
18
|
+
# * id<~String> - The resource's unique identifier
|
19
|
+
# * type<~String> - The type of the created resource
|
20
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
21
|
+
# * items<~Hash> - Collection of individual lan objects
|
22
|
+
# * id<~String> - The resource's unique identifier
|
23
|
+
# * type<~String> - The type of the created resource
|
24
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
25
|
+
# * metadata<~Hash> - Hash containing the LAN metadata
|
26
|
+
# * createdDate<~String> - The date the resource was created
|
27
|
+
# * createdBy<~String> - The user who created the resource
|
28
|
+
# * etag<~String> - The etag for the resource
|
29
|
+
# * lastModifiedDate<~String> - The last time the resource has been modified
|
30
|
+
# * lastModifiedBy<~String> - The user who last modified the resource
|
31
|
+
# * state<~String> - LAN state
|
32
|
+
# * properties<~Hash> - Hash containing the LAN properties
|
33
|
+
# * name<~String> - The name of the LAN
|
34
|
+
# * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not
|
35
|
+
# * entities<~Hash> - Hash containing the LAN entities
|
36
|
+
# * nics<~Hash> - Hash containing the NIC properties
|
37
|
+
# * id<~String> - The resource's unique identifier
|
38
|
+
# * type<~String> - The type of the created resource
|
39
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
40
|
+
# * items<~Hash> - Collection of individual nic objects
|
41
|
+
# * id<~String> - The resource's unique identifier
|
42
|
+
# * type<~String> - The type of the created resource
|
43
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
44
|
+
# * metadata<~Hash> - Hash containing the NIC metadata
|
45
|
+
# * createdDate<~String> - The date the resource was created
|
46
|
+
# * createdBy<~String> - The user who created the resource
|
47
|
+
# * etag<~String> - The etag for the resource
|
48
|
+
# * lastModifiedDate<~String> - The last time the resource has been modified
|
49
|
+
# * lastModifiedBy<~String> - The user who last modified the resource
|
50
|
+
# * state<~String> - NIC state
|
51
|
+
# * properties<~Hash> - Hash containing the NIC properties
|
52
|
+
# * name<~String> - The name of the NIC
|
53
|
+
# * mac<~String> - The MAC address of the NIC
|
54
|
+
# * ips<~Array> - IPs assigned to the NIC represented as a collection
|
55
|
+
# * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
|
56
|
+
# * lan<~Integer> - The LAN ID the NIC sits on
|
57
|
+
# * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
|
58
|
+
# * entities<~Hash> - Hash containing the NIC entities
|
59
|
+
# * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
|
60
|
+
# * id<~String> - The resource's unique identifier
|
61
|
+
# * type<~String> - The type of the resource
|
62
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
63
|
+
# * items<~Array> - Collection of individual firewall rules objects
|
64
|
+
# * id<~String> - The resource's unique identifier
|
65
|
+
# * type<~String> - The type of the resource
|
66
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
67
|
+
# * metadata<~Hash> - Hash containing the Firewall Rule metadata
|
68
|
+
# * createdDate<~String> - The date the resource was created
|
69
|
+
# * createdBy<~String> - The user who created the resource
|
70
|
+
# * etag<~String> - The etag for the resource
|
71
|
+
# * lastModifiedDate<~String> - The last time the resource has been modified
|
72
|
+
# * lastModifiedBy<~String> - The user who last modified the resource
|
73
|
+
# * state<~String> - Firewall Rule state
|
74
|
+
# * properties<~Hash> - Hash containing the Firewall Rule properties
|
75
|
+
# * name<~String> - The name of the Firewall Rule
|
76
|
+
# * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
|
77
|
+
# * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
|
78
|
+
# Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
|
79
|
+
# * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
|
80
|
+
# Value null allows all source IPs
|
81
|
+
# * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
|
82
|
+
# to the respective IP address of the NIC is allowed. Value null allows all target IPs
|
83
|
+
# * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
|
84
|
+
# Value null allows all codes.
|
85
|
+
# * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
|
86
|
+
# Value null allows all types
|
87
|
+
# * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
|
88
|
+
# if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
|
89
|
+
# value null to allow all ports
|
90
|
+
# * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
|
91
|
+
# if the protocol TCP or UDP is chosen. Leave portRangeStart and
|
92
|
+
# portRangeEnd value null to allow all ports
|
93
|
+
#
|
94
|
+
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-lan]
|
95
|
+
def create_lan(datacenter_id, properties = {}, entities = {})
|
96
|
+
lan = {
|
97
|
+
:properties => properties,
|
98
|
+
:entities => entities
|
99
|
+
}
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
101
|
+
request(
|
102
|
+
:expects => [202],
|
103
|
+
:method => 'POST',
|
104
|
+
:path => "/datacenters/#{datacenter_id}/lans",
|
105
|
+
:body => Fog::JSON.encode(lan)
|
106
|
+
)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
class Mock
|
111
|
+
def create_lan(datacenter_id, properties = {}, _entities = {})
|
112
|
+
response = Excon::Response.new
|
113
|
+
response.status = 202
|
114
|
+
|
115
|
+
if datacenter = data[:datacenters]['items'].find do |attrib|
|
116
|
+
attrib['id'] == datacenter_id
|
117
|
+
end
|
111
118
|
|
112
|
-
|
113
|
-
|
114
|
-
response = Excon::Response.new
|
115
|
-
response.status = 202
|
119
|
+
datacenter['properties']['version'] += 1 if datacenter['properties']
|
120
|
+
datacenter['version'] += 1 if datacenter['version']
|
116
121
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
datacenter['version'] += 1
|
121
|
-
else
|
122
|
-
raise Fog::Errors::NotFound.new('Data center resource could not be found')
|
123
|
-
end
|
122
|
+
else
|
123
|
+
raise Fog::Errors::NotFound, 'Data center resource could not be found'
|
124
|
+
end
|
124
125
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
126
|
+
lan = {
|
127
|
+
'id' => '10',
|
128
|
+
'type' => 'nic',
|
129
|
+
'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/lans/10",
|
130
|
+
'metadata' => {
|
131
|
+
'createdDate' => '2015-03-18T19:00:51Z',
|
132
|
+
'createdBy' => 'test@stackpointcloud.com',
|
133
|
+
'etag' => 'faa67fbacb1c0e2e02cf9650657251f1',
|
134
|
+
'lastModifiedDate' => '2015-03-18T19:00:51Z',
|
135
|
+
'lastModifiedBy' => 'test@stackpointcloud.com',
|
136
|
+
'state' => 'AVAILABLE'
|
137
|
+
},
|
138
|
+
'properties' => {
|
139
|
+
'name' => properties[:name],
|
140
|
+
'public' => properties[:public]
|
141
|
+
},
|
142
|
+
'entities' => {
|
143
|
+
'nics' => {
|
144
|
+
'id' => '10/nics',
|
145
|
+
'type' => 'collection',
|
146
|
+
'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/lans/10/nics",
|
147
|
+
'items' => []
|
148
|
+
}
|
149
|
+
},
|
150
|
+
'datacenter_id' => datacenter_id
|
151
|
+
}
|
151
152
|
|
152
|
-
|
153
|
+
data[:lans]['items'] << lan
|
153
154
|
|
154
|
-
|
155
|
-
|
156
|
-
end
|
157
|
-
end
|
155
|
+
response.body = lan
|
156
|
+
response
|
158
157
|
end
|
158
|
+
end
|
159
159
|
end
|
160
|
+
end
|
160
161
|
end
|