dployr 0.0.6 → 0.0.7
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/dployr.gemspec +1 -1
- data/lib/dployr/cli.rb +33 -13
- data/lib/dployr/commands/base.rb +10 -8
- data/lib/dployr/commands/config.rb +2 -13
- data/lib/dployr/commands/info.rb +0 -1
- data/lib/dployr/compute/baremetal.rb +12 -12
- data/lib/dployr/configuration.rb +20 -11
- data/lib/dployr/utils.rb +1 -1
- data/lib/dployr/version.rb +1 -1
- data/spec/configuration_spec.rb +48 -36
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84dbc231d29673da035d182bf6198848a4b0bbe1
|
4
|
+
data.tar.gz: 504c80fb2ea79996efa2b155affc7f1fcced00a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d1d4eb41cf77fc668a7e785a4c6228f9f15ce64add9cc1c434a10311964fe789b21031ef9a09c4930b932878a6962897732f1f3f03d18746e361c155ac90fb2
|
7
|
+
data.tar.gz: 102f3eb0359b547f595fc64e13cb3ba9db54b27a26101eef0eb27dc2113c75e15d1af101119f1affb0d797fc8f8ab8075bc5663c05307b9ead3e32c2f1c38cee
|
data/dployr.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_dependency "fog", "~> 1.21"
|
23
23
|
s.add_dependency "deep_merge", "~> 1.0"
|
24
|
-
s.add_dependency "net-ssh", "~> 2.
|
24
|
+
s.add_dependency "net-ssh", "~> 2.9.0"
|
25
25
|
s.add_dependency "net-scp", "~> 1.2.0"
|
26
26
|
s.add_dependency "colorize", "~> 0.7.2"
|
27
27
|
|
data/lib/dployr/cli.rb
CHANGED
@@ -45,11 +45,15 @@ opt_parser = OptionParser.new do |opt|
|
|
45
45
|
opt.on("-r", "--region REGION", "region to use (allow multiple values comma-separated)") do |v|
|
46
46
|
options[:region] = v
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
opt.on("-i", "--public-ip", "use public ip instead of private ip to when access instances") do |v|
|
50
50
|
options[:public_ip] = v
|
51
51
|
end
|
52
52
|
|
53
|
+
opt.on("--debug", "enable debug mode") do
|
54
|
+
options[:debug] = true
|
55
|
+
end
|
56
|
+
|
53
57
|
opt.on("-v", "-V", "--version", "version") do
|
54
58
|
puts Dployr::VERSION
|
55
59
|
exit 0
|
@@ -65,31 +69,47 @@ end
|
|
65
69
|
|
66
70
|
opt_parser.parse!
|
67
71
|
|
72
|
+
def run(command, options, arg = nil)
|
73
|
+
begin
|
74
|
+
cmd = Dployr::Commands.const_get command
|
75
|
+
raise "Command not supported: #{command}" unless cmd
|
76
|
+
if arg
|
77
|
+
cmd.new options, arg
|
78
|
+
else
|
79
|
+
cmd.new options
|
80
|
+
end
|
81
|
+
rescue => e
|
82
|
+
puts "Error: #{e}".red
|
83
|
+
puts e.backtrace if e.backtrace and options[:debug]
|
84
|
+
exit 1
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
68
88
|
case command
|
69
89
|
when "start"
|
70
|
-
|
90
|
+
run :Start, options
|
71
91
|
when "halt"
|
72
|
-
|
92
|
+
run :StopDestroy, options, "halt"
|
73
93
|
when "destroy"
|
74
|
-
|
94
|
+
run :StopDestroy, options, "destroy"
|
75
95
|
when "status"
|
76
96
|
puts "Command currently not available"
|
77
97
|
when "info"
|
78
|
-
|
98
|
+
run :Info, options
|
79
99
|
when "provision"
|
80
|
-
|
100
|
+
run :ProvisionTest, options, "provision"
|
81
101
|
when "test"
|
82
|
-
|
102
|
+
run :ProvisionTest, options, "test"
|
83
103
|
when "deploy"
|
84
|
-
|
85
|
-
|
86
|
-
|
104
|
+
run :Start, options
|
105
|
+
run :ProvisionTest, options, "provision"
|
106
|
+
run :ProvisionTest, options, "test"
|
87
107
|
when "execute"
|
88
|
-
|
108
|
+
run :Execute, options, ARGV[1..-1]
|
89
109
|
when "ssh"
|
90
|
-
|
110
|
+
run :Ssh, options
|
91
111
|
when "config"
|
92
|
-
|
112
|
+
run :Config, options
|
93
113
|
when "init"
|
94
114
|
Dployr::Config::Create.write_file
|
95
115
|
else
|
data/lib/dployr/commands/base.rb
CHANGED
@@ -11,27 +11,22 @@ module Dployr
|
|
11
11
|
|
12
12
|
include Dployr::Commands::Utils
|
13
13
|
|
14
|
-
attr_reader :options, :name, :log, :attrs, :dployr
|
15
|
-
|
16
14
|
def initialize(options)
|
17
15
|
@options = options
|
18
16
|
@name = options[:name]
|
19
17
|
@log = Logger.new STDOUT
|
20
18
|
@attrs = parse_attributes @options[:attributes]
|
21
|
-
if !options[:public_ip]
|
22
|
-
options[:public_ip] = false
|
23
|
-
end
|
19
|
+
@options[:public_ip] = false if !options[:public_ip]
|
24
20
|
@provider = options[:provider].upcase
|
25
21
|
create
|
26
|
-
|
27
|
-
@p_attrs = @config[:attributes]
|
22
|
+
get_config
|
28
23
|
end
|
29
24
|
|
30
25
|
def create
|
31
26
|
begin
|
32
27
|
@dployr = Dployr::Init.new @attrs
|
33
28
|
@dployr.load_config @options[:file]
|
34
|
-
rescue
|
29
|
+
rescue => e
|
35
30
|
raise "Cannot load the config: #{e}"
|
36
31
|
end
|
37
32
|
end
|
@@ -48,6 +43,13 @@ module Dployr
|
|
48
43
|
@dployr.config.get_region options[:name], options[:provider], options[:region]
|
49
44
|
end
|
50
45
|
|
46
|
+
private
|
47
|
+
|
48
|
+
def get_config
|
49
|
+
@config = get_region_config @options
|
50
|
+
@p_attrs = @config[:attributes]
|
51
|
+
end
|
52
|
+
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
@@ -6,12 +6,7 @@ module Dployr
|
|
6
6
|
|
7
7
|
def initialize(options)
|
8
8
|
super options
|
9
|
-
|
10
|
-
render_file
|
11
|
-
rescue Exception => e
|
12
|
-
@log.error e
|
13
|
-
exit 1
|
14
|
-
end
|
9
|
+
render_file
|
15
10
|
end
|
16
11
|
|
17
12
|
private
|
@@ -19,13 +14,7 @@ module Dployr
|
|
19
14
|
def render_file
|
20
15
|
raise "Dployrfile was not found" if @dployr.file_path.nil?
|
21
16
|
raise "Configuration is missing" unless @dployr.config.exists?
|
22
|
-
|
23
|
-
begin
|
24
|
-
print_config
|
25
|
-
rescue Exception => e
|
26
|
-
puts "Cannot generate the config: #{e}"
|
27
|
-
exit 1
|
28
|
-
end
|
17
|
+
print_config
|
29
18
|
end
|
30
19
|
|
31
20
|
def print_config
|
data/lib/dployr/commands/info.rb
CHANGED
@@ -5,42 +5,42 @@ require 'ostruct'
|
|
5
5
|
module Dployr
|
6
6
|
module Compute
|
7
7
|
class BAREMETAL
|
8
|
-
|
8
|
+
|
9
9
|
include Dployr::Compute::Common
|
10
|
-
|
10
|
+
|
11
11
|
def initialize(options, attrs)
|
12
12
|
@options = options
|
13
13
|
@attrs = attrs
|
14
14
|
end
|
15
15
|
|
16
|
-
def get_ip
|
16
|
+
def get_ip
|
17
17
|
if @options["public_ip"]
|
18
|
-
|
18
|
+
@attrs["public_ip"]
|
19
19
|
else
|
20
|
-
|
20
|
+
@attrs["private_ip"]
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
|
-
def get_info
|
23
|
+
|
24
|
+
def get_info
|
25
25
|
result = OpenStruct.new
|
26
26
|
result.attributes = {
|
27
27
|
public_ip: @attrs["public_ip"],
|
28
28
|
private_ip: @attrs["private_ip"],
|
29
29
|
}
|
30
|
-
|
30
|
+
result
|
31
31
|
end
|
32
32
|
|
33
|
-
def destroy
|
33
|
+
def destroy
|
34
34
|
puts "Could not destroy baremetal machine".yellow
|
35
35
|
end
|
36
36
|
|
37
|
-
def halt
|
37
|
+
def halt
|
38
38
|
puts "Could not halt baremetal machine".yellow
|
39
39
|
end
|
40
40
|
|
41
|
-
def start
|
41
|
+
def start
|
42
42
|
puts "Could not start baremetal machine".yellow
|
43
|
-
wait_ssh
|
43
|
+
wait_ssh attributes, server, @options["public_ip"]
|
44
44
|
end
|
45
45
|
|
46
46
|
end
|
data/lib/dployr/configuration.rb
CHANGED
@@ -37,7 +37,7 @@ module Dployr
|
|
37
37
|
def get_config(name, attributes = {})
|
38
38
|
instance = get_instance name
|
39
39
|
attributes = @attributes.merge (attributes or {})
|
40
|
-
raise
|
40
|
+
raise "Instance do not exists" if instance.nil?
|
41
41
|
render_config name, instance, attributes
|
42
42
|
end
|
43
43
|
|
@@ -54,7 +54,9 @@ module Dployr
|
|
54
54
|
if config.is_a? Hash
|
55
55
|
config = config[get_real_key(config, :providers)]
|
56
56
|
if config.is_a? Hash
|
57
|
-
|
57
|
+
provider_data = config[get_real_key(config, provider)]
|
58
|
+
raise "Provider #{provider} for #{name} do not exists" unless provider_data
|
59
|
+
provider_data
|
58
60
|
end
|
59
61
|
end
|
60
62
|
end
|
@@ -63,7 +65,9 @@ module Dployr
|
|
63
65
|
provider = get_provider name, provider, attributes
|
64
66
|
if provider.is_a? Hash
|
65
67
|
regions = get_by_key provider, :regions
|
66
|
-
|
68
|
+
region_data = get_by_key regions, region
|
69
|
+
raise "Region #{region} for #{name} do not exists" unless region_data
|
70
|
+
region_data
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
@@ -75,17 +79,12 @@ module Dployr
|
|
75
79
|
private
|
76
80
|
|
77
81
|
def render_config(name, instance, attributes)
|
78
|
-
attributes = replace_variables attributes
|
79
82
|
config = merge_config instance, attributes
|
80
83
|
config = replace_name name, config
|
81
84
|
config = replace_variables config, attributes
|
82
85
|
config
|
83
86
|
end
|
84
87
|
|
85
|
-
def replace_name(name, config)
|
86
|
-
replace_keywords 'name', name, config
|
87
|
-
end
|
88
|
-
|
89
88
|
def create_instance(name = 'unnamed', config)
|
90
89
|
Dployr::Config::Instance.new do |i|
|
91
90
|
i.name = name
|
@@ -93,17 +92,26 @@ module Dployr
|
|
93
92
|
end if config.is_a? Hash
|
94
93
|
end
|
95
94
|
|
95
|
+
def replace_name(name, config)
|
96
|
+
replace_keywords 'name', name, config
|
97
|
+
end
|
98
|
+
|
96
99
|
def replace_variables(config, attributes = {})
|
97
100
|
if config.is_a? Hash
|
98
101
|
attrs = get_all_attributes config
|
99
102
|
attrs.merge! attributes if attributes.is_a? Hash
|
100
|
-
|
101
|
-
replace_env_vars template(str, attrs)
|
102
|
-
end
|
103
|
+
config = replace config, attrs
|
103
104
|
end
|
104
105
|
config
|
105
106
|
end
|
106
107
|
|
108
|
+
def replace(hash, origin)
|
109
|
+
traverse_map hash do |str|
|
110
|
+
replace_env_vars template(str, origin)
|
111
|
+
end
|
112
|
+
hash
|
113
|
+
end
|
114
|
+
|
107
115
|
def get_all_attributes(config)
|
108
116
|
attrs = {}
|
109
117
|
config.each do |key, value|
|
@@ -113,6 +121,7 @@ module Dployr
|
|
113
121
|
attrs.merge! get_all_attributes value
|
114
122
|
end
|
115
123
|
end if config.is_a? Hash
|
124
|
+
attrs = replace attrs, attrs
|
116
125
|
attrs
|
117
126
|
end
|
118
127
|
|
data/lib/dployr/utils.rb
CHANGED
data/lib/dployr/version.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
@@ -14,37 +14,39 @@ describe Dployr::Configuration do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "default values" do
|
17
|
-
|
18
|
-
{
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
17
|
+
defaults = {
|
18
|
+
attributes: {
|
19
|
+
name: "example",
|
20
|
+
instance_type: "m1.small",
|
21
|
+
version: "${DPLOYR}"
|
22
|
+
},
|
23
|
+
scripts: [
|
24
|
+
{ path: "configure.sh" }
|
25
|
+
],
|
26
|
+
providers: {
|
27
|
+
aws: {
|
28
|
+
attributes: {
|
29
|
+
network_id: "be457fca",
|
30
|
+
instance_type: "m1.small",
|
31
|
+
"type-%{name}" => "small",
|
32
|
+
mixed: "%{network_id}-%{instance_type}"
|
33
|
+
},
|
34
|
+
scripts: [
|
35
|
+
{
|
36
|
+
path: "router.sh",
|
37
|
+
args: [ "%{name}", "${region}", "${provider}" ]
|
38
|
+
}
|
39
|
+
],
|
40
|
+
regions: {
|
41
|
+
"eu-west-1a" => {
|
42
|
+
attributes: {
|
43
|
+
keypair: "vagrant-aws-ireland"
|
42
44
|
}
|
43
45
|
}
|
44
46
|
}
|
45
47
|
}
|
46
48
|
}
|
47
|
-
|
49
|
+
}
|
48
50
|
|
49
51
|
describe "add default values" do
|
50
52
|
before do
|
@@ -105,12 +107,12 @@ describe Dployr::Configuration do
|
|
105
107
|
attributes: {
|
106
108
|
name: "zeus"
|
107
109
|
},
|
108
|
-
authentication: {
|
109
|
-
user: "admin",
|
110
|
-
key_path: "path/to/key.pem"
|
111
|
-
},
|
112
110
|
scripts: [
|
113
|
-
{
|
111
|
+
{
|
112
|
+
path: "setup.sh",
|
113
|
+
args: ["--id ${index}", "--name ${name}", "%{name}-%{instance_type}-%{version}", "%{mixed}"],
|
114
|
+
remote: true
|
115
|
+
}
|
114
116
|
],
|
115
117
|
providers: {
|
116
118
|
aws: {
|
@@ -250,7 +252,6 @@ describe Dployr::Configuration do
|
|
250
252
|
it "should have inherited scripts" do
|
251
253
|
region[:scripts].should have(2).items
|
252
254
|
end
|
253
|
-
|
254
255
|
end
|
255
256
|
end
|
256
257
|
|
@@ -267,7 +268,7 @@ describe Dployr::Configuration do
|
|
267
268
|
end
|
268
269
|
|
269
270
|
it "should have a valid number of attributes" do
|
270
|
-
zeus[:providers][:aws][:attributes].should have(
|
271
|
+
zeus[:providers][:aws][:attributes].should have(6).items
|
271
272
|
end
|
272
273
|
|
273
274
|
it "should have a valid instance_type" do
|
@@ -290,6 +291,10 @@ describe Dployr::Configuration do
|
|
290
291
|
it "should have a type key with valid replacement" do
|
291
292
|
zeus[:providers][:aws][:attributes]["type-zeus"].should eql "small"
|
292
293
|
end
|
294
|
+
|
295
|
+
it "should have a mixed attribute with self-referenced values" do
|
296
|
+
zeus[:providers][:aws][:attributes][:mixed].should eql "be457fca-m1.small"
|
297
|
+
end
|
293
298
|
end
|
294
299
|
end
|
295
300
|
|
@@ -311,7 +316,7 @@ describe Dployr::Configuration do
|
|
311
316
|
end
|
312
317
|
|
313
318
|
it "should have a valid number of arguments" do
|
314
|
-
zeus[:providers][:aws][:scripts][1][:args].should have(
|
319
|
+
zeus[:providers][:aws][:scripts][1][:args].should have(4).items
|
315
320
|
end
|
316
321
|
|
317
322
|
it "should have a remote property" do
|
@@ -330,6 +335,14 @@ describe Dployr::Configuration do
|
|
330
335
|
it "should replace the name context value" do
|
331
336
|
zeus[:providers][:aws][:scripts][1][:args][1].should eql "--name zeus"
|
332
337
|
end
|
338
|
+
|
339
|
+
it "should replace the multiple attributes" do
|
340
|
+
zeus[:providers][:aws][:scripts][1][:args][2].should eql "zeus-m1.small-0.1.0"
|
341
|
+
end
|
342
|
+
|
343
|
+
it "should replace the self-referenced attribute with other attributes" do
|
344
|
+
zeus[:providers][:aws][:scripts][1][:args][3].should eql "be457fca-m1.small"
|
345
|
+
end
|
333
346
|
end
|
334
347
|
end
|
335
348
|
|
@@ -416,7 +429,6 @@ describe Dployr::Configuration do
|
|
416
429
|
end
|
417
430
|
end
|
418
431
|
end
|
419
|
-
|
420
432
|
end
|
421
433
|
end
|
422
434
|
end
|
@@ -435,7 +447,7 @@ describe Dployr::Configuration do
|
|
435
447
|
@config.should be_a Hash
|
436
448
|
end
|
437
449
|
|
438
|
-
it "should have
|
450
|
+
it "should have a valid number of keys" do
|
439
451
|
@config.should have(3).items
|
440
452
|
end
|
441
453
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dployr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Aparicio
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 2.
|
48
|
+
version: 2.9.0
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 2.
|
55
|
+
version: 2.9.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: net-scp
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project: dployr
|
199
|
-
rubygems_version: 2.0.
|
199
|
+
rubygems_version: 2.0.6
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: Multicloud management and deployment with asteroids made simple
|