fog-oneandone 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +36 -0
  3. data/CONTRIBUTING.md +276 -0
  4. data/CONTRIBUTORS.md +1 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.md +20 -0
  7. data/README.md +317 -0
  8. data/bin/fog +78 -0
  9. data/examples/example_app.rb +80 -0
  10. data/fog-oneandone.gemspec +22 -0
  11. data/gemfiles/Gemfile-edge +7 -0
  12. data/lib/fog-oneandone.rb +10 -0
  13. data/lib/oneandone/compute.rb +713 -0
  14. data/lib/oneandone/core.rb +11 -0
  15. data/lib/oneandone/models/compute/firewall.rb +128 -0
  16. data/lib/oneandone/models/compute/firewalls.rb +24 -0
  17. data/lib/oneandone/models/compute/image.rb +72 -0
  18. data/lib/oneandone/models/compute/images.rb +24 -0
  19. data/lib/oneandone/models/compute/load_balancer.rb +149 -0
  20. data/lib/oneandone/models/compute/load_balancers.rb +24 -0
  21. data/lib/oneandone/models/compute/monitoring_policies.rb +24 -0
  22. data/lib/oneandone/models/compute/monitoring_policy.rb +196 -0
  23. data/lib/oneandone/models/compute/private_network.rb +105 -0
  24. data/lib/oneandone/models/compute/private_networks.rb +24 -0
  25. data/lib/oneandone/models/compute/public_ip.rb +68 -0
  26. data/lib/oneandone/models/compute/public_ips.rb +24 -0
  27. data/lib/oneandone/models/compute/server.rb +434 -0
  28. data/lib/oneandone/models/compute/servers.rb +24 -0
  29. data/lib/oneandone/models/compute/shared_storage.rb +101 -0
  30. data/lib/oneandone/models/compute/shared_storages.rb +24 -0
  31. data/lib/oneandone/models/compute/vpn.rb +70 -0
  32. data/lib/oneandone/models/compute/vpns.rb +24 -0
  33. data/lib/oneandone/requests/compute/access.rb +35 -0
  34. data/lib/oneandone/requests/compute/add_firewall.rb +70 -0
  35. data/lib/oneandone/requests/compute/add_firewall_ips.rb +67 -0
  36. data/lib/oneandone/requests/compute/add_firewall_rules.rb +68 -0
  37. data/lib/oneandone/requests/compute/add_hdds.rb +65 -0
  38. data/lib/oneandone/requests/compute/add_load_balancer.rb +76 -0
  39. data/lib/oneandone/requests/compute/add_load_balancer_ips.rb +67 -0
  40. data/lib/oneandone/requests/compute/add_load_balancer_rules.rb +68 -0
  41. data/lib/oneandone/requests/compute/add_mp_servers.rb +64 -0
  42. data/lib/oneandone/requests/compute/add_ports.rb +65 -0
  43. data/lib/oneandone/requests/compute/add_private_network.rb +65 -0
  44. data/lib/oneandone/requests/compute/add_private_network_servers.rb +67 -0
  45. data/lib/oneandone/requests/compute/add_processes.rb +65 -0
  46. data/lib/oneandone/requests/compute/add_server_ip.rb +72 -0
  47. data/lib/oneandone/requests/compute/add_shared_storage_servers.rb +64 -0
  48. data/lib/oneandone/requests/compute/change_password.rb +45 -0
  49. data/lib/oneandone/requests/compute/change_status.rb +69 -0
  50. data/lib/oneandone/requests/compute/clone_server.rb +67 -0
  51. data/lib/oneandone/requests/compute/create_firewall.rb +78 -0
  52. data/lib/oneandone/requests/compute/create_image.rb +101 -0
  53. data/lib/oneandone/requests/compute/create_load_balancer.rb +104 -0
  54. data/lib/oneandone/requests/compute/create_monitoring_policy.rb +93 -0
  55. data/lib/oneandone/requests/compute/create_private_network.rb +82 -0
  56. data/lib/oneandone/requests/compute/create_public_ip.rb +77 -0
  57. data/lib/oneandone/requests/compute/create_server.rb +139 -0
  58. data/lib/oneandone/requests/compute/create_shared_storage.rb +83 -0
  59. data/lib/oneandone/requests/compute/create_snapshot.rb +51 -0
  60. data/lib/oneandone/requests/compute/create_vpn.rb +80 -0
  61. data/lib/oneandone/requests/compute/delete_firewall.rb +51 -0
  62. data/lib/oneandone/requests/compute/delete_firewall_rule.rb +60 -0
  63. data/lib/oneandone/requests/compute/delete_hdd.rb +61 -0
  64. data/lib/oneandone/requests/compute/delete_image.rb +51 -0
  65. data/lib/oneandone/requests/compute/delete_load_balancer.rb +51 -0
  66. data/lib/oneandone/requests/compute/delete_load_balancer_rule.rb +60 -0
  67. data/lib/oneandone/requests/compute/delete_monitoring_policy.rb +51 -0
  68. data/lib/oneandone/requests/compute/delete_port.rb +60 -0
  69. data/lib/oneandone/requests/compute/delete_private_network.rb +51 -0
  70. data/lib/oneandone/requests/compute/delete_process.rb +60 -0
  71. data/lib/oneandone/requests/compute/delete_public_ip.rb +51 -0
  72. data/lib/oneandone/requests/compute/delete_server.rb +51 -0
  73. data/lib/oneandone/requests/compute/delete_server_ip.rb +60 -0
  74. data/lib/oneandone/requests/compute/delete_shared_storage.rb +51 -0
  75. data/lib/oneandone/requests/compute/delete_snapshot.rb +51 -0
  76. data/lib/oneandone/requests/compute/delete_vpn.rb +51 -0
  77. data/lib/oneandone/requests/compute/eject_dvd.rb +51 -0
  78. data/lib/oneandone/requests/compute/get_datacenter.rb +50 -0
  79. data/lib/oneandone/requests/compute/get_dvd.rb +50 -0
  80. data/lib/oneandone/requests/compute/get_dvd_iso.rb +50 -0
  81. data/lib/oneandone/requests/compute/get_firewall.rb +50 -0
  82. data/lib/oneandone/requests/compute/get_firewall_ip.rb +59 -0
  83. data/lib/oneandone/requests/compute/get_firewall_rule.rb +59 -0
  84. data/lib/oneandone/requests/compute/get_fixed_server.rb +50 -0
  85. data/lib/oneandone/requests/compute/get_hardware.rb +50 -0
  86. data/lib/oneandone/requests/compute/get_hdd.rb +60 -0
  87. data/lib/oneandone/requests/compute/get_hdds.rb +50 -0
  88. data/lib/oneandone/requests/compute/get_image.rb +50 -0
  89. data/lib/oneandone/requests/compute/get_load_balancer.rb +50 -0
  90. data/lib/oneandone/requests/compute/get_load_balancer_ip.rb +59 -0
  91. data/lib/oneandone/requests/compute/get_load_balancer_rule.rb +59 -0
  92. data/lib/oneandone/requests/compute/get_log.rb +51 -0
  93. data/lib/oneandone/requests/compute/get_monitored_server.rb +49 -0
  94. data/lib/oneandone/requests/compute/get_monitoring_policy.rb +50 -0
  95. data/lib/oneandone/requests/compute/get_mp_server.rb +59 -0
  96. data/lib/oneandone/requests/compute/get_port.rb +59 -0
  97. data/lib/oneandone/requests/compute/get_private_network.rb +50 -0
  98. data/lib/oneandone/requests/compute/get_private_network_server.rb +59 -0
  99. data/lib/oneandone/requests/compute/get_process.rb +59 -0
  100. data/lib/oneandone/requests/compute/get_public_ip.rb +50 -0
  101. data/lib/oneandone/requests/compute/get_server.rb +50 -0
  102. data/lib/oneandone/requests/compute/get_server_appliance.rb +50 -0
  103. data/lib/oneandone/requests/compute/get_server_image.rb +50 -0
  104. data/lib/oneandone/requests/compute/get_server_ip.rb +59 -0
  105. data/lib/oneandone/requests/compute/get_server_private_network.rb +59 -0
  106. data/lib/oneandone/requests/compute/get_shared_storage.rb +50 -0
  107. data/lib/oneandone/requests/compute/get_shared_storage_server.rb +59 -0
  108. data/lib/oneandone/requests/compute/get_snapshot.rb +50 -0
  109. data/lib/oneandone/requests/compute/get_vpn.rb +50 -0
  110. data/lib/oneandone/requests/compute/install_server_image.rb +72 -0
  111. data/lib/oneandone/requests/compute/list_datacenters.rb +56 -0
  112. data/lib/oneandone/requests/compute/list_dvds.rb +56 -0
  113. data/lib/oneandone/requests/compute/list_firewall_ips.rb +50 -0
  114. data/lib/oneandone/requests/compute/list_firewall_rules.rb +50 -0
  115. data/lib/oneandone/requests/compute/list_firewalls.rb +56 -0
  116. data/lib/oneandone/requests/compute/list_fixed_servers.rb +40 -0
  117. data/lib/oneandone/requests/compute/list_images.rb +56 -0
  118. data/lib/oneandone/requests/compute/list_ip_firewalls.rb +59 -0
  119. data/lib/oneandone/requests/compute/list_ip_load_balancers.rb +59 -0
  120. data/lib/oneandone/requests/compute/list_load_balancer_ips.rb +50 -0
  121. data/lib/oneandone/requests/compute/list_load_balancer_rules.rb +50 -0
  122. data/lib/oneandone/requests/compute/list_load_balancers.rb +56 -0
  123. data/lib/oneandone/requests/compute/list_logs.rb +59 -0
  124. data/lib/oneandone/requests/compute/list_monitored_servers.rb +51 -0
  125. data/lib/oneandone/requests/compute/list_monitoring_policies.rb +56 -0
  126. data/lib/oneandone/requests/compute/list_mp_servers.rb +50 -0
  127. data/lib/oneandone/requests/compute/list_ports.rb +51 -0
  128. data/lib/oneandone/requests/compute/list_private_network_servers.rb +50 -0
  129. data/lib/oneandone/requests/compute/list_private_networks.rb +56 -0
  130. data/lib/oneandone/requests/compute/list_processes.rb +51 -0
  131. data/lib/oneandone/requests/compute/list_public_ips.rb +56 -0
  132. data/lib/oneandone/requests/compute/list_server_appliances.rb +56 -0
  133. data/lib/oneandone/requests/compute/list_server_ips.rb +50 -0
  134. data/lib/oneandone/requests/compute/list_server_private_networks.rb +50 -0
  135. data/lib/oneandone/requests/compute/list_servers.rb +56 -0
  136. data/lib/oneandone/requests/compute/list_shared_storage_servers.rb +50 -0
  137. data/lib/oneandone/requests/compute/list_shared_storages.rb +56 -0
  138. data/lib/oneandone/requests/compute/list_usages.rb +54 -0
  139. data/lib/oneandone/requests/compute/list_vpns.rb +56 -0
  140. data/lib/oneandone/requests/compute/load_dvd.rb +65 -0
  141. data/lib/oneandone/requests/compute/ping.rb +38 -0
  142. data/lib/oneandone/requests/compute/ping_auth.rb +38 -0
  143. data/lib/oneandone/requests/compute/remove_firewall.rb +60 -0
  144. data/lib/oneandone/requests/compute/remove_firewall_ip.rb +60 -0
  145. data/lib/oneandone/requests/compute/remove_load_balancer.rb +71 -0
  146. data/lib/oneandone/requests/compute/remove_load_balancer_ip.rb +60 -0
  147. data/lib/oneandone/requests/compute/remove_mp_server.rb +60 -0
  148. data/lib/oneandone/requests/compute/remove_private_network.rb +60 -0
  149. data/lib/oneandone/requests/compute/remove_private_network_server.rb +60 -0
  150. data/lib/oneandone/requests/compute/remove_shared_storage_server.rb +60 -0
  151. data/lib/oneandone/requests/compute/restore_snapshot.rb +35 -0
  152. data/lib/oneandone/requests/compute/status.rb +50 -0
  153. data/lib/oneandone/requests/compute/update_firewall.rb +76 -0
  154. data/lib/oneandone/requests/compute/update_hardware.rb +82 -0
  155. data/lib/oneandone/requests/compute/update_hdd.rb +71 -0
  156. data/lib/oneandone/requests/compute/update_image.rb +80 -0
  157. data/lib/oneandone/requests/compute/update_load_balancer.rb +96 -0
  158. data/lib/oneandone/requests/compute/update_monitoring_policy.rb +82 -0
  159. data/lib/oneandone/requests/compute/update_port.rb +74 -0
  160. data/lib/oneandone/requests/compute/update_private_network.rb +82 -0
  161. data/lib/oneandone/requests/compute/update_process.rb +76 -0
  162. data/lib/oneandone/requests/compute/update_public_ip.rb +71 -0
  163. data/lib/oneandone/requests/compute/update_server.rb +76 -0
  164. data/lib/oneandone/requests/compute/update_shared_storage.rb +80 -0
  165. data/lib/oneandone/requests/compute/update_vpn.rb +76 -0
  166. data/tests/oneandone/test_firewalls.rb +188 -0
  167. data/tests/oneandone/test_images.rb +79 -0
  168. data/tests/oneandone/test_load_balancers.rb +192 -0
  169. data/tests/oneandone/test_monitoring_policies.rb +342 -0
  170. data/tests/oneandone/test_private_networks.rb +123 -0
  171. data/tests/oneandone/test_public_ips.rb +75 -0
  172. data/tests/oneandone/test_servers.rb +465 -0
  173. data/tests/oneandone/test_shared_storages.rb +131 -0
  174. metadata +259 -0
@@ -0,0 +1,192 @@
1
+ require_relative '../../lib/fog-oneandone'
2
+ require 'minitest/autorun'
3
+
4
+ Fog.mock!
5
+
6
+ class TestLoadBalancer < Minitest::Test
7
+
8
+ def self.test_order
9
+ :alpha
10
+ end
11
+
12
+ def setup
13
+
14
+ # Establish Connection
15
+ @compute = Fog::Compute::OneAndOne.new({
16
+ :oneandone_api_key => 'APIKEY'
17
+ })
18
+
19
+ end
20
+
21
+
22
+ def test_a_create_load_balancer
23
+
24
+ # Perform Request
25
+ rule1 = {
26
+ 'protocol' => 'TCP',
27
+ 'port_balancer' => 80,
28
+ 'port_server' => 80,
29
+ 'source' => '0.0.0.0'
30
+ }
31
+
32
+ rules = [rule1]
33
+
34
+ response = @compute.create_load_balancer(name: 'Test LB',
35
+ description: 'Example Desc', health_check_test: 'TCP',
36
+ health_check_interval: 40, persistence: true, persistence_time: 1200,
37
+ method: 'ROUND_ROBIN', rules: rules)
38
+
39
+ @@load_balancer_id = response.body['id']
40
+
41
+ # Assertions
42
+ assert_equal response.body['name'], 'Test LB'
43
+ assert_equal response.body['description'], 'Example Desc'
44
+ assert_equal response.body['health_check_test'], 'TCP'
45
+ assert_equal response.body['health_check_interval'], 40
46
+
47
+ end
48
+
49
+ def test_b_list_load_balancers
50
+
51
+ # Perform Request
52
+ response = @compute.list_load_balancers
53
+
54
+ # Assertions
55
+ assert_equal response.body.length, 1
56
+
57
+ end
58
+
59
+ def test_c_update_load_balancer
60
+
61
+ # Perform Request
62
+ response = @compute.update_load_balancer(load_balancer_id: @@load_balancer_id,
63
+ name: 'New Name', description: 'New Desc')
64
+
65
+ # Assertions
66
+ assert_equal response.body['name'], 'New Name'
67
+ assert_equal response.body['description'], 'New Desc'
68
+
69
+ end
70
+
71
+ def test_d_get_load_balancer
72
+
73
+ # Perform Request
74
+ response = @compute.get_load_balancer(@@load_balancer_id)
75
+
76
+ # Assertions
77
+ assert_equal response.body['id'], @@load_balancer_id
78
+
79
+ end
80
+
81
+ def test_e_add_load_balancer_ips
82
+
83
+ # Perform Request
84
+ ip1 = '<IP-ID>'
85
+
86
+ ips = [ip1]
87
+
88
+ response = @compute.add_load_balancer_ips(load_balancer_id: @@load_balancer_id,
89
+ ips: ips)
90
+
91
+ # Assertions
92
+ assert_equal response.body['server_ips'][0], '<IP-ID>'
93
+
94
+ end
95
+
96
+ def test_f_list_load_balancer_ips
97
+
98
+ # Perform Request
99
+ response = @compute.list_load_balancer_ips(@@load_balancer_id)
100
+
101
+ # Assertions
102
+ assert_equal response.body.length, 1
103
+
104
+ end
105
+
106
+ def test_g_get_load_balancer_ip
107
+
108
+ # Perform Request
109
+ response = @compute.get_load_balancer_ip(load_balancer_id: @@load_balancer_id,
110
+ ip_id: '<IP-ID>')
111
+
112
+ # Assertions
113
+ assert_equal response.body, '<IP-ID>'
114
+
115
+ end
116
+
117
+ def test_h_remove_load_balancer_ip
118
+
119
+ # Perform Request
120
+ response = @compute.remove_load_balancer_ip(load_balancer_id: @@load_balancer_id,
121
+ ip_id: '<IP-ID>')
122
+
123
+ # Assertions
124
+ assert_equal response.body['server_ips'].length, 0
125
+
126
+ end
127
+
128
+ def test_i_add_load_balancer_rules
129
+
130
+ # Perform Request
131
+ rule2 = {
132
+ 'protocol' => 'TCP',
133
+ 'port_balancer' => 90,
134
+ 'port_server' => 90,
135
+ 'source' => '0.0.0.0'
136
+ }
137
+
138
+ rules = [rule2]
139
+
140
+ response = @compute.add_load_balancer_rules(load_balancer_id: @@load_balancer_id,
141
+ rules: rules)
142
+
143
+ @@rule2_id = response.body['rules'][1]['id']
144
+
145
+ # Assertions
146
+ assert_equal response.body['rules'][1]['port_balancer'], 90
147
+
148
+ end
149
+
150
+ def test_j_list_load_balancer_rules
151
+
152
+ # Perform Request
153
+ response = @compute.list_load_balancer_rules(@@load_balancer_id)
154
+
155
+ # Assertions
156
+ assert_equal response.body.length, 2
157
+
158
+ end
159
+
160
+ def test_k_get_load_balancer_rule
161
+
162
+ # Perform Request
163
+ response = @compute.get_load_balancer_rule(load_balancer_id: @@load_balancer_id,
164
+ rule_id: @@rule2_id)
165
+
166
+ # Assertions
167
+ assert_equal response.body['id'], @@rule2_id
168
+
169
+ end
170
+
171
+ def test_l_delete_load_balancer_rule
172
+
173
+ # Perform Request
174
+ response = @compute.delete_load_balancer_rule(load_balancer_id: @@load_balancer_id,
175
+ rule_id: @@rule2_id)
176
+
177
+ # Assertions
178
+ assert_equal response.body['rules'].length, 1
179
+
180
+ end
181
+
182
+ def test_m_delete_load_balancer
183
+
184
+ # Perform Request
185
+ response = @compute.delete_load_balancer(@@load_balancer_id)
186
+
187
+ # Assertions
188
+ assert_equal response.body, 'The requested load balancer has been deleted.'
189
+
190
+ end
191
+
192
+ end
@@ -0,0 +1,342 @@
1
+ require_relative '../../lib/fog-oneandone'
2
+ require 'minitest/autorun'
3
+
4
+ Fog.mock!
5
+
6
+ class TestMonitoringPolicy < Minitest::Test
7
+
8
+ def self.test_order
9
+ :alpha
10
+ end
11
+
12
+ def setup
13
+
14
+ # Establish Connection
15
+ @compute = Fog::Compute::OneAndOne.new({
16
+ :oneandone_api_key => 'APIKEY'
17
+ })
18
+
19
+ end
20
+
21
+
22
+ def test_a_create_monitoring_policy
23
+
24
+ # Perform Request
25
+ thresholds = {
26
+ 'cpu' => {
27
+ 'warning' => {
28
+ 'value' => 90,
29
+ 'alert' => false
30
+ },
31
+ 'critical' => {
32
+ 'value' => 95,
33
+ 'alert' => false
34
+ }
35
+ },
36
+ 'ram' => {
37
+ 'warning' => {
38
+ 'value' => 90,
39
+ 'alert' => false
40
+ },
41
+ 'critical' => {
42
+ 'value' => 95,
43
+ 'alert' => false
44
+ }
45
+ },
46
+ 'disk' => {
47
+ 'warning' => {
48
+ 'value' => 90,
49
+ 'alert' => false
50
+ },
51
+ 'critical' => {
52
+ 'value' => 95,
53
+ 'alert' => false
54
+ }
55
+ },
56
+ 'transfer' => {
57
+ 'warning' => {
58
+ 'value' => 1000,
59
+ 'alert' => false
60
+ },
61
+ 'critical' => {
62
+ 'value' => 2000,
63
+ 'alert' => false
64
+ }
65
+ },
66
+ 'internal_ping' => {
67
+ 'warning' => {
68
+ 'value' => 50,
69
+ 'alert' => false
70
+ },
71
+ 'critical' => {
72
+ 'value' => 100,
73
+ 'alert' => false
74
+ }
75
+ }
76
+ }
77
+
78
+ port1 = {
79
+ 'protocol' => 'TCP',
80
+ 'port' => 80,
81
+ 'alert_if' => 'NOT_RESPONDING',
82
+ 'email_notification' => true
83
+ }
84
+
85
+ ports = [port1]
86
+
87
+ process1 = {
88
+ 'process' => 'test',
89
+ 'alert_if' => 'NOT_RUNNING',
90
+ 'email_notification' => true
91
+ }
92
+
93
+ processes = [process1]
94
+
95
+ response = @compute.create_monitoring_policy(name: 'Test Monitoring Policy',
96
+ email: 'test@example.com', agent: true, thresholds: thresholds,
97
+ ports: ports, processes: processes)
98
+
99
+ @@monitoring_policy_id = response.body['id']
100
+
101
+ # Assertions
102
+ assert_equal response.body['name'], 'Test Monitoring Policy'
103
+ assert_equal response.body['email'], 'test@example.com'
104
+ assert_equal response.body['agent'], true
105
+
106
+ end
107
+
108
+ def test_b_list_monitoring_policies
109
+
110
+ # Perform Request
111
+ response = @compute.list_monitoring_policies
112
+
113
+ # Assertions
114
+ assert_equal response.body.length, 1
115
+
116
+ end
117
+
118
+ def test_c_update_monitoring_policy
119
+
120
+ # Perform Request
121
+ response = @compute.update_monitoring_policy(monitoring_policy_id: @@monitoring_policy_id,
122
+ name: 'New Name', description: 'New Desc', email: 'new@example.com')
123
+
124
+ # Assertions
125
+ assert_equal response.body['name'], 'New Name'
126
+ assert_equal response.body['description'], 'New Desc'
127
+ assert_equal response.body['email'], 'new@example.com'
128
+
129
+ end
130
+
131
+ def test_d_get_monitoring_policy
132
+
133
+ # Perform Request
134
+ response = @compute.get_monitoring_policy(@@monitoring_policy_id)
135
+
136
+ # Assertions
137
+ assert_equal response.body['id'], @@monitoring_policy_id
138
+
139
+ end
140
+
141
+ def test_e_add_ports
142
+
143
+ # Perform Request
144
+ port2 = {
145
+ 'protocol' => 'TCP',
146
+ 'port' => 90,
147
+ 'alert_if' => 'NOT_RESPONDING',
148
+ 'email_notification' => true
149
+ }
150
+
151
+ ports = [port2]
152
+
153
+ response = @compute.add_ports(monitoring_policy_id: @@monitoring_policy_id,
154
+ ports: ports)
155
+
156
+ @@port2_id = response.body['ports'][1]['id']
157
+
158
+ # Assertions
159
+ assert_equal response.body['ports'].length, 2
160
+
161
+ end
162
+
163
+ def test_f_list_ports
164
+
165
+ # Perform Request
166
+ response = @compute.list_ports(@@monitoring_policy_id)
167
+
168
+ # Assertions
169
+ assert_equal response.body.length, 2
170
+
171
+ end
172
+
173
+ def test_g_get_port
174
+
175
+ # Perform Request
176
+ response = @compute.get_port(monitoring_policy_id: @@monitoring_policy_id,
177
+ port_id: @@port2_id)
178
+
179
+ # Assertions
180
+ assert_equal response.body['id'], @@port2_id
181
+
182
+ end
183
+
184
+ def test_h_update_port
185
+
186
+ # Perform Request
187
+ port = {
188
+ 'protocol' => 'TCP',
189
+ 'port' => 80,
190
+ 'alert_if' => 'RESPONDING',
191
+ 'email_notification' => false
192
+ }
193
+
194
+ response = @compute.update_port(monitoring_policy_id: @@monitoring_policy_id,
195
+ port_id: @@port2_id, new_port: port)
196
+
197
+ # Assertions
198
+ assert_equal response.body['ports'][1]['alert_if'], 'RESPONDING'
199
+ assert_equal response.body['ports'][1]['email_notification'], false
200
+
201
+ end
202
+
203
+ def test_i_delete_port
204
+
205
+ # Perform Request
206
+ response = @compute.delete_port(monitoring_policy_id: @@monitoring_policy_id,
207
+ port_id: @@port2_id)
208
+
209
+ # Assertions
210
+ assert_equal response.body['ports'].length, 1
211
+
212
+ end
213
+
214
+ def test_j_add_processes
215
+
216
+ # Perform Request
217
+ process2 = {
218
+ 'process' => 'logger',
219
+ 'alert_if' => 'NOT_RUNNING',
220
+ 'email_notification' => true
221
+ }
222
+
223
+ processes = [process2]
224
+
225
+ response = @compute.add_processes(monitoring_policy_id: @@monitoring_policy_id,
226
+ processes: processes)
227
+
228
+ @@process2_id = response.body['processes'][1]['id']
229
+
230
+ # Assertions
231
+ assert_equal response.body['processes'].length, 2
232
+
233
+ end
234
+
235
+ def test_k_list_processes
236
+
237
+ # Perform Request
238
+ response = @compute.list_processes(@@monitoring_policy_id)
239
+
240
+ # Assertions
241
+ assert_equal response.body.length, 2
242
+
243
+ end
244
+
245
+ def test_l_get_process
246
+
247
+ # Perform Request
248
+ response = @compute.get_process(monitoring_policy_id: @@monitoring_policy_id,
249
+ process_id: @@process2_id)
250
+
251
+ # Assertions
252
+ assert_equal response.body['id'], @@process2_id
253
+
254
+ end
255
+
256
+ def test_m_update_process
257
+
258
+ # Perform Request
259
+ process = {
260
+ 'process' => 'test',
261
+ 'alert_if' => 'RUNNING',
262
+ 'email_notification' => false
263
+ }
264
+
265
+ response = @compute.update_process(monitoring_policy_id: @@monitoring_policy_id,
266
+ process_id: @@process2_id, new_process: process)
267
+
268
+ # Assertions
269
+ assert_equal response.body['processes'][1]['alert_if'], 'RUNNING'
270
+ assert_equal response.body['processes'][1]['email_notification'], false
271
+
272
+ end
273
+
274
+ def test_n_delete_process
275
+
276
+ # Perform Request
277
+ response = @compute.delete_process(monitoring_policy_id: @@monitoring_policy_id,
278
+ process_id: @@process2_id)
279
+
280
+ # Assertions
281
+ assert_equal response.body['processes'].length, 1
282
+
283
+ end
284
+
285
+ def test_o_add_mp_servers
286
+
287
+ # Perform Request
288
+ server1 = '<SERVER-ID>'
289
+
290
+ servers = [server1]
291
+
292
+ response = @compute.add_mp_servers(monitoring_policy_id: @@monitoring_policy_id,
293
+ servers: servers)
294
+
295
+ # Assertions
296
+ assert_equal response.body['servers'][0], '<SERVER-ID>'
297
+
298
+ end
299
+
300
+ def test_p_list_mp_servers
301
+
302
+ # Perform Request
303
+ response = @compute.list_mp_servers(@@monitoring_policy_id)
304
+
305
+ # Assertions
306
+ assert_equal response.body.length, 1
307
+
308
+ end
309
+
310
+ def test_q_get_mp_server
311
+
312
+ # Perform Request
313
+ response = @compute.get_mp_server(monitoring_policy_id: @@monitoring_policy_id,
314
+ server_id: '<SERVER-ID>')
315
+
316
+ # Assertions
317
+ assert_equal response.body, '<SERVER-ID>'
318
+
319
+ end
320
+
321
+ def test_r_remove_mp_server
322
+
323
+ # Perform Request
324
+ response = @compute.remove_mp_server(monitoring_policy_id: @@monitoring_policy_id,
325
+ server_id: '<SERVER-ID>')
326
+
327
+ # Assertions
328
+ assert_equal response.body['servers'].length, 0
329
+
330
+ end
331
+
332
+ def test_s_delete_monitoring_policy
333
+
334
+ # Perform Request
335
+ response = @compute.delete_monitoring_policy(@@monitoring_policy_id)
336
+
337
+ # Assertions
338
+ assert_equal response.body, 'The requested monitoring policy has been deleted.'
339
+
340
+ end
341
+
342
+ end
@@ -0,0 +1,123 @@
1
+ require_relative '../../lib/fog-oneandone'
2
+ require 'minitest/autorun'
3
+
4
+ Fog.mock!
5
+
6
+ class TestPrivateNetwork < Minitest::Test
7
+
8
+ def self.test_order
9
+ :alpha
10
+ end
11
+
12
+ def setup
13
+
14
+ # Establish Connection
15
+ @compute = Fog::Compute::OneAndOne.new({
16
+ :oneandone_api_key => 'APIKEY'
17
+ })
18
+
19
+ end
20
+
21
+
22
+ def test_a_create_private_network
23
+
24
+ # Perform Request
25
+ response = @compute.create_private_network(name: 'Test Private Network')
26
+
27
+ @@private_network_id = response.body['id']
28
+
29
+ # Assertions
30
+ assert_equal response.body['name'], 'Test Private Network'
31
+
32
+ end
33
+
34
+ def test_b_list_private_networks
35
+
36
+ # Perform Request
37
+ response = @compute.list_private_networks
38
+
39
+ # Assertions
40
+ assert_equal response.body.length, 1
41
+
42
+ end
43
+
44
+ def test_c_update_private_network
45
+
46
+ # Perform Request
47
+ response = @compute.update_private_network(private_network_id: @@private_network_id,
48
+ name: 'New Name', description: 'New Desc')
49
+
50
+ # Assertions
51
+ assert_equal response.body['name'], 'New Name'
52
+ assert_equal response.body['description'], 'New Desc'
53
+
54
+ end
55
+
56
+ def test_d_get_private_network
57
+
58
+ # Perform Request
59
+ response = @compute.get_private_network(@@private_network_id)
60
+
61
+ # Assertions
62
+ assert_equal response.body['id'], @@private_network_id
63
+
64
+ end
65
+
66
+ def test_e_add_private_network_servers
67
+
68
+ # Perform Request
69
+ server1 = '<SERVER-ID>'
70
+
71
+ servers = [server1]
72
+
73
+ response = @compute.add_private_network_servers(private_network_id: @@private_network_id,
74
+ servers: servers)
75
+
76
+ # Assertions
77
+ assert_equal response.body['servers'][0], '<SERVER-ID>'
78
+
79
+ end
80
+
81
+ def test_f_list_private_network_servers
82
+
83
+ # Perform Request
84
+ response = @compute.list_private_network_servers(@@private_network_id)
85
+
86
+ # Assertions
87
+ assert_equal response.body.length, 1
88
+
89
+ end
90
+
91
+ def test_g_get_private_network_server
92
+
93
+ # Perform Request
94
+ response = @compute.get_private_network_server(private_network_id: @@private_network_id,
95
+ server_id: '<SERVER-ID>')
96
+
97
+ # Assertions
98
+ assert_equal response.body, '<SERVER-ID>'
99
+
100
+ end
101
+
102
+ def test_h_remove_private_network_server
103
+
104
+ # Perform Request
105
+ response = @compute.remove_private_network_server(private_network_id: @@private_network_id,
106
+ server_id: '<SERVER-ID>')
107
+
108
+ # Assertions
109
+ assert_equal response.body['servers'].length, 0
110
+
111
+ end
112
+
113
+ def test_m_delete_private_network
114
+
115
+ # Perform Request
116
+ response = @compute.delete_private_network(@@private_network_id)
117
+
118
+ # Assertions
119
+ assert_equal response.body, 'The requested private network has been deleted.'
120
+
121
+ end
122
+
123
+ end