forj 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -0
- data/.gitreview +4 -0
- data/Gemfile +21 -19
- data/Gemfile.lock +71 -0
- data/bin/forj +126 -83
- data/forj.gemspec +64 -0
- data/{lib → forj}/defaults.yaml +23 -1
- data/lib/appinit.rb +5 -5
- data/lib/build_tmpl/build-env.py +293 -0
- data/lib/cloud_test.rb +121 -0
- data/lib/forj-settings.rb +52 -39
- data/lib/forj/ForjCli.rb +11 -10
- data/lib/forj/ForjCore.rb +8 -6
- data/lib/forj/process/ForjProcess.rb +345 -82
- data/lib/ssh.rb +81 -20
- metadata +110 -80
- data/lib/compute.rb +0 -36
- data/lib/connection.rb +0 -144
- data/lib/down.rb +0 -60
- data/lib/forj-account.rb +0 -294
- data/lib/forj-config.rb +0 -522
- data/lib/helpers.rb +0 -56
- data/lib/lib-forj/lib/core/core.rb +0 -1740
- data/lib/lib-forj/lib/core/definition.rb +0 -441
- data/lib/lib-forj/lib/core/definition_internal.rb +0 -306
- data/lib/lib-forj/lib/core_process/CloudProcess.rb +0 -334
- data/lib/lib-forj/lib/core_process/global_process.rb +0 -406
- data/lib/lib-forj/lib/core_process/network_process.rb +0 -603
- data/lib/lib-forj/lib/lib-forj.rb +0 -37
- data/lib/lib-forj/lib/providers/hpcloud/Hpcloud.rb +0 -419
- data/lib/lib-forj/lib/providers/hpcloud/compute.rb +0 -108
- data/lib/lib-forj/lib/providers/hpcloud/network.rb +0 -117
- data/lib/lib-forj/lib/providers/hpcloud/security_groups.rb +0 -67
- data/lib/lib-forj/lib/providers/templates/compute.rb +0 -42
- data/lib/lib-forj/lib/providers/templates/core.rb +0 -61
- data/lib/lib-forj/lib/providers/templates/network.rb +0 -33
- data/lib/log.rb +0 -162
- data/lib/network.rb +0 -365
- data/lib/repositories.rb +0 -222
- data/lib/security.rb +0 -207
- data/lib/ssh.sh +0 -185
- data/spec/connection_spec.rb +0 -52
- data/spec/forj-config_spec.rb +0 -237
- data/spec/repositories_spec.rb +0 -50
@@ -1,37 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
|
19
|
-
# This is the ForjCloud base library.
|
20
|
-
|
21
|
-
# To use it, add require 'forj-cloud.rb'
|
22
|
-
|
23
|
-
slib_forj = File.dirname(__FILE__)
|
24
|
-
$FORJ_LIB = File.expand_path(File.join(File.dirname(slib_forj),'lib'))
|
25
|
-
|
26
|
-
|
27
|
-
raise "$FORJ_LIB is missing. Please set it." if not $FORJ_LIB
|
28
|
-
|
29
|
-
$PROVIDERS_PATH = File.expand_path(File.join($FORJ_LIB, "providers"))
|
30
|
-
$CORE_PROCESS_PATH = File.join($FORJ_LIB, "core_process")
|
31
|
-
|
32
|
-
require 'forj-config.rb' # Load class ForjConfig
|
33
|
-
require 'forj-account.rb' # Load class ForjAccount
|
34
|
-
|
35
|
-
require File.join($FORJ_LIB, "core", "core.rb")
|
36
|
-
require File.join($FORJ_LIB, "core", "definition.rb")
|
37
|
-
require File.join($FORJ_LIB, "core", "definition_internal.rb")
|
@@ -1,419 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
|
18
|
-
# This class describes how to process some actions, and will do everything prior
|
19
|
-
# this task to make it to work.
|
20
|
-
|
21
|
-
require 'fog' # We use fog to access HPCloud
|
22
|
-
|
23
|
-
$HPCLOUD_PATH = File.expand_path(File.dirname(__FILE__))
|
24
|
-
|
25
|
-
require File.join($HPCLOUD_PATH, "compute.rb")
|
26
|
-
require File.join($HPCLOUD_PATH, "network.rb")
|
27
|
-
require File.join($HPCLOUD_PATH, "security_groups.rb")
|
28
|
-
|
29
|
-
# Defines Meta HPCloud object
|
30
|
-
class Hpcloud < BaseDefinition
|
31
|
-
|
32
|
-
define_obj :services
|
33
|
-
obj_needs :data, :account_id, :mapping => :hp_access_key
|
34
|
-
obj_needs :data, :account_key, :mapping => :hp_secret_key
|
35
|
-
obj_needs :data, :auth_uri, :mapping => :hp_auth_uri
|
36
|
-
obj_needs :data, :tenant, :mapping => :hp_tenant_id
|
37
|
-
obj_needs :data, ":excon_opts/:connect_timeout", :default_value => 30
|
38
|
-
obj_needs :data, ":excon_opts/:read_timeout", :default_value => 240
|
39
|
-
obj_needs :data, ":excon_opts/:write_timeout", :default_value => 240
|
40
|
-
|
41
|
-
# Defines Object structure and function stored on the Hpcloud class object.
|
42
|
-
# Compute Object
|
43
|
-
define_obj :compute_connection
|
44
|
-
# Defines Data used by compute.
|
45
|
-
|
46
|
-
obj_needs :data, :account_id, :mapping => :hp_access_key
|
47
|
-
obj_needs :data, :account_key, :mapping => :hp_secret_key
|
48
|
-
obj_needs :data, :auth_uri, :mapping => :hp_auth_uri
|
49
|
-
obj_needs :data, :tenant, :mapping => :hp_tenant_id
|
50
|
-
obj_needs :data, :compute, :mapping => :hp_avl_zone
|
51
|
-
|
52
|
-
define_obj :network_connection
|
53
|
-
obj_needs :data, :account_id, :mapping => :hp_access_key
|
54
|
-
obj_needs :data, :account_key, :mapping => :hp_secret_key
|
55
|
-
obj_needs :data, :auth_uri, :mapping => :hp_auth_uri
|
56
|
-
obj_needs :data, :tenant, :mapping => :hp_tenant_id
|
57
|
-
obj_needs :data, :network, :mapping => :hp_avl_zone
|
58
|
-
|
59
|
-
# Forj predefine following query mapping, used by ForjProcess
|
60
|
-
# id => id, name => name
|
61
|
-
# If we need to add another mapping, add
|
62
|
-
# query_mapping :id => :MyID
|
63
|
-
# If the query is not push through and Hash object, the Provider
|
64
|
-
# will needs to create his own mapping function.
|
65
|
-
define_obj :network
|
66
|
-
query_mapping :external, :router_external
|
67
|
-
|
68
|
-
define_obj :rule
|
69
|
-
obj_needs :data, :dir, :mapping => :direction
|
70
|
-
attr_value_mapping :IN, 'ingress'
|
71
|
-
attr_value_mapping :OUT, 'egress'
|
72
|
-
|
73
|
-
obj_needs :data, :proto, :mapping => :protocol
|
74
|
-
obj_needs :data, :port_min, :mapping => :port_range_min
|
75
|
-
obj_needs :data, :port_max, :mapping => :port_range_max
|
76
|
-
obj_needs :data, :addr_map, :mapping => :remote_ip_prefix
|
77
|
-
obj_needs :data, :sg_id, :mapping => :security_group_id
|
78
|
-
|
79
|
-
get_attr_mapping :dir, :direction
|
80
|
-
get_attr_mapping :proto, :protocol
|
81
|
-
get_attr_mapping :port_min, :port_range_min
|
82
|
-
get_attr_mapping :port_max, :port_range_max
|
83
|
-
get_attr_mapping :addr_map, :remote_ip_prefix
|
84
|
-
get_attr_mapping :sg_id, :security_group_id
|
85
|
-
|
86
|
-
define_obj :keypairs
|
87
|
-
|
88
|
-
undefine_attribute :id # Do not return any predefined ID
|
89
|
-
|
90
|
-
# ************************************ Router Object
|
91
|
-
define_obj :router
|
92
|
-
|
93
|
-
obj_needs_optional
|
94
|
-
obj_needs :data, :router_name, :mapping => :name
|
95
|
-
# The FORJ gateway_network_id is extracted from Fog::HP::Network::Router[:external_gateway_info][:network_id]
|
96
|
-
obj_needs :data, :external_gateway_id, :mapping => [:external_gateway_info, 'network_id' ]
|
97
|
-
|
98
|
-
get_attr_mapping :gateway_network_id, [:external_gateway_info, 'network_id']
|
99
|
-
|
100
|
-
# ************************************ SERVER Object
|
101
|
-
define_obj :server
|
102
|
-
get_attr_mapping :status, :state
|
103
|
-
attr_value_mapping :create, "BUILD"
|
104
|
-
attr_value_mapping :boot, :boot
|
105
|
-
attr_value_mapping :active, "ACTIVE"
|
106
|
-
|
107
|
-
# ************************************ SERVER log Object
|
108
|
-
define_obj :server_log
|
109
|
-
|
110
|
-
# Excon::Response object type
|
111
|
-
get_attr_mapping :output, "output"
|
112
|
-
|
113
|
-
# ************************************* Public IP Object
|
114
|
-
define_obj :public_ip
|
115
|
-
get_attr_mapping :server_id, :instance_id
|
116
|
-
get_attr_mapping :public_ip, :ip
|
117
|
-
|
118
|
-
# defines setup Cloud data (:account => true for setup)
|
119
|
-
define_data(:account_id, {
|
120
|
-
:account => true,
|
121
|
-
:desc => 'HPCloud Access Key (From horizon, user drop down, manage keys)',
|
122
|
-
:validate => /^[A-Z0-9]*$/
|
123
|
-
})
|
124
|
-
define_data(:account_key, {
|
125
|
-
:account => true,
|
126
|
-
:desc => 'HPCloud secret Key (From horizon, user drop down, manage keys)',
|
127
|
-
:encrypted => false,
|
128
|
-
:validate => /^.+/
|
129
|
-
})
|
130
|
-
define_data(:auth_uri, {
|
131
|
-
:account => true,
|
132
|
-
:desc => 'HPCloud Authentication service URL (default is HP Public cloud)',
|
133
|
-
:validate => /^http(s)?:\/\/.*$/,
|
134
|
-
:default_value => "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/"
|
135
|
-
})
|
136
|
-
define_data(:tenant, {
|
137
|
-
:account => true,
|
138
|
-
:desc => 'HPCloud Tenant ID (from horizon, identity, projecs, Project ID)',
|
139
|
-
:validate => /^[0-9]+$/
|
140
|
-
})
|
141
|
-
|
142
|
-
define_data(:compute, {
|
143
|
-
:account => true,
|
144
|
-
:desc => 'HPCloud Compute service zone (Ex: region-a.geo-1)',
|
145
|
-
:depends_on => [:account_id, :account_key, :auth_uri,:tenant ],
|
146
|
-
:list_values => {
|
147
|
-
:query_type => :controller_call,
|
148
|
-
:object => :services,
|
149
|
-
:query_call => :get_services,
|
150
|
-
:query_params => { :list_services => [:Compute, :compute] },
|
151
|
-
:validate => :list_strict
|
152
|
-
}
|
153
|
-
})
|
154
|
-
|
155
|
-
define_data(:network, {
|
156
|
-
:account => true,
|
157
|
-
:desc => 'HPCloud Network service zone (Ex: region-a.geo-1)',
|
158
|
-
:depends_on => [:account_id, :account_key, :auth_uri,:tenant ],
|
159
|
-
:list_values => {
|
160
|
-
:query_type => :controller_call,
|
161
|
-
:object => :services ,
|
162
|
-
:query_call => :get_services,
|
163
|
-
:query_params => { :list_services => [:Networking, :network] },
|
164
|
-
:validate => :list_strict
|
165
|
-
}
|
166
|
-
})
|
167
|
-
|
168
|
-
data_value_mapping 'xsmall', "standard.xsmall"
|
169
|
-
data_value_mapping 'small', "standard.small"
|
170
|
-
data_value_mapping 'medium', "standard.medium"
|
171
|
-
data_value_mapping 'large', "standard.large"
|
172
|
-
data_value_mapping 'xlarge', "standard.xlarge"
|
173
|
-
|
174
|
-
|
175
|
-
end
|
176
|
-
|
177
|
-
# Following class describe how FORJ should handle HP Cloud objects.
|
178
|
-
# Except Cloud connection, all HPCloud objects management are described/called in HP* modules.
|
179
|
-
class HpcloudController < BaseController
|
180
|
-
|
181
|
-
def connect(sObjectType, hParams)
|
182
|
-
case sObjectType
|
183
|
-
when :services
|
184
|
-
Fog::HP.authenticate_v2(hParams[:hdata], hParams[:excon_opts])
|
185
|
-
when :compute_connection
|
186
|
-
Fog::Compute.new(hParams[:hdata].merge({:provider => :hp,:version => 'v2'}))
|
187
|
-
when :network_connection
|
188
|
-
Fog::HP::Network.new(hParams[:hdata])
|
189
|
-
else
|
190
|
-
forjError "'%s' is not a valid object for 'connect'" % sObjectType
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
def create(sObjectType, hParams)
|
195
|
-
case sObjectType
|
196
|
-
when :public_ip
|
197
|
-
required?(hParams, :compute_connection)
|
198
|
-
required?(hParams, :server)
|
199
|
-
HPCompute.server_assign_address(hParams[:compute_connection], hParams[:server])
|
200
|
-
when :server
|
201
|
-
required?(hParams, :compute_connection)
|
202
|
-
required?(hParams, :image)
|
203
|
-
required?(hParams, :network)
|
204
|
-
required?(hParams, :flavor)
|
205
|
-
required?(hParams, :keypairs)
|
206
|
-
required?(hParams, :security_groups)
|
207
|
-
required?(hParams, :server_name)
|
208
|
-
HPCompute.create_server(
|
209
|
-
hParams[:compute_connection],
|
210
|
-
hParams[:server_name], hParams[:security_groups],
|
211
|
-
hParams[:image], hParams[:network],
|
212
|
-
hParams[:flavor], hParams[:keypairs],
|
213
|
-
hParams[:user_data], hParams[:meta_data]
|
214
|
-
)
|
215
|
-
when :image
|
216
|
-
required?(hParams, :compute_connection)
|
217
|
-
required?(hParams, :image_name)
|
218
|
-
HPCompute.get_image(hParams[:compute_connection], hParams[:image_name])
|
219
|
-
when :network
|
220
|
-
required?(hParams, :network_connection)
|
221
|
-
required?(hParams, :network_name)
|
222
|
-
HPNetwork.create_network(hParams[:network_connection], hParams[:network_name])
|
223
|
-
when :subnetwork
|
224
|
-
required?(hParams, :network_connection)
|
225
|
-
required?(hParams, :network)
|
226
|
-
required?(hParams, :subnetwork_name)
|
227
|
-
HPNetwork.create_subnetwork(hParams[:network_connection], hParams[:network], hParams[:subnetwork_name])
|
228
|
-
when :security_groups
|
229
|
-
required?(hParams, :network_connection)
|
230
|
-
required?(hParams, :security_group)
|
231
|
-
HPSecurityGroups.create_sg(hParams[:network_connection], hParams[:security_group], hParams[:sg_desc])
|
232
|
-
when :keypairs
|
233
|
-
required?(hParams, :compute_connection)
|
234
|
-
required?(hParams, :keypair_name)
|
235
|
-
required?(hParams, :public_key)
|
236
|
-
HPKeyPairs.create_keypair(hParams[:compute_connection], hParams[:keypair_name], hParams[:public_key])
|
237
|
-
when :router
|
238
|
-
required?(hParams, :network_connection)
|
239
|
-
required?(hParams, :router_name)
|
240
|
-
#~ if hParams[:external_gateway_id]
|
241
|
-
#~ hParams[:hdata][:external_gateway_info] = { 'network_id' => hParams[:external_gateway_id] }
|
242
|
-
#~ end
|
243
|
-
hParams[:hdata] = hParams[:hdata].merge(:admin_state_up => true) # Forcelly used admin_status_up to true.
|
244
|
-
|
245
|
-
HPNetwork.create_router(hParams[:network_connection], hParams[:hdata])
|
246
|
-
when :rule
|
247
|
-
required?(hParams, :network_connection)
|
248
|
-
required?(hParams, :security_groups)
|
249
|
-
HPSecurityGroups.create_rule(hParams[:network_connection], hParams[:hdata])
|
250
|
-
when :router_interface
|
251
|
-
required?(hParams, :router)
|
252
|
-
required?(hParams, :subnetwork)
|
253
|
-
HPNetwork.add_interface(hParams[:router], hParams[:subnetwork])
|
254
|
-
else
|
255
|
-
forjError "'%s' is not a valid object for 'create'" % sObjectType
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
# This function return a collection which have to provide:
|
260
|
-
# functions: [], length, each
|
261
|
-
# Used by network process.
|
262
|
-
def query(sObjectType, sQuery, hParams)
|
263
|
-
case sObjectType
|
264
|
-
when :public_ip
|
265
|
-
required?(hParams, :compute_connection)
|
266
|
-
required?(hParams, :server)
|
267
|
-
HPCompute.query_server_assigned_addresses(hParams[:compute_connection], hParams[:server], sQuery)
|
268
|
-
when :server
|
269
|
-
required?(hParams, :compute_connection)
|
270
|
-
HPCompute.query_server(hParams[:compute_connection], sQuery)
|
271
|
-
when :image
|
272
|
-
required?(hParams, :compute_connection)
|
273
|
-
HPCompute.query_image(hParams[:compute_connection], sQuery)
|
274
|
-
when :network
|
275
|
-
required?(hParams, :network_connection)
|
276
|
-
HPNetwork.query_network(hParams[:network_connection], sQuery)
|
277
|
-
when :subnetwork
|
278
|
-
required?(hParams, :network_connection)
|
279
|
-
HPNetwork.query_subnetwork(hParams[:network_connection], sQuery)
|
280
|
-
when :router
|
281
|
-
required?(hParams, :network_connection)
|
282
|
-
HPNetwork.query_router(hParams[:network_connection], sQuery)
|
283
|
-
when :port
|
284
|
-
required?(hParams, :network_connection)
|
285
|
-
HPNetwork.query_port(hParams[:network_connection], sQuery)
|
286
|
-
when :security_groups
|
287
|
-
required?(hParams, :network_connection)
|
288
|
-
HPSecurityGroups.query_sg(hParams[:network_connection], sQuery)
|
289
|
-
when :rule
|
290
|
-
required?(hParams, :network_connection)
|
291
|
-
HPSecurityGroups.query_rule(hParams[:network_connection], sQuery)
|
292
|
-
when :keypairs
|
293
|
-
required?(hParams, :compute_connection)
|
294
|
-
HPKeyPairs.query_keypair(hParams[:compute_connection], sQuery)
|
295
|
-
when :flavor
|
296
|
-
required?(hParams, :compute_connection)
|
297
|
-
HPCompute.query_flavor(hParams[:compute_connection], sQuery)
|
298
|
-
else
|
299
|
-
forjError "'%s' is not a valid object for 'query'" % sObjectType
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
def delete(sObjectType, hParams)
|
304
|
-
case sObjectType
|
305
|
-
when :network
|
306
|
-
HPNetwork.delete_network(hParams[:network_connection], hParams[:network])
|
307
|
-
when :rule
|
308
|
-
HPSecurityGroups.delete_rule(hParams[:network_connection], hParams[:id])
|
309
|
-
hParams[:network_connection].security_group_rules.get(hParams[:id]).destroy
|
310
|
-
else
|
311
|
-
nil
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
def get(sObjectType, sUniqId, hParams)
|
316
|
-
case sObjectType
|
317
|
-
when :server_log
|
318
|
-
required?(hParams, :server)
|
319
|
-
|
320
|
-
hParams[:server].console_output(sUniqId)
|
321
|
-
when :server
|
322
|
-
required?(hParams, :compute_connection)
|
323
|
-
HPCompute.get_server(hParams[:compute_connection], sUniqId)
|
324
|
-
when :image
|
325
|
-
required?(hParams, :compute_connection)
|
326
|
-
HPCompute.get_image(hParams[:compute_connection], sUniqId)
|
327
|
-
when :network
|
328
|
-
required?(hParams, :network_connection)
|
329
|
-
HPNetwork.get_network(hParams[:network_connection], sUniqId)
|
330
|
-
else
|
331
|
-
forjError "'%s' is not a valid object for 'get'" % sObjectType
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
|
-
def query_each(oFogObject)
|
336
|
-
case oFogObject.class.to_s
|
337
|
-
when "Fog::HP::Network::Networks"
|
338
|
-
oFogObject.each { | value |
|
339
|
-
yield(value)
|
340
|
-
}
|
341
|
-
else
|
342
|
-
forjError "'%s' is not a valid list for 'each'" % oFogObject.class
|
343
|
-
end
|
344
|
-
end
|
345
|
-
|
346
|
-
def get_attr(oControlerObject, key)
|
347
|
-
begin
|
348
|
-
if oControlerObject.is_a?(Excon::Response)
|
349
|
-
rhGet(oControlerObject.data, :body, key)
|
350
|
-
else
|
351
|
-
attributes = oControlerObject.attributes
|
352
|
-
raise "attribute '%s' is unknown in '%s'. Valid one are : '%s'" % [key[0], oControlerObject.class, oControlerObject.class.attributes ] unless oControlerObject.class.attributes.include?(key[0])
|
353
|
-
rhGet(attributes, key)
|
354
|
-
end
|
355
|
-
rescue => e
|
356
|
-
forjError "Unable to map '%s'. %s" % [key, e.message]
|
357
|
-
end
|
358
|
-
end
|
359
|
-
|
360
|
-
def set_attr(oControlerObject, key, value)
|
361
|
-
begin
|
362
|
-
raise "No set feature for '%s'" % oControlerObject.class if oControlerObject.is_a?(Excon::Response)
|
363
|
-
attributes = oControlerObject.attributes
|
364
|
-
raise "attribute '%s' is unknown in '%s'. Valid one are : '%s'" % [key[0], oControlerObject.class, oControlerObject.class.attributes ] unless oControlerObject.class.attributes.include?(key[0])
|
365
|
-
rhSet(attributes, value, key)
|
366
|
-
rescue => e
|
367
|
-
forjError "Unable to map '%s' on '%s'" % [key, sObjectType]
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
|
372
|
-
def update(sObjectType, oObject, hParams)
|
373
|
-
case sObjectType
|
374
|
-
when :router
|
375
|
-
forjError "Object to update is nil" if oObject.nil?
|
376
|
-
|
377
|
-
HPNetwork.update_router(oObject[:object])
|
378
|
-
else
|
379
|
-
forjError "'%s' is not a valid list for 'update'" % oFogObject.class
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
# This function requires to return an Array of values or nil.
|
384
|
-
def get_services(sObjectType, oParams)
|
385
|
-
case sObjectType
|
386
|
-
when :services
|
387
|
-
# oParams[sObjectType] will provide the controller object.
|
388
|
-
# This one can be interpreted only by controller code,
|
389
|
-
# except if controller declares how to map with this object.
|
390
|
-
# Processes can deal only process mapped data.
|
391
|
-
# Currently there is no services process function. No need to map.
|
392
|
-
hServices = oParams[:services]
|
393
|
-
if not oParams[:list_services].is_a?(Array)
|
394
|
-
hServiceToFind = [oParams[:list_services]]
|
395
|
-
else
|
396
|
-
hServiceToFind = oParams[:list_services]
|
397
|
-
end
|
398
|
-
# Search for service. Ex: Can be :Networking or network. I currently do not know why...
|
399
|
-
hSearchServices= rhGet(hServices, :service_catalog)
|
400
|
-
sService = nil
|
401
|
-
hServiceToFind.each { | sServiceElem |
|
402
|
-
if hSearchServices.key?(sServiceElem)
|
403
|
-
sService = sServiceElem
|
404
|
-
break
|
405
|
-
end
|
406
|
-
}
|
407
|
-
|
408
|
-
forjError "Unable to find services %s" % hServiceToFind if sService.nil?
|
409
|
-
result = rhGet(hServices, :service_catalog, sService).keys
|
410
|
-
result.delete("name")
|
411
|
-
result.each_index { | iIndex |
|
412
|
-
result[iIndex] = result[iIndex].to_s if result[iIndex].is_a?(Symbol)
|
413
|
-
}
|
414
|
-
return result
|
415
|
-
else
|
416
|
-
forjError "'%s' is not a valid object for 'get_services'" % sObjectType
|
417
|
-
end
|
418
|
-
end
|
419
|
-
end
|