fission 0.4.0 → 0.5.0.beta.1
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.
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +12 -3
- data/README.md +45 -19
- data/bin/fission +1 -1
- data/fission.gemspec +3 -2
- data/lib/fission.rb +15 -0
- data/lib/fission/action/shell_executor.rb +37 -0
- data/lib/fission/action/snapshot/creator.rb +81 -0
- data/lib/fission/action/snapshot/deleter.rb +85 -0
- data/lib/fission/action/snapshot/lister.rb +90 -0
- data/lib/fission/action/snapshot/reverter.rb +81 -0
- data/lib/fission/action/vm/cloner.rb +191 -0
- data/lib/fission/action/vm/deleter.rb +73 -0
- data/lib/fission/action/vm/lister.rb +138 -0
- data/lib/fission/action/vm/starter.rb +88 -0
- data/lib/fission/action/vm/stopper.rb +79 -0
- data/lib/fission/action/vm/suspender.rb +68 -0
- data/lib/fission/cli.rb +21 -117
- data/lib/fission/command.rb +39 -0
- data/lib/fission/command/clone.rb +11 -6
- data/lib/fission/command/delete.rb +11 -6
- data/lib/fission/command/info.rb +62 -0
- data/lib/fission/command/snapshot_create.rb +9 -3
- data/lib/fission/command/snapshot_delete.rb +38 -0
- data/lib/fission/command/snapshot_list.rb +9 -3
- data/lib/fission/command/snapshot_revert.rb +9 -3
- data/lib/fission/command/start.rb +11 -6
- data/lib/fission/command/status.rb +9 -1
- data/lib/fission/command/stop.rb +9 -3
- data/lib/fission/command/suspend.rb +11 -6
- data/lib/fission/command_helpers.rb +18 -4
- data/lib/fission/command_line_parser.rb +189 -0
- data/lib/fission/config.rb +1 -1
- data/lib/fission/fusion.rb +3 -4
- data/lib/fission/lease.rb +2 -1
- data/lib/fission/metadata.rb +6 -1
- data/lib/fission/response.rb +17 -9
- data/lib/fission/version.rb +1 -1
- data/lib/fission/vm.rb +142 -382
- data/lib/fission/vm_configuration.rb +79 -0
- data/spec/fission/action/execute_shell_command_spec.rb +25 -0
- data/spec/fission/action/snapshot/creator_spec.rb +77 -0
- data/spec/fission/action/snapshot/deleter_spec.rb +84 -0
- data/spec/fission/action/snapshot/lister_spec.rb +67 -0
- data/spec/fission/action/snapshot/reverter_spec.rb +76 -0
- data/spec/fission/action/vm/cloner_spec.rb +198 -0
- data/spec/fission/action/vm/deleter_spec.rb +79 -0
- data/spec/fission/action/vm/lister_spec.rb +164 -0
- data/spec/fission/action/vm/starter_spec.rb +88 -0
- data/spec/fission/action/vm/stopper_spec.rb +71 -0
- data/spec/fission/action/vm/suspender_spec.rb +59 -0
- data/spec/fission/cli_spec.rb +32 -157
- data/spec/fission/command/clone_spec.rb +9 -3
- data/spec/fission/command/delete_spec.rb +11 -3
- data/spec/fission/command/info_spec.rb +130 -0
- data/spec/fission/command/snapshot_create_spec.rb +11 -3
- data/spec/fission/command/snapshot_delete_spec.rb +74 -0
- data/spec/fission/command/snapshot_list_spec.rb +11 -3
- data/spec/fission/command/snapshot_revert_spec.rb +11 -3
- data/spec/fission/command/start_spec.rb +11 -3
- data/spec/fission/command/status_spec.rb +16 -5
- data/spec/fission/command/stop_spec.rb +11 -3
- data/spec/fission/command/suspend_spec.rb +11 -3
- data/spec/fission/command_helpers_spec.rb +27 -5
- data/spec/fission/command_line_parser_spec.rb +267 -0
- data/spec/fission/command_spec.rb +16 -1
- data/spec/fission/config_spec.rb +3 -3
- data/spec/fission/fusion_spec.rb +11 -6
- data/spec/fission/lease_spec.rb +81 -45
- data/spec/fission/metadata_spec.rb +29 -6
- data/spec/fission/response_spec.rb +20 -9
- data/spec/fission/ui_spec.rb +1 -1
- data/spec/fission/vm_configuration_spec.rb +132 -0
- data/spec/fission/vm_spec.rb +393 -750
- data/spec/helpers/command_helpers.rb +1 -1
- metadata +93 -15
- data/.rvmrc +0 -1
@@ -1,7 +1,6 @@
|
|
1
1
|
module Fission
|
2
2
|
class Command
|
3
3
|
class Clone < Command
|
4
|
-
include Fission::CommandHelpers
|
5
4
|
|
6
5
|
def initialize(args=[])
|
7
6
|
super
|
@@ -9,9 +8,8 @@ module Fission
|
|
9
8
|
end
|
10
9
|
|
11
10
|
def execute
|
12
|
-
|
13
|
-
|
14
|
-
incorrect_arguments 'clone' unless @args.count > 1
|
11
|
+
super
|
12
|
+
incorrect_arguments unless @args.count > 1
|
15
13
|
|
16
14
|
source_vm = Fission::VM.new @args.first
|
17
15
|
target_vm = Fission::VM.new @args[1]
|
@@ -40,8 +38,11 @@ module Fission
|
|
40
38
|
|
41
39
|
def option_parser
|
42
40
|
optparse = OptionParser.new do |opts|
|
43
|
-
opts.banner = "
|
44
|
-
|
41
|
+
opts.banner = "Usage: fission clone SOURCE_VM TARGET_VM [OPTIONS]"
|
42
|
+
opts.separator ''
|
43
|
+
opts.separator 'Clones SOURCE_VM to a new VM (TARGET_VM).'
|
44
|
+
opts.separator ''
|
45
|
+
opts.separator 'OPTIONS:'
|
45
46
|
opts.on '--start', 'Start the VM after cloning' do
|
46
47
|
@options.start = true
|
47
48
|
end
|
@@ -50,6 +51,10 @@ module Fission
|
|
50
51
|
optparse
|
51
52
|
end
|
52
53
|
|
54
|
+
def summary
|
55
|
+
'Clone a VM'
|
56
|
+
end
|
57
|
+
|
53
58
|
end
|
54
59
|
end
|
55
60
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Fission
|
2
2
|
class Command
|
3
3
|
class Delete < Command
|
4
|
-
include Fission::CommandHelpers
|
5
4
|
|
6
5
|
def initialize(args=[])
|
7
6
|
super
|
@@ -9,9 +8,8 @@ module Fission
|
|
9
8
|
end
|
10
9
|
|
11
10
|
def execute
|
12
|
-
|
13
|
-
|
14
|
-
incorrect_arguments 'delete' if @args.count < 1
|
11
|
+
super
|
12
|
+
incorrect_arguments if @args.count < 1
|
15
13
|
|
16
14
|
vm = VM.new @args.first
|
17
15
|
|
@@ -54,8 +52,11 @@ module Fission
|
|
54
52
|
|
55
53
|
def option_parser
|
56
54
|
optparse = OptionParser.new do |opts|
|
57
|
-
opts.banner = "
|
58
|
-
|
55
|
+
opts.banner = "Usage: fission delete TARGET_VM [OPTIONS]"
|
56
|
+
opts.separator ''
|
57
|
+
opts.separator 'Deletes TARGET_VM.'
|
58
|
+
opts.separator ''
|
59
|
+
opts.separator 'OPTIONS:'
|
59
60
|
opts.on '--force', "Stop the VM if it's running and then delete it" do
|
60
61
|
@options.force = true
|
61
62
|
end
|
@@ -64,6 +65,10 @@ module Fission
|
|
64
65
|
optparse
|
65
66
|
end
|
66
67
|
|
68
|
+
def summary
|
69
|
+
'Delete a VM'
|
70
|
+
end
|
71
|
+
|
67
72
|
end
|
68
73
|
end
|
69
74
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Fission
|
2
|
+
class Command
|
3
|
+
class Info < Command
|
4
|
+
|
5
|
+
def execute
|
6
|
+
super
|
7
|
+
incorrect_arguments unless @args.count == 1
|
8
|
+
|
9
|
+
vm = VM.new @args.first
|
10
|
+
|
11
|
+
output "name: #{vm.name}"
|
12
|
+
|
13
|
+
guest_os_response = vm.guestos
|
14
|
+
|
15
|
+
if guest_os_response.successful?
|
16
|
+
os = guest_os_response.data.empty? ? 'unknown' : guest_os_response.data
|
17
|
+
output "os: #{os}"
|
18
|
+
else
|
19
|
+
output_and_exit "There was an error getting the OS info. The error was:\n#{guest_os_response.message}", guest_os_response.code
|
20
|
+
end
|
21
|
+
|
22
|
+
hardware_response = vm.hardware_info
|
23
|
+
|
24
|
+
if hardware_response.successful?
|
25
|
+
hardware_response.data.each_pair do |k, v|
|
26
|
+
output "#{k}: #{v}"
|
27
|
+
end
|
28
|
+
else
|
29
|
+
output_and_exit "There was an error getting the hardware info. The error was:\n#{hardware_response.message}", hardware_response.code
|
30
|
+
end
|
31
|
+
|
32
|
+
network_response = vm.network_info
|
33
|
+
|
34
|
+
if network_response.successful?
|
35
|
+
network_response.data.each_pair do |int, data|
|
36
|
+
data.each_pair do |k, v|
|
37
|
+
output "#{int} #{k.gsub(/[-_]/, ' ')}: #{v}"
|
38
|
+
end
|
39
|
+
output ""
|
40
|
+
end
|
41
|
+
else
|
42
|
+
output_and_exit "There was an error getting the network info. The error was:\n#{network_response.message}", network_response.code
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def option_parser
|
47
|
+
optparse = OptionParser.new do |opts|
|
48
|
+
opts.banner = 'Usage: fission info TARGET_VM'
|
49
|
+
opts.separator ''
|
50
|
+
opts.separator 'Lists known information about TARGET_VM'
|
51
|
+
end
|
52
|
+
|
53
|
+
optparse
|
54
|
+
end
|
55
|
+
|
56
|
+
def summary
|
57
|
+
'Show information for a VM'
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Fission
|
2
2
|
class Command
|
3
3
|
class SnapshotCreate < Command
|
4
|
-
include Fission::CommandHelpers
|
5
4
|
|
6
5
|
def execute
|
7
|
-
|
6
|
+
super
|
7
|
+
incorrect_arguments unless @args.count == 2
|
8
8
|
|
9
9
|
vm = VM.new @args[0]
|
10
10
|
snap_name = @args[1]
|
@@ -21,12 +21,18 @@ module Fission
|
|
21
21
|
|
22
22
|
def option_parser
|
23
23
|
optparse = OptionParser.new do |opts|
|
24
|
-
opts.banner = "
|
24
|
+
opts.banner = "Usage: fission snapshot create TARGET_VM SNAPSHOT_NAME"
|
25
|
+
opts.separator ''
|
26
|
+
opts.separator 'Creates a snapshot of TARGET_VM named SNAPSHOT_NAME'
|
25
27
|
end
|
26
28
|
|
27
29
|
optparse
|
28
30
|
end
|
29
31
|
|
32
|
+
def summary
|
33
|
+
'Create a snapshot of a VM'
|
34
|
+
end
|
35
|
+
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fission
|
2
|
+
class Command
|
3
|
+
class SnapshotDelete < Command
|
4
|
+
|
5
|
+
def execute
|
6
|
+
super
|
7
|
+
incorrect_arguments unless @args.count == 2
|
8
|
+
|
9
|
+
vm = VM.new @args[0]
|
10
|
+
snap_name = @args[1]
|
11
|
+
|
12
|
+
output "Deleting snapshot"
|
13
|
+
response = vm.delete_snapshot snap_name
|
14
|
+
|
15
|
+
if response.successful?
|
16
|
+
output "Snapshot '#{snap_name}' deleted"
|
17
|
+
else
|
18
|
+
output_and_exit "There was an error deleting the snapshot. The error was:\n#{response.message}", response.code
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def option_parser
|
23
|
+
optparse = OptionParser.new do |opts|
|
24
|
+
opts.banner = "Usage: fission snapshot delete TARGET_VM SNAPSHOT_NAME"
|
25
|
+
opts.separator ''
|
26
|
+
opts.separator 'Deletes the snapshot SNAPSHOT_NAME of TARGET_VM'
|
27
|
+
end
|
28
|
+
|
29
|
+
optparse
|
30
|
+
end
|
31
|
+
|
32
|
+
def summary
|
33
|
+
'Delete a snapshot of a VM'
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Fission
|
2
2
|
class Command
|
3
3
|
class SnapshotList < Command
|
4
|
-
include Fission::CommandHelpers
|
5
4
|
|
6
5
|
def execute
|
7
|
-
|
6
|
+
super
|
7
|
+
incorrect_arguments unless @args.count == 1
|
8
8
|
|
9
9
|
vm = VM.new @args.first
|
10
10
|
|
@@ -25,12 +25,18 @@ module Fission
|
|
25
25
|
|
26
26
|
def option_parser
|
27
27
|
optparse = OptionParser.new do |opts|
|
28
|
-
opts.banner = "
|
28
|
+
opts.banner = "Usage: fission snapshot list TARGET_VM"
|
29
|
+
opts.separator ''
|
30
|
+
opts.separator 'Lists all of the snapshots for TARGET_VM'
|
29
31
|
end
|
30
32
|
|
31
33
|
optparse
|
32
34
|
end
|
33
35
|
|
36
|
+
def summary
|
37
|
+
'List the snapshots of a VM'
|
38
|
+
end
|
39
|
+
|
34
40
|
end
|
35
41
|
end
|
36
42
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Fission
|
2
2
|
class Command
|
3
3
|
class SnapshotRevert < Command
|
4
|
-
include Fission::CommandHelpers
|
5
4
|
|
6
5
|
def execute
|
7
|
-
|
6
|
+
super
|
7
|
+
incorrect_arguments unless @args.count == 2
|
8
8
|
|
9
9
|
vm = VM.new @args[0]
|
10
10
|
snap_name = @args[1]
|
@@ -21,12 +21,18 @@ module Fission
|
|
21
21
|
|
22
22
|
def option_parser
|
23
23
|
optparse = OptionParser.new do |opts|
|
24
|
-
opts.banner = "
|
24
|
+
opts.banner = "Usage: fission snapshot revert TARGET_VM TARGET_SNAPSHOT"
|
25
|
+
opts.separator ''
|
26
|
+
opts.separator 'Reverts TARGET_VM to TARGET_SNAPSHOT'
|
25
27
|
end
|
26
28
|
|
27
29
|
optparse
|
28
30
|
end
|
29
31
|
|
32
|
+
def summary
|
33
|
+
'Revert a VM to a snapshot'
|
34
|
+
end
|
35
|
+
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Fission
|
2
2
|
class Command
|
3
3
|
class Start < Command
|
4
|
-
include CommandHelpers
|
5
4
|
|
6
5
|
def initialize(args=[])
|
7
6
|
super
|
@@ -9,9 +8,8 @@ module Fission
|
|
9
8
|
end
|
10
9
|
|
11
10
|
def execute
|
12
|
-
|
13
|
-
|
14
|
-
incorrect_arguments 'start' if @args.empty?
|
11
|
+
super
|
12
|
+
incorrect_arguments if @args.empty?
|
15
13
|
|
16
14
|
vm = VM.new @args.first
|
17
15
|
|
@@ -31,8 +29,11 @@ module Fission
|
|
31
29
|
|
32
30
|
def option_parser
|
33
31
|
optparse = OptionParser.new do |opts|
|
34
|
-
opts.banner = "
|
35
|
-
|
32
|
+
opts.banner = "Usage: fission start TARGET_VM [OPTIONS]"
|
33
|
+
opts.separator ''
|
34
|
+
opts.separator 'Starts TARGET_VM.'
|
35
|
+
opts.separator ''
|
36
|
+
opts.separator 'OPTIONS:'
|
36
37
|
opts.on '--headless', 'Start the VM in headless mode (i.e. no Fusion GUI console)' do
|
37
38
|
@options.headless = true
|
38
39
|
end
|
@@ -41,6 +42,10 @@ module Fission
|
|
41
42
|
optparse
|
42
43
|
end
|
43
44
|
|
45
|
+
def summary
|
46
|
+
'Start a VM'
|
47
|
+
end
|
48
|
+
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
@@ -3,6 +3,8 @@ module Fission
|
|
3
3
|
class Status < Command
|
4
4
|
|
5
5
|
def execute
|
6
|
+
super
|
7
|
+
|
6
8
|
response = VM.all_with_status
|
7
9
|
unless response.successful?
|
8
10
|
output_and_exit "There was an error getting the status of the VMs. The error was:\n#{response.message}", response.code
|
@@ -18,12 +20,18 @@ module Fission
|
|
18
20
|
|
19
21
|
def option_parser
|
20
22
|
optparse = OptionParser.new do |opts|
|
21
|
-
opts.banner = "
|
23
|
+
opts.banner = "Usage: fission status"
|
24
|
+
opts.separator ''
|
25
|
+
opts.separator 'Lists the status for all known VMs.'
|
22
26
|
end
|
23
27
|
|
24
28
|
optparse
|
25
29
|
end
|
26
30
|
|
31
|
+
def summary
|
32
|
+
'Show the status of all VMs'
|
33
|
+
end
|
34
|
+
|
27
35
|
end
|
28
36
|
end
|
29
37
|
end
|
data/lib/fission/command/stop.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Fission
|
2
2
|
class Command
|
3
3
|
class Stop < Command
|
4
|
-
include Fission::CommandHelpers
|
5
4
|
|
6
5
|
def execute
|
7
|
-
|
6
|
+
super
|
7
|
+
incorrect_arguments unless @args.count == 1
|
8
8
|
|
9
9
|
vm = VM.new @args.first
|
10
10
|
|
@@ -20,12 +20,18 @@ module Fission
|
|
20
20
|
|
21
21
|
def option_parser
|
22
22
|
optparse = OptionParser.new do |opts|
|
23
|
-
opts.banner = "
|
23
|
+
opts.banner = "Usage: fission stop TARGET_VM"
|
24
|
+
opts.separator ''
|
25
|
+
opts.separator 'Stop TARGET_VM.'
|
24
26
|
end
|
25
27
|
|
26
28
|
optparse
|
27
29
|
end
|
28
30
|
|
31
|
+
def summary
|
32
|
+
'Stop a VM'
|
33
|
+
end
|
34
|
+
|
29
35
|
end
|
30
36
|
end
|
31
37
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Fission
|
2
2
|
class Command
|
3
3
|
class Suspend < Command
|
4
|
-
include Fission::CommandHelpers
|
5
4
|
|
6
5
|
def initialize(args=[])
|
7
6
|
super
|
@@ -9,9 +8,8 @@ module Fission
|
|
9
8
|
end
|
10
9
|
|
11
10
|
def execute
|
12
|
-
|
13
|
-
|
14
|
-
incorrect_arguments 'suspend' if @args.count != 1 && !@options.all
|
11
|
+
super
|
12
|
+
incorrect_arguments if @args.count != 1 && !@options.all
|
15
13
|
|
16
14
|
vms_to_suspend.each do |vm|
|
17
15
|
output "Suspending '#{vm.name}'"
|
@@ -43,8 +41,11 @@ module Fission
|
|
43
41
|
|
44
42
|
def option_parser
|
45
43
|
optparse = OptionParser.new do |opts|
|
46
|
-
opts.banner = "
|
47
|
-
|
44
|
+
opts.banner = "Usage: fission suspend [TARGET_VM | --all]"
|
45
|
+
opts.separator ''
|
46
|
+
opts.separator 'Suspend TARGET_VM or all VMs.'
|
47
|
+
opts.separator ''
|
48
|
+
opts.separator 'OPTIONS:'
|
48
49
|
opts.on '--all', 'Suspend all running VMs' do
|
49
50
|
@options.all = true
|
50
51
|
end
|
@@ -53,6 +54,10 @@ module Fission
|
|
53
54
|
optparse
|
54
55
|
end
|
55
56
|
|
57
|
+
def summary
|
58
|
+
'Suspend a VM'
|
59
|
+
end
|
60
|
+
|
56
61
|
end
|
57
62
|
end
|
58
63
|
end
|
@@ -3,19 +3,33 @@ module Fission
|
|
3
3
|
|
4
4
|
# Internal: Outputs the help text for a command and exits.
|
5
5
|
#
|
6
|
-
# command_name - The name of the command to use in the output text.
|
7
|
-
#
|
8
6
|
# Examples
|
9
7
|
#
|
10
|
-
# incorrect_arguments
|
8
|
+
# incorrect_arguments
|
11
9
|
#
|
12
10
|
# Returns nothing.
|
13
11
|
# This will call the help class method for the help text. This will exit
|
14
12
|
# with the exit code 1.
|
15
|
-
def incorrect_arguments
|
13
|
+
def incorrect_arguments
|
16
14
|
output "#{self.class.help}\n"
|
17
15
|
output_and_exit "Incorrect arguments for #{command_name} command", 1
|
18
16
|
end
|
19
17
|
|
18
|
+
# Internal: Parses the command line arguments.
|
19
|
+
#
|
20
|
+
# Examples:
|
21
|
+
#
|
22
|
+
# parse_arguments
|
23
|
+
#
|
24
|
+
# Returns nothing.
|
25
|
+
# If there is an invalid argument, an error will be output and this will
|
26
|
+
# exit with exit code 1.
|
27
|
+
def parse_arguments
|
28
|
+
option_parser.parse! @args
|
29
|
+
rescue OptionParser::InvalidOption => e
|
30
|
+
output e
|
31
|
+
output_and_exit "\n#{self.class.help}", 1
|
32
|
+
end
|
33
|
+
|
20
34
|
end
|
21
35
|
end
|