lorj 1.0.3 → 1.0.4
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/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
@@ -15,6 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
# It requires Core objects to be defined + default ForjProcess functions.
|
18
|
+
|
19
|
+
# rubocop: disable Style/ClassAndModuleChildren
|
20
|
+
|
18
21
|
# ---------------------------------------------------------------------------
|
19
22
|
# Router management
|
20
23
|
# ---------------------------------------------------------------------------
|
@@ -23,75 +26,72 @@ class CloudProcess
|
|
23
26
|
def forj_get_or_create_router(_sCloudObj, hParams)
|
24
27
|
sub_net_obj = hParams[:subnetwork]
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
if hParams[:router_name].nil?
|
30
|
+
router_name = format('router-%s', hParams[:network, :name])
|
31
|
+
else
|
32
|
+
router_name = hParams[:router_name]
|
29
33
|
end
|
30
34
|
|
31
|
-
router_name = hParams[:router_name]
|
32
35
|
router_port = get_router_interface_attached(:port, hParams)
|
33
36
|
|
34
|
-
if
|
37
|
+
if router_port.length == 0
|
35
38
|
# Trying to get router
|
36
39
|
router = get_router(router_name)
|
37
|
-
router = create_router(router_name)
|
40
|
+
router = create_router(router_name) if router.empty?
|
38
41
|
create_router_interface(sub_net_obj, router) if router
|
39
42
|
else
|
40
|
-
router = query_router_from_port(router_port, hParams)
|
43
|
+
router = query_router_from_port(router_port[0], hParams)
|
41
44
|
end
|
42
45
|
router
|
43
46
|
end
|
44
47
|
end
|
45
48
|
|
46
|
-
#
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
def_attribute :gateway_network_id
|
66
|
-
end
|
49
|
+
# Router Object
|
50
|
+
# Identify the router of a network.
|
51
|
+
class Lorj::BaseDefinition
|
52
|
+
define_obj(:router,
|
53
|
+
|
54
|
+
:create_e => :forj_get_or_create_router,
|
55
|
+
# :query_e => :forj_query_router,
|
56
|
+
# :get_e => :forj_get_router,
|
57
|
+
:update_e => :controller_update
|
58
|
+
# :delete_e => :forj_delete_router
|
59
|
+
)
|
60
|
+
obj_needs :CloudObject, :network_connection
|
61
|
+
obj_needs :CloudObject, :network, :for => [:create_e]
|
62
|
+
obj_needs :CloudObject, :subnetwork, :for => [:create_e]
|
63
|
+
obj_needs_optional
|
64
|
+
obj_needs :data, :router_name, :for => [:create_e]
|
65
|
+
|
66
|
+
def_attribute :gateway_network_id
|
67
|
+
end
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
# Port Object
|
70
|
+
# Identify port attached to network
|
71
|
+
class Lorj::BaseDefinition
|
72
|
+
define_obj :port, :nohandler => true
|
72
73
|
|
73
|
-
|
74
|
-
|
74
|
+
obj_needs :CloudObject, :network_connection
|
75
|
+
def_attribute :device_id
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
def_attribute :network_id
|
78
|
+
def_attribute :device_owner
|
79
|
+
end
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
# Router interface Object
|
82
|
+
# Identify interface attached to a router
|
83
|
+
# This object will probably be moved to controller task
|
84
|
+
# To keep the network model more generic.
|
85
|
+
class Lorj::BaseDefinition
|
86
|
+
# No process handler defined. Just Controller object
|
87
|
+
define_obj :router_interface, :nohandler => true
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
obj_needs :CloudObject, :network_connection
|
90
|
+
obj_needs :CloudObject, :router, :for => [:create_e]
|
91
|
+
obj_needs :CloudObject, :subnetwork, :for => [:create_e]
|
91
92
|
|
92
|
-
|
93
|
-
|
94
|
-
end
|
93
|
+
undefine_attribute :name
|
94
|
+
undefine_attribute :id
|
95
95
|
end
|
96
96
|
|
97
97
|
# Router Process internal functions
|
@@ -99,16 +99,12 @@ class CloudProcess
|
|
99
99
|
def get_router(name)
|
100
100
|
PrcLib.state("Searching for router '%s'", name)
|
101
101
|
begin
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
nil
|
109
|
-
end
|
110
|
-
rescue => e
|
111
|
-
PrcLib.error("%s\n%s", e.message, e.backtrace.join("\n"))
|
102
|
+
query = { :name => name }
|
103
|
+
routers = query_single(:router, query, name)
|
104
|
+
return Lorj::Data.new if routers.length == 0
|
105
|
+
register(routers[0])
|
106
|
+
rescue => e
|
107
|
+
PrcLib.error("%s\n%s", e.message, e.backtrace.join("\n"))
|
112
108
|
end
|
113
109
|
end
|
114
110
|
|
@@ -124,7 +120,7 @@ class CloudProcess
|
|
124
120
|
router_name)
|
125
121
|
end
|
126
122
|
|
127
|
-
router = controller_create(:router)
|
123
|
+
router = controller_create(:router, :router_name => router_name)
|
128
124
|
if oExternalNetwork
|
129
125
|
PrcLib.info("Router '%s' created and attached to the external "\
|
130
126
|
"Network '%s'.", router_name, ext_net)
|
@@ -133,8 +129,8 @@ class CloudProcess
|
|
133
129
|
router_name)
|
134
130
|
end
|
135
131
|
rescue => e
|
136
|
-
|
137
|
-
|
132
|
+
PrcLib.error "Unable to create '%s' router\n%s\n%s", router_name,
|
133
|
+
e.message, e.backtrace.join("\n")
|
138
134
|
end
|
139
135
|
router
|
140
136
|
end
|
@@ -150,20 +146,20 @@ class CloudProcess
|
|
150
146
|
end
|
151
147
|
end
|
152
148
|
|
153
|
-
def query_router_from_port(router_port,
|
149
|
+
def query_router_from_port(router_port, _hParams)
|
154
150
|
query = { :id => router_port[:device_id] }
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
end
|
151
|
+
info = {
|
152
|
+
:notfound => 'No %s for port ID %s found',
|
153
|
+
:checkmatch => 'Found 1 %s. Checking exact match for port ID %s.',
|
154
|
+
:nomatch => 'No %s for port ID %s match',
|
155
|
+
:found => "Found %s '%s' from port ID #{router_port[:device_id]}.",
|
156
|
+
:more => 'Found several %s. Searching for port ID %s.'
|
157
|
+
}
|
158
|
+
routers = query_single(:router, query, router_port[:device_id], info)
|
159
|
+
return Lorj::Data.new if routers.length == 0
|
160
|
+
register(routers[0])
|
166
161
|
end
|
162
|
+
|
167
163
|
# TODO: Move router interface management to hpcloud controller.
|
168
164
|
# Router interface to connect to the network
|
169
165
|
def create_router_interface(oSubnet, router_obj)
|
@@ -193,28 +189,26 @@ class CloudProcess
|
|
193
189
|
end
|
194
190
|
|
195
191
|
def get_router_interface_attached(sCloudObj, hParams)
|
196
|
-
|
197
|
-
|
192
|
+
name = hParams[:network, :name]
|
193
|
+
PrcLib.state("Searching for router port attached to the network '%s'", name)
|
198
194
|
begin
|
199
195
|
# Searching for router port attached
|
200
196
|
#################
|
201
197
|
query = { :network_id => hParams[
|
202
198
|
:network, :id],
|
203
199
|
:device_owner => 'network:router_interface' }
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
rescue => e
|
217
|
-
PrcLib.error("%s\n%s", e.message, e.backtrace.join("\n"))
|
200
|
+
info = {
|
201
|
+
:notfound => "No router %s for network '%s' found",
|
202
|
+
:checkmatch => 'Found 1 router %s. '\
|
203
|
+
"Checking exact match for network '%s'.",
|
204
|
+
:nomatch => "No router %s for network '%s' match",
|
205
|
+
:found => "Found router %s ID %s attached to network '#{name}'.",
|
206
|
+
:more => "Found several router %s. Searching for network '%s'.",
|
207
|
+
:items => [:id]
|
208
|
+
}
|
209
|
+
query_single(sCloudObj, query, name, info)
|
210
|
+
rescue => e
|
211
|
+
PrcLib.error("%s\n%s", e.message, e.backtrace.join("\n"))
|
218
212
|
end
|
219
213
|
end
|
220
214
|
|
@@ -244,7 +238,7 @@ class CloudProcess
|
|
244
238
|
case networks.length
|
245
239
|
when 0
|
246
240
|
PrcLib.info('No external network')
|
247
|
-
|
241
|
+
Lorj::Data.new
|
248
242
|
when 1
|
249
243
|
PrcLib.info("Found external network '%s'.", networks[0, :name])
|
250
244
|
networks[0]
|
@@ -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
|
# SecurityGroups rules management
|
20
22
|
class CloudProcess
|
21
23
|
# Process Delete handler
|
@@ -58,7 +60,6 @@ class CloudProcess
|
|
58
60
|
:addr_map => hParams[:addr_map],
|
59
61
|
:sg_id => hParams[:sg_id]
|
60
62
|
}
|
61
|
-
|
62
63
|
rules = forj_query_rule(sCloudObj, query, hParams)
|
63
64
|
if rules.length == 0
|
64
65
|
create_rule(sCloudObj, hParams)
|
@@ -68,35 +69,32 @@ class CloudProcess
|
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
71
|
-
#
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
class BaseDefinition
|
76
|
-
define_obj(:rule,
|
72
|
+
# Security group rules Object
|
73
|
+
# Identify Rules attached to the security group
|
74
|
+
class Lorj::BaseDefinition
|
75
|
+
define_obj(:rule,
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
:create_e => :forj_get_or_create_rule,
|
78
|
+
:query_e => :forj_query_rule
|
79
|
+
# :delete_e => :forj_delete_rule
|
80
|
+
)
|
82
81
|
|
83
|
-
|
82
|
+
undefine_attribute :name # Do not return any predefined name attribute
|
84
83
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
obj_needs :CloudObject, :network_connection
|
85
|
+
obj_needs :CloudObject, :security_groups, :for => [:create_e]
|
86
|
+
obj_needs :data, :sg_id, :for => [:create_e],
|
87
|
+
:extract_from => [:security_groups,
|
88
|
+
:attrs, :id]
|
90
89
|
|
91
|
-
|
92
|
-
|
93
|
-
|
90
|
+
obj_needs :data, :dir, :for => [:create_e]
|
91
|
+
predefine_data_value :IN, :desc => 'Input NAT/firewall rule map type'
|
92
|
+
predefine_data_value :OUT, :desc => 'Output NAT/firewall rule map type'
|
94
93
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end
|
94
|
+
obj_needs :data, :proto, :for => [:create_e]
|
95
|
+
obj_needs :data, :port_min, :for => [:create_e]
|
96
|
+
obj_needs :data, :port_max, :for => [:create_e]
|
97
|
+
obj_needs :data, :addr_map, :for => [:create_e]
|
100
98
|
end
|
101
99
|
|
102
100
|
# SecurityGroups rules management
|
@@ -104,17 +102,18 @@ class CloudProcess
|
|
104
102
|
# Rules internal #
|
105
103
|
#----------------#
|
106
104
|
def create_rule(sCloudObj, hParams)
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
105
|
+
rule_msg = format('%s %s:%s - %s to %s',
|
106
|
+
hParams[:dir], hParams[:rule_proto],
|
107
|
+
hParams[:port_min], hParams[:port_max],
|
108
|
+
hParams[:addr_map])
|
109
|
+
PrcLib.state("Creating rule '%s'", rule_msg)
|
111
110
|
ssl_error_obj = SSLErrorMgt.new
|
112
111
|
begin
|
113
112
|
rule = controller_create(sCloudObj)
|
114
|
-
PrcLib.info("Rule '%s' created.",
|
113
|
+
PrcLib.info("Rule '%s' created.", rule_msg)
|
115
114
|
rescue StandardError => e
|
116
115
|
retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
|
117
|
-
PrcLib.error 'error creating the rule
|
116
|
+
PrcLib.error 'error creating the rule "%s"', rule_msg
|
118
117
|
end
|
119
118
|
rule
|
120
119
|
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
|
# SecurityGroups management
|
20
22
|
class CloudProcess
|
21
23
|
# Process Create handler
|
@@ -42,14 +44,15 @@ class CloudProcess
|
|
42
44
|
portmax = (port_found_match[3]) ? (port_found_match[3]) : (portmin)
|
43
45
|
# Need to set runtime data to get or if missing
|
44
46
|
# create the required rule.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
params = {}
|
48
|
+
params[:dir] = :IN
|
49
|
+
params[:proto] = 'tcp'
|
50
|
+
params[:port_min] = portmin.to_i
|
51
|
+
params[:port_max] = portmax.to_i
|
52
|
+
params[:addr_map] = '0.0.0.0/0'
|
50
53
|
|
51
54
|
# object.Create(:rule)
|
52
|
-
process_create(:rule)
|
55
|
+
process_create(:rule, params)
|
53
56
|
end
|
54
57
|
end
|
55
58
|
security_group
|
@@ -87,23 +90,19 @@ class CloudProcess
|
|
87
90
|
end
|
88
91
|
end
|
89
92
|
|
90
|
-
#
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
:query_e => :forj_query_sg,
|
99
|
-
:delete_e => :forj_delete_sg
|
100
|
-
)
|
93
|
+
# ************************************ Security groups Object
|
94
|
+
# Identify security_groups
|
95
|
+
class Lorj::BaseDefinition
|
96
|
+
define_obj(:security_groups,
|
97
|
+
:create_e => :forj_get_or_create_sg,
|
98
|
+
:query_e => :forj_query_sg,
|
99
|
+
:delete_e => :forj_delete_sg
|
100
|
+
)
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
102
|
+
obj_needs :CloudObject, :network_connection
|
103
|
+
obj_needs :data, :security_group, :for => [:create_e]
|
104
|
+
obj_needs_optional
|
105
|
+
obj_needs :data, :sg_desc, :for => [:create_e]
|
107
106
|
end
|
108
107
|
|
109
108
|
# SecurityGroups Process internal functions #
|
@@ -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
|
# ---------------------------------------------------------------------------
|
20
22
|
# Server management
|
21
23
|
# ---------------------------------------------------------------------------
|
@@ -62,42 +64,39 @@ class CloudProcess
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
|
-
#
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
class BaseDefinition
|
70
|
-
define_obj(:server,
|
67
|
+
# SERVER Object
|
68
|
+
# Identify the server to use/build on the network/...
|
69
|
+
class Lorj::BaseDefinition
|
70
|
+
define_obj(:server,
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
:create_e => :forj_get_or_create_server,
|
73
|
+
:query_e => :forj_query_server,
|
74
|
+
:get_e => :forj_get_server,
|
75
|
+
# :update_e => :forj_update_server,
|
76
|
+
:delete_e => :forj_delete_server
|
77
|
+
)
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
obj_needs :CloudObject, :compute_connection
|
80
|
+
obj_needs :CloudObject, :flavor, :for => [:create_e]
|
81
|
+
obj_needs :CloudObject, :network, :for => [:create_e]
|
82
|
+
obj_needs :CloudObject, :security_groups, :for => [:create_e]
|
83
|
+
obj_needs :CloudObject, :keypairs, :for => [:create_e]
|
84
|
+
obj_needs :CloudObject, :image, :for => [:create_e]
|
85
|
+
obj_needs :data, :server_name, :for => [:create_e]
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
obj_needs_optional
|
88
|
+
obj_needs :data, :user_data, :for => [:create_e]
|
89
|
+
obj_needs :data, :meta_data, :for => [:create_e]
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
91
|
+
def_attribute :status
|
92
|
+
predefine_data_value :create, :desc => 'Server is creating.'
|
93
|
+
predefine_data_value :boot, :desc => 'Server is booting.'
|
94
|
+
predefine_data_value :active, :desc => 'Server is started.'
|
95
|
+
def_attribute :private_ip_address
|
96
|
+
def_attribute :public_ip_address
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
end
|
98
|
+
def_attribute :image_id
|
99
|
+
def_attribute :key_name
|
101
100
|
end
|
102
101
|
|
103
102
|
# Internal Process function
|
@@ -16,20 +16,19 @@
|
|
16
16
|
|
17
17
|
# It requires Core objects to be defined + default ForjProcess functions.
|
18
18
|
|
19
|
-
#
|
20
|
-
module Lorj
|
21
|
-
# ************************************ SERVER Console Object
|
22
|
-
# Object representing the console log attached to a server
|
23
|
-
class BaseDefinition
|
24
|
-
define_obj(:server_log,
|
19
|
+
# rubocop: disable Style/ClassAndModuleChildren
|
25
20
|
|
26
|
-
|
27
|
-
|
21
|
+
# SERVER Console Object
|
22
|
+
# Object representing the console log attached to a server
|
23
|
+
class Lorj::BaseDefinition
|
24
|
+
define_obj(:server_log,
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
:get_e => :forj_get_server_log
|
27
|
+
)
|
28
|
+
|
29
|
+
obj_needs :CloudObject, :server
|
30
|
+
obj_needs :data, :log_lines
|
31
|
+
undefine_attribute :name
|
32
|
+
undefine_attribute :id
|
33
|
+
def_attribute :output
|
35
34
|
end
|
@@ -16,13 +16,15 @@
|
|
16
16
|
|
17
17
|
# It requires Core objects to be defined + default ForjProcess functions.
|
18
18
|
|
19
|
+
# rubocop: disable Style/ClassAndModuleChildren
|
20
|
+
|
19
21
|
# Subnetwork Management
|
20
22
|
class CloudProcess
|
21
23
|
def forj_get_or_create_subnetwork(sCloudObj, hParams)
|
22
|
-
|
23
|
-
unless
|
24
|
-
register(
|
25
|
-
return
|
24
|
+
subnets = query_subnet(sCloudObj, hParams)
|
25
|
+
unless subnets.length == 0
|
26
|
+
register(subnets[0])
|
27
|
+
return subnets[0]
|
26
28
|
end
|
27
29
|
|
28
30
|
# Create the subnet
|
@@ -34,21 +36,18 @@ class CloudProcess
|
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
37
|
-
# ************************************ SubNetwork Object model
|
38
39
|
# Define framework object on BaseDefinition
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
)
|
40
|
+
# Identify subnetwork as part of network.
|
41
|
+
class Lorj::BaseDefinition
|
42
|
+
define_obj(:subnetwork,
|
43
|
+
:create_e => :forj_get_or_create_subnetwork
|
44
|
+
)
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
obj_needs :CloudObject, :network_connection
|
47
|
+
obj_needs :CloudObject, :network
|
48
|
+
obj_needs :data, :subnetwork_name
|
49
49
|
|
50
|
-
|
51
|
-
end
|
50
|
+
def_attribute :network_id
|
52
51
|
end
|
53
52
|
|
54
53
|
# Subnetwork Management - internal functions
|
@@ -57,7 +56,7 @@ class CloudProcess
|
|
57
56
|
name = hParams[:subnetwork_name]
|
58
57
|
PrcLib.state("Creating subnet '%s'", name)
|
59
58
|
begin
|
60
|
-
subnet = controller_create(sCloudObj)
|
59
|
+
subnet = controller_create(sCloudObj, hParams)
|
61
60
|
PrcLib.info("Subnet '%s' created.", subnet[:name])
|
62
61
|
rescue => e
|
63
62
|
PrcLib.fatal(1, "Unable to create '%s' subnet.", name, e)
|
@@ -78,34 +77,20 @@ class CloudProcess
|
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
81
|
-
def
|
80
|
+
def query_subnet(sCloudObj, hParams)
|
82
81
|
PrcLib.state('Searching for sub-network attached to '\
|
83
82
|
"network '%s'", hParams[:network, :name])
|
84
83
|
#######################
|
85
84
|
begin
|
86
85
|
query = { :network_id => hParams[:network, :id] }
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
PrcLib.info('No subnet found from '\
|
96
|
-
"'%s' network", hParams[:network, :name])
|
97
|
-
ForjLib::Data.new
|
98
|
-
when 1
|
99
|
-
PrcLib.info("Found '%s' subnet from "\
|
100
|
-
"'%s' network", subnets[0, :name],
|
101
|
-
hParams[:network, :name])
|
102
|
-
subnets[0]
|
103
|
-
else
|
104
|
-
PrcLib.warning('Several subnet was found on '\
|
105
|
-
"'%s'. Choosing the first one "\
|
106
|
-
"= '%s'", hParams[:network, :name],
|
107
|
-
subnets[0, :name])
|
108
|
-
subnets[0]
|
86
|
+
info = {
|
87
|
+
:notfound => "No %s found from '%s' network",
|
88
|
+
:checkmatch => "Found 1 %s. checking exact match for network '%s'.",
|
89
|
+
:nomatch => "No %s for network '%s' match"
|
90
|
+
}
|
91
|
+
query_single(sCloudObj, query, hParams[:network, :name], info)
|
92
|
+
rescue => e
|
93
|
+
PrcLib.error("%s\n%s", e.message, e.backtrace.join("\n"))
|
109
94
|
end
|
110
95
|
end
|
111
96
|
end
|