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,63 @@
|
|
|
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
|
+
# It requires Core objects to be defined + default ForjProcess functions.
|
|
19
|
+
|
|
20
|
+
# Define framework object on BaseDefinition
|
|
21
|
+
module Lorj
|
|
22
|
+
# Common definition
|
|
23
|
+
class BaseDefinition
|
|
24
|
+
# All objects used by this process are built from a Controller
|
|
25
|
+
process_default :use_controller => true
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Class to manage retry on errors before failing
|
|
30
|
+
class SSLErrorMgt
|
|
31
|
+
def initialize(iMaxRetry = 5)
|
|
32
|
+
@retry = 0
|
|
33
|
+
@max_retry = iMaxRetry
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def wait(message, issue = nil)
|
|
37
|
+
if @retry < @max_retry
|
|
38
|
+
sleep(2)
|
|
39
|
+
@retry += 1
|
|
40
|
+
if PrcLib.level == 0
|
|
41
|
+
msg = format('%s/%s try... ', @retry, @max_retry)
|
|
42
|
+
msg += issue unless issue.nil?
|
|
43
|
+
print msg
|
|
44
|
+
end
|
|
45
|
+
return false
|
|
46
|
+
else
|
|
47
|
+
PrcLib.error('Too many retry. %s', message)
|
|
48
|
+
return true
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def error_detected(message, backtrace, e)
|
|
53
|
+
if message.match('SSLv2/v3 read server hello A: unknown protocol')
|
|
54
|
+
return wait(message, "'unknown protocol' SSL Error")
|
|
55
|
+
elsif e.is_a?(Excon::Errors::InternalServerError)
|
|
56
|
+
return wait(message, ANSI.red(e.class))
|
|
57
|
+
else
|
|
58
|
+
PrcLib.error("Exception %s: %s\n%s", e.class, message,
|
|
59
|
+
backtrace.join("\n"))
|
|
60
|
+
return true
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
# It requires Core objects to be defined + default ForjProcess functions.
|
|
19
|
+
|
|
20
|
+
# Connection process code
|
|
21
|
+
class CloudProcess
|
|
22
|
+
def connect(sCloudObj, hParams)
|
|
23
|
+
ssl_error_obj = SSLErrorMgt.new # Retry object
|
|
24
|
+
PrcLib.debug("%s:%s Connecting to '%s' "\
|
|
25
|
+
"- Project '%s'",
|
|
26
|
+
self.class, sCloudObj, config[:provider], hParams[:tenant])
|
|
27
|
+
begin
|
|
28
|
+
controller_connect(sCloudObj)
|
|
29
|
+
rescue => e
|
|
30
|
+
retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
|
|
31
|
+
|
|
32
|
+
PrcLib.error('%s:%s: Unable to connect.\n%s',
|
|
33
|
+
self.class, sCloudObj, e.message)
|
|
34
|
+
nil
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Define framework object on BaseDefinition
|
|
40
|
+
module Lorj
|
|
41
|
+
# Define services model
|
|
42
|
+
class BaseDefinition
|
|
43
|
+
# predefined list of objects.
|
|
44
|
+
# Links between objects is not predefined. To do it, use needs declaration
|
|
45
|
+
# in your provider class.
|
|
46
|
+
|
|
47
|
+
# object to get list of services
|
|
48
|
+
# Defines Process handler to call
|
|
49
|
+
define_obj(:services,
|
|
50
|
+
|
|
51
|
+
:create_e => :connect
|
|
52
|
+
)
|
|
53
|
+
obj_needs :data, :auth_uri
|
|
54
|
+
obj_needs :data, :account_id
|
|
55
|
+
obj_needs :data, :account_key
|
|
56
|
+
obj_needs :data, :tenant
|
|
57
|
+
|
|
58
|
+
undefine_attribute :id # Do not return any predefined ID
|
|
59
|
+
undefine_attribute :name # Do not return any predefined NAME
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# compute_connection
|
|
63
|
+
class BaseDefinition
|
|
64
|
+
define_obj(:compute_connection,
|
|
65
|
+
|
|
66
|
+
:create_e => :connect # Will call ForjProcess connect
|
|
67
|
+
)
|
|
68
|
+
obj_needs :data, :account_id
|
|
69
|
+
obj_needs :data, :account_key
|
|
70
|
+
obj_needs :data, :auth_uri
|
|
71
|
+
obj_needs :data, :tenant
|
|
72
|
+
obj_needs :data, :compute
|
|
73
|
+
|
|
74
|
+
undefine_attribute :id # Do not return any predefined ID
|
|
75
|
+
undefine_attribute :name # Do not return any predefined NAME
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# network_connection
|
|
79
|
+
class BaseDefinition
|
|
80
|
+
define_obj(:network_connection,
|
|
81
|
+
|
|
82
|
+
:create_e => :connect
|
|
83
|
+
)
|
|
84
|
+
obj_needs :data, :account_id
|
|
85
|
+
obj_needs :data, :account_key
|
|
86
|
+
obj_needs :data, :auth_uri
|
|
87
|
+
obj_needs :data, :tenant
|
|
88
|
+
obj_needs :data, :network
|
|
89
|
+
|
|
90
|
+
undefine_attribute :id # Do not return any predefined ID
|
|
91
|
+
undefine_attribute :name # Do not return any predefined NAME
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
# It requires Core objects to be defined + default ForjProcess functions.
|
|
18
|
+
|
|
19
|
+
# External network process attached to a network
|
|
20
|
+
class CloudProcess
|
|
21
|
+
def forj_get_or_create_ext_net(sCloudObj, hParams)
|
|
22
|
+
PrcLib.state("Checking router '%s' gateway", hParams[:router, :name])
|
|
23
|
+
|
|
24
|
+
router_obj = hParams[:router]
|
|
25
|
+
router_name = hParams[:router, :name]
|
|
26
|
+
network_id = hParams[:router, :gateway_network_id]
|
|
27
|
+
if network_id
|
|
28
|
+
external_network = forj_query_external_network(sCloudObj,
|
|
29
|
+
{ :id => network_id },
|
|
30
|
+
hParams)
|
|
31
|
+
PrcLib.info("Router '%s' is attached to the "\
|
|
32
|
+
"external gateway '%s'.", router_name,
|
|
33
|
+
external_network[:name])
|
|
34
|
+
else
|
|
35
|
+
PrcLib.info("Router '%s' needs to be attached to an "\
|
|
36
|
+
'external gateway.', router_name)
|
|
37
|
+
PrcLib.state('Attaching')
|
|
38
|
+
external_network = forj_query_external_network(:network, {}, hParams)
|
|
39
|
+
if !external_network.empty?
|
|
40
|
+
router_obj[:gateway_network_id] = external_network[:id]
|
|
41
|
+
forj_update_router(:router, hParams)
|
|
42
|
+
PrcLib.info("Router '%s' attached to the "\
|
|
43
|
+
"external network '%s'.",
|
|
44
|
+
router_name, external_network[:name])
|
|
45
|
+
else
|
|
46
|
+
PrcLib.fatal(1, "Unable to attach router '%s' to an external gateway. "\
|
|
47
|
+
'Required for boxes to get internet access. ',
|
|
48
|
+
get_data(:router, :name))
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Need to keep the :network object as :external_network object type.
|
|
53
|
+
external_network.type = sCloudObj
|
|
54
|
+
external_network
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def forj_query_external_network(_sCloudObj, sQuery, _hParams)
|
|
58
|
+
PrcLib.state('Identifying External gateway')
|
|
59
|
+
begin
|
|
60
|
+
# Searching for external network
|
|
61
|
+
networks = controller_query(:network, sQuery.merge(:external => true))
|
|
62
|
+
|
|
63
|
+
case networks.length
|
|
64
|
+
when 0
|
|
65
|
+
PrcLib.info('No external network')
|
|
66
|
+
nil
|
|
67
|
+
when 1
|
|
68
|
+
PrcLib.info("Found external network '%s'.", networks[0, :name])
|
|
69
|
+
networks[0]
|
|
70
|
+
else
|
|
71
|
+
PrcLib.warning('Found several external networks. '\
|
|
72
|
+
"Selecting the first one '%s'", networks[0, :name])
|
|
73
|
+
networks[0]
|
|
74
|
+
end
|
|
75
|
+
rescue => e
|
|
76
|
+
PrcLib.error("%s\n%s", e.message, e.backtrace.join("\n"))
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Define framework object on BaseDefinition
|
|
82
|
+
module Lorj
|
|
83
|
+
# Identify an external network thanks to the network router.
|
|
84
|
+
class BaseDefinition
|
|
85
|
+
define_obj(:external_network,
|
|
86
|
+
|
|
87
|
+
:create_e => :forj_get_or_create_ext_net,
|
|
88
|
+
:query_e => :forj_query_external_network
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
obj_needs :CloudObject, :network_connection
|
|
92
|
+
obj_needs :CloudObject, :router
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
# It requires Core objects to be defined + default ForjProcess functions.
|
|
18
|
+
|
|
19
|
+
# ---------------------------------------------------------------------------
|
|
20
|
+
# flavor management
|
|
21
|
+
# ---------------------------------------------------------------------------
|
|
22
|
+
class CloudProcess
|
|
23
|
+
# Depending on clouds/rights, we can create flavor or not.
|
|
24
|
+
# Usually, flavor records already exists, and the controller may map them
|
|
25
|
+
# CloudProcess predefines some values. Consult CloudProcess.rb for details
|
|
26
|
+
def forj_get_or_create_flavor(sCloudObj, hParams)
|
|
27
|
+
flavor_name = hParams[:flavor_name]
|
|
28
|
+
PrcLib.state("Searching for flavor '%s'", flavor_name)
|
|
29
|
+
|
|
30
|
+
flavors = query_flavor(sCloudObj, { :name => flavor_name }, hParams)
|
|
31
|
+
if flavors.length == 0
|
|
32
|
+
if !hParams[:create]
|
|
33
|
+
PrcLib.error("Unable to create %s '%s'. Creation is not "\
|
|
34
|
+
'supported.', sCloudObj, flavor_name)
|
|
35
|
+
ForjLib::Data.new.set(nil, sCloudObj)
|
|
36
|
+
else
|
|
37
|
+
create_flavor(sCloudObj, hParams)
|
|
38
|
+
end
|
|
39
|
+
else
|
|
40
|
+
flavors[0]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Should return 1 or 0 flavor.
|
|
45
|
+
def query_flavor(sCloudObj, sQuery, hParams)
|
|
46
|
+
flavor_name = hParams[:flavor_name]
|
|
47
|
+
list = forj_query_flavor(sCloudObj, sQuery, hParams)
|
|
48
|
+
query_single(sCloudObj, list, sQuery, flavor_name)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Should return 1 or 0 flavor.
|
|
52
|
+
def forj_query_flavor(sCloudObj, sQuery, _hParams)
|
|
53
|
+
ssl_error_obj = SSLErrorMgt.new
|
|
54
|
+
begin
|
|
55
|
+
list = controller_query(sCloudObj, sQuery)
|
|
56
|
+
rescue => e
|
|
57
|
+
retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
|
|
58
|
+
end
|
|
59
|
+
list
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Define framework object on BaseDefinition
|
|
64
|
+
module Lorj
|
|
65
|
+
# ************************************ Flavor Object
|
|
66
|
+
# Identify flavor
|
|
67
|
+
class BaseDefinition # rubocop: disable ClassAndModuleChildren
|
|
68
|
+
define_obj(:flavor,
|
|
69
|
+
|
|
70
|
+
:create_e => :forj_get_or_create_flavor,
|
|
71
|
+
:query_e => :forj_query_flavor
|
|
72
|
+
# :get_e => :forj_get_flavor,
|
|
73
|
+
# :update_e => :forj_update_flavor,
|
|
74
|
+
# :delete_e => :forj_delete_flavor
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
obj_needs :CloudObject, :compute_connection
|
|
78
|
+
obj_needs :data, :flavor_name, :for => [:create_e]
|
|
79
|
+
# Cloud provider will need to map to one of those predefined flavors.
|
|
80
|
+
# limitation values may match exactly or at least ensure those limitation
|
|
81
|
+
# are under provider limitation
|
|
82
|
+
# ie, at least the CloudProcess limitation can less than the
|
|
83
|
+
# Cloud provider defines.
|
|
84
|
+
# CloudProcess EHD = 160, then Provider EHD = 200 is ok
|
|
85
|
+
# but Provider EHD = 150 is not ok.
|
|
86
|
+
predefine_data_value('tiny', :desc => 'VCU: 1, RAM:512M, HD:1G, '\
|
|
87
|
+
'EHD: 0G, Swap: 0G')
|
|
88
|
+
predefine_data_value('xsmall', :desc => 'VCU: 1, RAM:1G, HD:10G, '\
|
|
89
|
+
'EHD: 10G, Swap: 0G')
|
|
90
|
+
predefine_data_value('small', :desc => 'VCU: 2, RAM:2G, HD:30G, '\
|
|
91
|
+
'EHD: 10G, Swap: 0G')
|
|
92
|
+
predefine_data_value('medium', :desc => 'VCU: 2, RAM:4G, HD:30G, '\
|
|
93
|
+
'EHD: 50G, Swap: 0G')
|
|
94
|
+
predefine_data_value('large', :desc => 'VCU: 4, RAM:8G, HD:30G, '\
|
|
95
|
+
'EHD: 100G, Swap: 0G')
|
|
96
|
+
predefine_data_value('xlarge', :desc => 'VCU: 8, RAM:16G, HD:30G, '\
|
|
97
|
+
'EHD: 200G, Swap: 0G')
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
# It requires Core objects to be defined + default ForjProcess functions.
|
|
18
|
+
|
|
19
|
+
# ---------------------------------------------------------------------------
|
|
20
|
+
# Image management
|
|
21
|
+
# ---------------------------------------------------------------------------
|
|
22
|
+
class CloudProcess
|
|
23
|
+
def forj_get_or_create_image(sCloudObj, hParams)
|
|
24
|
+
image_name = hParams[:image_name]
|
|
25
|
+
PrcLib.state("Searching for image '%s'", image_name)
|
|
26
|
+
|
|
27
|
+
search_the_image(sCloudObj, { :name => image_name }, hParams)
|
|
28
|
+
# No creation possible.
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def search_the_image(sCloudObj, sQuery, hParams)
|
|
32
|
+
image_name = hParams[:image_name]
|
|
33
|
+
images = forj_query_image(sCloudObj, sQuery, hParams)
|
|
34
|
+
case images.length
|
|
35
|
+
when 0
|
|
36
|
+
PrcLib.info("No image '%s' found", image_name)
|
|
37
|
+
nil
|
|
38
|
+
when 1
|
|
39
|
+
PrcLib.info("Found image '%s'.", image_name)
|
|
40
|
+
images[0, :ssh_user] = ssh_user(images[0, :name])
|
|
41
|
+
images[0]
|
|
42
|
+
else
|
|
43
|
+
PrcLib.info("Found several images '%s'. Selecting the first "\
|
|
44
|
+
"one '%s'", image_name, images[0, :name])
|
|
45
|
+
images[0, :ssh_user] = ssh_user(images[0, :name])
|
|
46
|
+
images[0]
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def forj_query_image(sCloudObj, sQuery, _hParams)
|
|
51
|
+
ssl_error_obj = SSLErrorMgt.new
|
|
52
|
+
begin
|
|
53
|
+
images = controller_query(sCloudObj, sQuery)
|
|
54
|
+
rescue => e
|
|
55
|
+
retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
|
|
56
|
+
end
|
|
57
|
+
images.each do |image|
|
|
58
|
+
image[:ssh_user] = ssh_user(image[:name])
|
|
59
|
+
end
|
|
60
|
+
images
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def ssh_user(image_name)
|
|
64
|
+
return 'fedora' if image_name =~ /fedora/i
|
|
65
|
+
return 'centos' if image_name =~ /centos/i
|
|
66
|
+
'ubuntu'
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Define framework object on BaseDefinition
|
|
71
|
+
module Lorj
|
|
72
|
+
# ************************************ Image Object
|
|
73
|
+
# Identify image
|
|
74
|
+
class BaseDefinition
|
|
75
|
+
define_obj(:image,
|
|
76
|
+
|
|
77
|
+
:create_e => :forj_get_or_create_image,
|
|
78
|
+
:query_e => :forj_query_image
|
|
79
|
+
# :get_e => :forj_get_image
|
|
80
|
+
# :update_e => :forj_update_image
|
|
81
|
+
# :delete_e => :forj_delete_image
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
obj_needs :CloudObject, :compute_connection
|
|
85
|
+
obj_needs :data, :image_name, :for => [:create_e]
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
# It requires Core objects to be defined + default ForjProcess functions.
|
|
18
|
+
|
|
19
|
+
# Define framework object on BaseDefinition
|
|
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)
|
|
30
|
+
|
|
31
|
+
obj_needs :CloudObject, :external_network # External network to connect if
|
|
32
|
+
# needed.
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
# It requires Core objects to be defined + default ForjProcess functions.
|
|
18
|
+
|
|
19
|
+
# Define framework object on BaseDefinition
|
|
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)
|
|
25
|
+
|
|
26
|
+
obj_needs :CloudObject, :internet_network
|
|
27
|
+
obj_needs :CloudObject, :server
|
|
28
|
+
obj_needs :CloudObject, :public_ip
|
|
29
|
+
end
|
|
30
|
+
end
|