lorj 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.gitreview +4 -0
  4. data/Gemfile +25 -0
  5. data/Gemfile.lock +34 -0
  6. data/LICENSE.txt +14 -0
  7. data/README.md +652 -0
  8. data/Rakefile +24 -0
  9. data/bin/cloud_test.rb +81 -0
  10. data/example/students_1/process/Students.rb +20 -0
  11. data/example/students_1/students.rb +16 -0
  12. data/example/students_2/process/Students.rb +27 -0
  13. data/example/students_2/students.rb +36 -0
  14. data/example/students_3/controller/yaml_students.rb +94 -0
  15. data/example/students_3/controller/yaml_students_controller.rb +123 -0
  16. data/example/students_3/process/students.rb +118 -0
  17. data/example/students_3/students.rb +93 -0
  18. data/example/students_4/controller/yaml_students.rb +82 -0
  19. data/example/students_4/controller/yaml_students_controller.rb +141 -0
  20. data/example/students_4/process/students.rb +112 -0
  21. data/example/students_4/students.rb +103 -0
  22. data/example/yaml_students/students.rb +78 -0
  23. data/example/yaml_students/yaml_students.rb +115 -0
  24. data/lib/concept.md +111 -0
  25. data/lib/core/core.rb +723 -0
  26. data/lib/core/definition.rb +505 -0
  27. data/lib/core/definition_internal.rb +338 -0
  28. data/lib/core/lorj-basecontroller.rb +90 -0
  29. data/lib/core/lorj-basedefinition.rb +1079 -0
  30. data/lib/core/lorj-baseprocess.rb +231 -0
  31. data/lib/core/lorj-data.rb +567 -0
  32. data/lib/core/lorj-keypath.rb +115 -0
  33. data/lib/core_process/CloudProcess.rb +334 -0
  34. data/lib/core_process/global_process.rb +406 -0
  35. data/lib/core_process/network_process.rb +603 -0
  36. data/lib/img/.directory +4 -0
  37. data/lib/img/account_data_access.png +0 -0
  38. data/lib/img/config_data_access.png +0 -0
  39. data/lib/img/forj-lib-concept.png +0 -0
  40. data/lib/lorj/version.rb +3 -0
  41. data/lib/lorj.rb +51 -0
  42. data/lib/prc-account.rb +339 -0
  43. data/lib/prc-config.rb +1023 -0
  44. data/lib/prc-logging.rb +183 -0
  45. data/lib/prc.rb +108 -0
  46. data/lib/providers/hpcloud/Hpcloud.rb +419 -0
  47. data/lib/providers/hpcloud/compute.rb +108 -0
  48. data/lib/providers/hpcloud/network.rb +117 -0
  49. data/lib/providers/hpcloud/security_groups.rb +67 -0
  50. data/lib/providers/mock/Mock.rb +141 -0
  51. data/lib/providers/openstack/Openstack.rb +47 -0
  52. data/lib/providers/templates/compute.rb +42 -0
  53. data/lib/providers/templates/core.rb +61 -0
  54. data/lib/providers/templates/network.rb +33 -0
  55. data/lorj-spec/defaults.yaml +26 -0
  56. data/lorj.gemspec +39 -0
  57. data/spec/forj-account_spec.rb +75 -0
  58. data/spec/forj-config_spec.rb +196 -0
  59. metadata +164 -0
@@ -0,0 +1,334 @@
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
+ # It requires Core objects to be defined + default ForjProcess functions.
19
+
20
+ require File.join($CORE_PROCESS_PATH, "global_process.rb")
21
+ require File.join($CORE_PROCESS_PATH, "network_process.rb")
22
+
23
+ # Define framework object on BaseDefinition
24
+ class BaseDefinition
25
+
26
+ # All objects used by this process are built from a Controller
27
+ process_default :use_controller => true
28
+
29
+ # predefined list of objects.
30
+ # Links between objects is not predefined. To do it, use needs declaration in your provider class.
31
+
32
+ # object to get list of services
33
+ # Defines Process handler to call
34
+ define_obj(:services,
35
+ {
36
+ :create_e => :connect
37
+ })
38
+ obj_needs :data, :auth_uri
39
+ obj_needs :data, :account_id
40
+ obj_needs :data, :account_key
41
+ obj_needs :data, :tenant
42
+
43
+ undefine_attribute :id # Do not return any predefined ID
44
+ undefine_attribute :name # Do not return any predefined NAME
45
+
46
+
47
+ # compute_connection
48
+ define_obj(:compute_connection,
49
+ {
50
+ :create_e => :connect # Will call ForjProcess connect
51
+ })
52
+ obj_needs :data, :account_id
53
+ obj_needs :data, :account_key
54
+ obj_needs :data, :auth_uri
55
+ obj_needs :data, :tenant
56
+ obj_needs :data, :compute
57
+
58
+ undefine_attribute :id # Do not return any predefined ID
59
+ undefine_attribute :name # Do not return any predefined NAME
60
+
61
+ # network_connection
62
+ define_obj(:network_connection,
63
+ {
64
+ :create_e => :connect
65
+ })
66
+ obj_needs :data, :account_id
67
+ obj_needs :data, :account_key
68
+ obj_needs :data, :auth_uri
69
+ obj_needs :data, :tenant
70
+ obj_needs :data, :network
71
+
72
+ undefine_attribute :id # Do not return any predefined ID
73
+ undefine_attribute :name # Do not return any predefined NAME
74
+
75
+ # ************************************ Network Object
76
+ # Identify the network
77
+
78
+ define_obj(:network,
79
+ :create_e => :forj_get_or_create_network,
80
+ :query_e => :forj_query_network,
81
+ :get_e => :forj_get_network,
82
+ :delete_e => :forj_delete_network
83
+ )
84
+ obj_needs :CloudObject, :network_connection
85
+ obj_needs :data, :network_name, { :for => [:create_e] }
86
+
87
+ obj_needs_optional
88
+ obj_needs :data, :subnetwork_name, { :for => [:create_e] }
89
+
90
+ def_query_attribute :external # true if network is external or not.
91
+
92
+ # ************************************ SubNetwork Object
93
+ # Identify subnetwork as part of network.
94
+ define_obj(:subnetwork,
95
+ :create_e => :forj_get_or_create_subnetwork
96
+ )
97
+
98
+ obj_needs :CloudObject, :network_connection
99
+ obj_needs :CloudObject, :network
100
+ obj_needs :data, :subnetwork_name
101
+
102
+ def_query_attribute :network_id
103
+
104
+ # ************************************ Port Object
105
+ # Identify port attached to network
106
+ define_obj :port, :nohandler => true
107
+
108
+ obj_needs :CloudObject, :network_connection
109
+ def_attribute :device_id
110
+
111
+ def_query_attribute :network_id
112
+ def_query_attribute :device_owner
113
+
114
+
115
+ # ************************************ Router Object
116
+ # Identify the router of a network.
117
+ define_obj(:router,
118
+ {
119
+ :create_e => :forj_get_or_create_router,
120
+ # :query_e => :forj_query_router,
121
+ # :get_e => :forj_get_router,
122
+ :update_e => :forj_update_router
123
+ # :delete_e => :forj_delete_router
124
+ })
125
+ obj_needs :CloudObject, :network_connection
126
+ obj_needs :CloudObject, :network, { :for => [:create_e] }
127
+ obj_needs :CloudObject, :subnetwork, { :for => [:create_e] }
128
+ obj_needs_optional
129
+ obj_needs :data, :router_name, { :for => [:create_e] }
130
+
131
+ def_attribute :gateway_network_id
132
+
133
+ # ************************************ Router interface Object
134
+ # Identify interface attached to a router
135
+ # This object will probably be moved to controller task
136
+ # To keep the network model more generic.
137
+
138
+ # No process handler defined. Just Controller object
139
+ define_obj :router_interface, :nohandler => true
140
+
141
+ obj_needs :CloudObject, :network_connection
142
+ obj_needs :CloudObject, :router, { :for => [:create_e] }
143
+ obj_needs :CloudObject, :subnetwork, { :for => [:create_e] }
144
+
145
+ undefine_attribute :name
146
+ undefine_attribute :id
147
+
148
+ # Identify an external network thanks to the network router.
149
+ define_obj(:external_network,
150
+ {
151
+ :create_e => :forj_get_or_create_ext_net,
152
+ :query_e => :forj_query_external_network
153
+ })
154
+
155
+ obj_needs :CloudObject, :network_connection
156
+ obj_needs :CloudObject, :router
157
+
158
+
159
+ # ************************************ Security groups Object
160
+ # Identify security_groups
161
+ define_obj(:security_groups,
162
+ {
163
+ :create_e => :forj_get_or_create_sg,
164
+ :query_e => :forj_query_sg,
165
+ :delete_e => :forj_delete_sg
166
+ })
167
+
168
+ obj_needs :CloudObject, :network_connection
169
+ obj_needs :data, :security_group, { :for => [:create_e] }
170
+ obj_needs_optional
171
+ obj_needs :data, :sg_desc, { :for => [:create_e] }
172
+
173
+ # ************************************ Security group rules Object
174
+ # Identify Rules attached to the security group
175
+ define_obj(:rule,
176
+ {
177
+ :create_e => :forj_get_or_create_rule,
178
+ :query_e => :forj_query_rule
179
+ # :delete_e => :forj_delete_rule
180
+ })
181
+
182
+ undefine_attribute :name # Do not return any predefined name attribute
183
+
184
+ obj_needs :CloudObject, :network_connection
185
+ obj_needs :CloudObject, :security_groups, { :for => [:create_e] }
186
+ obj_needs :data, :sg_id, { :for => [:create_e], :extract_from => [:security_groups, :attrs, :id] }
187
+ obj_needs :data, :dir, { :for => [:create_e] }
188
+ predefine_data_value :IN, { :desc => "Input NAT/firewall rule map type" }
189
+ predefine_data_value :OUT, { :desc => "Output NAT/firewall rule map type" }
190
+ obj_needs :data, :proto, { :for => [:create_e] }
191
+ obj_needs :data, :port_min, { :for => [:create_e] }
192
+ obj_needs :data, :port_max, { :for => [:create_e] }
193
+ obj_needs :data, :addr_map, { :for => [:create_e] }
194
+
195
+ # ************************************ keypairs Object
196
+ # Identify keypairs
197
+ define_obj(:keypairs,
198
+ {
199
+ :create_e => :forj_get_or_create_keypair,
200
+ :query_e => :forj_query_keypair
201
+ # :delete_e => :forj_delete_keypair
202
+ })
203
+
204
+ obj_needs :CloudObject, :compute_connection
205
+ obj_needs :data, :keypair_name, { :for => [:create_e] }
206
+ obj_needs :data, :keypair_path, { :for => [:create_e] }
207
+
208
+ obj_needs_optional
209
+ obj_needs :data, :public_key, { :for => [:create_e] }
210
+
211
+ def_attribute :public_key
212
+
213
+ # ************************************ Image Object
214
+ # Identify image
215
+ define_obj(:image,
216
+ {
217
+ :create_e => :forj_get_or_create_image,
218
+ :query_e => :forj_query_image
219
+ # :get_e => :forj_get_image
220
+ # :update_e => :forj_update_image
221
+ # :delete_e => :forj_delete_image
222
+ })
223
+
224
+ obj_needs :CloudObject, :compute_connection
225
+ obj_needs :data, :image_name, { :for => [:create_e] }
226
+
227
+ # ************************************ Flavor Object
228
+ # Identify flavor
229
+ define_obj(:flavor,
230
+ {
231
+ :create_e => :forj_get_or_create_flavor,
232
+ :query_e => :forj_query_flavor
233
+ # :get_e => :forj_get_flavor,
234
+ # :update_e => :forj_update_flavor,
235
+ # :delete_e => :forj_delete_flavor
236
+ })
237
+
238
+ obj_needs :CloudObject, :compute_connection
239
+ obj_needs :data, :flavor_name, { :for => [:create_e] }
240
+ # Cloud provider will need to map to one of those predefined flavors.
241
+ # limitation values may match exactly or at least ensure those limitation
242
+ # are under provider limitation
243
+ # ie, at least the CloudProcess limitation can less than the Cloud provider defines.
244
+ # CloudProcess EHD = 160, then Provider EHD = 200 is ok
245
+ # but Provider EHD = 150 is not ok.
246
+ predefine_data_value('tiny', { :desc => "VCU: 1, RAM:512M, HD:1G, EHD: 0G, Swap: 0G" })
247
+ predefine_data_value('xsmall', { :desc => "VCU: 1, RAM:1G, HD:10G, EHD: 10G, Swap: 0G" })
248
+ predefine_data_value('small', { :desc => "VCU: 2, RAM:2G, HD:30G, EHD: 10G, Swap: 0G" })
249
+ predefine_data_value('medium', { :desc => "VCU: 2, RAM:4G, HD:30G, EHD: 50G, Swap: 0G" })
250
+ predefine_data_value('large', { :desc => "VCU: 4, RAM:8G, HD:30G, EHD: 100G, Swap: 0G" })
251
+ predefine_data_value('xlarge', { :desc => "VCU: 8, RAM:16G, HD:30G, EHD: 200G, Swap: 0G" })
252
+
253
+ # ************************************ Internet network Object
254
+ # Define Internet network
255
+ #
256
+ # This object contains the logic to ensure the router's network has a gateway to the external network (internet)
257
+ # is capable to connect to internet
258
+ # And to create this connection if possible.
259
+
260
+ define_obj(:internet_network, :nohandler => true )
261
+
262
+ obj_needs :CloudObject, :external_network # External network to connect if needed.
263
+
264
+ # ************************************ SERVER Object
265
+ # Identify the server to use/build on the network/...
266
+ define_obj(:server,
267
+ {
268
+ :create_e => :forj_get_or_create_server,
269
+ :query_e => :forj_query_server,
270
+ :get_e => :forj_get_server
271
+ # :update_e => :forj_update_server,
272
+ # :delete_e => :forj_delete_server
273
+ })
274
+
275
+ obj_needs :CloudObject, :compute_connection
276
+ obj_needs :CloudObject, :flavor, { :for => [:create_e] }
277
+ obj_needs :CloudObject, :network, { :for => [:create_e] }
278
+ obj_needs :CloudObject, :security_groups, { :for => [:create_e] }
279
+ obj_needs :CloudObject, :keypairs, { :for => [:create_e] }
280
+ obj_needs :CloudObject, :image, { :for => [:create_e] }
281
+ obj_needs :data, :server_name, { :for => [:create_e] }
282
+
283
+ obj_needs_optional
284
+ obj_needs :data, :user_data, { :for => [:create_e] }
285
+ obj_needs :data, :meta_data, { :for => [:create_e] }
286
+
287
+ def_attribute :status
288
+ predefine_data_value :create, { :desc => "Server is creating." }
289
+ predefine_data_value :boot, { :desc => "Server is booting." }
290
+ predefine_data_value :active, { :desc => "Server is started." }
291
+ def_attribute :private_ip_address
292
+ def_attribute :public_ip_address
293
+
294
+ # ************************************ SERVER Addresses Object
295
+ # Object representing the list of IP addresses attached to a server.
296
+ define_obj(:public_ip,
297
+ :create_e => :forj_get_or_assign_public_address,
298
+ :query_e => :forj_query_public_address
299
+ # :get_e => :forj_get_address
300
+ # :update_e => :forj_update_address
301
+ # :delete_e => :forj_delete_address
302
+ )
303
+
304
+ obj_needs :CloudObject, :compute_connection
305
+ obj_needs :CloudObject, :server
306
+
307
+ def_attribute :server_id
308
+ def_attribute :public_ip
309
+ undefine_attribute :name # No name to extract
310
+
311
+ # ************************************ SERVER Console Object
312
+ # Object representing the console log attached to a server
313
+
314
+ define_obj(:server_log,
315
+ {
316
+ :get_e => :forj_get_server_log
317
+ })
318
+
319
+ obj_needs :CloudObject, :server
320
+ obj_needs :data, :log_lines
321
+ undefine_attribute :name
322
+ undefine_attribute :id
323
+ def_attribute :output
324
+
325
+ # ************************************ Internet SERVER Object
326
+ # internet server is a server connected to the internet network.
327
+ define_obj(:internet_server, :nohandler => true )
328
+
329
+ obj_needs :CloudObject, :internet_network
330
+ obj_needs :CloudObject, :server
331
+ obj_needs :CloudObject, :public_ip
332
+
333
+
334
+ end