fission 0.4.0.beta.2 → 0.4.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +1 -1
- data/lib/fission/command/status.rb +7 -25
- data/lib/fission/version.rb +1 -1
- data/lib/fission/vm.rb +42 -0
- data/spec/fission/command/status_spec.rb +12 -30
- data/spec/fission/vm_spec.rb +38 -0
- metadata +39 -45
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
## 0.4.0
|
6
6
|
* major internal refactoring for usage as a lib
|
7
|
-
* add fix for loading a custom vmrun_bin in ~/.fissionrc
|
7
|
+
* add fix for loading a custom vmrun_bin in ~/.fissionrc (issue #8 )
|
8
8
|
|
9
9
|
## 0.3.0 (09/16/2011)
|
10
10
|
* add ability to suspend all running VMs ('--all')
|
@@ -3,34 +3,16 @@ module Fission
|
|
3
3
|
class Status < Command
|
4
4
|
|
5
5
|
def execute
|
6
|
-
response = VM.
|
7
|
-
|
8
|
-
|
6
|
+
response = VM.all_with_status
|
7
|
+
unless response.successful?
|
8
|
+
output_and_exit "There was an error getting the status of the VMs. The error was:\n#{response.message}", response.code
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
all_running_vm_names = response.data.collect { |v| v.name }
|
14
|
-
else
|
15
|
-
output_and_exit "There was an error getting the list of running VMs. The error was:\n#{response.message}", response.code
|
16
|
-
end
|
17
|
-
|
18
|
-
vm_names = all_vms.collect { |v| v.name }
|
19
|
-
|
20
|
-
longest_vm_name = vm_names.max { |a,b| a.length <=> b.length }
|
21
|
-
|
22
|
-
all_vms.each do |vm|
|
23
|
-
if all_running_vm_names.include? vm.name
|
24
|
-
status = '[running]'
|
25
|
-
else
|
26
|
-
if vm.suspend_file_exists?
|
27
|
-
status = '[suspended]'
|
28
|
-
else
|
29
|
-
status = '[not running]'
|
30
|
-
end
|
31
|
-
end
|
11
|
+
vms_status = response.data
|
12
|
+
longest_vm_name = vms_status.keys.max { |a,b| a.length <=> b.length }
|
32
13
|
|
33
|
-
|
14
|
+
vms_status.each_pair do |vm_name, status|
|
15
|
+
output_printf "%-#{longest_vm_name.length}s [%s]\n", vm_name, status
|
34
16
|
end
|
35
17
|
end
|
36
18
|
|
data/lib/fission/version.rb
CHANGED
data/lib/fission/vm.rb
CHANGED
@@ -564,6 +564,48 @@ module Fission
|
|
564
564
|
response
|
565
565
|
end
|
566
566
|
|
567
|
+
# Public: Provides a list of all of the VMs and their associated status
|
568
|
+
#
|
569
|
+
# Examples
|
570
|
+
#
|
571
|
+
# Fission::VM.all_with_status.data
|
572
|
+
# # => { 'vm1' => 'running', 'vm2' => 'suspended', 'vm3' => 'not running'}
|
573
|
+
#
|
574
|
+
# Returns a Response with the result.
|
575
|
+
# If successful, the Response's data attribute will be a Hash of with the VM
|
576
|
+
# names as keys and their status as the values.
|
577
|
+
# If there is an error, an unsuccessful Repsonse will be returned.
|
578
|
+
def self.all_with_status
|
579
|
+
all_response = all
|
580
|
+
return all_response unless all_response.successful?
|
581
|
+
|
582
|
+
all_vms = all_response.data
|
583
|
+
|
584
|
+
running_response = all_running
|
585
|
+
return running_response unless running_response.successful?
|
586
|
+
|
587
|
+
response = Response.new :code => 0
|
588
|
+
|
589
|
+
all_running_vm_names = running_response.data.collect { |v| v.name }
|
590
|
+
|
591
|
+
response.data = all_vms.inject({}) do |result, vm|
|
592
|
+
if all_running_vm_names.include? vm.name
|
593
|
+
status = 'running'
|
594
|
+
else
|
595
|
+
if vm.suspend_file_exists?
|
596
|
+
status = 'suspended'
|
597
|
+
else
|
598
|
+
status = 'not running'
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
result[vm.name] = status
|
603
|
+
result
|
604
|
+
end
|
605
|
+
|
606
|
+
response
|
607
|
+
end
|
608
|
+
|
567
609
|
# Public: Creates a new VM which is a clone of an existing VM. As Fusion
|
568
610
|
# doesn't provide a native cloning mechanism, this is a best effort. This
|
569
611
|
# essentially is a directory copy with updates to relevant files. It's
|
@@ -4,61 +4,43 @@ describe Fission::Command::Status do
|
|
4
4
|
include_context 'command_setup'
|
5
5
|
|
6
6
|
before do
|
7
|
-
@
|
8
|
-
|
9
|
-
|
10
|
-
@
|
11
|
-
@vm_4 = Fission::VM.new 'blah'
|
7
|
+
@vms_status = { 'foo' => 'running',
|
8
|
+
'bar' => 'suspended',
|
9
|
+
'baz' => 'not running' }
|
10
|
+
@all_status_response_mock = mock('response')
|
12
11
|
end
|
13
12
|
|
14
13
|
describe 'execute' do
|
15
14
|
before do
|
16
|
-
|
17
|
-
|
18
|
-
Fission::VM.should_receive(:all).and_return(@all_response_mock)
|
19
|
-
Fission::VM.stub(:all_running).and_return(@all_running_response_mock)
|
15
|
+
Fission::VM.should_receive(:all_with_status).
|
16
|
+
and_return(@all_status_response_mock)
|
20
17
|
end
|
21
18
|
|
22
19
|
describe 'when successful' do
|
23
20
|
before do
|
24
|
-
@
|
21
|
+
@all_status_response_mock.stub_as_successful @vms_status
|
25
22
|
end
|
26
23
|
|
27
|
-
it 'should output the VMs
|
24
|
+
it 'should output the VMs and their status' do
|
28
25
|
command = Fission::Command::Status.new
|
29
26
|
command.execute
|
30
27
|
|
31
28
|
@string_io.string.should match /foo.+\[running\]/
|
32
|
-
@string_io.string.should match /
|
33
|
-
|
34
|
-
|
35
|
-
it 'should output the VMs which are not running' do
|
36
|
-
command = Fission::Command::Status.new
|
37
|
-
command.execute
|
38
|
-
|
39
|
-
@string_io.string.should match /bar.+\[not running\]/
|
29
|
+
@string_io.string.should match /bar.+\[suspended\]/
|
30
|
+
@string_io.string.should match /baz.+\[not running\]/
|
40
31
|
end
|
41
|
-
|
42
|
-
it 'should output the VMs which are suspended' do
|
43
|
-
@vm_4.stub(:suspend_file_exists?).and_return(true)
|
44
|
-
command = Fission::Command::Status.new
|
45
|
-
command.execute
|
46
|
-
|
47
|
-
@string_io.string.should match /blah.+\[suspended\]/
|
48
|
-
end
|
49
|
-
|
50
32
|
end
|
51
33
|
|
52
34
|
describe 'when unsuccessful' do
|
53
35
|
before do
|
54
|
-
@
|
36
|
+
@all_status_response_mock.stub_as_unsuccessful
|
55
37
|
end
|
56
38
|
|
57
39
|
it 'should output an error and exit if there was an error getting the list of running VMs' do
|
58
40
|
command = Fission::Command::Status.new
|
59
41
|
lambda { command.execute }.should raise_error SystemExit
|
60
42
|
|
61
|
-
@string_io.string.should match /There was an error getting the
|
43
|
+
@string_io.string.should match /There was an error getting the status of the VMs.+it blew up/m
|
62
44
|
end
|
63
45
|
end
|
64
46
|
end
|
data/spec/fission/vm_spec.rb
CHANGED
@@ -1078,6 +1078,44 @@ ethernet1.generatedAddressenable = "TRUE"'
|
|
1078
1078
|
|
1079
1079
|
end
|
1080
1080
|
|
1081
|
+
describe 'self.all_with_status' do
|
1082
|
+
before do
|
1083
|
+
@vm_1 = Fission::VM.new 'foo'
|
1084
|
+
@vm_2 = Fission::VM.new 'bar'
|
1085
|
+
@vm_2.stub(:suspend_file_exists?).and_return('true')
|
1086
|
+
@vm_3 = Fission::VM.new 'baz'
|
1087
|
+
|
1088
|
+
@all_vms_response_mock = mock('all_vms_mock')
|
1089
|
+
@all_vms_response_mock.stub_as_successful [@vm_1, @vm_2, @vm_3]
|
1090
|
+
|
1091
|
+
@all_running_response_mock = mock('all_running_mock')
|
1092
|
+
@all_running_response_mock.stub_as_successful [@vm_1]
|
1093
|
+
|
1094
|
+
Fission::VM.stub(:all).and_return(@all_vms_response_mock)
|
1095
|
+
Fission::VM.stub(:all_running).and_return(@all_running_response_mock)
|
1096
|
+
end
|
1097
|
+
|
1098
|
+
it 'should return a sucessful response with the VMs and their status' do
|
1099
|
+
response = Fission::VM.all_with_status
|
1100
|
+
response.should be_a_successful_response
|
1101
|
+
response.data.should == { 'foo' => 'running',
|
1102
|
+
'bar' => 'suspended',
|
1103
|
+
'baz' => 'not running' }
|
1104
|
+
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
it 'should return an unsuccessful response if unable to get all of the VMs' do
|
1108
|
+
@all_vms_response_mock.stub_as_unsuccessful
|
1109
|
+
Fission::VM.all_with_status.should be_an_unsuccessful_response
|
1110
|
+
end
|
1111
|
+
|
1112
|
+
it 'should return an unsuccessful repsonse if unable to get the running VMs' do
|
1113
|
+
@all_running_response_mock.stub_as_unsuccessful
|
1114
|
+
Fission::VM.all_with_status.should be_an_unsuccessful_response
|
1115
|
+
end
|
1116
|
+
|
1117
|
+
end
|
1118
|
+
|
1081
1119
|
describe 'delete' do
|
1082
1120
|
before do
|
1083
1121
|
@running_response_mock = mock('running?')
|
metadata
CHANGED
@@ -1,60 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: fission
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0.beta.3
|
4
5
|
prerelease: 6
|
5
|
-
version: 0.4.0.beta.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Tommy Bishop
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-30 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: CFPropertyList
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70357096609200 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
18
|
+
requirements:
|
21
19
|
- - ~>
|
22
|
-
- !ruby/object:Gem::Version
|
20
|
+
- !ruby/object:Gem::Version
|
23
21
|
version: 2.0.17
|
24
22
|
type: :runtime
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: rspec
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: *70357096609200
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70357096608700 !ruby/object:Gem::Requirement
|
30
28
|
none: false
|
31
|
-
requirements:
|
29
|
+
requirements:
|
32
30
|
- - ~>
|
33
|
-
- !ruby/object:Gem::Version
|
31
|
+
- !ruby/object:Gem::Version
|
34
32
|
version: 2.6.0
|
35
33
|
type: :development
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: fakefs
|
39
34
|
prerelease: false
|
40
|
-
|
35
|
+
version_requirements: *70357096608700
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: fakefs
|
38
|
+
requirement: &70357096608240 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
|
-
requirements:
|
40
|
+
requirements:
|
43
41
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
42
|
+
- !ruby/object:Gem::Version
|
45
43
|
version: 0.3.2
|
46
44
|
type: :development
|
47
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70357096608240
|
48
47
|
description: A simple utility to manage VMware Fusion VMs from the command line
|
49
|
-
email:
|
48
|
+
email:
|
50
49
|
- bishop.thomas@gmail.com
|
51
|
-
executables:
|
50
|
+
executables:
|
52
51
|
- fission
|
53
52
|
extensions: []
|
54
|
-
|
55
53
|
extra_rdoc_files: []
|
56
|
-
|
57
|
-
files:
|
54
|
+
files:
|
58
55
|
- .gitignore
|
59
56
|
- .rspec
|
60
57
|
- .rvmrc
|
@@ -117,32 +114,29 @@ files:
|
|
117
114
|
- spec/spec_helper.rb
|
118
115
|
homepage: https://github.com/thbishop/fission
|
119
116
|
licenses: []
|
120
|
-
|
121
117
|
post_install_message:
|
122
118
|
rdoc_options: []
|
123
|
-
|
124
|
-
require_paths:
|
119
|
+
require_paths:
|
125
120
|
- lib
|
126
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
122
|
none: false
|
128
|
-
requirements:
|
129
|
-
- -
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version:
|
132
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
128
|
none: false
|
134
|
-
requirements:
|
135
|
-
- -
|
136
|
-
- !ruby/object:Gem::Version
|
129
|
+
requirements:
|
130
|
+
- - ! '>'
|
131
|
+
- !ruby/object:Gem::Version
|
137
132
|
version: 1.3.1
|
138
133
|
requirements: []
|
139
|
-
|
140
134
|
rubyforge_project: fission
|
141
|
-
rubygems_version: 1.8.
|
135
|
+
rubygems_version: 1.8.10
|
142
136
|
signing_key:
|
143
137
|
specification_version: 3
|
144
138
|
summary: Command line tool to manage VMware Fusion VMs
|
145
|
-
test_files:
|
139
|
+
test_files:
|
146
140
|
- spec/contexts/command.rb
|
147
141
|
- spec/fission/cli_spec.rb
|
148
142
|
- spec/fission/command/clone_spec.rb
|