dployr 0.0.4 → 0.0.5
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/lib/dployr/cli.rb +7 -0
- data/lib/dployr/commands/config.rb +1 -0
- data/lib/dployr/commands/execute.rb +1 -1
- data/lib/dployr/commands/info.rb +35 -0
- data/lib/dployr/commands/provision_test.rb +1 -1
- data/lib/dployr/commands/ssh.rb +1 -1
- data/lib/dployr/commands/start.rb +1 -1
- data/lib/dployr/commands/stop_destroy.rb +1 -1
- data/lib/dployr/compute/aws.rb +13 -3
- data/lib/dployr/compute/gce.rb +11 -3
- data/lib/dployr/scripts/default_hooks.rb +1 -1
- data/lib/dployr/scripts/local_shell.rb +6 -2
- data/lib/dployr/scripts/scp.rb +1 -1
- data/lib/dployr/scripts/shell.rb +6 -2
- data/lib/dployr/version.rb +1 -1
- data/lib/dployr.rb +1 -0
- data/spec/fixtures/german/Dployrfile.yml +4 -2
- data/spec/fixtures/german/real_test.rb +16 -0
- data/spec/fixtures/german/server_aws.info +0 -0
- data/spec/fixtures/german/server_gce.info +7565 -0
- metadata +12 -11
- data/spec/fixtures/hello/createExecUser.sh +0 -18
- data/spec/fixtures/hello/jetty +0 -562
- data/spec/fixtures/hello/jetty.sh +0 -28
- /data/spec/fixtures/{hello → german/hello}/hello.sh +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cb69bcafe1f40f150073a9ceedd816ab18edbe6
|
4
|
+
data.tar.gz: 986eee01920f5d35961069fa0d250d24d8685182
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2874793ccd7fd16b02f20fcc40ed355b3ef77b3190c7a2760619c27fe64ef00e7639eb23dc1bebf542afcc12e50936359627638d2931e22bafcf51b5ac52101
|
7
|
+
data.tar.gz: 8e0275679ba5c03b65b2b4ff29adcd304bc4cb0cf20634f0fbcb5415ab14f907adfbbed2e6013acb9ce793084f4439b2af95d4940431ed0cc87d57c5ef13245b
|
data/lib/dployr/cli.rb
CHANGED
@@ -14,6 +14,7 @@ opt_parser = OptionParser.new do |opt|
|
|
14
14
|
opt.separator " halt stop instances"
|
15
15
|
opt.separator " destroy destroy instances"
|
16
16
|
opt.separator " status retrieve the instances status"
|
17
|
+
opt.separator " info retrieve instance information and output it in YAML format"
|
17
18
|
opt.separator " test run remote test in instances"
|
18
19
|
opt.separator " deploy start, provision and test running instances"
|
19
20
|
opt.separator " provision instance provisioning"
|
@@ -44,6 +45,10 @@ opt_parser = OptionParser.new do |opt|
|
|
44
45
|
opt.on("-r", "--region REGION", "region to use (allow multiple values comma-separated)") do |v|
|
45
46
|
options[:region] = v
|
46
47
|
end
|
48
|
+
|
49
|
+
opt.on("-i", "--public-ip", "use public ip instead of private ip to when access instances") do |v|
|
50
|
+
options[:public_ip] = v
|
51
|
+
end
|
47
52
|
|
48
53
|
opt.on("-v", "-V", "--version", "version") do
|
49
54
|
puts Dployr::VERSION
|
@@ -69,6 +74,8 @@ when "destroy"
|
|
69
74
|
Dployr::Commands::StopDestroy.new options, "destroy"
|
70
75
|
when "status"
|
71
76
|
puts "Command currently not available"
|
77
|
+
when "info"
|
78
|
+
Dployr::Commands::Info.new options
|
72
79
|
when "provision"
|
73
80
|
Dployr::Commands::ProvisionTest.new options, "provision"
|
74
81
|
when "test"
|
@@ -19,7 +19,7 @@ module Dployr
|
|
19
19
|
@client = Dployr::Compute.const_get(@provider.to_sym).new @region
|
20
20
|
|
21
21
|
puts "Looking for #{@name} in #{@region}...".yellow
|
22
|
-
@ip = @client.get_ip
|
22
|
+
@ip = @client.get_ip(@name, options[:public_ip])
|
23
23
|
if @ip
|
24
24
|
puts "#{@name} found with IP #{@ip}".yellow
|
25
25
|
else
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'dployr/commands/base'
|
2
|
+
require 'dployr/compute/aws'
|
3
|
+
|
4
|
+
module Dployr
|
5
|
+
module Commands
|
6
|
+
class Info < Base
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
super options
|
10
|
+
begin
|
11
|
+
create
|
12
|
+
config = get_region_config options
|
13
|
+
|
14
|
+
@name = config[:attributes]["name"]
|
15
|
+
@provider = options[:provider].upcase
|
16
|
+
@region = options[:region]
|
17
|
+
|
18
|
+
@client = Dployr::Compute.const_get(@provider.to_sym).new @region
|
19
|
+
|
20
|
+
@info = @client.get_info @name
|
21
|
+
if @info
|
22
|
+
puts @info.to_yaml
|
23
|
+
else
|
24
|
+
raise "#{@name} not found"
|
25
|
+
end
|
26
|
+
|
27
|
+
rescue Exception => e
|
28
|
+
self.log.error e
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -19,7 +19,7 @@ module Dployr
|
|
19
19
|
@client = Dployr::Compute.const_get(@provider.to_sym).new @region
|
20
20
|
|
21
21
|
puts "Looking for #{@name} in #{@region}...".yellow
|
22
|
-
@ip = @client.get_ip
|
22
|
+
@ip = @client.get_ip(@name, options[:public_ip])
|
23
23
|
if @ip
|
24
24
|
puts "#{@name} found with IP #{@ip}".yellow
|
25
25
|
else
|
data/lib/dployr/commands/ssh.rb
CHANGED
@@ -20,7 +20,7 @@ module Dployr
|
|
20
20
|
@client = Dployr::Compute.const_get(@provider.to_sym).new @region
|
21
21
|
|
22
22
|
puts "Looking for #{@name} in #{@region}...".yellow
|
23
|
-
@ip = @client.get_ip
|
23
|
+
@ip = @client.get_ip(@name, options[:public_ip])
|
24
24
|
if @ip
|
25
25
|
puts "#{@name} found with IP #{@ip}".yellow
|
26
26
|
else
|
@@ -21,7 +21,7 @@ module Dployr
|
|
21
21
|
@client = Dployr::Compute.const_get(@provider.to_sym).new @region
|
22
22
|
|
23
23
|
puts "Looking for #{@name} in #{@region}...".yellow
|
24
|
-
@ip = @client.get_ip
|
24
|
+
@ip = @client.get_ip(@name, options[:public_ip])
|
25
25
|
|
26
26
|
Dployr::Scripts::Default_Hooks.new @ip, config, "start", self
|
27
27
|
rescue Exception => e
|
@@ -21,7 +21,7 @@ module Dployr
|
|
21
21
|
@client = Dployr::Compute.const_get(@provider.to_sym).new @region
|
22
22
|
|
23
23
|
puts "Looking for #{@name} in #{@region}...".yellow
|
24
|
-
@ip = @client.get_ip
|
24
|
+
@ip = @client.get_ip(@name, options[:public_ip])
|
25
25
|
if @ip
|
26
26
|
puts "#{@name} found with IP #{@ip}".yellow
|
27
27
|
else
|
data/lib/dployr/compute/aws.rb
CHANGED
@@ -17,9 +17,19 @@ module Dployr
|
|
17
17
|
@compute = Fog::Compute.new @options
|
18
18
|
end
|
19
19
|
|
20
|
-
def get_ip(name)
|
21
|
-
instance = get_instance(name, ["running"])
|
22
|
-
|
20
|
+
def get_ip(name, public)
|
21
|
+
instance = get_instance(name, ["running"]) # TODO: add starting states
|
22
|
+
if instance
|
23
|
+
if public
|
24
|
+
return instance.public_ip_address
|
25
|
+
else
|
26
|
+
return instance.private_ip_address
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_info(name)
|
32
|
+
get_instance(name, ["running", "stopped", "stopping"])
|
23
33
|
end
|
24
34
|
|
25
35
|
def destroy(name)
|
data/lib/dployr/compute/gce.rb
CHANGED
@@ -29,12 +29,20 @@ module Dployr
|
|
29
29
|
return nil
|
30
30
|
end
|
31
31
|
|
32
|
-
def get_ip(name)
|
32
|
+
def get_ip(name, public)
|
33
33
|
instance = get_instance(name, ["PROVISIONING", "STAGING", "RUNNING"])
|
34
34
|
if instance
|
35
|
-
|
35
|
+
if public
|
36
|
+
return instance.public_ip_address
|
37
|
+
else
|
38
|
+
return instance.private_ip_address
|
39
|
+
end
|
36
40
|
end
|
37
41
|
end
|
42
|
+
|
43
|
+
def get_info(name)
|
44
|
+
get_instance(name,["RUNNING", "STOPPED"])
|
45
|
+
end
|
38
46
|
|
39
47
|
def destroy(name)
|
40
48
|
instance = get_instance(name, ["RUNNING", "STOPPED"])
|
@@ -88,7 +96,7 @@ module Dployr
|
|
88
96
|
|
89
97
|
def start(attributes, region)
|
90
98
|
external_ip(attributes, region)
|
91
|
-
server = get_instance(attributes["name"], ["
|
99
|
+
server = get_instance(attributes["name"], ["STOPPED"])
|
92
100
|
if server
|
93
101
|
puts "Starting stopped instance for #{attributes["name"]} in #{region}...".yellow
|
94
102
|
server.start
|
@@ -16,9 +16,13 @@ module Dployr
|
|
16
16
|
arguments = @script["args"]
|
17
17
|
|
18
18
|
puts "Running local script '#{command} #{arguments}'".yellow
|
19
|
-
|
19
|
+
total_command = command
|
20
|
+
if arguments
|
21
|
+
total_command = command + ' ' + arguments
|
22
|
+
end
|
23
|
+
result = system(total_command)
|
20
24
|
if result == false
|
21
|
-
raise "Exit code non zero when running local script '#{
|
25
|
+
raise "Exit code non zero when running local script '#{total_command}'".yellow
|
22
26
|
else
|
23
27
|
puts "Local script '#{command} #{arguments}' finished succesfully".yellow
|
24
28
|
end
|
data/lib/dployr/scripts/scp.rb
CHANGED
@@ -10,7 +10,7 @@ module Dployr
|
|
10
10
|
Net::SCP.start(ip, username, :keys => [private_key_path]) do |scp|
|
11
11
|
source = script["source"]
|
12
12
|
target = script["target"]
|
13
|
-
puts "
|
13
|
+
puts "Copying #{source} -> #{target}".yellow
|
14
14
|
scp.upload(source, target, :recursive => true, :preserve => true)
|
15
15
|
end
|
16
16
|
rescue Exception => e
|
data/lib/dployr/scripts/shell.rb
CHANGED
@@ -22,9 +22,13 @@ module Dployr
|
|
22
22
|
arguments = @script["args"]
|
23
23
|
|
24
24
|
puts "Running remote script '#{command} #{arguments}'".yellow
|
25
|
-
|
25
|
+
total_command = command
|
26
|
+
if arguments
|
27
|
+
total_command = command + ' ' + arguments
|
28
|
+
end
|
29
|
+
result = ssh_exec!(ssh, total_command)
|
26
30
|
if result[:exit_code] > 0
|
27
|
-
raise "Exit code #{result[:exit_code]} when running script '#{
|
31
|
+
raise "Exit code #{result[:exit_code]} when running script '#{total_command}'".yellow
|
28
32
|
else
|
29
33
|
puts "Remote script '#{command} #{arguments}' finished succesfully".yellow
|
30
34
|
end
|
data/lib/dployr/version.rb
CHANGED
data/lib/dployr.rb
CHANGED
@@ -6,6 +6,7 @@ require 'dployr/config/create'
|
|
6
6
|
require 'dployr/config/file_utils'
|
7
7
|
require 'dployr/config/instance'
|
8
8
|
require 'dployr/commands/provision_test'
|
9
|
+
require 'dployr/commands/info'
|
9
10
|
require 'dployr/commands/start'
|
10
11
|
require 'dployr/commands/stop_destroy'
|
11
12
|
require 'dployr/commands/config'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#OPTIONS=" -f Dployrfile.yml -n german-template -p aws -r sa-east-1a"
|
2
|
+
OPTIONS=" -f Dployrfile.yml -n german-template -p gce -r europe-west1-a"
|
3
|
+
|
4
|
+
|
5
|
+
BIN="../../../bin/dployr"
|
6
|
+
COMMANDS = ["start", "provision", "halt", "start", "execute pre-provision", "destroy"]
|
7
|
+
|
8
|
+
COMMANDS.each do |cmd|
|
9
|
+
to_run = "#{BIN} #{cmd} #{OPTIONS}"
|
10
|
+
puts to_run
|
11
|
+
result = system(to_run)
|
12
|
+
if result == false
|
13
|
+
raise "ERROR"
|
14
|
+
end
|
15
|
+
puts "\n\n"
|
16
|
+
end
|
File without changes
|