lorj_cloud 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +13 -0
- data/bin/lorj_cloud +67 -0
- data/bin/setup +15 -0
- data/lib/lorj_cloud/version.rb +2 -1
- data/lib/process/cloud/data.yaml +136 -0
- data/lib/process/cloud/defaults.yaml +17 -0
- data/lib/process/cloud/process/connection.rb +17 -20
- data/lib/process/cloud/process/flavor.rb +4 -4
- data/lib/process/cloud/process/images.rb +3 -3
- data/lib/process/cloud/process/keypairs.rb +9 -7
- data/lib/{providers → process/cloud/providers}/hpcloud/hpcloud.rb +26 -26
- data/lib/{providers → process/cloud/providers}/openstack/openstack.rb +165 -61
- data/lib/{providers → process/cloud/providers}/openstack/openstack_create.rb +7 -3
- data/lib/{providers → process/cloud/providers}/openstack/openstack_process.rb +6 -1
- data/lorj_cloud.gemspec +3 -3
- metadata +24 -38
- data/lib/data.yaml +0 -0
- data/lib/defaults.yaml +0 -0
- /data/lib/{providers → process/cloud/providers}/hpcloud/compute.rb +0 -0
- /data/lib/{providers → process/cloud/providers}/hpcloud/network.rb +0 -0
- /data/lib/{providers → process/cloud/providers}/hpcloud/security_groups.rb +0 -0
- /data/lib/{providers → process/cloud/providers}/mock/mock.rb +0 -0
- /data/lib/{providers → process/cloud/providers}/openstack/openstack_delete.rb +0 -0
- /data/lib/{providers → process/cloud/providers}/openstack/openstack_get.rb +0 -0
- /data/lib/{providers → process/cloud/providers}/openstack/openstack_query.rb +0 -0
- /data/lib/{providers → process/cloud/providers}/openstack/openstack_update.rb +0 -0
- /data/lib/{providers → process/cloud/providers}/templates/compute.rb +0 -0
- /data/lib/{providers → process/cloud/providers}/templates/mycloud.rb +0 -0
- /data/lib/{providers → process/cloud/providers}/templates/network.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c97d1a526cc33c76ce049d26943adab2c485c976
|
4
|
+
data.tar.gz: acfd3212f964e401b51dd8b03d6dabe631e6a1ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f84ffe8eb4fc5d91b8148e3d7779c3416d721f3021ca691b40ef97094ddb456368992f6dd1708d4d1ad42836bd9d848f96e90b5a3962b17decc2a2290c7e0b6
|
7
|
+
data.tar.gz: 9e0aecb2ca0c8c8a93b124d8ab4dbba4433b8bcc7b2647d2ffc24b1712f6b3fa2745cd2aae91c9ff884bccab832a4fbcd918d2158228fd68ca040ab7b39f9057
|
data/bin/console
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
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.
|
3
16
|
require 'bundler/setup'
|
4
17
|
require 'lorj_cloud'
|
5
18
|
|
data/bin/lorj_cloud
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
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
|
+
# require 'byebug'
|
17
|
+
|
18
|
+
require 'bundler/setup'
|
19
|
+
require 'lorj_cloud'
|
20
|
+
|
21
|
+
process_module = 'cloud'
|
22
|
+
|
23
|
+
PrcLib.log_object = Logger.new(STDOUT)
|
24
|
+
PrcLib.level = Logger::DEBUG
|
25
|
+
PrcLib.core_level = 5
|
26
|
+
|
27
|
+
unless Lorj.processes.key?(process_module)
|
28
|
+
PrcLib.fatal(1, "Unable to found the process module '%s'. \n"\
|
29
|
+
'Modules loaded:', process_module, Lorj.processes.keys)
|
30
|
+
end
|
31
|
+
|
32
|
+
if Lorj.processes[process_module].controllers.nil?
|
33
|
+
PrcLib.fatal(1, "no controllers found in module '%s'.\n", process_module)
|
34
|
+
end
|
35
|
+
|
36
|
+
PrcLib.high_level_msg('Welcome to lorj_cloud - Simple process to build a '\
|
37
|
+
"cloud box\n"\
|
38
|
+
'This simple script uses lorj_cloud process to guide you'\
|
39
|
+
' setup and create a server in your cloud.')
|
40
|
+
|
41
|
+
# say("Please choose your cloud provider:")
|
42
|
+
# provider = choose do |q|
|
43
|
+
# controllers = Lorj.processes[process_module].controllers.keys
|
44
|
+
# q.choices(*controllers)
|
45
|
+
# end
|
46
|
+
|
47
|
+
provider = 'openstack'
|
48
|
+
|
49
|
+
processes = [{ :process_module => process_module,
|
50
|
+
:controller_name => provider }]
|
51
|
+
|
52
|
+
core = Lorj::Core.new(nil, processes)
|
53
|
+
|
54
|
+
PrcLib.message('You are going to create a server')
|
55
|
+
|
56
|
+
# server = ask('Enter a server name:') do |q|
|
57
|
+
# q.validate = /\w+/
|
58
|
+
# end
|
59
|
+
server = 'test'
|
60
|
+
|
61
|
+
PrcLib.message('Now, we are going to ask you some data about your cloud and '\
|
62
|
+
'information to create your server')
|
63
|
+
# byebug
|
64
|
+
|
65
|
+
core.setup(:server)
|
66
|
+
|
67
|
+
core.create(:server, :server_name => server)
|
data/bin/setup
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
#!/bin/bash
|
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
|
+
|
2
17
|
set -euo pipefail
|
3
18
|
IFS=$'\n\t'
|
4
19
|
|
data/lib/lorj_cloud/version.rb
CHANGED
@@ -0,0 +1,136 @@
|
|
1
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# Following declares generic FORJ data to handle Fog object (compute/network/dns/...)
|
16
|
+
# It defines the account file structure. section/key=value
|
17
|
+
# All data can be predefined by default value (config.yaml/defaults.yaml) except
|
18
|
+
# those identified by :account_exclusive: true
|
19
|
+
:setup:
|
20
|
+
:steps:
|
21
|
+
:provider_config:
|
22
|
+
:desc: "Provider configuration:"
|
23
|
+
:cloud_config:
|
24
|
+
:desc: "Cloud configuration:"
|
25
|
+
:add:
|
26
|
+
- :keypair_path
|
27
|
+
- :keypair_base
|
28
|
+
:sections:
|
29
|
+
# This section define updatable data available from config.yaml. But will never be added in an account file.
|
30
|
+
# Used by forj set/get functions
|
31
|
+
:default:
|
32
|
+
:account_name:
|
33
|
+
:desc: "Default account name used by forj cli"
|
34
|
+
:provider_name:
|
35
|
+
:desc: "Default provider name while running forj setup. By default, hpcloud is selected."
|
36
|
+
# Defines account credentials data
|
37
|
+
:account:
|
38
|
+
:name:
|
39
|
+
:desc: "Account Name"
|
40
|
+
:readonly: true
|
41
|
+
:account_exclusive: true
|
42
|
+
:provider:
|
43
|
+
:desc: "Cloud provider name."
|
44
|
+
:readonly: true
|
45
|
+
:account_exclusive: true
|
46
|
+
|
47
|
+
# Defines services
|
48
|
+
:services:
|
49
|
+
:compute:
|
50
|
+
:desc: "Service identification for compute"
|
51
|
+
:account_exclusive: true
|
52
|
+
:account: true
|
53
|
+
:step: :provider_config
|
54
|
+
:network:
|
55
|
+
:desc: "Service identification for network"
|
56
|
+
:account_exclusive: true
|
57
|
+
:account: true
|
58
|
+
:step: :provider_config
|
59
|
+
|
60
|
+
# Defines ssh keys credentials
|
61
|
+
:credentials:
|
62
|
+
:keypair_path:
|
63
|
+
:desc: "Contains the full path to the :keypair_base."
|
64
|
+
:ask_step: :provider_config
|
65
|
+
:keypair_base:
|
66
|
+
:desc: "Contains the key file base name without .pem/.pub."
|
67
|
+
:ask_step: :provider_config
|
68
|
+
:keypair_name:
|
69
|
+
:desc: "keypair name defined in your cloud to access your server."
|
70
|
+
:ask_step: :provider_config
|
71
|
+
:auth_uri:
|
72
|
+
:desc: "Generic service auth url"
|
73
|
+
:ask_step: :provider_config
|
74
|
+
:account_exclusive: true
|
75
|
+
:account: true
|
76
|
+
:required: true
|
77
|
+
:user_domain:
|
78
|
+
:ask_step: :provider_config
|
79
|
+
:account_exclusive: true
|
80
|
+
:account: true
|
81
|
+
:required: false
|
82
|
+
:account_id:
|
83
|
+
:desc: "Generic Cloud Account name."
|
84
|
+
:ask_step: :provider_config
|
85
|
+
:account_exclusive: true
|
86
|
+
:account: true
|
87
|
+
:required: true
|
88
|
+
:account_key:
|
89
|
+
:desc: "Generic cloud account key"
|
90
|
+
:ask_step: :provider_config
|
91
|
+
:account_exclusive: true
|
92
|
+
:account: true
|
93
|
+
:required: true
|
94
|
+
:encrypted: true
|
95
|
+
:tenant:
|
96
|
+
:desc: "Tenant Name (Project name)"
|
97
|
+
:ask_step: :provider_config
|
98
|
+
:account_exclusive: true
|
99
|
+
:account: true
|
100
|
+
:required: true
|
101
|
+
:prj_domain:
|
102
|
+
:ask_step: :provider_config
|
103
|
+
:account_exclusive: true
|
104
|
+
:account: true
|
105
|
+
:required: false
|
106
|
+
|
107
|
+
:server:
|
108
|
+
:network_name:
|
109
|
+
:ask_step: :cloud_config
|
110
|
+
:desc: "Network name to attach to each forge boxes. By default we use 'forj'. If it doesn't exist, it will be created."
|
111
|
+
:security_group:
|
112
|
+
:desc: "Security group name to configure and attach to each forge boxes."
|
113
|
+
:ask_step: :cloud_config
|
114
|
+
:box_name:
|
115
|
+
:desc: "Box name"
|
116
|
+
:flavor_name:
|
117
|
+
:desc: "Server Flavor name"
|
118
|
+
:ask_step: :cloud_config
|
119
|
+
:account: true
|
120
|
+
:list_values:
|
121
|
+
:query_type: :query_call # Will execute a query on flavor, query_params is empty for all.
|
122
|
+
:object: :flavor
|
123
|
+
:value: :name
|
124
|
+
:validate: :list_strict
|
125
|
+
:image_name:
|
126
|
+
:desc: "Image name"
|
127
|
+
:ask_step: :cloud_config
|
128
|
+
:account: true
|
129
|
+
:list_values:
|
130
|
+
:query_type: :query_call # Will execute a query on flavor, query_params is empty for all. No filter currently working.
|
131
|
+
:object: :image
|
132
|
+
:value: :name
|
133
|
+
:validate: :list_strict
|
134
|
+
:ports:
|
135
|
+
:desc: "List of security group rules (1 port or range of ports) to open to the external network."
|
136
|
+
:ask_step: :cloud_config
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
:default:
|
16
|
+
# Users: Default user for ssh connection, if user doesn't exits, forj cli will try to get the user from the server image on it's name attribute
|
17
|
+
:users: ['ubuntu', 'fedora', 'cloud-user', 'cirros', 'centos', 'cloud', 'root']
|
@@ -23,9 +23,9 @@
|
|
23
23
|
class CloudProcess
|
24
24
|
def connect(sCloudObj, hParams)
|
25
25
|
ssl_error_obj = SSLErrorMgt.new # Retry object
|
26
|
-
PrcLib.debug("%s:%s Connecting to '%s' "
|
27
|
-
|
28
|
-
|
26
|
+
PrcLib.debug("%s:%s Connecting to '%s' - Project '%s'",
|
27
|
+
self.class, sCloudObj, config[:provider],
|
28
|
+
hParams['credentials#tenant'])
|
29
29
|
begin
|
30
30
|
controller_connect(sCloudObj)
|
31
31
|
rescue => e
|
@@ -47,13 +47,12 @@ class Lorj::BaseDefinition
|
|
47
47
|
# object to get list of services
|
48
48
|
# Defines Process handler to call
|
49
49
|
define_obj(:services,
|
50
|
-
|
51
50
|
:create_e => :connect
|
52
51
|
)
|
53
|
-
obj_needs :data,
|
54
|
-
obj_needs :data,
|
55
|
-
obj_needs :data,
|
56
|
-
obj_needs :data,
|
52
|
+
obj_needs :data, 'credentials#auth_uri'
|
53
|
+
obj_needs :data, 'credentials#account_id'
|
54
|
+
obj_needs :data, 'credentials#account_key'
|
55
|
+
obj_needs :data, 'credentials#tenant'
|
57
56
|
|
58
57
|
undefine_attribute :id # Do not return any predefined ID
|
59
58
|
undefine_attribute :name # Do not return any predefined NAME
|
@@ -62,14 +61,13 @@ end
|
|
62
61
|
# compute_connection
|
63
62
|
class Lorj::BaseDefinition
|
64
63
|
define_obj(:compute_connection,
|
65
|
-
|
66
64
|
:create_e => :connect # Will call ForjProcess connect
|
67
65
|
)
|
68
|
-
obj_needs :data,
|
69
|
-
obj_needs :data,
|
70
|
-
obj_needs :data,
|
71
|
-
obj_needs :data,
|
72
|
-
obj_needs :data,
|
66
|
+
obj_needs :data, 'credentials#account_id'
|
67
|
+
obj_needs :data, 'credentials#account_key'
|
68
|
+
obj_needs :data, 'credentials#auth_uri'
|
69
|
+
obj_needs :data, 'credentials#tenant'
|
70
|
+
obj_needs :data, 'services#compute'
|
73
71
|
|
74
72
|
undefine_attribute :id # Do not return any predefined ID
|
75
73
|
undefine_attribute :name # Do not return any predefined NAME
|
@@ -78,14 +76,13 @@ end
|
|
78
76
|
# network_connection
|
79
77
|
class Lorj::BaseDefinition
|
80
78
|
define_obj(:network_connection,
|
81
|
-
|
82
79
|
:create_e => :connect
|
83
80
|
)
|
84
|
-
obj_needs :data,
|
85
|
-
obj_needs :data,
|
86
|
-
obj_needs :data,
|
87
|
-
obj_needs :data,
|
88
|
-
obj_needs :data,
|
81
|
+
obj_needs :data, 'credentials#account_id'
|
82
|
+
obj_needs :data, 'credentials#account_key'
|
83
|
+
obj_needs :data, 'credentials#auth_uri'
|
84
|
+
obj_needs :data, 'credentials#tenant'
|
85
|
+
obj_needs :data, 'services#network'
|
89
86
|
|
90
87
|
undefine_attribute :id # Do not return any predefined ID
|
91
88
|
undefine_attribute :name # Do not return any predefined NAME
|
@@ -24,7 +24,7 @@ class CloudProcess
|
|
24
24
|
# Usually, flavor records already exists, and the controller may map them
|
25
25
|
# CloudProcess predefines some values. Consult CloudProcess.rb for details
|
26
26
|
def forj_get_or_create_flavor(sCloudObj, hParams)
|
27
|
-
flavor_name = hParams[
|
27
|
+
flavor_name = hParams['server#flavor_name']
|
28
28
|
PrcLib.state("Searching for flavor '%s'", flavor_name)
|
29
29
|
|
30
30
|
flavors = query_flavor(sCloudObj, { :name => flavor_name }, hParams)
|
@@ -43,7 +43,7 @@ class CloudProcess
|
|
43
43
|
|
44
44
|
# Should return 1 or 0 flavor.
|
45
45
|
def query_flavor(sCloudObj, sQuery, hParams)
|
46
|
-
flavor_name = hParams[
|
46
|
+
flavor_name = hParams['server#flavor_name']
|
47
47
|
# list = forj_query_flavor(sCloudObj, sQuery, hParams)
|
48
48
|
# query_single(sCloudObj, list, sQuery, flavor_name)
|
49
49
|
query_single(sCloudObj, sQuery, flavor_name)
|
@@ -73,8 +73,8 @@ class Lorj::BaseDefinition # rubocop: disable ClassAndModuleChildren
|
|
73
73
|
# :delete_e => :forj_delete_flavor
|
74
74
|
)
|
75
75
|
|
76
|
-
obj_needs :CloudObject,
|
77
|
-
obj_needs :data,
|
76
|
+
obj_needs :CloudObject, :compute_connection
|
77
|
+
obj_needs :data, 'server#flavor_name', :for => [:create_e]
|
78
78
|
# Cloud provider will need to map to one of those predefined flavors.
|
79
79
|
# limitation values may match exactly or at least ensure those limitation
|
80
80
|
# are under provider limitation
|
@@ -21,7 +21,7 @@
|
|
21
21
|
# ---------------------------------------------------------------------------
|
22
22
|
class CloudProcess
|
23
23
|
def forj_get_or_create_image(sCloudObj, hParams)
|
24
|
-
image_name = hParams[
|
24
|
+
image_name = hParams['server#image_name']
|
25
25
|
PrcLib.state("Searching for image '%s'", image_name)
|
26
26
|
|
27
27
|
search_the_image(sCloudObj, { :name => image_name }, hParams)
|
@@ -29,7 +29,7 @@ class CloudProcess
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def search_the_image(sCloudObj, sQuery, hParams)
|
32
|
-
image_name = hParams[
|
32
|
+
image_name = hParams['server#image_name']
|
33
33
|
images = forj_query_image(sCloudObj, sQuery, hParams)
|
34
34
|
case images.length
|
35
35
|
when 0
|
@@ -95,5 +95,5 @@ class Lorj::BaseDefinition # rubocop: disable Style/ClassAndModuleChildren
|
|
95
95
|
)
|
96
96
|
|
97
97
|
obj_needs :CloudObject, :compute_connection
|
98
|
-
obj_needs :data,
|
98
|
+
obj_needs :data, 'server#image_name', :for => [:create_e]
|
99
99
|
end
|
@@ -39,7 +39,7 @@ class CloudProcess
|
|
39
39
|
# also set - Used to import it)
|
40
40
|
#
|
41
41
|
def forj_get_or_create_keypair(sCloudObj, hParams)
|
42
|
-
keypair_name = hParams[
|
42
|
+
keypair_name = hParams['credentials#keypair_name']
|
43
43
|
PrcLib.state("Searching for keypair '%s'", keypair_name)
|
44
44
|
|
45
45
|
keypair = forj_get_keypair(sCloudObj, keypair_name, hParams)
|
@@ -102,7 +102,7 @@ class Lorj::BaseDefinition
|
|
102
102
|
)
|
103
103
|
|
104
104
|
obj_needs :CloudObject, :compute_connection
|
105
|
-
obj_needs :data,
|
105
|
+
obj_needs :data, 'credentials#keypair_name', :for => [:create_e]
|
106
106
|
obj_needs :data, :keypair_path
|
107
107
|
obj_needs :data, :keypair_base
|
108
108
|
|
@@ -174,9 +174,11 @@ class CloudProcess
|
|
174
174
|
|
175
175
|
def keypair_import(hParams, loc_kpair)
|
176
176
|
PrcLib.fatal(1, "Unable to import keypair '%s'. "\
|
177
|
-
|
177
|
+
"Public key file '%s' is not found. "\
|
178
178
|
"Please run 'forj setup %s'",
|
179
|
-
hParams[
|
179
|
+
hParams['credentials#keypair_name'],
|
180
|
+
File.join(loc_kpair[:keypair_path],
|
181
|
+
loc_kpair[:public_key_name]),
|
180
182
|
config[:account_name]) unless loc_kpair[:public_key_exist?]
|
181
183
|
public_key_file = File.join(loc_kpair[:keypair_path],
|
182
184
|
loc_kpair[:public_key_name])
|
@@ -185,7 +187,7 @@ class CloudProcess
|
|
185
187
|
public_key = File.read(public_key_file)
|
186
188
|
rescue => e
|
187
189
|
PrcLib.fatal(1, "Unable to import keypair '%s'. '%s' is "\
|
188
|
-
"unreadable.\n%s", hParams[
|
190
|
+
"unreadable.\n%s", hParams['credentials#keypair_name'],
|
189
191
|
loc_kpair[:public_key_file],
|
190
192
|
e.message)
|
191
193
|
end
|
@@ -200,7 +202,7 @@ class CloudProcess
|
|
200
202
|
end
|
201
203
|
|
202
204
|
def create_keypair(sCloudObj, hParams)
|
203
|
-
key_name = hParams[
|
205
|
+
key_name = hParams['credentials#keypair_name']
|
204
206
|
PrcLib.state("Importing keypair '%s'", key_name)
|
205
207
|
ssl_error_obj = SSLErrorMgt.new
|
206
208
|
begin
|
@@ -274,7 +276,7 @@ class CloudProcess
|
|
274
276
|
end
|
275
277
|
|
276
278
|
def get_keypairs_path(hParams, hKeys)
|
277
|
-
keypair_name = hParams[
|
279
|
+
keypair_name = hParams['credentials#keypair_name']
|
278
280
|
|
279
281
|
if hKeys[:private_key_exist?]
|
280
282
|
hParams[:private_key_file] = File.join(hKeys[:keypair_path],
|
@@ -28,10 +28,10 @@ load File.join(hpcloud_path, 'security_groups.rb')
|
|
28
28
|
# Defines Meta HPCloud object
|
29
29
|
class Hpcloud
|
30
30
|
define_obj :services
|
31
|
-
obj_needs :data,
|
32
|
-
obj_needs :data,
|
33
|
-
obj_needs :data,
|
34
|
-
obj_needs :data,
|
31
|
+
obj_needs :data, 'credentials#account_id', :mapping => :hp_access_key
|
32
|
+
obj_needs :data, 'credentials#account_key', :mapping => :hp_secret_key
|
33
|
+
obj_needs :data, 'credentials#auth_uri', :mapping => :hp_auth_uri
|
34
|
+
obj_needs :data, 'credentials#tenant', :mapping => :hp_tenant_id
|
35
35
|
obj_needs :data, ':excon_opts/:connect_timeout', :default_value => 30
|
36
36
|
obj_needs :data, ':excon_opts/:read_timeout', :default_value => 240
|
37
37
|
obj_needs :data, ':excon_opts/:write_timeout', :default_value => 240
|
@@ -41,18 +41,18 @@ class Hpcloud
|
|
41
41
|
define_obj :compute_connection
|
42
42
|
# Defines Data used by compute.
|
43
43
|
|
44
|
-
obj_needs :data,
|
45
|
-
obj_needs :data,
|
46
|
-
obj_needs :data,
|
47
|
-
obj_needs :data,
|
48
|
-
obj_needs :data,
|
44
|
+
obj_needs :data, 'credentials#account_id', :mapping => :hp_access_key
|
45
|
+
obj_needs :data, 'credentials#account_key', :mapping => :hp_secret_key
|
46
|
+
obj_needs :data, 'credentials#auth_uri', :mapping => :hp_auth_uri
|
47
|
+
obj_needs :data, 'credentials#tenant', :mapping => :hp_tenant_id
|
48
|
+
obj_needs :data, 'services#compute', :mapping => :hp_avl_zone
|
49
49
|
|
50
50
|
define_obj :network_connection
|
51
|
-
obj_needs :data,
|
52
|
-
obj_needs :data,
|
53
|
-
obj_needs :data,
|
54
|
-
obj_needs :data,
|
55
|
-
obj_needs :data,
|
51
|
+
obj_needs :data, 'credentials#account_id', :mapping => :hp_access_key
|
52
|
+
obj_needs :data, 'credentials#account_key', :mapping => :hp_secret_key
|
53
|
+
obj_needs :data, 'credentials#auth_uri', :mapping => :hp_auth_uri
|
54
|
+
obj_needs :data, 'credentials#tenant', :mapping => :hp_tenant_id
|
55
|
+
obj_needs :data, 'services#network', :mapping => :hp_avl_zone
|
56
56
|
|
57
57
|
# Forj predefine following query mapping, used by ForjProcess
|
58
58
|
# id => id, name => name
|
@@ -117,20 +117,20 @@ class Hpcloud
|
|
117
117
|
def_attr_mapping :public_ip, :ip
|
118
118
|
|
119
119
|
# defines setup Cloud data (:account => true for setup)
|
120
|
-
define_data(
|
120
|
+
define_data('credentials#account_id',
|
121
121
|
:account => true,
|
122
122
|
:desc => 'HPCloud Access Key (From horizon, user drop down, '\
|
123
123
|
'manage keys)',
|
124
124
|
:validate => /^[A-Z0-9]*$/
|
125
125
|
)
|
126
|
-
define_data(
|
126
|
+
define_data('credentials#account_key',
|
127
127
|
:account => true,
|
128
128
|
:desc => 'HPCloud secret Key (From horizon, user drop down, '\
|
129
129
|
'manage keys)',
|
130
130
|
:encrypted => false,
|
131
131
|
:validate => /^.+/
|
132
132
|
)
|
133
|
-
define_data(
|
133
|
+
define_data('credentials#auth_uri',
|
134
134
|
:account => true,
|
135
135
|
:desc => 'HPCloud Authentication service URL (default is HP '\
|
136
136
|
'Public cloud)',
|
@@ -138,17 +138,16 @@ class Hpcloud
|
|
138
138
|
:default_value => 'https://region-a.geo-1.identity.hpcloudsvc'\
|
139
139
|
'.com:35357/v2.0/'
|
140
140
|
)
|
141
|
-
define_data(
|
141
|
+
define_data('credentials#tenant',
|
142
142
|
:account => true,
|
143
143
|
:desc => 'HPCloud Tenant ID (from horizon, identity, projecs,'\
|
144
144
|
' Project ID)',
|
145
145
|
:validate => /^[0-9]+$/
|
146
146
|
)
|
147
147
|
|
148
|
-
define_data(
|
148
|
+
define_data('services#compute',
|
149
149
|
:account => true,
|
150
150
|
:desc => 'HPCloud Compute service zone (Ex: region-a.geo-1)',
|
151
|
-
:depends_on => [:account_id, :account_key, :auth_uri, :tenant],
|
152
151
|
:list_values => {
|
153
152
|
:query_type => :controller_call,
|
154
153
|
:object => :services,
|
@@ -158,10 +157,9 @@ class Hpcloud
|
|
158
157
|
}
|
159
158
|
)
|
160
159
|
|
161
|
-
define_data(
|
160
|
+
define_data('services#network',
|
162
161
|
:account => true,
|
163
162
|
:desc => 'HPCloud Network service zone (Ex: region-a.geo-1)',
|
164
|
-
:depends_on => [:account_id, :account_key, :auth_uri, :tenant],
|
165
163
|
:list_values => {
|
166
164
|
:query_type => :controller_call,
|
167
165
|
:object => :services,
|
@@ -227,9 +225,10 @@ class HpcloudController # rubocop: disable Metrics/ClassLength
|
|
227
225
|
hParams[:user_data], hParams[:meta_data])
|
228
226
|
when :image
|
229
227
|
required?(hParams, :compute_connection)
|
230
|
-
required?(hParams,
|
228
|
+
required?(hParams, 'server#image_name')
|
231
229
|
|
232
|
-
HPCompute.get_image(hParams[:compute_connection],
|
230
|
+
HPCompute.get_image(hParams[:compute_connection],
|
231
|
+
hParams['server#image_name'])
|
233
232
|
when :network
|
234
233
|
required?(hParams, :network_connection)
|
235
234
|
required?(hParams, :network_name)
|
@@ -252,11 +251,12 @@ class HpcloudController # rubocop: disable Metrics/ClassLength
|
|
252
251
|
hParams[:security_group], hParams[:sg_desc])
|
253
252
|
when :keypairs
|
254
253
|
required?(hParams, :compute_connection)
|
255
|
-
required?(hParams,
|
254
|
+
required?(hParams, 'credentials#keypair_name')
|
256
255
|
required?(hParams, :public_key)
|
257
256
|
|
258
257
|
HPKeyPairs.create_keypair(hParams[:compute_connection],
|
259
|
-
hParams[
|
258
|
+
hParams['credentials#keypair_name'],
|
259
|
+
hParams[:public_key])
|
260
260
|
when :router
|
261
261
|
required?(hParams, :network_connection)
|
262
262
|
required?(hParams, :router_name)
|
@@ -21,11 +21,11 @@ require 'uri'
|
|
21
21
|
|
22
22
|
hpcloud_path = File.expand_path(File.dirname(__FILE__))
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
load File.join(hpcloud_path, 'openstack_query.rb')
|
25
|
+
load File.join(hpcloud_path, 'openstack_get.rb')
|
26
|
+
load File.join(hpcloud_path, 'openstack_delete.rb')
|
27
|
+
load File.join(hpcloud_path, 'openstack_create.rb')
|
28
|
+
load File.join(hpcloud_path, 'openstack_update.rb')
|
29
29
|
|
30
30
|
# Defines Meta Openstack object
|
31
31
|
class Openstack
|
@@ -34,37 +34,49 @@ class Openstack
|
|
34
34
|
define_obj :services
|
35
35
|
# Define Data used by service
|
36
36
|
|
37
|
-
obj_needs :data,
|
38
|
-
obj_needs :data,
|
39
|
-
|
40
|
-
obj_needs :data,
|
41
|
-
obj_needs :data,
|
37
|
+
obj_needs :data, 'credentials#account_id', :mapping => :openstack_username
|
38
|
+
obj_needs :data, 'credentials#account_key', :mapping => :openstack_api_key,
|
39
|
+
:decrypt => true
|
40
|
+
obj_needs :data, 'credentials#auth_uri', :mapping => :openstack_auth_url
|
41
|
+
obj_needs :data, 'credentials#tenant', :mapping => :openstack_tenant
|
42
42
|
obj_needs :data, ':excon_opts/:connect_timeout', :default_value => 30
|
43
43
|
obj_needs :data, ':excon_opts/:read_timeout', :default_value => 240
|
44
44
|
obj_needs :data, ':excon_opts/:write_timeout', :default_value => 240
|
45
45
|
|
46
|
+
obj_needs_optional # Data required if uri contains v3
|
47
|
+
obj_needs :data, :user_domain, :mapping => :openstack_user_domain
|
48
|
+
obj_needs :data, :prj_domain, :mapping => :openstack_project_domain
|
49
|
+
|
46
50
|
define_obj :compute_connection
|
47
51
|
# Defines Data used by compute.
|
48
52
|
|
49
|
-
obj_needs :data,
|
50
|
-
obj_needs :data,
|
51
|
-
|
52
|
-
obj_needs :data,
|
53
|
-
obj_needs :data,
|
54
|
-
obj_needs :data,
|
53
|
+
obj_needs :data, 'credentials#account_id', :mapping => :openstack_username
|
54
|
+
obj_needs :data, 'credentials#account_key', :mapping => :openstack_api_key,
|
55
|
+
:decrypt => true
|
56
|
+
obj_needs :data, 'credentials#auth_uri', :mapping => :openstack_auth_url
|
57
|
+
obj_needs :data, 'credentials#tenant', :mapping => :openstack_tenant
|
58
|
+
obj_needs :data, 'services#compute', :mapping => :openstack_region
|
59
|
+
|
60
|
+
obj_needs_optional # Data required if uri contains v3
|
61
|
+
obj_needs :data, :user_domain, :mapping => :openstack_user_domain
|
62
|
+
obj_needs :data, :prj_domain, :mapping => :openstack_project_domain
|
55
63
|
|
56
64
|
define_obj :network_connection
|
57
|
-
obj_needs :data,
|
58
|
-
obj_needs :data,
|
59
|
-
|
60
|
-
obj_needs :data,
|
61
|
-
obj_needs :data,
|
62
|
-
obj_needs :data,
|
65
|
+
obj_needs :data, 'credentials#account_id', :mapping => :openstack_username
|
66
|
+
obj_needs :data, 'credentials#account_key', :mapping => :openstack_api_key,
|
67
|
+
:decrypt => true
|
68
|
+
obj_needs :data, 'credentials#auth_uri', :mapping => :openstack_auth_url
|
69
|
+
obj_needs :data, 'credentials#tenant', :mapping => :openstack_tenant
|
70
|
+
obj_needs :data, 'services#network', :mapping => :openstack_region
|
71
|
+
|
72
|
+
obj_needs_optional # Data required if uri contains v3
|
73
|
+
obj_needs :data, :user_domain, :mapping => :openstack_user_domain
|
74
|
+
obj_needs :data, :prj_domain, :mapping => :openstack_project_domain
|
63
75
|
|
64
76
|
# Openstack tenants object
|
65
77
|
define_obj(:tenants, :create_e => :openstack_get_tenant)
|
66
78
|
obj_needs :CloudObject, :compute_connection
|
67
|
-
obj_needs :data,
|
79
|
+
obj_needs :data, 'credentials#tenant'
|
68
80
|
|
69
81
|
# Openstack Network
|
70
82
|
define_obj :network
|
@@ -101,28 +113,32 @@ class Openstack
|
|
101
113
|
def_attr_mapping :port_max, :port_range_max
|
102
114
|
def_attr_mapping :addr_map, :remote_ip_prefix
|
103
115
|
def_attr_mapping :sg_id, :security_group_id
|
116
|
+
end
|
104
117
|
|
105
|
-
|
118
|
+
# Defines Meta Openstack object
|
119
|
+
class Openstack
|
120
|
+
define_data('credentials#account_id',
|
106
121
|
:account => true,
|
107
122
|
:desc => 'Openstack Username',
|
108
123
|
:validate => /^.+/
|
109
124
|
)
|
110
125
|
|
111
|
-
define_data(
|
126
|
+
define_data('credentials#account_key',
|
112
127
|
:account => true,
|
113
128
|
:desc => 'Openstack Password',
|
114
129
|
:validate => /^.+/
|
115
130
|
)
|
116
|
-
define_data(
|
131
|
+
define_data('credentials#auth_uri',
|
117
132
|
:account => true,
|
118
133
|
:explanation => "The authentication service is identified as '"\
|
119
134
|
"identity' under your horizon UI - Project/Compute then "\
|
120
135
|
'Access & security.',
|
121
136
|
:desc => 'Openstack Authentication service URL. '\
|
122
|
-
'Ex: https://mycloud:5000/v2.0/tokens'
|
137
|
+
'Ex: https://mycloud:5000/v2.0/tokens, '\
|
138
|
+
'https://mycloud:5000/v3/auth/tokens, ...',
|
123
139
|
:validate => %r{^http(s)?:\/\/.*\/tokens$}
|
124
140
|
)
|
125
|
-
define_data(
|
141
|
+
define_data('credentials#tenant',
|
126
142
|
:account => true,
|
127
143
|
:explanation => 'The Project name is shown from your horizon UI'\
|
128
144
|
', on top left, close to the logo',
|
@@ -130,9 +146,30 @@ class Openstack
|
|
130
146
|
:validate => /^.+/
|
131
147
|
)
|
132
148
|
|
133
|
-
define_data(:
|
149
|
+
define_data(:user_domain,
|
150
|
+
:account => true,
|
151
|
+
:explanation => 'Openstack authentication (v3) requires your '\
|
152
|
+
'user domain.',
|
153
|
+
:desc => 'User domain name',
|
154
|
+
:validate => /^.+/,
|
155
|
+
:pre_step_function => :openstack_domain_required?,
|
156
|
+
:before => 'credentials#account_id',
|
157
|
+
:after => 'credentials#auth_uri'
|
158
|
+
)
|
159
|
+
|
160
|
+
define_data(:prj_domain,
|
161
|
+
:account => true,
|
162
|
+
:desc => 'Tenant domain name',
|
163
|
+
:default_value => 'Default',
|
164
|
+
:validate => /^.+/,
|
165
|
+
:pre_step_function => :openstack_domain_required?,
|
166
|
+
:before => 'credentials#tenant',
|
167
|
+
:after => 'credentials#auth_uri'
|
168
|
+
)
|
169
|
+
|
170
|
+
define_data('services#compute',
|
134
171
|
:account => true,
|
135
|
-
:default_value =>
|
172
|
+
:default_value => "<%= config['services#network'] %>",
|
136
173
|
:explanation => 'Depending on your installation, you may need to'\
|
137
174
|
' provide a Region name. This information is shown under your '\
|
138
175
|
'horizon UI - close right to the project name (top left).'\
|
@@ -141,19 +178,18 @@ class Openstack
|
|
141
178
|
'set as OS_REGION_NAME.'\
|
142
179
|
"\nIf there is no region shown, you can ignore it.",
|
143
180
|
:desc => 'Openstack Compute Region (Ex: RegionOne)',
|
144
|
-
:depends_on => [:account_id, :account_key, :auth_uri, :tenant],
|
145
181
|
:list_values => {
|
146
182
|
:query_type => :controller_call,
|
147
183
|
:object => :services,
|
148
|
-
:query_call => :
|
184
|
+
:query_call => :list_services,
|
149
185
|
:query_params => { :list_services => [:Compute, :compute] },
|
150
186
|
:validate => :list_strict
|
151
187
|
}
|
152
188
|
)
|
153
189
|
|
154
|
-
define_data(
|
190
|
+
define_data('services#network',
|
155
191
|
:account => true,
|
156
|
-
:default_value =>
|
192
|
+
:default_value => "<%= config['services#compute'] %>",
|
157
193
|
:desc => 'Openstack Network Region (Ex: RegionOne)',
|
158
194
|
:explanation => 'Depending on your installation, you may need to'\
|
159
195
|
' provide a Region name. This information is shown under your '\
|
@@ -162,11 +198,10 @@ class Openstack
|
|
162
198
|
'API, then download the Openstack RC file. The Region name is '\
|
163
199
|
'set as OS_REGION_NAME.'\
|
164
200
|
"\nIf there is no region shown, you can ignore it.",
|
165
|
-
:depends_on => [:account_id, :account_key, :auth_uri, :tenant],
|
166
201
|
:list_values => {
|
167
202
|
:query_type => :controller_call,
|
168
203
|
:object => :services,
|
169
|
-
:query_call => :
|
204
|
+
:query_call => :list_services,
|
170
205
|
:query_params => { :list_services => [:Networking, :network] },
|
171
206
|
:validate => :list_strict
|
172
207
|
}
|
@@ -177,7 +212,7 @@ class Openstack
|
|
177
212
|
attr_value_mapping :create, 'BUILD'
|
178
213
|
attr_value_mapping :boot, :boot
|
179
214
|
attr_value_mapping :active, 'ACTIVE'
|
180
|
-
attr_value_mapping :error,
|
215
|
+
attr_value_mapping :error, 'ERROR'
|
181
216
|
|
182
217
|
def_attr_mapping :private_ip_address, :accessIPv4
|
183
218
|
def_attr_mapping :public_ip_address, :accessIPv4
|
@@ -266,15 +301,7 @@ class OpenstackController
|
|
266
301
|
def connect(sObjectType, hParams)
|
267
302
|
case sObjectType
|
268
303
|
when :services
|
269
|
-
|
270
|
-
# Convert openstack_auth_uri to type URI
|
271
|
-
hParams[:hdata][:openstack_auth_uri] =
|
272
|
-
URI.parse(hParams[:hdata][:openstack_auth_uri])
|
273
|
-
retrieve_result =
|
274
|
-
Fog::OpenStack.retrieve_tokens_v2(hParams[:hdata],
|
275
|
-
hParams[:excon_opts])
|
276
|
-
creds = format_retrieve_result(retrieve_result)
|
277
|
-
return creds
|
304
|
+
get_services(hParams)
|
278
305
|
when :compute_connection
|
279
306
|
Fog::Compute.new(
|
280
307
|
hParams[:hdata].merge(:provider => :openstack)
|
@@ -333,7 +360,7 @@ end
|
|
333
360
|
# Following class describe how FORJ should handle Openstack Cloud objects.
|
334
361
|
class OpenstackController
|
335
362
|
# This function requires to return an Array of values or nil.
|
336
|
-
def
|
363
|
+
def list_services(sObjectType, oParams)
|
337
364
|
case sObjectType
|
338
365
|
when :services
|
339
366
|
# oParams[sObjectType] will provide the controller object.
|
@@ -367,22 +394,88 @@ class OpenstackController
|
|
367
394
|
end
|
368
395
|
return result
|
369
396
|
else
|
370
|
-
controller_error "'%s' is not a valid object for '
|
397
|
+
controller_error "'%s' is not a valid object for 'list_services'",
|
371
398
|
sObjectType
|
372
399
|
end
|
373
400
|
end
|
374
401
|
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
402
|
+
# function to return a well formatted data for list of services
|
403
|
+
def get_services(hParams)
|
404
|
+
# Fog use URI type for auth uri: URI.parse('credentials#auth_uri')
|
405
|
+
# Convert openstack_auth_uri to type URI
|
406
|
+
openstack_auth_url = hParams[:hdata][:openstack_auth_url]
|
407
|
+
hParams[:hdata][:openstack_auth_uri] = URI.parse(openstack_auth_url)
|
408
|
+
|
409
|
+
case openstack_auth_url
|
410
|
+
when /v1(\.\d+)?/
|
411
|
+
version = :v1
|
412
|
+
body = Fog::OpenStack.retrieve_tokens_v1(hParams[:hdata],
|
413
|
+
hParams[:excon_opts])
|
414
|
+
when /v2(\.\d+)?/
|
415
|
+
version = :v2
|
416
|
+
body = Fog::OpenStack.retrieve_tokens_v2(hParams[:hdata],
|
417
|
+
hParams[:excon_opts])
|
418
|
+
when /v3(\.\d+)?/
|
419
|
+
version = :v3
|
420
|
+
body = Fog::OpenStack.retrieve_tokens_v3(hParams[:hdata],
|
421
|
+
hParams[:excon_opts])
|
422
|
+
else
|
423
|
+
version = :v2
|
424
|
+
body = Fog::OpenStack.retrieve_tokens_v2(hParams[:hdata],
|
425
|
+
hParams[:excon_opts])
|
426
|
+
end
|
427
|
+
build_result(version, body)
|
428
|
+
end
|
429
|
+
# Function to provide a wel formatted standard data, usable by openstack
|
430
|
+
# provider
|
431
|
+
#
|
432
|
+
# * *args*:
|
433
|
+
# - version: :v1, :v2 or :v3. Based on openstack authentication version
|
434
|
+
# - body: result of Internal Fog::OpenStack.retrieve_tokens_v?
|
435
|
+
# * *returns*:
|
436
|
+
# - Hash: Requires at least:
|
437
|
+
# - :service_catalog : Hash of services available.
|
438
|
+
#
|
439
|
+
def build_result(version, body)
|
440
|
+
case version
|
441
|
+
when :v1 # Not supported
|
442
|
+
{ :service_catalog => {} }
|
443
|
+
when :v2 #
|
444
|
+
{
|
445
|
+
:auth_token => body['access']['token']['id'],
|
446
|
+
:expires => body['access']['token']['expires'],
|
447
|
+
:service_catalog =>
|
448
|
+
get_service_catalog(body['access']['serviceCatalog']),
|
449
|
+
:endpoint_url => nil,
|
450
|
+
:cdn_endpoint_url => nil
|
451
|
+
}
|
452
|
+
when :v3 # body is an Array: 0 is the body, and 1 is the header
|
453
|
+
{
|
454
|
+
:auth_token => body[1]['X-Subject-Token'],
|
455
|
+
:expires => body[0]['token']['expires'],
|
456
|
+
:service_catalog =>
|
457
|
+
get_service_catalog(body[0]['token']['catalog']),
|
458
|
+
:endpoint_url => nil,
|
459
|
+
:cdn_endpoint_url => nil
|
460
|
+
}
|
461
|
+
end
|
384
462
|
end
|
385
463
|
|
464
|
+
# Build service catalog at the following format:
|
465
|
+
#
|
466
|
+
# :<type>:
|
467
|
+
# 'name': <name>
|
468
|
+
# :<region> : <url>
|
469
|
+
#
|
470
|
+
# where:
|
471
|
+
# - type : Can be :identity, :orchestration, :volume, ...
|
472
|
+
# - name : Is the name of the service like 'swift', 'heat', 'cinder', ...
|
473
|
+
# - region: Is the region name. Can be any string like 'regionOne'
|
474
|
+
# - url : is the exposed url of that service
|
475
|
+
# like https://swift.company.com/v1/HOSP_...
|
476
|
+
#
|
477
|
+
# It supports V2/V3 service auth response.
|
478
|
+
#
|
386
479
|
def get_service_catalog(body)
|
387
480
|
fail 'Unable to parse service catalog.' unless body
|
388
481
|
service_catalog = {}
|
@@ -392,19 +485,30 @@ class OpenstackController
|
|
392
485
|
type = type.to_sym
|
393
486
|
next if s['endpoints'].nil?
|
394
487
|
service_catalog[type] = {}
|
488
|
+
# V2/V3 auth output
|
395
489
|
service_catalog[type]['name'] = s['name']
|
396
|
-
|
490
|
+
parse_service_catalog_endpoint(s, type, service_catalog)
|
397
491
|
end
|
398
492
|
service_catalog
|
399
493
|
end
|
400
494
|
|
495
|
+
# function which read a list of endpoints of a service to extract the url
|
496
|
+
#
|
497
|
+
# v2: Get 'endpoints'[]/'publicURL'
|
498
|
+
# v3: Get 'endpoints'[]/'url' if 'endpoints'[]/'interface' == 'public'
|
401
499
|
def parse_service_catalog_endpoint(s, type, service_catalog)
|
402
500
|
s['endpoints'].each do |ep|
|
403
501
|
next if ep['region'].nil?
|
404
|
-
|
405
|
-
|
502
|
+
|
503
|
+
if ep['interface'] == 'public' # V3 auth output
|
504
|
+
service_catalog[type][ep['region'].to_sym] = ep['url']
|
505
|
+
break
|
506
|
+
end
|
507
|
+
|
508
|
+
next if ep['publicURL'].nil? || ep['publicURL'].empty?
|
509
|
+
# V2 auth output
|
406
510
|
service_catalog[type][ep['region'].to_sym] = ep['publicURL']
|
511
|
+
break
|
407
512
|
end
|
408
|
-
service_catalog
|
409
513
|
end
|
410
514
|
end
|
@@ -78,13 +78,13 @@ class OpenstackController
|
|
78
78
|
|
79
79
|
def create_keypairs(hParams)
|
80
80
|
required?(hParams, :compute_connection)
|
81
|
-
required?(hParams,
|
81
|
+
required?(hParams, 'credentials#keypair_name')
|
82
82
|
required?(hParams, :public_key)
|
83
83
|
|
84
84
|
# API:
|
85
85
|
# https://github.com/fog/fog/blob/master/lib/fog/openstack/docs/compute.md
|
86
86
|
service = hParams[:compute_connection]
|
87
|
-
service.key_pairs.create(:name => hParams[
|
87
|
+
service.key_pairs.create(:name => hParams['credentials#keypair_name'],
|
88
88
|
:public_key => hParams[:public_key])
|
89
89
|
end
|
90
90
|
|
@@ -126,7 +126,11 @@ class OpenstackController
|
|
126
126
|
while server.state != 'ACTIVE'
|
127
127
|
sleep(5)
|
128
128
|
server = compute_connect.servers.get(server.id)
|
129
|
-
|
129
|
+
|
130
|
+
if server.state == 'Error'
|
131
|
+
controller_error('Unable to assign a Public IP to a server '\
|
132
|
+
"in error '%s'", server.name)
|
133
|
+
end
|
130
134
|
end
|
131
135
|
|
132
136
|
addresses = compute_connect.addresses.all
|
@@ -17,10 +17,15 @@
|
|
17
17
|
# Specific openstack process added to the application process.
|
18
18
|
class OpenstackProcess
|
19
19
|
def openstack_get_tenant(sObjectType, hParams)
|
20
|
-
tenant_name = hParams[
|
20
|
+
tenant_name = hParams['credentials#tenant']
|
21
21
|
query = { :name => tenant_name }
|
22
22
|
PrcLib.state("searching for tenant '%s'", tenant_name)
|
23
23
|
list = query_single(sObjectType, query, tenant_name)
|
24
24
|
return list[0] if list.length > 0
|
25
25
|
end
|
26
|
+
|
27
|
+
def openstack_domain_required?(_data)
|
28
|
+
return true if config[:auth_uri].match(%r{/v3/})
|
29
|
+
false
|
30
|
+
end
|
26
31
|
end
|
data/lorj_cloud.gemspec
CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = LorjCloud::VERSION
|
9
9
|
spec.authors = ["Christophe Larsonneur"]
|
10
10
|
spec.email = ["clarsonneur@gmail.com"]
|
11
|
+
spec.date = LorjCloud::DATE
|
11
12
|
|
12
13
|
spec.summary = %q{Lorj cloud process.}
|
13
14
|
spec.description = %q{simplify cloud management, thanks to predefined process to manage cloud obj and make it work. }
|
@@ -25,8 +26,7 @@ Gem::Specification.new do |spec|
|
|
25
26
|
spec.add_development_dependency "bundler", "~> 1.9"
|
26
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
28
|
|
28
|
-
spec.add_runtime_dependency "lorj", "~> 1.0.
|
29
|
-
spec.add_runtime_dependency "fog", "~> 1.
|
29
|
+
spec.add_runtime_dependency "lorj", "~> 1.0.11"
|
30
|
+
spec.add_runtime_dependency "fog", "~> 1.30.0"
|
30
31
|
spec.add_development_dependency "rspec", "~> 3.1.0"
|
31
|
-
spec.add_development_dependency "rubocop", "~> 0.30.0"
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lorj_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christophe Larsonneur
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.0.
|
47
|
+
version: 1.0.11
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0.
|
54
|
+
version: 1.0.11
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: fog
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.30.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.30.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 3.1.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ~>
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.30.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ~>
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.30.0
|
97
83
|
description: 'simplify cloud management, thanks to predefined process to manage cloud
|
98
84
|
obj and make it work. '
|
99
85
|
email:
|
@@ -110,11 +96,12 @@ files:
|
|
110
96
|
- README.md
|
111
97
|
- Rakefile
|
112
98
|
- bin/console
|
99
|
+
- bin/lorj_cloud
|
113
100
|
- bin/setup
|
114
|
-
- lib/data.yaml
|
115
|
-
- lib/defaults.yaml
|
116
101
|
- lib/lorj_cloud.rb
|
117
102
|
- lib/lorj_cloud/version.rb
|
103
|
+
- lib/process/cloud/data.yaml
|
104
|
+
- lib/process/cloud/defaults.yaml
|
118
105
|
- lib/process/cloud/process/common.rb
|
119
106
|
- lib/process/cloud/process/connection.rb
|
120
107
|
- lib/process/cloud/process/external_network.rb
|
@@ -131,22 +118,22 @@ files:
|
|
131
118
|
- lib/process/cloud/process/server.rb
|
132
119
|
- lib/process/cloud/process/server_log.rb
|
133
120
|
- lib/process/cloud/process/subnetwork.rb
|
121
|
+
- lib/process/cloud/providers/hpcloud/compute.rb
|
122
|
+
- lib/process/cloud/providers/hpcloud/hpcloud.rb
|
123
|
+
- lib/process/cloud/providers/hpcloud/network.rb
|
124
|
+
- lib/process/cloud/providers/hpcloud/security_groups.rb
|
125
|
+
- lib/process/cloud/providers/mock/mock.rb
|
126
|
+
- lib/process/cloud/providers/openstack/openstack.rb
|
127
|
+
- lib/process/cloud/providers/openstack/openstack_create.rb
|
128
|
+
- lib/process/cloud/providers/openstack/openstack_delete.rb
|
129
|
+
- lib/process/cloud/providers/openstack/openstack_get.rb
|
130
|
+
- lib/process/cloud/providers/openstack/openstack_process.rb
|
131
|
+
- lib/process/cloud/providers/openstack/openstack_query.rb
|
132
|
+
- lib/process/cloud/providers/openstack/openstack_update.rb
|
133
|
+
- lib/process/cloud/providers/templates/compute.rb
|
134
|
+
- lib/process/cloud/providers/templates/mycloud.rb
|
135
|
+
- lib/process/cloud/providers/templates/network.rb
|
134
136
|
- lib/process/cloud_process.rb
|
135
|
-
- lib/providers/hpcloud/compute.rb
|
136
|
-
- lib/providers/hpcloud/hpcloud.rb
|
137
|
-
- lib/providers/hpcloud/network.rb
|
138
|
-
- lib/providers/hpcloud/security_groups.rb
|
139
|
-
- lib/providers/mock/mock.rb
|
140
|
-
- lib/providers/openstack/openstack.rb
|
141
|
-
- lib/providers/openstack/openstack_create.rb
|
142
|
-
- lib/providers/openstack/openstack_delete.rb
|
143
|
-
- lib/providers/openstack/openstack_get.rb
|
144
|
-
- lib/providers/openstack/openstack_process.rb
|
145
|
-
- lib/providers/openstack/openstack_query.rb
|
146
|
-
- lib/providers/openstack/openstack_update.rb
|
147
|
-
- lib/providers/templates/compute.rb
|
148
|
-
- lib/providers/templates/mycloud.rb
|
149
|
-
- lib/providers/templates/network.rb
|
150
137
|
- lorj_cloud.gemspec
|
151
138
|
homepage: https://github.com/forj-oss/lorj_cloud
|
152
139
|
licenses: []
|
@@ -172,4 +159,3 @@ signing_key:
|
|
172
159
|
specification_version: 4
|
173
160
|
summary: Lorj cloud process.
|
174
161
|
test_files: []
|
175
|
-
has_rdoc:
|
data/lib/data.yaml
DELETED
File without changes
|
data/lib/defaults.yaml
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|