lorj 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +46 -0
- data/Gemfile +15 -15
- data/README.md +22 -17
- data/Rakefile +12 -2
- data/bin/cloud_test.rb +13 -65
- data/example/students_1/process/students.rb +39 -0
- data/example/students_1/students.rb +22 -5
- data/example/students_2/process/students.rb +48 -0
- data/example/students_2/students.rb +39 -16
- data/example/students_3/controller/yaml_students.rb +50 -43
- data/example/students_3/controller/yaml_students_controller.rb +100 -87
- data/example/students_3/process/students.rb +161 -97
- data/example/students_3/students.rb +85 -56
- data/example/yaml_students/students.rb +40 -40
- data/example/yaml_students/yaml_students.rb +103 -90
- data/lib/core/core.rb +356 -696
- data/lib/core/core_controller.rb +227 -0
- data/lib/core/core_internal.rb +339 -0
- data/lib/core/core_model.rb +328 -0
- data/lib/core/core_object_data.rb +330 -0
- data/lib/core/core_object_params.rb +230 -0
- data/lib/core/core_process.rb +391 -0
- data/lib/core/core_process_setup.rb +353 -0
- data/lib/core/core_setup_ask.rb +241 -0
- data/lib/core/core_setup_encrypt.rb +146 -0
- data/lib/core/core_setup_init.rb +229 -0
- data/lib/core/core_setup_list.rb +160 -0
- data/lib/core/definition.rb +647 -469
- data/lib/core/definition_internal.rb +264 -308
- data/lib/core/lorj_basecontroller.rb +95 -0
- data/lib/core/lorj_basedefinition.rb +307 -0
- data/lib/core/lorj_baseprocess.rb +265 -0
- data/lib/core/lorj_data.rb +583 -0
- data/lib/core/lorj_keypath.rb +119 -0
- data/lib/core_process/cloud/process/common.rb +63 -0
- data/lib/core_process/cloud/process/connection.rb +93 -0
- data/lib/core_process/cloud/process/external_network.rb +94 -0
- data/lib/core_process/cloud/process/flavor.rb +99 -0
- data/lib/core_process/cloud/process/images.rb +87 -0
- data/lib/core_process/cloud/process/internet_network.rb +34 -0
- data/lib/core_process/cloud/process/internet_server.rb +30 -0
- data/lib/core_process/cloud/process/keypairs.rb +276 -0
- data/lib/core_process/cloud/process/network.rb +108 -0
- data/lib/core_process/cloud/process/public_ip.rb +100 -0
- data/lib/core_process/cloud/process/router.rb +260 -0
- data/lib/core_process/cloud/process/rules.rb +120 -0
- data/lib/core_process/cloud/process/security_groups.rb +121 -0
- data/lib/core_process/cloud/process/server.rb +127 -0
- data/lib/core_process/cloud/process/server_log.rb +35 -0
- data/lib/core_process/cloud/process/subnetwork.rb +108 -0
- data/lib/core_process/cloud_process.rb +30 -0
- data/lib/logging.rb +298 -0
- data/lib/lorj/version.rb +18 -1
- data/lib/lorj.rb +58 -18
- data/lib/lorj_account.rb +556 -0
- data/lib/lorj_config.rb +468 -0
- data/lib/lorj_defaults.rb +278 -0
- data/lib/prc.rb +136 -104
- data/lib/prc_base_config.rb +285 -0
- data/lib/prc_core_config.rb +878 -0
- data/lib/prc_section_config.rb +57 -0
- data/lib/providers/hpcloud/compute.rb +81 -93
- data/lib/providers/hpcloud/hpcloud.rb +462 -0
- data/lib/providers/hpcloud/network.rb +96 -98
- data/lib/providers/hpcloud/security_groups.rb +41 -40
- data/lib/providers/mock/mock.rb +144 -0
- data/lib/providers/openstack/openstack.rb +45 -0
- data/lib/providers/templates/compute.rb +21 -23
- data/lib/providers/templates/mycloud.rb +72 -0
- data/lib/providers/templates/network.rb +11 -12
- data/lib/rh.rb +339 -0
- data/lorj-spec/defaults.yaml +4 -0
- data/lorj.gemspec +6 -0
- data/spec/00_lorj_log_spec.rb +53 -0
- data/spec/01_hash_rh_spec.rb +243 -0
- data/spec/02_prc_base_config_spec.rb +216 -0
- data/spec/04_prc_core_config_spec.rb +83 -0
- data/spec/11_lorj_config_spec.rb +263 -0
- data/spec/12_lorj_account_spec.rb +181 -0
- metadata +76 -28
- data/Gemfile.lock +0 -37
- data/example/students_1/process/Students.rb +0 -20
- data/example/students_2/process/Students.rb +0 -27
- data/example/students_4/controller/yaml_students.rb +0 -82
- data/example/students_4/controller/yaml_students_controller.rb +0 -141
- data/example/students_4/process/students.rb +0 -112
- data/example/students_4/students.rb +0 -103
- data/lib/core/lorj-basecontroller.rb +0 -90
- data/lib/core/lorj-basedefinition.rb +0 -1139
- data/lib/core/lorj-baseprocess.rb +0 -236
- data/lib/core/lorj-data.rb +0 -567
- data/lib/core/lorj-keypath.rb +0 -115
- data/lib/core_process/CloudProcess.rb +0 -337
- data/lib/core_process/global_process.rb +0 -502
- data/lib/core_process/network_process.rb +0 -605
- data/lib/prc-account.rb +0 -339
- data/lib/prc-config.rb +0 -1030
- data/lib/prc-logging.rb +0 -261
- data/lib/providers/hpcloud/Hpcloud.rb +0 -426
- data/lib/providers/mock/Mock.rb +0 -141
- data/lib/providers/openstack/Openstack.rb +0 -47
- data/lib/providers/templates/core.rb +0 -61
- data/spec/forj-account_spec.rb +0 -75
- data/spec/forj-config_spec.rb +0 -196
@@ -1,236 +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
|
-
# Module Lorj which contains several classes.
|
19
|
-
#
|
20
|
-
# Those classes describes :
|
21
|
-
# - processes (BaseProcess) : How to create/delete/edit/query object.
|
22
|
-
# - controler (BaseControler) : If a provider is defined, define how will do object creation/etc...
|
23
|
-
# - definition(BaseDefinition): Functions to declare objects, query/data mapping and setup
|
24
|
-
# this task to make it to work.
|
25
|
-
|
26
|
-
module Lorj
|
27
|
-
# class describing generic Object Process
|
28
|
-
# Ex: How to get a Network Object (ie: get a network or create it if missing)
|
29
|
-
class BaseProcess
|
30
|
-
def initialize()
|
31
|
-
@oDefinition = nil
|
32
|
-
end
|
33
|
-
|
34
|
-
def set_BaseObject(oDefinition)
|
35
|
-
@oDefinition = oDefinition
|
36
|
-
end
|
37
|
-
|
38
|
-
def controller_connect(sObjectType, hParams = {})
|
39
|
-
raise Lorj::PrcError.new(), "No Controler object loaded." if not @oDefinition
|
40
|
-
@oDefinition.connect(sObjectType)
|
41
|
-
end
|
42
|
-
|
43
|
-
def controller_create(sObjectType, hParams = {})
|
44
|
-
raise Lorj::PrcError.new(), "No Controler object loaded." if not @oDefinition
|
45
|
-
@oDefinition.create(sObjectType)
|
46
|
-
end
|
47
|
-
|
48
|
-
def controller_query(sObjectType, sQuery, hParams = {})
|
49
|
-
raise Lorj::PrcError.new(), "No Controler object loaded." if not @oDefinition
|
50
|
-
@oDefinition.query(sObjectType, sQuery)
|
51
|
-
end
|
52
|
-
|
53
|
-
def controller_update(sObjectType, hParams = {})
|
54
|
-
raise Lorj::PrcError.new(), "No Controler object loaded." if not @oDefinition
|
55
|
-
@oDefinition.update(sObjectType)
|
56
|
-
end
|
57
|
-
|
58
|
-
def controller_delete(sObjectType, hParams = {})
|
59
|
-
raise Lorj::PrcError.new(), "No Controler object loaded." if not @oDefinition
|
60
|
-
@oDefinition.delete(sObjectType)
|
61
|
-
end
|
62
|
-
|
63
|
-
def controller_get(sObjectType, sId, hParams = {})
|
64
|
-
raise Lorj::PrcError.new(), "No Controler object loaded." if not @oDefinition
|
65
|
-
@oDefinition.get(sObjectType, sId)
|
66
|
-
end
|
67
|
-
|
68
|
-
def Create(sObjectType)
|
69
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
70
|
-
@oDefinition.Create(sObjectType)
|
71
|
-
end
|
72
|
-
|
73
|
-
def Query(sObjectType, sQuery)
|
74
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
75
|
-
@oDefinition.Query(sObjectType, sQuery)
|
76
|
-
end
|
77
|
-
|
78
|
-
def Update(sObjectType)
|
79
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
80
|
-
@oDefinition.Update(sObjectType)
|
81
|
-
end
|
82
|
-
|
83
|
-
def Get(sObjectType, sId)
|
84
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
85
|
-
@oDefinition.Get(sObjectType, sId)
|
86
|
-
end
|
87
|
-
|
88
|
-
def Delete(sObjectType)
|
89
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
90
|
-
@oDefinition.Delete(sObjectType)
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
def query_cache_cleanup(sObjectType)
|
96
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
97
|
-
@oDefinition.query_cleanup(sObjectType)
|
98
|
-
end
|
99
|
-
|
100
|
-
def object_cache_cleanup(sObjectType)
|
101
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
102
|
-
@oDefinition.object_cleanup(sObjectType)
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
def controler
|
108
|
-
PrcLib::warning("controler object call is obsolete. Please update your code. Use controller_<action> instead.\n%s" % caller)
|
109
|
-
raise Lorj::PrcError.new(), "No Controler object loaded." if not @oDefinition
|
110
|
-
@oDefinition
|
111
|
-
end
|
112
|
-
|
113
|
-
def object
|
114
|
-
PrcLib::warning("object call is obsolete. Please update your code. Use <Action> instead.\n%s" % caller)
|
115
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
116
|
-
@oDefinition
|
117
|
-
end
|
118
|
-
|
119
|
-
def format_object(sObjectType, oMiscObj)
|
120
|
-
|
121
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
122
|
-
@oDefinition.format_object(sObjectType, oMiscObj)
|
123
|
-
end
|
124
|
-
|
125
|
-
def format_query(sObjectType, oMiscObj, hQuery)
|
126
|
-
|
127
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
128
|
-
@oDefinition.format_list(sObjectType, oMiscObj, hQuery)
|
129
|
-
end
|
130
|
-
|
131
|
-
def DataObjects(sObjectType, *key)
|
132
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
133
|
-
@oDefinition.DataObjects(sObjectType, *key)
|
134
|
-
end
|
135
|
-
|
136
|
-
def get_data(oObj, *key)
|
137
|
-
PrcLib::warning("get_data call is obsolete. Please update your code. Use [] instead.\n%s" % caller)
|
138
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
139
|
-
@oDefinition.get_data(oObj, :attrs, key)
|
140
|
-
end
|
141
|
-
|
142
|
-
def register(oObject, sObjectType = nil)
|
143
|
-
|
144
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
145
|
-
@oDefinition.register(oObject, sObjectType)
|
146
|
-
end
|
147
|
-
|
148
|
-
def config
|
149
|
-
raise Lorj::PrcError.new(), "No Base object loaded." if not @oDefinition
|
150
|
-
@oDefinition.config
|
151
|
-
end
|
152
|
-
|
153
|
-
def query_single(sCloudObj, oList, sQuery, name, sInfoMsg = {})
|
154
|
-
oList = controller_query(sCloudObj, sQuery)
|
155
|
-
sInfo = {
|
156
|
-
:notfound => "No %s '%s' found",
|
157
|
-
:checkmatch => "Found 1 %s. checking exact match for '%s'.",
|
158
|
-
:nomatch => "No %s '%s' match",
|
159
|
-
:found => "Found %s '%s'.",
|
160
|
-
:more => "Found several %s. Searching for '%s'.",
|
161
|
-
:items_form => "%s",
|
162
|
-
:items => [:name]
|
163
|
-
}
|
164
|
-
sInfo[:notfound] = sInfoMsg[:notfound] if sInfoMsg.key?(:notfound)
|
165
|
-
sInfo[:checkmatch] = sInfoMsg[:checkmatch] if sInfoMsg.key?(:checkmatch)
|
166
|
-
sInfo[:nomatch] = sInfoMsg[:nomatch] if sInfoMsg.key?(:nomatch)
|
167
|
-
sInfo[:found] = sInfoMsg[:found] if sInfoMsg.key?(:found)
|
168
|
-
sInfo[:more] = sInfoMsg[:more] if sInfoMsg.key?(:more)
|
169
|
-
sInfo[:items] = sInfoMsg[:items] if sInfoMsg.key?(:items)
|
170
|
-
sInfo[:items_form] = sInfoMsg[:items_form] if sInfoMsg.key?(:items_form)
|
171
|
-
case oList.length()
|
172
|
-
when 0
|
173
|
-
PrcLib.info( sInfo[:notfound] % [sCloudObj, name] )
|
174
|
-
oList
|
175
|
-
when 1
|
176
|
-
Lorj.debug(2, sInfo[:checkmatch] % [sCloudObj, name])
|
177
|
-
element = nil
|
178
|
-
oList.each { | oElem |
|
179
|
-
bFound = true
|
180
|
-
sQuery.each { | key, value |
|
181
|
-
if oElem[key] != value
|
182
|
-
bFound = false
|
183
|
-
break
|
184
|
-
end
|
185
|
-
}
|
186
|
-
:remove if not bFound
|
187
|
-
}
|
188
|
-
if oList.length == 0
|
189
|
-
PrcLib.info(sInfo[:nomatch] % [sCloudObj, name])
|
190
|
-
else
|
191
|
-
sItems = []
|
192
|
-
if sInfo[:items].is_a?(Array)
|
193
|
-
sInfo[:items].each { | key |
|
194
|
-
sItems << oList[0, key]
|
195
|
-
}
|
196
|
-
else
|
197
|
-
sItems << oList[0, sInfo[:items]]
|
198
|
-
end
|
199
|
-
sItem = sInfo[:items_form] % sItems
|
200
|
-
PrcLib.info(sInfo[:found] % [sCloudObj, sItem])
|
201
|
-
end
|
202
|
-
oList
|
203
|
-
else
|
204
|
-
Lorj.debug(2, sInfo[:more] % [sCloudObj, name])
|
205
|
-
# Looping to find the one corresponding
|
206
|
-
element = nil
|
207
|
-
oList.each { | oElem |
|
208
|
-
bFound = true
|
209
|
-
sQuery.each { | key, value |
|
210
|
-
if oElem[key] != value
|
211
|
-
bFound = false
|
212
|
-
break
|
213
|
-
end
|
214
|
-
}
|
215
|
-
:remove if not bFound
|
216
|
-
}
|
217
|
-
if oList.length == 0
|
218
|
-
PrcLib.info(sInfo[:notfound] % [sCloudObj, name])
|
219
|
-
else
|
220
|
-
sItems = []
|
221
|
-
if sInfo[:items].is_a?(Array)
|
222
|
-
sInfo[:items].each { | key |
|
223
|
-
sItems << oList[0, key]
|
224
|
-
}
|
225
|
-
else
|
226
|
-
sItems << oList[0, sInfo[:items]]
|
227
|
-
end
|
228
|
-
sItem = sInfo[:items_form] % sItems
|
229
|
-
PrcLib.info(sInfo[:found] % [sCloudObj, sItem])
|
230
|
-
end
|
231
|
-
oList
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
end
|
236
|
-
end
|