dployr 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55e8744de1ada22c752a30e73a533774383b957a
4
- data.tar.gz: 71bd763bd9e8de49200a57c9622f6c142de98aec
3
+ metadata.gz: 3cb69bcafe1f40f150073a9ceedd816ab18edbe6
4
+ data.tar.gz: 986eee01920f5d35961069fa0d250d24d8685182
5
5
  SHA512:
6
- metadata.gz: 59247fbc73d154f5d8535adbc1e20584be2e5e243764260e033482f09b12f73f29513b7f2887f7676d5bd1706a733237c9257aed82533f5cf22aa4db00c4f1fc
7
- data.tar.gz: 964b34cf57543d3db61b460147d920b539ac7e40202dd5194488354fd21e8f3d29842d1038910b4602bbe0e719fe71a1767265a6f00d7fcc92839e798c5721c6
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"
@@ -38,6 +38,7 @@ module Dployr
38
38
  config = @dployr.config.get_config_all @attrs
39
39
  end
40
40
  unless config.nil?
41
+ puts @options.to_yaml
41
42
  puts config.to_yaml
42
43
  else
43
44
  raise "Missing configuration data"
@@ -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 @name
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 @name
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
@@ -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 @name
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 @name
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 @name
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
@@ -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
- instance.private_ip_address if instance
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)
@@ -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
- return instance.private_ip_address
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"], ["stopped", "stopping"])
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
@@ -15,7 +15,7 @@ module Dployr
15
15
  Dployr::Scripts::Hook.new @ip, config, "#{@stage}"
16
16
  end
17
17
  if @config[:scripts]["post-#{@stage}"]
18
- Dployr::Scripts::Hook.new @ip, config, "#{@stage}"
18
+ Dployr::Scripts::Hook.new @ip, config, "post-#{@stage}"
19
19
  end
20
20
  end
21
21
 
@@ -16,9 +16,13 @@ module Dployr
16
16
  arguments = @script["args"]
17
17
 
18
18
  puts "Running local script '#{command} #{arguments}'".yellow
19
- result = system(command + ' ' + arguments)
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 '#{command} #{arguments}'".yellow
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
@@ -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 "Coping #{source} -> #{target}".yellow
13
+ puts "Copying #{source} -> #{target}".yellow
14
14
  scp.upload(source, target, :recursive => true, :preserve => true)
15
15
  end
16
16
  rescue Exception => e
@@ -22,9 +22,13 @@ module Dployr
22
22
  arguments = @script["args"]
23
23
 
24
24
  puts "Running remote script '#{command} #{arguments}'".yellow
25
- result = ssh_exec!(ssh, command + ' ' + arguments)
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 '#{command} #{arguments}'".yellow
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
@@ -1,3 +1,3 @@
1
1
  module Dployr
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
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'
@@ -9,8 +9,10 @@ german-template:
9
9
  - source: ./hello
10
10
  target: /tmp
11
11
  provision:
12
- - remote_path: /tmp/hello/jetty.sh
13
- args: ""
12
+ - remote_path: /tmp/hello/hello.sh
13
+ post-halt:
14
+ - local_path: sleep
15
+ args: "50"
14
16
  providers:
15
17
  aws:
16
18
  attributes:
@@ -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