lorj 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
require 'rubygems'
|
|
18
|
+
require 'yaml'
|
|
19
|
+
|
|
20
|
+
module PRC
|
|
21
|
+
# SectionConfig class layer
|
|
22
|
+
class SectionConfig < PRC::BaseConfig
|
|
23
|
+
# Get the value of a specific key under a section.
|
|
24
|
+
#
|
|
25
|
+
# * *Args* :
|
|
26
|
+
# - +keys+ : keys to get values from a section set by data_options.
|
|
27
|
+
# If section is set, it will use :default
|
|
28
|
+
# * *Returns* :
|
|
29
|
+
# - key value.
|
|
30
|
+
# * *Raises* :
|
|
31
|
+
# Nothing
|
|
32
|
+
def [](*keys)
|
|
33
|
+
return _get(:default, *keys) if @data_options[:section].nil?
|
|
34
|
+
_get(@data_options[:section], *keys)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def []=(*keys, value)
|
|
38
|
+
return _set(:default, *keys, value) if @data_options[:section].nil?
|
|
39
|
+
_set(@data_options[:section], *keys, value)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def exist?(*keys)
|
|
43
|
+
return _exist?(:default, *keys) if @data_options[:section].nil?
|
|
44
|
+
_exist?(@data_options[:section], *keys)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def where?(*keys)
|
|
48
|
+
return _exist?(:default, *keys) if @data_options[:section].nil?
|
|
49
|
+
_where?(@data_options[:section], *keys)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def del(*keys)
|
|
53
|
+
return _del(:default, *keys) if @data_options[:section].nil?
|
|
54
|
+
_del(@data_options[:section], *keys)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -14,100 +14,88 @@
|
|
|
14
14
|
# See the License for the specific language governing permissions and
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
|
|
17
|
+
# Defined HPCloud controller.
|
|
17
18
|
module HPCompute
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
# Following is the translation to get the public IPs for the server
|
|
64
|
-
|
|
65
|
-
result = []
|
|
66
|
-
oAddresses = oComputeConnect.addresses.all()
|
|
67
|
-
oAddresses.each { | oElem |
|
|
68
|
-
bFound = true
|
|
69
|
-
sQuery.each { | key, value |
|
|
70
|
-
if not oElem.attributes.key?(key) or oElem.attributes[key] != value
|
|
71
|
-
bFound = false
|
|
72
|
-
break
|
|
73
|
-
end
|
|
74
|
-
}
|
|
75
|
-
result << oElem if bFound
|
|
76
|
-
}
|
|
77
|
-
result
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def HPCompute.server_assign_address(oComputeConnect, oServer)
|
|
81
|
-
|
|
82
|
-
while oServer.state != 'ACTIVE'
|
|
83
|
-
sleep(5)
|
|
84
|
-
oServer = oComputeConnect.servers.get(oServer.id)
|
|
19
|
+
def self.get_server(oComputeConnect, sId)
|
|
20
|
+
oComputeConnect.servers.get(sId)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.query_addresses(oComputeConnect, sQuery)
|
|
24
|
+
oComputeConnect.addresses.all(sQuery)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.query_server(oComputeConnect, sQuery)
|
|
28
|
+
oComputeConnect.servers.all(sQuery)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.query_image(oComputeConnect, sQuery)
|
|
32
|
+
# HP Fog query is exact matching. No way to filter with a Regexp
|
|
33
|
+
# Testing it and filtering it.
|
|
34
|
+
# TODO: Be able to support Regexp in queries then extract all and filter.
|
|
35
|
+
oComputeConnect.images.all(sQuery)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.query_flavor(oComputeConnect, sQuery)
|
|
39
|
+
oComputeConnect.flavors.all(sQuery)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.create_server(oComputeConnect, options, oUser_data, oMeta_data)
|
|
43
|
+
if oUser_data
|
|
44
|
+
options[:user_data_encoded] = Base64.strict_encode64(oUser_data)
|
|
45
|
+
end
|
|
46
|
+
options[:metadata] = oMeta_data if oMeta_data
|
|
47
|
+
server = oComputeConnect.servers.create(options)
|
|
48
|
+
HPCompute.get_server(oComputeConnect, server.id) if server
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.query_server_assigned_addresses(oComputeConnect, _oServer, sQuery)
|
|
52
|
+
# CloudProcess used a simplified way to manage IPs.
|
|
53
|
+
# Following is the translation to get the public IPs for the server
|
|
54
|
+
|
|
55
|
+
result = []
|
|
56
|
+
addresses = oComputeConnect.addresses.all
|
|
57
|
+
addresses.each do | oElem |
|
|
58
|
+
is_found = true
|
|
59
|
+
sQuery.each do | key, value |
|
|
60
|
+
if !oElem.attributes.key?(key) || oElem.attributes[key] != value
|
|
61
|
+
is_found = false
|
|
62
|
+
break
|
|
63
|
+
end
|
|
85
64
|
end
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
65
|
+
result << oElem if is_found
|
|
66
|
+
end
|
|
67
|
+
result
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.server_assign_address(oComputeConnect, server)
|
|
71
|
+
while server.state != 'ACTIVE'
|
|
72
|
+
sleep(5)
|
|
73
|
+
server = oComputeConnect.servers.get(server.id)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
addresses = oComputeConnect.addresses.all
|
|
77
|
+
address = nil
|
|
78
|
+
# Search for an available IP
|
|
79
|
+
addresses.each do | oElem |
|
|
80
|
+
if oElem.fixed_ip.nil?
|
|
81
|
+
address = oElem
|
|
82
|
+
break
|
|
100
83
|
end
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
#
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if address.nil?
|
|
87
|
+
# Create a new public IP to add in the pool.
|
|
88
|
+
address = oComputeConnect.addresses.create
|
|
89
|
+
end
|
|
90
|
+
fail "No Public IP to assign to server '%s'", server.name if address.nil?
|
|
91
|
+
address.server = server # associate the server
|
|
92
|
+
address.reload
|
|
93
|
+
# This function needs to returns a list of object.
|
|
94
|
+
# This list must support the each function.
|
|
95
|
+
address
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def self.delete_server(oComputeConnect, server)
|
|
99
|
+
oComputeConnect.servers.get(server.id).destroy
|
|
100
|
+
end
|
|
113
101
|
end
|