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
@@ -33,16 +33,16 @@ module Fog
|
|
33
33
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-ip-blocks]
|
34
34
|
def get_all_ip_blocks
|
35
35
|
request(
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
:expects => [200],
|
37
|
+
:method => 'GET',
|
38
|
+
:path => "/ipblocks?depth=5"
|
39
39
|
)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
class Mock
|
44
44
|
def get_all_ip_blocks
|
45
|
-
ip_blocks =
|
45
|
+
ip_blocks = data[:ip_blocks]
|
46
46
|
|
47
47
|
response = Excon::Response.new
|
48
48
|
response.status = 200
|
@@ -53,4 +53,4 @@ module Fog
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
-
end
|
56
|
+
end
|
@@ -1,120 +1,120 @@
|
|
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
|
-
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
# Retrieves a list of LANs
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * datacenter_id<~String> - UUID of the datacenter
|
9
|
+
#
|
10
|
+
# ==== Returns
|
11
|
+
# * response<~Excon::Response>:
|
12
|
+
# * body<~Hash>:
|
13
|
+
# * id<~String> - The resource's unique identifier
|
14
|
+
# * type<~String> - The type of the created resource
|
15
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
16
|
+
# * items<~Hash> - Collection of individual lan objects
|
17
|
+
# * id<~String> - The resource's unique identifier
|
18
|
+
# * type<~String> - The type of the created resource
|
19
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
20
|
+
# * metadata<~Hash> - Hash containing the LAN metadata
|
21
|
+
# * createdDate<~String> - The date the resource was created
|
22
|
+
# * createdBy<~String> - The user who created the resource
|
23
|
+
# * etag<~String> - The etag for the resource
|
24
|
+
# * lastModifiedDate<~String> - The last time the resource has been modified
|
25
|
+
# * lastModifiedBy<~String> - The user who last modified the resource
|
26
|
+
# * state<~String> - LAN state
|
27
|
+
# * properties<~Hash> - Hash containing the LAN properties
|
28
|
+
# * name<~String> - The name of the LAN
|
29
|
+
# * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not
|
30
|
+
# * entities<~Hash> - Hash containing the LAN entities
|
31
|
+
# * nics<~Hash> - Hash containing the NIC properties
|
32
|
+
# * id<~String> - The resource's unique identifier
|
33
|
+
# * type<~String> - The type of the created resource
|
34
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
35
|
+
# * items<~Hash> - Collection of individual nic objects
|
36
|
+
# * id<~String> - The resource's unique identifier
|
37
|
+
# * type<~String> - The type of the created resource
|
38
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
39
|
+
# * metadata<~Hash> - Hash containing the NIC metadata
|
40
|
+
# * createdDate<~String> - The date the resource was created
|
41
|
+
# * createdBy<~String> - The user who created the resource
|
42
|
+
# * etag<~String> - The etag for the resource
|
43
|
+
# * lastModifiedDate<~String> - The last time the resource has been modified
|
44
|
+
# * lastModifiedBy<~String> - The user who last modified the resource
|
45
|
+
# * state<~String> - NIC state
|
46
|
+
# * properties<~Hash> - Hash containing the NIC properties
|
47
|
+
# * name<~String> - The name of the NIC
|
48
|
+
# * mac<~String> - The MAC address of the NIC
|
49
|
+
# * ips<~Array> - IPs assigned to the NIC represented as a collection
|
50
|
+
# * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
|
51
|
+
# * lan<~Integer> - The LAN ID the NIC sits on
|
52
|
+
# * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
|
53
|
+
# * entities<~Hash> - Hash containing the NIC entities
|
54
|
+
# * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
|
55
|
+
# * id<~String> - The resource's unique identifier
|
56
|
+
# * type<~String> - The type of the resource
|
57
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
58
|
+
# * items<~Array> - Collection of individual firewall rules objects
|
59
|
+
# * id<~String> - The resource's unique identifier
|
60
|
+
# * type<~String> - The type of the resource
|
61
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
62
|
+
# * metadata<~Hash> - Hash containing the Firewall Rule metadata
|
63
|
+
# * createdDate<~String> - The date the resource was created
|
64
|
+
# * createdBy<~String> - The user who created the resource
|
65
|
+
# * etag<~String> - The etag for the resource
|
66
|
+
# * lastModifiedDate<~String> - The last time the resource has been modified
|
67
|
+
# * lastModifiedBy<~String> - The user who last modified the resource
|
68
|
+
# * state<~String> - Firewall Rule state
|
69
|
+
# * properties<~Hash> - Hash containing the Firewall Rule properties
|
70
|
+
# * name<~String> - The name of the Firewall Rule
|
71
|
+
# * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
|
72
|
+
# * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
|
73
|
+
# Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
|
74
|
+
# * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
|
75
|
+
# Value null allows all source IPs
|
76
|
+
# * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
|
77
|
+
# to the respective IP address of the NIC is allowed. Value null allows all target IPs
|
78
|
+
# * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
|
79
|
+
# Value null allows all codes.
|
80
|
+
# * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
|
81
|
+
# Value null allows all types
|
82
|
+
# * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
|
83
|
+
# if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
|
84
|
+
# value null to allow all ports
|
85
|
+
# * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
|
86
|
+
# if the protocol TCP or UDP is chosen. Leave portRangeStart and
|
87
|
+
# portRangeEnd value null to allow all ports
|
88
|
+
#
|
89
|
+
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-lans]
|
90
|
+
def get_all_lans(datacenter_id)
|
91
|
+
request(
|
92
|
+
:expects => [200],
|
93
|
+
:method => 'GET',
|
94
|
+
:path => "/datacenters/#{datacenter_id}/lans?depth=1"
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
class Mock
|
100
|
+
def get_all_lans(datacenter_id)
|
101
|
+
lans = data[:lans]
|
102
102
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
103
|
+
if lns = data[:lans]['items'].select do |attrib|
|
104
|
+
attrib['datacenter_id'] == datacenter_id
|
105
|
+
end
|
106
|
+
else
|
107
|
+
raise Fog::Errors::NotFound, 'The resource could not be found'
|
108
|
+
end
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
lans['items'] = lns
|
111
|
+
response = Excon::Response.new
|
112
|
+
response.status = 200
|
113
|
+
response.body = lans
|
114
114
|
|
115
|
-
|
116
|
-
end
|
117
|
-
end
|
115
|
+
response
|
118
116
|
end
|
117
|
+
end
|
119
118
|
end
|
120
|
-
end
|
119
|
+
end
|
120
|
+
end
|
@@ -71,23 +71,29 @@ module Fog
|
|
71
71
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-load-balanced-nics]
|
72
72
|
def get_all_load_balanced_nics(datacenter_id, load_balancer_id)
|
73
73
|
request(
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
:expects => [200],
|
75
|
+
:method => 'GET',
|
76
|
+
:path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics?depth=5"
|
77
77
|
)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
class Mock
|
82
82
|
def get_all_load_balanced_nics(datacenter_id, load_balancer_id)
|
83
|
-
if load_balancer =
|
84
|
-
|
85
|
-
|
83
|
+
if load_balancer = data[:load_balancers]['items'].find do |lb|
|
84
|
+
lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id
|
85
|
+
end
|
86
86
|
else
|
87
|
-
raise Fog::Errors::NotFound
|
87
|
+
raise Fog::Errors::NotFound, "The requested resource could not be found"
|
88
88
|
end
|
89
89
|
|
90
|
-
load_balanced_nics =
|
90
|
+
load_balanced_nics = nil
|
91
|
+
|
92
|
+
load_balanced_nics = if load_balancer['entities']
|
93
|
+
load_balancer['entities']['balancednics']
|
94
|
+
else
|
95
|
+
load_balancer['balancednics']
|
96
|
+
end
|
91
97
|
|
92
98
|
response = Excon::Response.new
|
93
99
|
response.status = 200
|
@@ -97,4 +103,4 @@ module Fog
|
|
97
103
|
end
|
98
104
|
end
|
99
105
|
end
|
100
|
-
end
|
106
|
+
end
|
@@ -90,28 +90,28 @@ module Fog
|
|
90
90
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-load-balancers]
|
91
91
|
def get_all_load_balancers(datacenter_id)
|
92
92
|
request(
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
:expects => [200],
|
94
|
+
:method => 'GET',
|
95
|
+
:path => "/datacenters/#{datacenter_id}/loadbalancers?depth=5"
|
96
96
|
)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
class Mock
|
101
101
|
def get_all_load_balancers(datacenter_id)
|
102
|
-
if load_balancers =
|
103
|
-
|
104
|
-
|
102
|
+
if load_balancers = data[:load_balancers]['items'].select do |attrib|
|
103
|
+
attrib['datacenter_id'] == datacenter_id
|
104
|
+
end
|
105
105
|
else
|
106
|
-
raise Fog::Errors::NotFound
|
106
|
+
raise Fog::Errors::NotFound, 'The requested Load Balancer resource could not be found'
|
107
107
|
end
|
108
108
|
|
109
109
|
response = Excon::Response.new
|
110
110
|
response.status = 200
|
111
|
-
response.body =
|
111
|
+
response.body = data[:load_balancers]
|
112
112
|
response
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
117
|
-
end
|
117
|
+
end
|
@@ -32,12 +32,12 @@ module Fog
|
|
32
32
|
end
|
33
33
|
|
34
34
|
class Mock
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
def get_all_locations(_options = {})
|
36
|
+
response = Excon::Response.new
|
37
|
+
response.status = 200
|
38
|
+
response.body = data[:locations]
|
39
|
+
response
|
40
|
+
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -1,102 +1,102 @@
|
|
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
|
-
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
# Retrieves a list of NICs
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * datacenter_id<~String> - UUID of the datacenter
|
9
|
+
# * server_id<~String> - UUID of the server
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# * id<~String> - The resource's unique identifier
|
15
|
+
# * type<~String> - The type of the created resource
|
16
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
17
|
+
# * items<~Hash> - Collection of individual nic objects
|
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
|
+
# * metadata<~Hash> - Hash containing the NIC metadata
|
22
|
+
# * createdDate<~String> - The date the resource was created
|
23
|
+
# * createdBy<~String> - The user who created the resource
|
24
|
+
# * etag<~String> - The etag for the resource
|
25
|
+
# * lastModifiedDate<~String> - The last time the resource has been modified
|
26
|
+
# * lastModifiedBy<~String> - The user who last modified the resource
|
27
|
+
# * state<~String> - NIC state
|
28
|
+
# * properties<~Hash> - Hash containing the NIC properties
|
29
|
+
# * name<~String> - The name of the NIC
|
30
|
+
# * mac<~String> - The MAC address of the NIC
|
31
|
+
# * ips<~Array> - IPs assigned to the NIC represented as a collection
|
32
|
+
# * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
|
33
|
+
# * lan<~Integer> - The LAN ID the NIC sits on
|
34
|
+
# * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
|
35
|
+
# * entities<~Hash> - Hash containing the NIC entities
|
36
|
+
# * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
|
37
|
+
# * id<~String> - The resource's unique identifier
|
38
|
+
# * type<~String> - The type of the resource
|
39
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
40
|
+
# * items<~Array> - Collection of individual firewall rules objects
|
41
|
+
# * id<~String> - The resource's unique identifier
|
42
|
+
# * type<~String> - The type of the resource
|
43
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
44
|
+
# * metadata<~Hash> - Hash containing the Firewall Rule 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> - Firewall Rule state
|
51
|
+
# * properties<~Hash> - Hash containing the Firewall Rule properties
|
52
|
+
# * name<~String> - The name of the Firewall Rule
|
53
|
+
# * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
|
54
|
+
# * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
|
55
|
+
# Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
|
56
|
+
# * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
|
57
|
+
# Value null allows all source IPs
|
58
|
+
# * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
|
59
|
+
# to the respective IP address of the NIC is allowed. Value null allows all target IPs
|
60
|
+
# * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
|
61
|
+
# Value null allows all codes.
|
62
|
+
# * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
|
63
|
+
# Value null allows all types
|
64
|
+
# * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
|
65
|
+
# if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
|
66
|
+
# value null to allow all ports
|
67
|
+
# * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
|
68
|
+
# if the protocol TCP or UDP is chosen. Leave portRangeStart and
|
69
|
+
# portRangeEnd value null to allow all ports
|
70
|
+
#
|
71
|
+
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-nics]
|
72
|
+
def get_all_nic(datacenter_id, server_id)
|
73
|
+
request(
|
74
|
+
:expects => [200],
|
75
|
+
:method => 'GET',
|
76
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics?depth=5"
|
77
|
+
)
|
78
|
+
end
|
79
|
+
end
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
class Mock
|
82
|
+
def get_all_nic(datacenter_id, _server_id)
|
83
|
+
interfaces = data[:nics]
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
if nics = interfaces['items'].select do |attrib|
|
86
|
+
attrib['datacenter_id'] == datacenter_id
|
87
|
+
end
|
88
|
+
else
|
89
|
+
raise Fog::Errors::NotFound, 'The resource could not be found'
|
90
|
+
end
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
interfaces['items'] = nics
|
93
|
+
response = Excon::Response.new
|
94
|
+
response.status = 200
|
95
|
+
response.body = interfaces
|
96
96
|
|
97
|
-
|
98
|
-
end
|
99
|
-
end
|
97
|
+
response
|
100
98
|
end
|
99
|
+
end
|
101
100
|
end
|
101
|
+
end
|
102
102
|
end
|