File: stop.rb

package info (click to toggle)
ruby-fission 0.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 624 kB
  • sloc: ruby: 4,664; makefile: 10
file content (37 lines) | stat: -rw-r--r-- 774 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Fission
  class Command
    class Stop < Command

      def execute
        super
        incorrect_arguments unless @args.count == 1

        vm = VM.new @args.first

        output "Stopping '#{vm.name}'"
        response = vm.stop

        if response.successful?
          output "VM '#{vm.name}' stopped"
        else
          output_and_exit "There was an error stopping the VM.  The error was:\n#{response.message}", response.code
        end
      end

      def option_parser
        optparse = OptionParser.new do |opts|
          opts.banner = "Usage: fission stop TARGET_VM"
          opts.separator ''
          opts.separator 'Stop TARGET_VM.'
        end

        optparse
      end

      def summary
        'Stop a VM'
      end

    end
  end
end