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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +46 -0
  4. data/Gemfile +15 -15
  5. data/README.md +22 -17
  6. data/Rakefile +12 -2
  7. data/bin/cloud_test.rb +13 -65
  8. data/example/students_1/process/students.rb +39 -0
  9. data/example/students_1/students.rb +22 -5
  10. data/example/students_2/process/students.rb +48 -0
  11. data/example/students_2/students.rb +39 -16
  12. data/example/students_3/controller/yaml_students.rb +50 -43
  13. data/example/students_3/controller/yaml_students_controller.rb +100 -87
  14. data/example/students_3/process/students.rb +161 -97
  15. data/example/students_3/students.rb +85 -56
  16. data/example/yaml_students/students.rb +40 -40
  17. data/example/yaml_students/yaml_students.rb +103 -90
  18. data/lib/core/core.rb +356 -696
  19. data/lib/core/core_controller.rb +227 -0
  20. data/lib/core/core_internal.rb +339 -0
  21. data/lib/core/core_model.rb +328 -0
  22. data/lib/core/core_object_data.rb +330 -0
  23. data/lib/core/core_object_params.rb +230 -0
  24. data/lib/core/core_process.rb +391 -0
  25. data/lib/core/core_process_setup.rb +353 -0
  26. data/lib/core/core_setup_ask.rb +241 -0
  27. data/lib/core/core_setup_encrypt.rb +146 -0
  28. data/lib/core/core_setup_init.rb +229 -0
  29. data/lib/core/core_setup_list.rb +160 -0
  30. data/lib/core/definition.rb +647 -469
  31. data/lib/core/definition_internal.rb +264 -308
  32. data/lib/core/lorj_basecontroller.rb +95 -0
  33. data/lib/core/lorj_basedefinition.rb +307 -0
  34. data/lib/core/lorj_baseprocess.rb +265 -0
  35. data/lib/core/lorj_data.rb +583 -0
  36. data/lib/core/lorj_keypath.rb +119 -0
  37. data/lib/core_process/cloud/process/common.rb +63 -0
  38. data/lib/core_process/cloud/process/connection.rb +93 -0
  39. data/lib/core_process/cloud/process/external_network.rb +94 -0
  40. data/lib/core_process/cloud/process/flavor.rb +99 -0
  41. data/lib/core_process/cloud/process/images.rb +87 -0
  42. data/lib/core_process/cloud/process/internet_network.rb +34 -0
  43. data/lib/core_process/cloud/process/internet_server.rb +30 -0
  44. data/lib/core_process/cloud/process/keypairs.rb +276 -0
  45. data/lib/core_process/cloud/process/network.rb +108 -0
  46. data/lib/core_process/cloud/process/public_ip.rb +100 -0
  47. data/lib/core_process/cloud/process/router.rb +260 -0
  48. data/lib/core_process/cloud/process/rules.rb +120 -0
  49. data/lib/core_process/cloud/process/security_groups.rb +121 -0
  50. data/lib/core_process/cloud/process/server.rb +127 -0
  51. data/lib/core_process/cloud/process/server_log.rb +35 -0
  52. data/lib/core_process/cloud/process/subnetwork.rb +108 -0
  53. data/lib/core_process/cloud_process.rb +30 -0
  54. data/lib/logging.rb +298 -0
  55. data/lib/lorj/version.rb +18 -1
  56. data/lib/lorj.rb +58 -18
  57. data/lib/lorj_account.rb +556 -0
  58. data/lib/lorj_config.rb +468 -0
  59. data/lib/lorj_defaults.rb +278 -0
  60. data/lib/prc.rb +136 -104
  61. data/lib/prc_base_config.rb +285 -0
  62. data/lib/prc_core_config.rb +878 -0
  63. data/lib/prc_section_config.rb +57 -0
  64. data/lib/providers/hpcloud/compute.rb +81 -93
  65. data/lib/providers/hpcloud/hpcloud.rb +462 -0
  66. data/lib/providers/hpcloud/network.rb +96 -98
  67. data/lib/providers/hpcloud/security_groups.rb +41 -40
  68. data/lib/providers/mock/mock.rb +144 -0
  69. data/lib/providers/openstack/openstack.rb +45 -0
  70. data/lib/providers/templates/compute.rb +21 -23
  71. data/lib/providers/templates/mycloud.rb +72 -0
  72. data/lib/providers/templates/network.rb +11 -12
  73. data/lib/rh.rb +339 -0
  74. data/lorj-spec/defaults.yaml +4 -0
  75. data/lorj.gemspec +6 -0
  76. data/spec/00_lorj_log_spec.rb +53 -0
  77. data/spec/01_hash_rh_spec.rb +243 -0
  78. data/spec/02_prc_base_config_spec.rb +216 -0
  79. data/spec/04_prc_core_config_spec.rb +83 -0
  80. data/spec/11_lorj_config_spec.rb +263 -0
  81. data/spec/12_lorj_account_spec.rb +181 -0
  82. metadata +76 -28
  83. data/Gemfile.lock +0 -37
  84. data/example/students_1/process/Students.rb +0 -20
  85. data/example/students_2/process/Students.rb +0 -27
  86. data/example/students_4/controller/yaml_students.rb +0 -82
  87. data/example/students_4/controller/yaml_students_controller.rb +0 -141
  88. data/example/students_4/process/students.rb +0 -112
  89. data/example/students_4/students.rb +0 -103
  90. data/lib/core/lorj-basecontroller.rb +0 -90
  91. data/lib/core/lorj-basedefinition.rb +0 -1139
  92. data/lib/core/lorj-baseprocess.rb +0 -236
  93. data/lib/core/lorj-data.rb +0 -567
  94. data/lib/core/lorj-keypath.rb +0 -115
  95. data/lib/core_process/CloudProcess.rb +0 -337
  96. data/lib/core_process/global_process.rb +0 -502
  97. data/lib/core_process/network_process.rb +0 -605
  98. data/lib/prc-account.rb +0 -339
  99. data/lib/prc-config.rb +0 -1030
  100. data/lib/prc-logging.rb +0 -261
  101. data/lib/providers/hpcloud/Hpcloud.rb +0 -426
  102. data/lib/providers/mock/Mock.rb +0 -141
  103. data/lib/providers/openstack/Openstack.rb +0 -47
  104. data/lib/providers/templates/core.rb +0 -61
  105. data/spec/forj-account_spec.rb +0 -75
  106. 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
- def HPCompute.get_server(oComputeConnect, sId)
19
- oComputeConnect.servers.get(sId)
20
- end
21
-
22
- def HPCompute.query_addresses(oComputeConnect, sQuery)
23
- oComputeConnect.addresses.all(sQuery)
24
- end
25
-
26
- def HPCompute.query_server(oComputeConnect, sQuery)
27
- oComputeConnect.servers.all(sQuery)
28
- end
29
-
30
- def HPCompute.query_image(oComputeConnect, sQuery)
31
- # HP Fog query is exact matching. No way to filter with a Regexp
32
- # Testing it and filtering it.
33
- # TODO: Be able to support Regexp in queries then extract all and filter.
34
- oComputeConnect.images.all(sQuery)
35
- end
36
-
37
- def HPCompute.query_flavor(oComputeConnect, sQuery)
38
- oComputeConnect.flavors.all(sQuery)
39
- end
40
-
41
- def HPCompute.create_server(oComputeConnect,
42
- sServerName, oSecurity_groups,
43
- oImage, oNetwork,
44
- oFlavor, oKeypairs,
45
- oUser_data, oMeta_data)
46
-
47
- options = {
48
- :name => sServerName,
49
- :flavor_id => oFlavor.id,
50
- :image_id => oImage.id,
51
- :key_name => oKeypairs.name,
52
- :security_groups => [oSecurity_groups.name],
53
- :networks => [oNetwork.id]
54
- }
55
- options[:user_data_encoded] = Base64.strict_encode64(oUser_data) if oUser_data
56
- options[:metadata] = oMeta_data if oMeta_data
57
- server = oComputeConnect.servers.create(options)
58
- HPCompute.get_server(oComputeConnect, server.id ) if server
59
- end
60
-
61
- def HPCompute.query_server_assigned_addresses(oComputeConnect, oServer, sQuery)
62
- # CloudProcess used a simplified way to manage IPs.
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
- oAddresses = oComputeConnect.addresses.all()
88
- oAddress = nil
89
- # Search for an available IP
90
- oAddresses.each { | oElem |
91
- if oElem.fixed_ip.nil?
92
- oAddress = oElem
93
- break
94
- end
95
- }
96
-
97
- if oAddress.nil?
98
- # Create a new public IP to add in the pool.
99
- oAddress = oComputeConnect.addresses.create
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
- raise "No Public IP to assign to server '%s'" % oServer.name if oAddress.nil?
102
- oAddress.server = oServer # associate the server
103
- oAddress.reload
104
- # This function needs to returns a list of object.
105
- # This list must support the each function.
106
- oAddress
107
- end
108
-
109
- def HPCompute.delete_server(oComputeConnect, oServer)
110
- oComputeConnect.servers.get(oServer.id).destroy
111
- end
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