lorj 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/students_1/students.rb +5 -6
- data/example/students_2/students.rb +4 -5
- data/example/students_3/students.rb +4 -5
- data/example/students_4/students.rb +4 -5
- data/example/students_5/students.rb +5 -5
- data/lib/core/core.rb +6 -1
- data/lib/core/core_controller.rb +1 -9
- data/lib/core/core_internal.rb +2 -1
- data/lib/core/core_model.rb +2 -10
- data/lib/core/core_object_data.rb +18 -0
- data/lib/core/core_object_params.rb +43 -4
- data/lib/core/core_process.rb +1 -9
- data/lib/core/core_process_setup.rb +32 -6
- data/lib/core/core_setup_ask.rb +41 -33
- data/lib/core/core_setup_encrypt.rb +29 -6
- data/lib/core/core_setup_init.rb +2 -2
- data/lib/core/definition.rb +33 -10
- data/lib/core/definition_internal.rb +10 -14
- data/lib/core/lorj_basedefinition.rb +16 -24
- data/lib/core/lorj_baseprocess.rb +113 -44
- data/lib/core/lorj_data.rb +2 -9
- data/lib/core/lorj_keypath.rb +5 -2
- data/lib/core_process/cloud/process/common.rb +4 -7
- data/lib/core_process/cloud/process/connection.rb +44 -45
- data/lib/core_process/cloud/process/external_network.rb +24 -28
- data/lib/core_process/cloud/process/flavor.rb +31 -34
- data/lib/core_process/cloud/process/images.rb +12 -15
- data/lib/core_process/cloud/process/internet_network.rb +13 -14
- data/lib/core_process/cloud/process/internet_server.rb +9 -10
- data/lib/core_process/cloud/process/keypairs.rb +34 -27
- data/lib/core_process/cloud/process/network.rb +21 -23
- data/lib/core_process/cloud/process/public_ip.rb +17 -18
- data/lib/core_process/cloud/process/router.rb +86 -92
- data/lib/core_process/cloud/process/rules.rb +30 -31
- data/lib/core_process/cloud/process/security_groups.rb +21 -22
- data/lib/core_process/cloud/process/server.rb +30 -31
- data/lib/core_process/cloud/process/server_log.rb +13 -14
- data/lib/core_process/cloud/process/subnetwork.rb +25 -40
- data/lib/logging.rb +4 -17
- data/lib/lorj/version.rb +1 -1
- data/lib/lorj.rb +2 -1
- data/lib/lorj_account.rb +137 -90
- data/lib/lorj_config.rb +13 -19
- data/lib/lorj_defaults.rb +46 -292
- data/lib/lorj_meta.rb +729 -0
- data/lib/prc.rb +119 -30
- data/lib/prc_base_config.rb +53 -47
- data/lib/prc_core_config.rb +837 -565
- data/lib/prc_section_config.rb +44 -16
- data/lib/providers/hpcloud/hpcloud.rb +1 -1
- data/lib/providers/openstack/openstack.rb +278 -21
- data/lib/providers/openstack/openstack_create.rb +205 -0
- data/lib/providers/openstack/openstack_delete.rb +28 -0
- data/lib/providers/openstack/openstack_get.rb +39 -0
- data/lib/providers/openstack/openstack_process.rb +26 -0
- data/lib/providers/openstack/openstack_query.rb +96 -0
- data/lib/providers/openstack/openstack_update.rb +35 -0
- data/lib/rh.rb +91 -6
- data/lorj-spec/defaults.yaml +18 -12
- data/lorj.gemspec +1 -0
- data/spec/01_hash_rh_spec.rb +41 -2
- data/spec/02_prc_base_config_spec.rb +1 -1
- data/spec/03_prc_section_config_spec.rb +1 -1
- data/spec/04_prc_core_config_spec.rb +148 -4
- data/spec/09_prc_spec.rb +104 -0
- data/spec/{00_lorj_log_spec.rb → 10_lorj_log_spec.rb} +23 -2
- data/spec/11_lorj_config_spec.rb +9 -27
- data/spec/12_lorj_account_spec.rb +36 -20
- data/spec/20_lorj_meta_spec.rb +271 -0
- data/spec/21_lorj_defaults_spec.rb +85 -0
- metadata +31 -4
@@ -16,6 +16,8 @@
|
|
16
16
|
|
17
17
|
# It requires Core objects to be defined + default ForjProcess functions.
|
18
18
|
|
19
|
+
# rubocop: disable Style/ClassAndModuleChildren
|
20
|
+
|
19
21
|
# External network process attached to a network
|
20
22
|
class CloudProcess
|
21
23
|
def forj_get_or_create_ext_net(sCloudObj, hParams)
|
@@ -38,7 +40,7 @@ class CloudProcess
|
|
38
40
|
external_network = forj_query_external_network(:network, {}, hParams)
|
39
41
|
if !external_network.empty?
|
40
42
|
router_obj[:gateway_network_id] = external_network[:id]
|
41
|
-
|
43
|
+
controller_update(:router, router_obj)
|
42
44
|
PrcLib.info("Router '%s' attached to the "\
|
43
45
|
"external network '%s'.",
|
44
46
|
router_name, external_network[:name])
|
@@ -58,37 +60,31 @@ class CloudProcess
|
|
58
60
|
PrcLib.state('Identifying External gateway')
|
59
61
|
begin
|
60
62
|
# Searching for external network
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
rescue => e
|
76
|
-
PrcLib.error("%s\n%s", e.message, e.backtrace.join("\n"))
|
63
|
+
query = sQuery.merge(:external => true)
|
64
|
+
info = {
|
65
|
+
:notfound => 'No external network found',
|
66
|
+
:checkmatch => 'Found 1 %s. Checking if it is an %s.',
|
67
|
+
:nomatch => 'No %s identified as %s match',
|
68
|
+
:found => "Found external %s '%s'.",
|
69
|
+
:more => 'Found several %s. Searching for the first one to be an %s.'
|
70
|
+
}
|
71
|
+
networks = query_single(:network, query, 'external network', info)
|
72
|
+
return Lorj::Data.new if networks.length == 0
|
73
|
+
networks[0]
|
74
|
+
rescue => e
|
75
|
+
PrcLib.error("%s\n%s", e.message, e.backtrace.join("\n"))
|
77
76
|
end
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
81
|
-
#
|
82
|
-
|
83
|
-
|
84
|
-
class BaseDefinition
|
85
|
-
define_obj(:external_network,
|
80
|
+
# Identify an external network thanks to the network router.
|
81
|
+
class Lorj::BaseDefinition
|
82
|
+
define_obj(:external_network,
|
86
83
|
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
:create_e => :forj_get_or_create_ext_net,
|
85
|
+
:query_e => :forj_query_external_network
|
86
|
+
)
|
90
87
|
|
91
|
-
|
92
|
-
|
93
|
-
end
|
88
|
+
obj_needs :CloudObject, :network_connection
|
89
|
+
obj_needs :CloudObject, :router
|
94
90
|
end
|
@@ -61,40 +61,37 @@ class CloudProcess
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
#
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
class BaseDefinition # rubocop: disable ClassAndModuleChildren
|
69
|
-
define_obj(:flavor,
|
64
|
+
# Flavor Object
|
65
|
+
# Identify flavor
|
66
|
+
class Lorj::BaseDefinition # rubocop: disable ClassAndModuleChildren
|
67
|
+
define_obj(:flavor,
|
70
68
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
69
|
+
:create_e => :forj_get_or_create_flavor,
|
70
|
+
:query_e => :forj_query_flavor
|
71
|
+
# :get_e => :forj_get_flavor,
|
72
|
+
# :update_e => :forj_update_flavor,
|
73
|
+
# :delete_e => :forj_delete_flavor
|
74
|
+
)
|
77
75
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end
|
76
|
+
obj_needs :CloudObject, :compute_connection
|
77
|
+
obj_needs :data, :flavor_name, :for => [:create_e]
|
78
|
+
# Cloud provider will need to map to one of those predefined flavors.
|
79
|
+
# limitation values may match exactly or at least ensure those limitation
|
80
|
+
# are under provider limitation
|
81
|
+
# ie, at least the CloudProcess limitation can less than the
|
82
|
+
# Cloud provider defines.
|
83
|
+
# CloudProcess EHD = 160, then Provider EHD = 200 is ok
|
84
|
+
# but Provider EHD = 150 is not ok.
|
85
|
+
predefine_data_value('tiny', :desc => 'VCU: 1, RAM:512M, HD:1G, '\
|
86
|
+
'EHD: 0G, Swap: 0G')
|
87
|
+
predefine_data_value('xsmall', :desc => 'VCU: 1, RAM:1G, HD:10G, '\
|
88
|
+
'EHD: 10G, Swap: 0G')
|
89
|
+
predefine_data_value('small', :desc => 'VCU: 2, RAM:2G, HD:30G, '\
|
90
|
+
'EHD: 10G, Swap: 0G')
|
91
|
+
predefine_data_value('medium', :desc => 'VCU: 2, RAM:4G, HD:30G, '\
|
92
|
+
'EHD: 50G, Swap: 0G')
|
93
|
+
predefine_data_value('large', :desc => 'VCU: 4, RAM:8G, HD:30G, '\
|
94
|
+
'EHD: 100G, Swap: 0G')
|
95
|
+
predefine_data_value('xlarge', :desc => 'VCU: 8, RAM:16G, HD:30G, '\
|
96
|
+
'EHD: 200G, Swap: 0G')
|
100
97
|
end
|
@@ -82,21 +82,18 @@ class CloudProcess
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
#
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
class BaseDefinition
|
90
|
-
define_obj(:image,
|
85
|
+
# ************************************ Image Object
|
86
|
+
# Identify image
|
87
|
+
class Lorj::BaseDefinition # rubocop: disable Style/ClassAndModuleChildren
|
88
|
+
define_obj(:image,
|
91
89
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
90
|
+
:create_e => :forj_get_or_create_image,
|
91
|
+
:query_e => :forj_query_image,
|
92
|
+
:get_e => :forj_get_image
|
93
|
+
# :update_e => :forj_update_image
|
94
|
+
# :delete_e => :forj_delete_image
|
95
|
+
)
|
98
96
|
|
99
|
-
|
100
|
-
|
101
|
-
end
|
97
|
+
obj_needs :CloudObject, :compute_connection
|
98
|
+
obj_needs :data, :image_name, :for => [:create_e]
|
102
99
|
end
|
@@ -16,19 +16,18 @@
|
|
16
16
|
|
17
17
|
# It requires Core objects to be defined + default ForjProcess functions.
|
18
18
|
|
19
|
-
#
|
20
|
-
module Lorj
|
21
|
-
# ************************************ Internet network Object
|
22
|
-
# Define Internet network
|
23
|
-
#
|
24
|
-
# This object contains the logic to ensure the router's network has a gateway
|
25
|
-
# to the external network (internet)
|
26
|
-
# is capable to connect to internet
|
27
|
-
# And to create this connection if possible.
|
28
|
-
class BaseDefinition # rubocop: disable ClassAndModuleChildren
|
29
|
-
define_obj(:internet_network, :nohandler => true)
|
19
|
+
# rubocop: disable Style/ClassAndModuleChildren
|
30
20
|
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
# Internet network Object
|
22
|
+
# Define Internet network
|
23
|
+
#
|
24
|
+
# This object contains the logic to ensure the router's network has a gateway
|
25
|
+
# to the external network (internet)
|
26
|
+
# is capable to connect to internet
|
27
|
+
# And to create this connection if possible.
|
28
|
+
class Lorj::BaseDefinition # rubocop: disable ClassAndModuleChildren
|
29
|
+
define_obj(:internet_network, :nohandler => true)
|
30
|
+
|
31
|
+
obj_needs :CloudObject, :external_network # External network to connect if
|
32
|
+
# needed.
|
34
33
|
end
|
@@ -16,15 +16,14 @@
|
|
16
16
|
|
17
17
|
# It requires Core objects to be defined + default ForjProcess functions.
|
18
18
|
|
19
|
-
#
|
20
|
-
module Lorj
|
21
|
-
# ************************************ Internet SERVER Object
|
22
|
-
# internet server is a server connected to the internet network.
|
23
|
-
class BaseDefinition
|
24
|
-
define_obj(:internet_server, :nohandler => true)
|
19
|
+
# rubocop: disable Style/ClassAndModuleChildren
|
25
20
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
# Internet SERVER Object
|
22
|
+
# internet server is a server connected to the internet network.
|
23
|
+
class Lorj::BaseDefinition
|
24
|
+
define_obj(:internet_server, :nohandler => true)
|
25
|
+
|
26
|
+
obj_needs :CloudObject, :internet_network
|
27
|
+
obj_needs :CloudObject, :server
|
28
|
+
obj_needs :CloudObject, :public_ip
|
30
29
|
end
|
@@ -16,6 +16,8 @@
|
|
16
16
|
|
17
17
|
# It requires Core objects to be defined + default ForjProcess functions.
|
18
18
|
|
19
|
+
# rubocop: disable Style/ClassAndModuleChildren
|
20
|
+
|
19
21
|
# Keypair management
|
20
22
|
class CloudProcess
|
21
23
|
# KeyPair Create Process Handler
|
@@ -59,15 +61,16 @@ class CloudProcess
|
|
59
61
|
{ :name => keypair_name }, hParams)
|
60
62
|
|
61
63
|
if keypairs.length == 0
|
62
|
-
keypair = keypair_import(
|
64
|
+
keypair = keypair_import(hParams, loc_kpair)
|
63
65
|
else
|
64
66
|
keypair = keypairs[0]
|
65
67
|
keypair[:coherent] = coherent_keypair?(loc_kpair, keypair)
|
66
68
|
# Adding information about key files.
|
67
69
|
end
|
68
70
|
if keypair[:coherent]
|
69
|
-
keypair[:
|
70
|
-
keypair[:
|
71
|
+
keypair[:private_key_name] = loc_kpair[:private_key_name]
|
72
|
+
keypair[:public_key_name] = loc_kpair[:public_key_name]
|
73
|
+
keypair[:keypair_path] = loc_kpair[:keypair_path]
|
71
74
|
end
|
72
75
|
keypair
|
73
76
|
end
|
@@ -87,20 +90,27 @@ end
|
|
87
90
|
|
88
91
|
# Keypair management: Internal process functions
|
89
92
|
class CloudProcess
|
90
|
-
def keypair_import(
|
93
|
+
def keypair_import(hParams, loc_kpair)
|
91
94
|
PrcLib.fatal(1, "Unable to import keypair '%s'. "\
|
92
95
|
'Public key file is not found. '\
|
93
96
|
"Please run 'forj setup %s'",
|
94
|
-
keypair_name,
|
97
|
+
hParams[:keypair_name],
|
95
98
|
config[:account_name]) unless loc_kpair[:public_key_exist?]
|
99
|
+
public_key_file = File.join(loc_kpair[:keypair_path],
|
100
|
+
loc_kpair[:public_key_name])
|
101
|
+
|
96
102
|
begin
|
97
|
-
config[:public_key] = File.read(
|
103
|
+
config[:public_key] = File.read(public_key_file)
|
98
104
|
rescue => e
|
99
105
|
PrcLib.fatal(1, "Unable to import keypair '%s'. '%s' is "\
|
100
|
-
"unreadable.\n%s", keypair_name,
|
101
|
-
loc_kpair[:public_key_file],
|
106
|
+
"unreadable.\n%s", hParams[:keypair_name],
|
107
|
+
loc_kpair[:public_key_file],
|
108
|
+
e.message)
|
102
109
|
end
|
103
|
-
keypair = create_keypair(
|
110
|
+
keypair = create_keypair(:keypairs, hParams)
|
111
|
+
|
112
|
+
return nil if keypair.nil?
|
113
|
+
|
104
114
|
if !loc_kpair[:private_key_exist?]
|
105
115
|
keypair[:coherent] = false
|
106
116
|
else
|
@@ -252,26 +262,23 @@ class CloudProcess
|
|
252
262
|
end
|
253
263
|
end
|
254
264
|
|
255
|
-
#
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
class BaseDefinition
|
260
|
-
define_obj(:keypairs,
|
265
|
+
# ************************************ keypairs Object
|
266
|
+
# Identify keypairs
|
267
|
+
class Lorj::BaseDefinition
|
268
|
+
define_obj(:keypairs,
|
261
269
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
270
|
+
:create_e => :forj_get_or_create_keypair,
|
271
|
+
:query_e => :forj_query_keypair,
|
272
|
+
:get_e => :forj_get_keypair
|
273
|
+
# :delete_e => :forj_delete_keypair
|
274
|
+
)
|
267
275
|
|
268
|
-
|
269
|
-
|
270
|
-
|
276
|
+
obj_needs :CloudObject, :compute_connection
|
277
|
+
obj_needs :data, :keypair_name, :for => [:create_e]
|
278
|
+
obj_needs :data, :keypair_path, :for => [:create_e]
|
271
279
|
|
272
|
-
|
273
|
-
|
280
|
+
obj_needs_optional
|
281
|
+
obj_needs :data, :public_key, :for => [:create_e]
|
274
282
|
|
275
|
-
|
276
|
-
end
|
283
|
+
def_attribute :public_key
|
277
284
|
end
|
@@ -16,6 +16,8 @@
|
|
16
16
|
|
17
17
|
# It requires Core objects to be defined + default ForjProcess functions.
|
18
18
|
|
19
|
+
# rubocop: disable Style/ClassAndModuleChildren
|
20
|
+
|
19
21
|
# Network Management
|
20
22
|
class CloudProcess
|
21
23
|
# Process Create handler
|
@@ -31,13 +33,12 @@ class CloudProcess
|
|
31
33
|
|
32
34
|
# Attaching if missing the subnet.
|
33
35
|
# Creates an object subnet, attached to the network.
|
36
|
+
params = {}
|
34
37
|
unless hParams[:subnetwork_name]
|
35
|
-
|
36
|
-
config[:subnetwork_name] = hParams[:subnetwork_name]
|
38
|
+
params[:subnetwork_name] = 'sub-' + hParams[:network_name]
|
37
39
|
end
|
38
40
|
|
39
|
-
|
40
|
-
process_create(:subnetwork)
|
41
|
+
process_create(:subnetwork, params)
|
41
42
|
|
42
43
|
network
|
43
44
|
end
|
@@ -56,25 +57,23 @@ class CloudProcess
|
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
|
-
#
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
obj_needs :CloudObject, :network_connection
|
71
|
-
obj_needs :data, :network_name, :for => [:create_e]
|
60
|
+
# Network Object
|
61
|
+
# Identify the network
|
62
|
+
class Lorj::BaseDefinition
|
63
|
+
define_obj(:network,
|
64
|
+
:create_e => :forj_get_or_create_network,
|
65
|
+
:query_e => :controller_query,
|
66
|
+
:get_e => :forj_get_network,
|
67
|
+
:delete_e => :forj_delete_network
|
68
|
+
)
|
69
|
+
obj_needs :CloudObject, :network_connection
|
70
|
+
obj_needs :data, :network_name, :for => [:create_e]
|
72
71
|
|
73
|
-
|
74
|
-
|
72
|
+
obj_needs_optional
|
73
|
+
obj_needs :data, :subnetwork_name, :for => [:create_e]
|
75
74
|
|
76
|
-
|
77
|
-
|
75
|
+
# Any attribute are queriable
|
76
|
+
def_attribute :external # true if network is external or not.
|
78
77
|
end
|
79
78
|
|
80
79
|
# Network Process internal functions #
|
@@ -100,8 +99,7 @@ class CloudProcess
|
|
100
99
|
# nil or Provider Object
|
101
100
|
def find_network(sCloudObj, hParams)
|
102
101
|
query = { :name => hParams[:network_name] }
|
103
|
-
|
104
|
-
# query_single(sCloudObj, list, query, hParams[:network_name])
|
102
|
+
|
105
103
|
query_single(sCloudObj, query, hParams[:network_name])
|
106
104
|
rescue => e
|
107
105
|
PrcLib.error("%s\n%s", e.message, e.backtrace.join("\n"))
|
@@ -16,6 +16,8 @@
|
|
16
16
|
|
17
17
|
# It requires Core objects to be defined + default ForjProcess functions.
|
18
18
|
|
19
|
+
# rubocop: disable Style/ClassAndModuleChildren
|
20
|
+
|
19
21
|
# Addresses management
|
20
22
|
class CloudProcess
|
21
23
|
# Process Handler functions
|
@@ -62,26 +64,23 @@ class CloudProcess
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
|
-
#
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
# :delete_e => :forj_delete_address
|
76
|
-
)
|
67
|
+
# SERVER Addresses Object
|
68
|
+
# Object representing the list of IP addresses attached to a server.
|
69
|
+
class Lorj::BaseDefinition
|
70
|
+
define_obj(:public_ip,
|
71
|
+
:create_e => :forj_get_or_assign_public_address,
|
72
|
+
:query_e => :forj_query_public_address
|
73
|
+
# :get_e => :forj_get_address
|
74
|
+
# :update_e => :forj_update_address
|
75
|
+
# :delete_e => :forj_delete_address
|
76
|
+
)
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
obj_needs :CloudObject, :compute_connection
|
79
|
+
obj_needs :CloudObject, :server
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
81
|
+
def_attribute :server_id
|
82
|
+
def_attribute :public_ip
|
83
|
+
undefine_attribute :name # No name to extract
|
85
84
|
end
|
86
85
|
|
87
86
|
# Internal Process function
|