virtualmaster 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  pkg/*
4
4
  vendor/bundle
5
5
  vendor/cache
6
+ coverage
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- virtualmaster (0.1.3)
4
+ virtualmaster (0.1.4)
5
5
  commander (~> 4.1.2)
6
6
  deltacloud-client (~> 0.5.0)
7
7
  net-ssh (~> 2.3.0)
@@ -16,8 +16,9 @@ GEM
16
16
  nokogiri (>= 1.4.3)
17
17
  rest-client (>= 1.6.1)
18
18
  diff-lcs (1.1.3)
19
- highline (1.6.11)
19
+ highline (1.6.12)
20
20
  mime-types (1.18)
21
+ multi_json (1.3.5)
21
22
  net-ssh (2.3.0)
22
23
  nokogiri (1.5.2)
23
24
  rest-client (1.6.7)
@@ -30,6 +31,12 @@ GEM
30
31
  rspec-expectations (2.9.1)
31
32
  diff-lcs (~> 1.1.3)
32
33
  rspec-mocks (2.9.0)
34
+ simplecov (0.6.4)
35
+ multi_json (~> 1.0)
36
+ simplecov-html (~> 0.5.3)
37
+ simplecov-html (0.5.3)
38
+ simplecov-rcov (0.2.3)
39
+ simplecov (>= 0.4.1)
33
40
  terminal-table (1.4.5)
34
41
 
35
42
  PLATFORMS
@@ -37,4 +44,6 @@ PLATFORMS
37
44
 
38
45
  DEPENDENCIES
39
46
  rspec (~> 2)
47
+ simplecov
48
+ simplecov-rcov
40
49
  virtualmaster!
@@ -17,6 +17,10 @@ program :help_formatter, :compact
17
17
 
18
18
  default_command :help
19
19
 
20
+ global_option '-c', '--config FILE', String, 'Config file to use (~/.virtualmaster is default)' do |file|
21
+ VirtualMaster::CLI.config_file(file)
22
+ end
23
+
20
24
  VirtualMaster::CLI.run do
21
25
  # load callback
22
26
  callback_files = File.join(File.dirname(__FILE__), "../lib/vmaster/callbacks/*.rb")
@@ -32,5 +36,3 @@ VirtualMaster::CLI.run do
32
36
  end
33
37
 
34
38
  Commander::Runner.instance.run!
35
-
36
-
@@ -3,41 +3,52 @@ require 'deltacloud'
3
3
 
4
4
  module VirtualMaster
5
5
  class CLI
6
+ @@config_file = nil
6
7
  @@api = nil
7
8
  @@config = nil
8
9
  @@callbacks = []
9
10
 
10
11
  def self.run
11
- # load config
12
- config_file = File.join(ENV["HOME"], ".virtualmaster")
13
- if File.exists? config_file
14
- config = YAML::load(File.open(config_file))
15
-
16
- @@config = config.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
17
-
18
- unless @@config[:profiles]
19
- puts "WARNING: Please, reconfigure virtualmaster-cli (delete your '~/.virtualmaster' and run `virtualmaster config` again). This way you can use custom instance profiles correctly (new in version 0.0.5)"
20
- puts
21
- end
22
-
23
- begin
24
- @@api = DeltaCloud.new(@@config[:username], @@config[:password], VirtualMaster::DEFAULT_URL)
25
- rescue DeltaCloud::API::BackendError => e
26
- abort "Invalid API response: #{e.message}"
27
- rescue Exception => e
28
- abort "Unable to connect to Virtualmaster's DeltaCloud API: #{e.message}"
29
- end
30
- end
12
+ @@config_file = File.join(ENV["HOME"], ".virtualmaster")
31
13
 
32
14
  yield
33
15
  end
34
16
 
17
+ def self.config_file(config)
18
+ @@config_file = config
19
+ end
20
+
35
21
  def self.api
22
+ self.config unless @@config
23
+
36
24
  abort "No configuration available! Please run 'virtualmaster config' first!" unless @@api
37
25
  @@api
38
26
  end
39
27
 
40
28
  def self.config
29
+ unless @@config
30
+ if File.exists? @@config_file
31
+ config = YAML::load(File.open(@@config_file))
32
+
33
+ @@config = config.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
34
+
35
+ unless @@config[:profiles]
36
+ puts "WARNING: Please, reconfigure virtualmaster-cli (delete your '~/.virtualmaster' and run `virtualmaster config` again). This way you can use custom instance profiles correctly (new in version 0.0.5)"
37
+ puts
38
+ end
39
+
40
+ begin
41
+ @@api = DeltaCloud.new(@@config[:username], @@config[:password], VirtualMaster::DEFAULT_URL)
42
+ rescue DeltaCloud::API::BackendError => e
43
+ abort "Invalid API response: #{e.message}"
44
+ rescue Exception => e
45
+ abort "Unable to connect to Virtualmaster's DeltaCloud API: #{e.message}"
46
+ end
47
+ else
48
+ abort "Specified configuration file (#{config_file}) does not exist!"
49
+ end
50
+ end
51
+
41
52
  @@config
42
53
  end
43
54
 
@@ -1,5 +1,5 @@
1
1
  module VirtualMaster
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
 
4
4
  def self.cli_spec_version
5
5
  VERSION.to_f.to_s
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "VirtualMaster commands" do
3
+ describe "VirtualMaster CLI" do
4
4
  before :each do
5
5
  @runner = Commander::Runner.instance
6
6
  end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'deltacloud'
3
+ require 'vmaster/helpers'
4
+
5
+ describe "DeltaCloud API integration" do
6
+ it "should return HTTP 401 when called without valid credentials" do
7
+ lambda {
8
+ DeltaCloud.new(nil,nil, VirtualMaster::DEFAULT_URL)
9
+ }.should raise_error(DeltaCloud::API::BackendError, "401 : Not authorized / Invalid credentials")
10
+ end
11
+ end
@@ -1,7 +1,23 @@
1
1
  $:.unshift File.dirname(__FILE__) + '/../lib'
2
2
 
3
+ if ENV['COVERAGE']
4
+ require 'simplecov'
5
+ require 'simplecov-rcov'
6
+
7
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
8
+
9
+ SimpleCov.start do
10
+ add_filter '/vendor'
11
+ add_filter '/spec'
12
+ end
13
+ end
14
+
3
15
  require 'vmaster'
4
16
 
17
+ # manually load commands
18
+ require 'vmaster/config_command'
19
+ require 'vmaster/server_commands'
20
+
5
21
  program :name, "virtualmaster"
6
22
  program :version, VirtualMaster::VERSION
7
23
  program :description, "Virtualmaster command line interface"
@@ -11,3 +27,5 @@ default_command :test
11
27
 
12
28
  command :test do |c|
13
29
  end
30
+
31
+
@@ -28,4 +28,6 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency "net-ssh", "~> 2.3.0"
29
29
 
30
30
  s.add_development_dependency "rspec", "~> 2"
31
+ s.add_development_dependency "simplecov"
32
+ s.add_development_dependency "simplecov-rcov"
31
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtualmaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-16 00:00:00.000000000 Z
12
+ date: 2012-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
16
- requirement: &70276151073440 !ruby/object:Gem::Requirement
16
+ requirement: &70110396604660 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.1.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70276151073440
24
+ version_requirements: *70110396604660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: deltacloud-client
27
- requirement: &70276151071480 !ruby/object:Gem::Requirement
27
+ requirement: &70110396603860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.5.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70276151071480
35
+ version_requirements: *70110396603860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: terminal-table
38
- requirement: &70276151069480 !ruby/object:Gem::Requirement
38
+ requirement: &70110396603080 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.4.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70276151069480
46
+ version_requirements: *70110396603080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: net-ssh
49
- requirement: &70276151067760 !ruby/object:Gem::Requirement
49
+ requirement: &70110396602420 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.3.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70276151067760
57
+ version_requirements: *70110396602420
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70276151065760 !ruby/object:Gem::Requirement
60
+ requirement: &70110396601400 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,29 @@ dependencies:
65
65
  version: '2'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70276151065760
68
+ version_requirements: *70110396601400
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: &70110396600160 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70110396600160
80
+ - !ruby/object:Gem::Dependency
81
+ name: simplecov-rcov
82
+ requirement: &70110396598020 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70110396598020
69
91
  description: Command line interface to Virtualmaster. Control your virtual infrastructure.
70
92
  email:
71
93
  - radim@laststation.net
@@ -92,6 +114,7 @@ files:
92
114
  - lib/vmaster/server_commands.rb
93
115
  - lib/vmaster/version.rb
94
116
  - spec/commands_spec.rb
117
+ - spec/deltacloud_spec.rb
95
118
  - spec/spec_helper.rb
96
119
  - virtualmaster.gemspec
97
120
  homepage: https://github.com/virtualmaster/virtualmaster-cli
@@ -120,4 +143,5 @@ specification_version: 3
120
143
  summary: Command line interface to Virtualmaster
121
144
  test_files:
122
145
  - spec/commands_spec.rb
146
+ - spec/deltacloud_spec.rb
123
147
  - spec/spec_helper.rb