befog 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/befog.rb CHANGED
@@ -1 +1,12 @@
1
+ module Befog
2
+ VERSION = begin
3
+ path = File.expand_path("../../VERSION", Pathname.new(__FILE__).realpath)
4
+ File.read(path).chomp
5
+ end
6
+
7
+ def self.show_version
8
+ $stdout.puts "Befog Version #{VERSION}"
9
+ end
10
+ end
11
+
1
12
  require "befog/cli"
data/lib/befog/cli.rb CHANGED
@@ -50,6 +50,13 @@ module Befog
50
50
 
51
51
  def self.run(arguments)
52
52
  subcommand = arguments.shift
53
+ # TODO: Rejigger this so we can have top-level options
54
+ # instead of special-casing --version
55
+ if subcommand == "--version" or subcommand == "-v"
56
+ Befog.show_version
57
+ exit if arguments.empty?
58
+ subcommand = arguments.shift
59
+ end
53
60
  if subcommand && (command = COMMANDS[subcommand])
54
61
  command.run(CLI.parse(arguments))
55
62
  elsif subcommand
@@ -42,7 +42,7 @@ module Befog
42
42
 
43
43
  option :keypair,
44
44
  :short => :x,
45
- :description => "The keypair name to use with SSH"
45
+ :description => "The cloud provider SSH key pair name to use with the instances in this bank"
46
46
 
47
47
  option :group,
48
48
  :short => :g,
@@ -70,4 +70,4 @@ module Befog
70
70
  end
71
71
  end
72
72
  end
73
- end
73
+ end
@@ -21,9 +21,10 @@ module Befog
21
21
  def options ; @options||=[] ; end
22
22
 
23
23
  def run(options)
24
+ Befog.show_version if options[:version] or options[:v]
24
25
  new(options).run
25
26
  end
26
-
27
+
27
28
  end
28
29
 
29
30
  end
@@ -35,7 +35,9 @@ module Befog
35
35
  end
36
36
 
37
37
  def save
38
- File.open(File.expand_path(configuration_path),"w") { |f| YAML.dump(_configuration,f) }
38
+ # Make sure we load the configuration before opening the file for writing
39
+ configuration_for_writing = _configuration
40
+ File.open(configuration_path,"w") { |f| YAML.dump(configuration_for_writing,f) }
39
41
  $stdout.puts "Configuration written to: #{configuration_path}"
40
42
  end
41
43
 
@@ -40,18 +40,18 @@ module Befog
40
40
  end
41
41
  run_for_selected do |id|
42
42
  if options[:all] or count > 0
43
- threads << Thread.new do
43
+ # threads << Thread.new do
44
44
  safely do
45
45
  log "Deprovisioning server #{id} ..."
46
46
  compute.servers.get(id).destroy
47
47
  deleted << id
48
48
  count -= 1
49
49
  end
50
- end
50
+ # end
51
51
  end
52
52
  end
53
53
  $stdout.print "This may take a few minutes .."
54
- sleep 1 while threads.any? { |t| $stdout.print "."; $stdout.flush ; t.alive? }
54
+ # sleep 1 while threads.any? { |t| $stdout.print "."; $stdout.flush ; t.alive? }
55
55
  $stdout.print "\n"
56
56
  self.servers -= deleted
57
57
  save
@@ -24,7 +24,7 @@ module Befog
24
24
 
25
25
  option :all,
26
26
  :short => :a,
27
- :description => "Deprovision all selected servers"
27
+ :description => "Start all selected servers"
28
28
 
29
29
  def run
30
30
  run_for_selected do |id|
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: befog
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.2
5
+ version: 0.5.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Carlo Flores carlo@spire.io