fog-arubacloud 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +0 -0
- data/.gitignore +0 -0
- data/.rubocop.yml +0 -0
- data/.ruby-version +0 -0
- data/.travis.yml +0 -0
- data/CONTRIBUTING.md +0 -0
- data/CONTRIBUTORS.md +0 -0
- data/Gemfile +0 -0
- data/LICENSE.md +0 -0
- data/README.md +3 -3
- data/Rakefile +99 -5
- data/{lib/fog/arubacloud/examples → examples}/create_pro_server.rb +3 -3
- data/{lib/fog/arubacloud/examples → examples}/create_smart_server.rb +0 -0
- data/{lib/fog/arubacloud/examples → examples}/get_objects.rb +1 -1
- data/{lib/fog/arubacloud/examples → examples}/get_servers.rb +0 -0
- data/{lib/fog/arubacloud/examples → examples}/vm_operations.rb +1 -1
- data/fog-arubacloud.gemspec +12 -12
- data/gemfiles/fog-arubacloud-0.0.4.gem +0 -0
- data/lib/fog/arubacloud/compute/models/custom_template.rb +60 -0
- data/lib/fog/arubacloud/compute/models/custom_templates.rb +19 -0
- data/lib/fog/arubacloud/{models/compute → compute/models}/disk.rb +6 -5
- data/lib/fog/arubacloud/{models/compute → compute/models}/disks.rb +7 -7
- data/lib/fog/arubacloud/{models/compute → compute/models}/ip.rb +6 -5
- data/lib/fog/arubacloud/{models/compute → compute/models}/ips.rb +6 -6
- data/lib/fog/arubacloud/compute/models/loadbalancer.rb +135 -0
- data/lib/fog/arubacloud/compute/models/loadbalancers.rb +21 -0
- data/lib/fog/arubacloud/{models/compute → compute/models}/network_adapter.rb +2 -2
- data/lib/fog/arubacloud/{models/compute → compute/models}/network_adapters.rb +4 -4
- data/lib/fog/arubacloud/compute/models/schedule.rb +90 -0
- data/lib/fog/arubacloud/compute/models/schedules.rb +19 -0
- data/lib/fog/arubacloud/{models/compute → compute/models}/server.rb +74 -35
- data/lib/fog/arubacloud/{models/compute → compute/models}/servers.rb +10 -9
- data/lib/fog/arubacloud/compute/models/sharedstorage.rb +58 -0
- data/lib/fog/arubacloud/compute/models/sharedstorages.rb +19 -0
- data/lib/fog/arubacloud/compute/models/snapshot.rb +58 -0
- data/lib/fog/arubacloud/compute/models/snapshots.rb +19 -0
- data/lib/fog/arubacloud/{models/compute → compute/models}/template.rb +2 -2
- data/lib/fog/arubacloud/{models/compute → compute/models}/templates.rb +10 -10
- data/lib/fog/arubacloud/compute/requests/add_contact.rb +59 -0
- data/lib/fog/arubacloud/compute/requests/add_instance.rb +56 -0
- data/lib/fog/arubacloud/compute/requests/add_lb_rule.rb +58 -0
- data/lib/fog/arubacloud/compute/requests/apply_snapshot.rb +53 -0
- data/lib/fog/arubacloud/compute/requests/archive_vm.rb +59 -0
- data/lib/fog/arubacloud/compute/requests/create_loadbalancer.rb +76 -0
- data/lib/fog/arubacloud/compute/requests/create_scheduled_occurrence.rb +71 -0
- data/lib/fog/arubacloud/compute/requests/create_scheduled_operation.rb +56 -0
- data/lib/fog/arubacloud/compute/requests/create_shared_storage.rb +55 -0
- data/lib/fog/arubacloud/compute/requests/create_snapshot.rb +54 -0
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/create_vm_pro.rb +9 -14
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/create_vm_smart.rb +11 -15
- data/lib/fog/arubacloud/compute/requests/delete_custom_template.rb +43 -0
- data/lib/fog/arubacloud/compute/requests/delete_scheduled_operation.rb +43 -0
- data/lib/fog/arubacloud/compute/requests/delete_shared_storage.rb +49 -0
- data/lib/fog/arubacloud/compute/requests/delete_snapshot.rb +60 -0
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/delete_vm.rb +13 -13
- data/lib/fog/arubacloud/compute/requests/disable_loadbalancer.rb +47 -0
- data/lib/fog/arubacloud/compute/requests/edit_shared_storage.rb +50 -0
- data/lib/fog/arubacloud/compute/requests/enable_loadbalancer.rb +47 -0
- data/lib/fog/arubacloud/compute/requests/get_custom_templates.rb +43 -0
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/get_hypervisors.rb +8 -11
- data/lib/fog/arubacloud/compute/requests/get_lb_loads.rb +49 -0
- data/lib/fog/arubacloud/compute/requests/get_lb_stats.rb +49 -0
- data/lib/fog/arubacloud/compute/requests/get_loadbalancer.rb +47 -0
- data/lib/fog/arubacloud/compute/requests/get_notifications.rb +50 -0
- data/lib/fog/arubacloud/compute/requests/get_package_id.rb +60 -0
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/get_purchased_ip_addresses.rb +7 -11
- data/lib/fog/arubacloud/compute/requests/get_scheduled_operations.rb +42 -0
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/get_server_details.rb +7 -13
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/get_servers.rb +11 -14
- data/lib/fog/arubacloud/compute/requests/get_shared_storage.rb +43 -0
- data/lib/fog/arubacloud/compute/requests/manage_custom_template.rb +72 -0
- data/lib/fog/arubacloud/compute/requests/modify_loadbalancer.rb +49 -0
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/power_off_vm.rb +8 -11
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/power_on_vm.rb +8 -11
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/purchase_ip.rb +7 -11
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/reinitialize_vm.rb +8 -14
- data/lib/fog/arubacloud/compute/requests/remove_contact.rb +48 -0
- data/lib/fog/arubacloud/compute/requests/remove_instance.rb +56 -0
- data/lib/fog/arubacloud/{requests/compute → compute/requests}/remove_ip.rb +7 -11
- data/lib/fog/arubacloud/compute/requests/remove_loadbalancer.rb +47 -0
- data/lib/fog/arubacloud/compute/requests/rename_shared_storage.rb +50 -0
- data/lib/fog/arubacloud/compute/requests/restore_vm.rb +61 -0
- data/lib/fog/arubacloud/compute/requests/suspend_scheduled_operations.rb +43 -0
- data/lib/fog/arubacloud/compute.rb +106 -22
- data/lib/fog/arubacloud/error.rb +4 -0
- data/lib/fog/arubacloud/service.rb +4 -2
- data/lib/fog/arubacloud/version.rb +3 -2
- data/lib/fog/arubacloud.rb +4 -12
- data/spec/fog/arubacloud/config_spec.rb +0 -0
- data/spec/fog/compute/arubacloud/models/disk_spec.rb +63 -0
- data/spec/fog/compute/arubacloud/models/disks_spec.rb +11 -0
- data/spec/fog/compute/arubacloud/models/ip_spec.rb +53 -0
- data/spec/fog/compute/arubacloud/models/ips_spec.rb +11 -0
- data/spec/fog/compute/arubacloud/models/loadbalancer_spec.rb +100 -0
- data/spec/fog/compute/arubacloud/models/loadbalancers_spec.rb +15 -0
- data/spec/fog/compute/arubacloud/models/network_adapter_spec.rb +33 -0
- data/spec/fog/compute/arubacloud/models/network_adapters_spec.rb +11 -0
- data/spec/fog/compute/arubacloud/models/schedule_spec.rb +102 -0
- data/spec/fog/compute/arubacloud/models/schedules_spec.rb +11 -0
- data/spec/fog/compute/arubacloud/models/server_spec.rb +155 -0
- data/spec/fog/compute/arubacloud/models/servers_spec.rb +15 -0
- data/spec/fog/compute/arubacloud/models/sharedstorage_spec.rb +86 -0
- data/spec/fog/compute/arubacloud/models/sharedstorages_spec.rb +10 -0
- data/spec/fog/compute/arubacloud/models/snapshot_spec.rb +17 -0
- data/spec/fog/compute/arubacloud/models/snapshots_spec.rb +11 -0
- data/spec/fog/compute/arubacloud/models/template_spec.rb +39 -0
- data/spec/fog/compute/arubacloud/models/templates_spec.rb +21 -0
- data/spec/fog/compute/arubacloud_spec.rb +21 -4
- data/spec/model_setup.rb +3 -1
- data/spec/spec_helper.rb +1 -1
- metadata +121 -48
- data/gemfiles/fog-arubacloud-0.0.1.gem +0 -0
- data/gemfiles/fog-arubacloud-0.0.2.gem +0 -0
- data/spec/fog/compute/arubacloud/server_spec.rb +0 -26
- data/spec/fog/compute/arubacloud/servers_spec.rb +0 -11
- data/tests/test_helper.rb +0 -8
@@ -0,0 +1,90 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# Author:: Dangleterre Michaël
|
4
|
+
# © Copyright ArubaCloud.
|
5
|
+
#
|
6
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'fog/core/model'
|
10
|
+
require 'fog/arubacloud/error'
|
11
|
+
|
12
|
+
module Fog
|
13
|
+
module ArubaCloud
|
14
|
+
class Compute
|
15
|
+
class Schedule < Fog::Model
|
16
|
+
ADD = 'Add'
|
17
|
+
EDIT = 'Edit'
|
18
|
+
SUSPEND = 'Suspend'
|
19
|
+
DELETE = 'Delete'
|
20
|
+
|
21
|
+
identity :id, :aliases => 'OperationId'
|
22
|
+
|
23
|
+
attribute :name
|
24
|
+
attribute :OperationId, :aliases => 'OperationId'
|
25
|
+
attribute :ServerId, :aliases => 'ServerId'
|
26
|
+
attribute :OperationType, :aliases => 'OperationType'
|
27
|
+
attribute :OperationLabel, :aliases => 'OperationLabel'
|
28
|
+
attribute :dateStart, :aliases => 'dateStart'
|
29
|
+
attribute :dateEnd, :aliases => 'dateEnd'
|
30
|
+
#attribute :OperationParameters, :aliases => 'OperationParameters'
|
31
|
+
attribute :frequencyType, :aliases => 'frequencyType'
|
32
|
+
attribute :ScheduleDaysOfMonth, :aliases => ':ScheduleDaysOfMonth'
|
33
|
+
attribute :monthlyRecurrence, :aliases => 'monthlyRecurrence'
|
34
|
+
attribute :ScheduleWeekDays, :aliases => 'ScheduleWeekDays'
|
35
|
+
attribute :daysOfMonth, :aliases => 'daysOfMonth'
|
36
|
+
attribute :daysOfWeek, :aliases => 'daysOfWeek'
|
37
|
+
attribute :frequency, :aliases => 'frequency'
|
38
|
+
|
39
|
+
ignore_attributes :OperationParameters
|
40
|
+
|
41
|
+
def initialize
|
42
|
+
@service = attributes[:service]
|
43
|
+
end # initialize
|
44
|
+
|
45
|
+
def get_scheduled_operations
|
46
|
+
requires :dateStart, :dateEnd
|
47
|
+
response = service.get_scheduled_operations
|
48
|
+
new_attributes = response
|
49
|
+
merge_attributes(new_attributes)
|
50
|
+
end # get_schedule
|
51
|
+
|
52
|
+
def create_scheduled_operation
|
53
|
+
requires :dateStart, :dateEnd, :OperationType, :ServerId
|
54
|
+
data = attributes
|
55
|
+
service.create_scheduled_operation(data)
|
56
|
+
end # create_schedule_operation
|
57
|
+
|
58
|
+
def create_scheduled_occurrence
|
59
|
+
requires :ServerId, :OperationType, :OperationLabel, :dateStart, :dateEnd, :frequencyType, :monthlyRecurrence, :daysOfMonth, :daysOfWeek, :frequency
|
60
|
+
if :name != nil
|
61
|
+
data[:name] = name
|
62
|
+
else
|
63
|
+
raise Fog::ArubaCloud::Errors::BadParameters.Exception('Missing Parameter')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def suspend_scheduled_operation
|
68
|
+
requires :id
|
69
|
+
data = :attributes
|
70
|
+
if :OperationId != nil
|
71
|
+
data[:OperationId] = id
|
72
|
+
else
|
73
|
+
raise Fog::ArubaCloud::Errors::BadParameters.Exception('Missing Parameter')
|
74
|
+
end
|
75
|
+
end # suspend_scheduled_operation
|
76
|
+
|
77
|
+
def delete_scheduled_operation
|
78
|
+
requires :operationid
|
79
|
+
data = :attributes
|
80
|
+
if :OperationId != nil
|
81
|
+
data[:OperationId] = operationid
|
82
|
+
else
|
83
|
+
raise Fog::ArubaCloud::Errors::BadParameters.Exception('Missing Parameter')
|
84
|
+
end
|
85
|
+
end # delete_scheduled_operation
|
86
|
+
|
87
|
+
end # Schedule
|
88
|
+
end # Compute
|
89
|
+
end # ArubaCloud
|
90
|
+
end # Fog
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Dangleterre Michaël
|
3
|
+
# © Copyright ArubaCloud.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'fog/core/collection'
|
9
|
+
require 'fog/arubacloud/compute/models/schedule'
|
10
|
+
|
11
|
+
module Fog
|
12
|
+
module ArubaCloud
|
13
|
+
class Compute
|
14
|
+
class Schedules < Fog::Collection
|
15
|
+
model Fog::ArubaCloud::Compute::Schedules
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
#
|
2
3
|
# Author:: Alessio Rocchi (<alessio.rocchi@staff.aruba.it>)
|
3
4
|
# © Copyright ArubaCloud.
|
@@ -9,8 +10,9 @@ require 'fog/compute/models/server'
|
|
9
10
|
require 'fog/arubacloud/error'
|
10
11
|
|
11
12
|
module Fog
|
12
|
-
module
|
13
|
-
class
|
13
|
+
module ArubaCloud
|
14
|
+
class Compute
|
15
|
+
# noinspection RubyTooManyMethodsInspection
|
14
16
|
class Server < Fog::Compute::Server
|
15
17
|
CREATING = 1
|
16
18
|
STOPPED = 2
|
@@ -18,6 +20,8 @@ module Fog
|
|
18
20
|
ARCHIVED = 4
|
19
21
|
DELETED = 5
|
20
22
|
|
23
|
+
#collection_name :servers
|
24
|
+
|
21
25
|
# This is the instance ID which is unique per Datacenter
|
22
26
|
identity :id, :aliases => 'ServerId'
|
23
27
|
|
@@ -49,12 +53,21 @@ module Fog
|
|
49
53
|
@service = attributes[:service]
|
50
54
|
|
51
55
|
if attributes[:vm_type].nil?
|
52
|
-
self.vm_type = 'smart' if attributes['HypervisorType'].eql? '4'
|
56
|
+
self.vm_type = 'smart' if attributes['HypervisorType'].eql? '4'
|
57
|
+
else
|
58
|
+
'pro'
|
53
59
|
end
|
54
60
|
|
55
61
|
super
|
56
62
|
end
|
57
63
|
|
64
|
+
def action_hook(method, expected_state, message)
|
65
|
+
unless state.eql? expected_state
|
66
|
+
raise Fog::ArubaCloud::Errors::VmStatus.new(message)
|
67
|
+
end
|
68
|
+
@service.send method, id
|
69
|
+
end
|
70
|
+
|
58
71
|
# Is server in ready state
|
59
72
|
# @param [String] ready_state By default state is RUNNING
|
60
73
|
# @return [Boolean] return true if server is in ready state
|
@@ -87,7 +100,6 @@ module Fog
|
|
87
100
|
def create
|
88
101
|
requires :name, :cpu, :memory, :admin_passwd, :vm_type
|
89
102
|
data = attributes
|
90
|
-
|
91
103
|
if vm_type.eql? 'pro'
|
92
104
|
# Automatically purchase a public ip address
|
93
105
|
data[:ipv4_id] = service.purchase_ip['Value']['ResourceId']
|
@@ -100,28 +112,22 @@ module Fog
|
|
100
112
|
|
101
113
|
# Retrieve new server list and filter the current virtual machine
|
102
114
|
# in order to retrieve the ID
|
103
|
-
# In case of failure, I will try it 3 for 3 times
|
104
|
-
try = 0
|
105
115
|
server = nil
|
106
|
-
while server.nil?
|
116
|
+
while server.nil?
|
107
117
|
servers = service.get_servers
|
108
|
-
#server = servers['Value'].select { |v| v['Name'].include?(data[:name]) }.first
|
109
118
|
servers['Value'].each do |s|
|
110
|
-
if s['Name'].to_s.include? data[:name].to_s
|
111
|
-
server = s
|
112
|
-
end
|
119
|
+
server = s if s['Name'].to_s.include? data[:name].to_s
|
113
120
|
end
|
114
|
-
Fog::Logger.debug("Fog::Compute::ArubaCloud::Server.create, #{data[:name]} server: #{server.inspect}")
|
115
|
-
if server
|
116
|
-
merge_attributes(server)
|
117
|
-
else
|
118
|
-
message = "error during attribute merge, `server` object is not ready, try n.#{try}"
|
119
|
-
Fog::Logger.warning("Fog::Compute::ArubaCloud::Server.create, #{message}")
|
120
|
-
Fog::Logger.warning(servers.inspect.to_yaml)
|
121
|
-
sleep(1)
|
122
|
-
end
|
123
|
-
try += 1
|
124
121
|
end
|
122
|
+
Fog::Logger.debug("Fog::ArubaCloud::Compute::Server.create, #{data[:name]} server: #{server.inspect}")
|
123
|
+
if server
|
124
|
+
merge_attributes(server)
|
125
|
+
else
|
126
|
+
message = 'error during attribute merge, `server` object is not ready.'
|
127
|
+
Fog::Logger.warning("Fog::ArubaCloud::Compute::Server.create, #{message}")
|
128
|
+
sleep(1)
|
129
|
+
end
|
130
|
+
|
125
131
|
end
|
126
132
|
|
127
133
|
def get_server_details
|
@@ -151,35 +157,68 @@ module Fog
|
|
151
157
|
|
152
158
|
def power_off
|
153
159
|
requires :id, :state
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
@service.power_off_vm(id)
|
160
|
+
self.action_hook(method=:power_off_vm, expected_state=RUNNING,
|
161
|
+
message="Cannot poweroff vm in current state: #{state}"
|
162
|
+
)
|
158
163
|
end
|
159
164
|
|
160
165
|
def power_on
|
161
166
|
requires :id, :state
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
@service.power_on_vm(id)
|
167
|
+
self.action_hook(method=:power_on_vm, expected_state=STOPPED,
|
168
|
+
message="Cannot poweron vm in current state: #{state}"
|
169
|
+
)
|
166
170
|
end
|
167
171
|
|
168
172
|
def delete
|
169
173
|
requires :id
|
170
|
-
|
171
|
-
|
172
|
-
)
|
174
|
+
self.action_hook(method=:delete_vm, expected_state=STOPPED,
|
175
|
+
message="Cannot delete vm in current state: #{state}"
|
176
|
+
)
|
173
177
|
end
|
174
178
|
|
175
179
|
def reinitialize
|
176
180
|
requires :id, :hypervisor
|
177
|
-
|
178
|
-
|
181
|
+
self.action_hook(method=:reinitialize_vm, expected_state=STOPPED,
|
182
|
+
message="Cannot reinitialize vm in current state: #{state}"
|
183
|
+
)
|
184
|
+
end
|
185
|
+
|
186
|
+
def archive
|
187
|
+
requires :id, :state, :vm_type
|
188
|
+
if state == STOPPED and vm_type.eql?('pro')
|
189
|
+
service.archive_vm(id)
|
190
|
+
else
|
191
|
+
raise(Fog::ArubaCloud::Errors::VmStatus.new(
|
192
|
+
"Cannot archive VM in current state #{state} or VM type #{vm_type}"))
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def restore
|
197
|
+
requires :id, :memory, :cpu
|
198
|
+
state == ARCHIVED and memory != nil and cpu != nil ? service.restore_vm(id) : raise(
|
199
|
+
Fog::ArubaCloud::Errors::VmStatus.new("Cannot restore VM without specifying #{cpu} and #{memory}"
|
200
|
+
))
|
201
|
+
end
|
202
|
+
|
203
|
+
def create_snapshot
|
204
|
+
requires :id
|
205
|
+
id != nil ? service.create_snapshot(id) : raise(Fog::ArubaCloud::Errors::VmStatus.new(
|
206
|
+
'Cannot crate snapshot without vm id'
|
179
207
|
))
|
180
208
|
end
|
181
209
|
|
210
|
+
def apply_snapshot
|
211
|
+
requires :id
|
212
|
+
self.action_hook(method=:apply_snapshot, expected_state=STOPPED,
|
213
|
+
message="Cannot restore vm in current state: #{state}"
|
214
|
+
)
|
215
|
+
end
|
216
|
+
|
217
|
+
def delete_snapshot
|
218
|
+
requires :id
|
219
|
+
service.delete_snapshot(id)
|
220
|
+
end
|
182
221
|
end
|
183
222
|
end
|
184
223
|
end
|
185
|
-
end
|
224
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
#
|
2
3
|
# Author:: Alessio Rocchi (<alessio.rocchi@staff.aruba.it>)
|
3
4
|
# © Copyright ArubaCloud.
|
@@ -6,18 +7,18 @@
|
|
6
7
|
#
|
7
8
|
|
8
9
|
require 'fog/core/collection'
|
9
|
-
require 'fog/arubacloud/models/
|
10
|
+
require 'fog/arubacloud/compute/models/server'
|
10
11
|
|
11
12
|
|
12
13
|
module Fog
|
13
|
-
module
|
14
|
-
class
|
14
|
+
module ArubaCloud
|
15
|
+
class Compute
|
15
16
|
class Servers < Fog::Collection
|
16
|
-
model Fog::Compute::
|
17
|
+
model Fog::ArubaCloud::Compute::Server
|
17
18
|
|
18
19
|
# Returns list of servers
|
19
|
-
# @return [Fog::Compute::
|
20
|
-
# @raise [Fog::Compute::
|
20
|
+
# @return [Fog::ArubaCloud::Compute::Servers] Retrieves a list servers.
|
21
|
+
# @raise [Fog::ArubaCloud::Compute::NotFound]
|
21
22
|
# @note The filter parameter on the method is just to maintain compatibility with other providers that support
|
22
23
|
# filtering.
|
23
24
|
def all(filters = [])
|
@@ -28,11 +29,11 @@ module Fog
|
|
28
29
|
|
29
30
|
# Retrieves server
|
30
31
|
# @param [String] server_id for server to be returned.
|
31
|
-
# @return [Fog::Compute::
|
32
|
+
# @return [Fog::ArubaCloud::Compute::Server]
|
32
33
|
def get(server_id)
|
33
34
|
data = service.get_server_details(server_id)
|
34
35
|
objects = data['Value']
|
35
|
-
msg = "Fog::Compute::
|
36
|
+
msg = "Fog::ArubaCloud::Compute::Servers.get 'objects' must be an hash, actually is: #{objects.class} #{objects.to_yaml}"
|
36
37
|
Fog::Logger.debug(msg)
|
37
38
|
raise Fog::ArubaCloud::Errors::BadObjectType.new("#{msg}") unless objects.instance_of? Hash
|
38
39
|
new(objects)
|
@@ -40,4 +41,4 @@ module Fog
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
43
|
-
end
|
44
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# Author:: Dangleterre Michaël
|
4
|
+
# © Copyright ArubaCloud.
|
5
|
+
#
|
6
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'fog/core/model'
|
10
|
+
require 'fog/arubacloud/error'
|
11
|
+
|
12
|
+
|
13
|
+
module Fog
|
14
|
+
module ArubaCloud
|
15
|
+
class Compute
|
16
|
+
class SharedStorage < Fog::Model
|
17
|
+
identity :id, :aliases => 'id'
|
18
|
+
|
19
|
+
attribute :quantity, :aliases => 'quantity'
|
20
|
+
attribute :value, :aliases => 'value'
|
21
|
+
attribute :sharedstoragename, :aliases => 'sharedstoragename'
|
22
|
+
attribute :sharedstorageprotocoltype
|
23
|
+
|
24
|
+
def initialize(attributes = {})
|
25
|
+
@service = attributes[:service]
|
26
|
+
end
|
27
|
+
|
28
|
+
def create
|
29
|
+
requires :sharedstorageprotocoltype, :quantity, :sharedstoragename
|
30
|
+
if :sharedstorageprotocoltype.upcase == 'ISCSI'
|
31
|
+
requires :value
|
32
|
+
end
|
33
|
+
data = attributes
|
34
|
+
service.create_shared_storage(data)
|
35
|
+
end # create
|
36
|
+
|
37
|
+
def edit
|
38
|
+
requires :id
|
39
|
+
data = :attributes
|
40
|
+
service.edit_shared_storage(data)
|
41
|
+
end # edit
|
42
|
+
|
43
|
+
def delete
|
44
|
+
requires :id
|
45
|
+
data = :attributes
|
46
|
+
service.delete_shared_storage(data)
|
47
|
+
end # delete
|
48
|
+
|
49
|
+
def rename
|
50
|
+
requires :id, :sharedstoragename
|
51
|
+
data = :attributes
|
52
|
+
service.rename_shared_storage(data)
|
53
|
+
end # rename
|
54
|
+
|
55
|
+
end # Custom_Template
|
56
|
+
end # Compute
|
57
|
+
end # ArubaCloud
|
58
|
+
end # Fog
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Dangleterre Michaël
|
3
|
+
# © Copyright ArubaCloud.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'fog/core/collection'
|
9
|
+
require 'fog/arubacloud/compute/models/sharedstorage'
|
10
|
+
|
11
|
+
module Fog
|
12
|
+
module ArubaCloud
|
13
|
+
class Compute
|
14
|
+
class SharedStorages < Fog::Collection
|
15
|
+
model Fog::ArubaCloud::Compute::SharedStorage
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Dangleterre Michaël
|
3
|
+
# © Copyright ArubaCloud.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'fog/arubacloud/error'
|
9
|
+
|
10
|
+
module Fog
|
11
|
+
module ArubaCloud
|
12
|
+
class Compute
|
13
|
+
class Snapshot < Fog::Model
|
14
|
+
CREATING = 'Create'
|
15
|
+
APPLYING = 'Restore'
|
16
|
+
DELETING = 'Delete'
|
17
|
+
identity :id, :aliases => 'id'
|
18
|
+
|
19
|
+
attribute :ServerId, :aliases => 'serverid'
|
20
|
+
attribute :SnapshotOperation, :aliases => 'Snapshot Operation'
|
21
|
+
|
22
|
+
def initialize(attributes = {})
|
23
|
+
@service = attributes[:service]
|
24
|
+
if attributes[:name].nil?
|
25
|
+
'operation impossible'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
def create
|
29
|
+
requires :ServerId
|
30
|
+
data = :attributes
|
31
|
+
if :name != nil
|
32
|
+
data[:name] = name
|
33
|
+
else
|
34
|
+
raise Fog::ArubaCloud::Errors::BadParameters.Exception('Missing Parameter')
|
35
|
+
end
|
36
|
+
end # Create
|
37
|
+
def apply
|
38
|
+
requires :ServerId
|
39
|
+
data = :attributes
|
40
|
+
if :name != nil
|
41
|
+
data[:name] = name
|
42
|
+
else
|
43
|
+
raise Fog::ArubaCloud::Errors::BadParameters.Exception('Missing Parameter')
|
44
|
+
end
|
45
|
+
end # Apply
|
46
|
+
def delete
|
47
|
+
requires :ServerId
|
48
|
+
data = :attributes
|
49
|
+
if :name != nil
|
50
|
+
data[:name] = name
|
51
|
+
else
|
52
|
+
raise Fog::ArubaCloud::Errors::BadParameters.Exception('Missing Parameter')
|
53
|
+
end
|
54
|
+
end # Delete
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Dangleterre Michaël
|
3
|
+
# © Copyright ArubaCloud.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'fog/core/collection'
|
9
|
+
require 'fog/arubacloud/compute/models/snapshot'
|
10
|
+
|
11
|
+
module Fog
|
12
|
+
module ArubaCloud
|
13
|
+
class Compute
|
14
|
+
class Snapshots < Fog::Collection
|
15
|
+
model Fog::ArubaCloud::Compute::Snapshot
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -6,18 +6,18 @@
|
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'fog/core/collection'
|
9
|
-
require 'fog/arubacloud/models/
|
9
|
+
require 'fog/arubacloud/compute/models/template'
|
10
10
|
|
11
11
|
|
12
12
|
module Fog
|
13
|
-
module
|
14
|
-
class
|
13
|
+
module ArubaCloud
|
14
|
+
class Compute
|
15
15
|
class Templates < Fog::Collection
|
16
|
-
model Fog::Compute::
|
16
|
+
model Fog::ArubaCloud::Compute::Template
|
17
17
|
|
18
18
|
# Returns list of Template
|
19
|
-
# @return [Fog::Compute::
|
20
|
-
# @raise [Fog::Compute::
|
19
|
+
# @return [Fog::ArubaCloud::Compute::Template] Retrieves the complete Templates list.
|
20
|
+
# @raise [Fog::ArubaCloud::Compute::NotFound]
|
21
21
|
def all
|
22
22
|
data = service.get_hypervisors
|
23
23
|
objects = data['Value']
|
@@ -34,8 +34,8 @@ module Fog
|
|
34
34
|
|
35
35
|
# Return only templates assigned to a specific service, default is smart (4)
|
36
36
|
# @param hv [Int] The ID of the hypervisor
|
37
|
-
# @return [Fog::Compute::
|
38
|
-
# @raise [Fog::Compute::
|
37
|
+
# @return [Fog::ArubaCloud::Compute::Template] List of templates
|
38
|
+
# @raise [Fog::ArubaCloud::Compute::NotFound]
|
39
39
|
def get_hypervisor(hv=4)
|
40
40
|
manipulated_objects = Array.new
|
41
41
|
data = service.get_hypervisors
|
@@ -46,7 +46,7 @@ module Fog
|
|
46
46
|
# select{|f| f['HypervisorType'].eql?(hv)}
|
47
47
|
t.merge!({'hypervisor' => hv_type})
|
48
48
|
if t['hypervisor'].eql?(4)
|
49
|
-
Fog::Logger.debug("Fog::Compute::
|
49
|
+
Fog::Logger.debug("Fog::ArubaCloud::Compute::Templates.get_hypervisors: t: #{h.to_yaml}")
|
50
50
|
manipulated_objects << t
|
51
51
|
end
|
52
52
|
end
|
@@ -56,7 +56,7 @@ module Fog
|
|
56
56
|
|
57
57
|
# Retrieves Single Template Item
|
58
58
|
# @param [String] template_id for server to be returned.
|
59
|
-
# @return [Fog::Compute::
|
59
|
+
# @return [Fog::ArubaCloud::Compute::Template]
|
60
60
|
def get(template_id)
|
61
61
|
# TODO: Implement retrieve of a single template
|
62
62
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# Author:: Dangleterre Michaël
|
4
|
+
# © Copyright ArubaCloud.
|
5
|
+
#
|
6
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'fog/arubacloud/service'
|
10
|
+
require 'fog/arubacloud/error'
|
11
|
+
require 'benchmark'
|
12
|
+
|
13
|
+
|
14
|
+
module Fog
|
15
|
+
module ArubaCloud
|
16
|
+
class Compute
|
17
|
+
class Real
|
18
|
+
def add_contact(data)
|
19
|
+
body = self.body('SetAddLoadBalancerContacts').merge(
|
20
|
+
:request => {
|
21
|
+
:loadBalancerID => data[:id],
|
22
|
+
:NotificationContacts => [
|
23
|
+
{
|
24
|
+
:NotificationContact => [
|
25
|
+
{
|
26
|
+
:ContactValue => data[:contactvalue],
|
27
|
+
:LoadBalancerContactID => data[:loadbalancercontactid],
|
28
|
+
:Type => data[:type]
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
]
|
33
|
+
}
|
34
|
+
)
|
35
|
+
|
36
|
+
response = nil
|
37
|
+
time = Benchmark.realtime {
|
38
|
+
response = request(body, 'SetAddLoadBalancerContacts' , 'SetAddLoadBalancerContacts Error')
|
39
|
+
}
|
40
|
+
Fog::Logger.debug("SetAddLoadBalancerContacts time: #{time}")
|
41
|
+
if response['Success']
|
42
|
+
response
|
43
|
+
else
|
44
|
+
raise Fog::ArubaCloud::Errors::RequestError.new('Error during the request.')
|
45
|
+
end
|
46
|
+
end # add_contact
|
47
|
+
|
48
|
+
class Mock
|
49
|
+
def add_contact
|
50
|
+
raise Fog::Errors::MockNotImplemented.new(
|
51
|
+
'Mock not implemented. Feel free to contribute.'
|
52
|
+
)
|
53
|
+
end # add_contact
|
54
|
+
end # Mock
|
55
|
+
end # Real
|
56
|
+
|
57
|
+
end # Compute
|
58
|
+
end # ArubaCloud
|
59
|
+
end # Fog
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# Author:: Dangleterre Michaël
|
4
|
+
# © Copyright ArubaCloud.
|
5
|
+
#
|
6
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'fog/arubacloud/service'
|
10
|
+
require 'fog/arubacloud/error'
|
11
|
+
require 'benchmark'
|
12
|
+
|
13
|
+
|
14
|
+
module Fog
|
15
|
+
module ArubaCloud
|
16
|
+
class Compute
|
17
|
+
class Real
|
18
|
+
def add_instance(data)
|
19
|
+
body = self.body('SetEnqueueLoadBalancerAddInstances').merge(
|
20
|
+
:Instances => {
|
21
|
+
:loadBalancerID => data[:id],
|
22
|
+
:Instances => [
|
23
|
+
{
|
24
|
+
:LoadBalancerInstance => [
|
25
|
+
{
|
26
|
+
:IPAddress => data[:ipaddress]
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
)
|
33
|
+
response = nil
|
34
|
+
time = Benchmark.realtime {
|
35
|
+
response = request(body, 'SetEnqueueLoadBalancerAddInstances', 'SetEnqueueLoadBalancerAddInstances Error')
|
36
|
+
}
|
37
|
+
Fog::Logger.debug("SetEnqueueLoadBalancerAddInstances time: #{time}")
|
38
|
+
if response['Success']
|
39
|
+
response
|
40
|
+
else
|
41
|
+
raise Fog::ArubaCloud::Errors::RequestError.new('Error during the request.')
|
42
|
+
end
|
43
|
+
end # add_instance
|
44
|
+
|
45
|
+
class Mock
|
46
|
+
def add_instance
|
47
|
+
raise Fog::Errors::MockNotImplemented.new(
|
48
|
+
'Mock not implemented. Feel free to contribute.'
|
49
|
+
)
|
50
|
+
end # add_instance
|
51
|
+
end # Mock
|
52
|
+
end # Real
|
53
|
+
|
54
|
+
end # Compute
|
55
|
+
end # ArubaCloud
|
56
|
+
end # Fog
|