forj 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/.rubocop.yml +59 -0
- data/Gemfile +14 -15
- data/Rakefile +11 -3
- data/bin/forj +231 -338
- data/forj.gemspec +4 -7
- data/forj/defaults.yaml +3 -3
- data/lib/appinit.rb +21 -32
- data/lib/boot.rb +156 -0
- data/lib/cloud_connection.rb +42 -0
- data/lib/cloud_test.rb +86 -68
- data/lib/destroy.rb +97 -0
- data/lib/forj-settings.rb +350 -167
- data/lib/forj/ForjCli.rb +12 -14
- data/lib/forj/ForjCore.rb +78 -85
- data/lib/forj/process/ForjProcess.rb +1157 -771
- data/lib/get.rb +51 -0
- data/lib/ssh.rb +86 -78
- data/spec/boot_spec.rb +0 -1
- data/spec/spec_helper.rb +65 -65
- metadata +14 -22
data/lib/get.rb
ADDED
@@ -0,0 +1,51 @@
|
|
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
|
+
require 'highline/import'
|
19
|
+
|
20
|
+
#
|
21
|
+
# Get module
|
22
|
+
#
|
23
|
+
module Forj
|
24
|
+
# This module gets your account/default configuration
|
25
|
+
module Get
|
26
|
+
def self.get(options, key)
|
27
|
+
@account = Lorj::Account.new
|
28
|
+
if options[:account_name]
|
29
|
+
get_account(options, key)
|
30
|
+
else
|
31
|
+
get_default(key)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.get_account(options, key)
|
36
|
+
if key
|
37
|
+
Forj::Settings.account_get(@account, options[:account_name], key)
|
38
|
+
else
|
39
|
+
Forj::Settings.account_get_all(@account, options[:account_name])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.get_default(key)
|
44
|
+
if !key
|
45
|
+
Forj::Settings.config_get_all(@account)
|
46
|
+
else
|
47
|
+
Forj::Settings.config_get(@account, key)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/ssh.rb
CHANGED
@@ -15,97 +15,105 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
# ~ require 'rubygems'
|
19
|
+
require 'lorj'
|
20
20
|
require 'highline/import'
|
21
|
+
require 'cloud_connection.rb'
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
# ~ require 'security.rb'
|
24
|
+
# ~ include SecurityGroup
|
24
25
|
|
25
26
|
#
|
26
27
|
# ssh module
|
27
28
|
#
|
28
29
|
module Forj
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
30
|
+
# This module provides the behavior to create a ssh connection
|
31
|
+
module Ssh
|
32
|
+
def self.connect(name, account)
|
33
|
+
o_cloud = Forj::CloudConnection.connect(account)
|
34
|
+
|
35
|
+
PrcLib.state(format("Getting information about forge '%s'", name))
|
36
|
+
|
37
|
+
o_forge = o_cloud.get(:forge, name)
|
38
|
+
|
39
|
+
if o_forge[:servers].count > 0
|
40
|
+
if account[:box_ssh]
|
41
|
+
o_server = validate_server_name(name, account, o_forge)
|
42
|
+
|
43
|
+
if !o_server.nil?
|
44
|
+
ssh_connection(account, o_cloud, name, o_server[:id])
|
45
|
+
else
|
46
|
+
PrcLib.debug("server '%s.%s' was not found",
|
47
|
+
account[:box_ssh], name)
|
48
|
+
PrcLib.high_level_msg("server '%s.%s' was not found.\n",
|
49
|
+
account[:box_ssh], name)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
o_server_number = select_forge_server(o_forge)
|
53
|
+
|
54
|
+
ssh_connection(
|
55
|
+
account,
|
56
|
+
o_cloud,
|
57
|
+
name,
|
58
|
+
o_forge[:servers][o_server_number][:id]
|
59
|
+
)
|
60
|
+
end
|
61
|
+
else
|
62
|
+
PrcLib.high_level_msg("No server(s) found for instance name '%s' \n",
|
63
|
+
name)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.select_forge_server(o_forge)
|
68
|
+
# Ask the user to get server(s) to create ssh connection
|
69
|
+
server_list = []
|
70
|
+
index = 0
|
71
|
+
s_default = nil
|
72
|
+
o_forge[:servers].each do |server|
|
73
|
+
server_list[index] = server[:name]
|
74
|
+
s_default = server[:name] if server[:name].include? 'maestro'
|
75
|
+
index += 1
|
76
|
+
end
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
78
|
+
say(format(
|
79
|
+
'Select box for ssh connection %s',
|
80
|
+
((s_default.nil?) ? '' : format(
|
81
|
+
'Default: ' + "|%s|\n", s_default
|
82
|
+
))
|
83
|
+
)
|
84
|
+
)
|
85
|
+
value = choose do |q|
|
86
|
+
q.choices(*server_list)
|
87
|
+
q.default = s_default unless s_default.nil?
|
88
|
+
end
|
88
89
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
q.default = sDefault if not sDefault.nil?
|
93
|
-
}
|
90
|
+
o_server_number = server_list.index(value)
|
91
|
+
o_server_number
|
92
|
+
end
|
94
93
|
|
95
|
-
|
94
|
+
def self.ssh_connection(account, o_cloud, name, server_id)
|
95
|
+
# Property for :forge
|
96
|
+
account.set(:instance_name, name)
|
97
|
+
# Property for :ssh
|
98
|
+
account.set(:forge_server, server_id)
|
96
99
|
|
97
|
-
|
98
|
-
|
99
|
-
#Property for :ssh
|
100
|
-
oConfig.set(:forge_server, oForge[:servers][oServerNumber][:id])
|
100
|
+
o_cloud.create(:ssh)
|
101
|
+
end
|
101
102
|
|
102
|
-
|
103
|
+
def self.validate_server_name(name, account, o_forge)
|
104
|
+
box_ssh = account[:box_ssh]
|
103
105
|
|
104
|
-
|
105
|
-
|
106
|
-
PrcLib.high_level_msg("No server(s) found for instance name '%s' \n" % name )
|
107
|
-
end
|
106
|
+
o_server = nil
|
107
|
+
regex = Regexp.new(format('%s\.%s$', box_ssh, name))
|
108
108
|
|
109
|
+
o_forge[:servers].each do |server|
|
110
|
+
o_name = server[:name]
|
111
|
+
next if (regex =~ o_name).nil?
|
112
|
+
o_server = server
|
113
|
+
break
|
109
114
|
end
|
110
|
-
|
115
|
+
|
116
|
+
o_server
|
117
|
+
end
|
118
|
+
end
|
111
119
|
end
|
data/spec/boot_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
2
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will
|
4
|
-
# file to always be loaded, without a need to explicitly require it
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will
|
4
|
+
# cause this file to always be loaded, without a need to explicitly require it
|
5
|
+
# in any files.
|
5
6
|
#
|
6
7
|
# Given that it is always loaded, you are encouraged to keep this file as
|
7
8
|
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
-
# will add to the boot time of your test.rb suite on EVERY test.rb run, even for
|
9
|
-
# individual file that may not need all of that loaded. Instead, make a
|
9
|
+
# will add to the boot time of your test.rb suite on EVERY test.rb run, even for
|
10
|
+
# an individual file that may not need all of that loaded. Instead, make a
|
10
11
|
# separate helper file that requires this one and then use it only in the specs
|
11
12
|
# that actually need it.
|
12
13
|
#
|
@@ -14,65 +15,64 @@
|
|
14
15
|
# users commonly want.
|
15
16
|
#
|
16
17
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
-
RSpec.configure do |
|
18
|
-
# The settings below are suggested to provide a good initial experience
|
19
|
-
# with RSpec, but feel free to customize to your heart's content.
|
20
|
-
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
config.
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
|
48
|
-
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
#
|
66
|
-
#
|
67
|
-
config.mock_with :rspec do |mocks|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
=end
|
18
|
+
RSpec.configure do |_config|
|
19
|
+
# The settings below are suggested to provide a good initial experience
|
20
|
+
# with RSpec, but feel free to customize to your heart's content.
|
21
|
+
# # These two settings work together to allow you to limit a spec run
|
22
|
+
# # to individual examples or groups you care about by tagging them with
|
23
|
+
# # `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
24
|
+
# # get run.
|
25
|
+
# config.filter_run :focus
|
26
|
+
# config.run_all_when_everything_filtered = true
|
27
|
+
#
|
28
|
+
# # Many RSpec users commonly either run the entire suite or an individual
|
29
|
+
# # file, and it's useful to allow more verbose output when running an
|
30
|
+
# # individual spec file.
|
31
|
+
# if config.files_to_run.one?
|
32
|
+
# # Use the documentation formatter for detailed output,
|
33
|
+
# # unless a formatter has already been configured
|
34
|
+
# # (e.g. via a command-line flag).
|
35
|
+
# config.default_formatter = 'doc'
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# # Print the 10 slowest examples and example groups at the
|
39
|
+
# # end of the spec run, to help surface which specs are running
|
40
|
+
# # particularly slow.
|
41
|
+
# config.profile_examples = 10
|
42
|
+
#
|
43
|
+
# # Run specs in random order to surface order dependencies. If you find an
|
44
|
+
# # order dependency and want to debug it, you can fix the order by
|
45
|
+
# # providing the seed, which is printed after each run.
|
46
|
+
# # --seed 1234
|
47
|
+
# config.order = :random
|
48
|
+
#
|
49
|
+
# # Seed global randomization in this process using the `--seed` CLI option.
|
50
|
+
# # Setting this allows you to use `--seed` to deterministically reproduce
|
51
|
+
# # test.rb failures related to randomization by passing the same `--seed`
|
52
|
+
# # value as the one that triggered the failure.
|
53
|
+
# Kernel.srand config.seed
|
54
|
+
#
|
55
|
+
# # rspec-expectations config goes here. You can use an alternate
|
56
|
+
# # assertion/expectation library such as wrong or the stdlib/minitest
|
57
|
+
# # assertions if you prefer.
|
58
|
+
# config.expect_with :rspec do |expectations|
|
59
|
+
# # Enable only the newer, non-monkey-patching expect syntax.
|
60
|
+
# # For more details, see:
|
61
|
+
# # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
62
|
+
# expectations.syntax = :expect
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# # rspec-mocks config goes here. You can use an alternate test.rb double
|
66
|
+
# # library (such as bogus or mocha) by changing the `mock_with`
|
67
|
+
# # option here.
|
68
|
+
# config.mock_with :rspec do |mocks|
|
69
|
+
# # Enable only the newer, non-monkey-patching expect syntax.
|
70
|
+
# # For more details, see:
|
71
|
+
# # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
72
|
+
# mocks.syntax = :expect
|
73
|
+
#
|
74
|
+
# # Prevents you from mocking or stubbing a method that does not exist on
|
75
|
+
# # a real object. This is generally recommended.
|
76
|
+
# mocks.verify_partial_doubles = true
|
77
|
+
# end
|
78
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- forj team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: fog
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.26.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.26.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: git
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,28 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - ~>
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.2
|
145
|
+
version: 1.0.2
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - ~>
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.2
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: bundler
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - '>='
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - '>='
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
152
|
+
version: 1.0.2
|
167
153
|
- !ruby/object:Gem::Dependency
|
168
154
|
name: rake
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,6 +188,7 @@ extra_rdoc_files: []
|
|
202
188
|
files:
|
203
189
|
- .gitignore
|
204
190
|
- .gitreview
|
191
|
+
- .rubocop.yml
|
205
192
|
- Gemfile
|
206
193
|
- README.md
|
207
194
|
- Rakefile
|
@@ -209,14 +196,18 @@ files:
|
|
209
196
|
- forj.gemspec
|
210
197
|
- forj/defaults.yaml
|
211
198
|
- lib/appinit.rb
|
199
|
+
- lib/boot.rb
|
212
200
|
- lib/build_tmpl/bootstrap_build.sh
|
213
201
|
- lib/build_tmpl/build-env.py
|
214
202
|
- lib/build_tmpl/write-mime-multipart.py
|
203
|
+
- lib/cloud_connection.rb
|
215
204
|
- lib/cloud_test.rb
|
205
|
+
- lib/destroy.rb
|
216
206
|
- lib/forj-settings.rb
|
217
207
|
- lib/forj/ForjCli.rb
|
218
208
|
- lib/forj/ForjCore.rb
|
219
209
|
- lib/forj/process/ForjProcess.rb
|
210
|
+
- lib/get.rb
|
220
211
|
- lib/ssh.rb
|
221
212
|
- spec/boot_spec.rb
|
222
213
|
- spec/down_spec.rb
|
@@ -259,3 +250,4 @@ test_files:
|
|
259
250
|
- spec/setup_spec.rb
|
260
251
|
- spec/spec_helper.rb
|
261
252
|
- spec/ssh_spec.rb
|
253
|
+
has_rdoc:
|