vagrant-nodemaster 0.0.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.
Files changed (36) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +1 -0
  4. data/lib/vagrant-nodemaster.rb +26 -0
  5. data/lib/vagrant-nodemaster/apidesc.rb +220 -0
  6. data/lib/vagrant-nodemaster/node/nodeadd.rb +33 -0
  7. data/lib/vagrant-nodemaster/node/nodedbmanager.rb +176 -0
  8. data/lib/vagrant-nodemaster/node/nodelist.rb +34 -0
  9. data/lib/vagrant-nodemaster/node/noderemove.rb +43 -0
  10. data/lib/vagrant-nodemaster/node/nodestatus.rb +73 -0
  11. data/lib/vagrant-nodemaster/node/nodeupdate.rb +43 -0
  12. data/lib/vagrant-nodemaster/nodecommand.rb +102 -0
  13. data/lib/vagrant-nodemaster/remote/remotebackupcommand.rb +90 -0
  14. data/lib/vagrant-nodemaster/remote/remotebackuplog.rb +62 -0
  15. data/lib/vagrant-nodemaster/remote/remotebackuptake.rb +50 -0
  16. data/lib/vagrant-nodemaster/remote/remoteboxadd.rb +35 -0
  17. data/lib/vagrant-nodemaster/remote/remoteboxcommand.rb +98 -0
  18. data/lib/vagrant-nodemaster/remote/remoteboxdelete.rb +40 -0
  19. data/lib/vagrant-nodemaster/remote/remoteboxlist.rb +32 -0
  20. data/lib/vagrant-nodemaster/remote/remotedestroy.rb +66 -0
  21. data/lib/vagrant-nodemaster/remote/remotehalt.rb +48 -0
  22. data/lib/vagrant-nodemaster/remote/remoteprovision.rb +43 -0
  23. data/lib/vagrant-nodemaster/remote/remoteresume.rb +32 -0
  24. data/lib/vagrant-nodemaster/remote/remotesnapshotcommand.rb +93 -0
  25. data/lib/vagrant-nodemaster/remote/remotesnapshotlist.rb +60 -0
  26. data/lib/vagrant-nodemaster/remote/remotesnapshotrestore.rb +34 -0
  27. data/lib/vagrant-nodemaster/remote/remotesnapshottake.rb +31 -0
  28. data/lib/vagrant-nodemaster/remote/remotessh.rb +55 -0
  29. data/lib/vagrant-nodemaster/remote/remotesuspend.rb +32 -0
  30. data/lib/vagrant-nodemaster/remote/remoteup.rb +43 -0
  31. data/lib/vagrant-nodemaster/remote/remotevmstatus.rb +43 -0
  32. data/lib/vagrant-nodemaster/remotecommand.rb +155 -0
  33. data/lib/vagrant-nodemaster/requestcontroller.rb +344 -0
  34. data/lib/vagrant-nodemaster/version.rb +5 -0
  35. data/vagrant-nodemaster.gemspec +29 -0
  36. metadata +157 -0
@@ -0,0 +1,50 @@
1
+ require 'optparse'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+
4
+
5
+ module Vagrant
6
+ module NodeMaster
7
+
8
+ class BackupTake < Vagrant.plugin(2, :command)
9
+ def execute
10
+ options = {}
11
+
12
+ options[:background]=false
13
+ options[:download] = nil
14
+
15
+ opts = OptionParser.new do |opts|
16
+ opts.banner = "Usage: vagrant remote backup take [node-name] [vmname] [--download target_directory][--background] [-h]"
17
+ opts.separator ""
18
+ opts.on("-b", "--background", "Take backup in background") do |b|
19
+ options[:background] = b
20
+ end
21
+ opts.on("--download target_directory", String,"Download backup to target directory") do |d|
22
+ options[:download] = d
23
+ end
24
+
25
+ end
26
+
27
+
28
+
29
+ argv = parse_options(opts)
30
+
31
+ return if !argv
32
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length > 2
33
+
34
+
35
+
36
+
37
+ ui=nil
38
+ ui = @env.ui if options[:background]==false
39
+
40
+ p = fork { RequestController.node_backup_take(ui,options[:download],argv[0],argv[1]) }
41
+
42
+ Process.waitpid(p) if options[:background]==false
43
+
44
+ 0
45
+ end
46
+
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,35 @@
1
+ require 'optparse'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+ module Vagrant
4
+ module NodeMaster
5
+ class BoxAdd < Vagrant.plugin(2, :command)
6
+ def execute
7
+ options = {}
8
+
9
+ opts = OptionParser.new do |opts|
10
+ opts.banner = "Usage: vagrant remote box add <node-name> <box-name> <url>"
11
+ end
12
+
13
+
14
+ argv = parse_options(opts)
15
+
16
+ return if !argv
17
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 3
18
+
19
+
20
+
21
+ # begin
22
+
23
+ RequestController.box_add(argv[0],argv[1],argv[2])
24
+ # @env.ui.info("Remote Client \"#{argv[0]}\": Box \"#{argv[1]}\" with provider \"#{argv[2]}\" removed")
25
+ # rescue RestClient::ResourceNotFound => e
26
+ # @env.ui.error("Remote Client \"#{argv[0]}\": Box \"#{argv[1]}\" with provider \"#{argv[2]}\" could not be found")
27
+ # end
28
+
29
+ 0
30
+ end
31
+
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,98 @@
1
+
2
+ require 'vagrant/plugin'
3
+
4
+
5
+ module Vagrant
6
+ module NodeMaster
7
+
8
+ class BoxCommand < Vagrant.plugin(2, :command)
9
+ def initialize(argv, env)
10
+ super
11
+
12
+ @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
13
+
14
+ # puts "MAIN ARGS #{@main_args}"
15
+ # puts "SUB COMMAND #{@sub_command}"
16
+ # puts "SUB ARGS #{@sub_args}"
17
+
18
+ @subcommands = Vagrant::Registry.new
19
+ # @subcommands.register(:add) do
20
+ # require File.expand_path("../add", __FILE__)
21
+ # Add
22
+ # end
23
+ #
24
+ @subcommands.register(:list) do
25
+ require File.expand_path("../remoteboxlist", __FILE__)
26
+ BoxList
27
+ end
28
+
29
+ @subcommands.register(:remove) do
30
+ require File.expand_path("../remoteboxdelete", __FILE__)
31
+ BoxDelete
32
+ end
33
+
34
+ @subcommands.register(:add) do
35
+ require File.expand_path("../remoteboxadd", __FILE__)
36
+ BoxAdd
37
+ end
38
+
39
+ end
40
+
41
+ def execute
42
+ # if @main_args.include?("-h") || @main_args.include?("--help")
43
+ # Print the help for all the box commands.
44
+ # return help
45
+ # end
46
+
47
+ # If we reached this far then we must have a subcommand. If not,
48
+ # then we also just print the help and exit.
49
+ command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
50
+ return help if !command_class || !@sub_command
51
+
52
+ @logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
53
+
54
+
55
+ begin
56
+ # Initialize and execute the command class
57
+ command_class.new(@sub_args, @env).execute
58
+ rescue RestClient::RequestFailed => e
59
+ @env.ui.error("Remote Client \"#{@sub_args[0]}\": Request Failed")
60
+ rescue RestClient::ResourceNotFound => e
61
+ @env.ui.error("Remote Client \"#{@sub_args[0]}\": Box \"#{@sub_args[1]}\" could not be found")
62
+ rescue RestClient::ExceptionWithResponse=> e
63
+ @env.ui.error(e.response)
64
+ rescue Exception => e
65
+ @env.ui.error(e.message)
66
+ end
67
+
68
+
69
+ end
70
+
71
+ def help
72
+ opts = OptionParser.new do |opts|
73
+ opts.banner = "Usage: vagrant remote box <command> [<args>]"
74
+ opts.separator ""
75
+ opts.separator "Available subcommands:"
76
+
77
+ # Add the available subcommands as separators in order to print them
78
+ # out as well.
79
+ keys = []
80
+ @subcommands.each { |key, value| keys << key.to_s }
81
+
82
+ keys.sort.each do |key|
83
+ opts.separator " #{key}"
84
+ end
85
+
86
+ opts.separator ""
87
+ opts.separator "For help on any individual command run `vagrant remote COMMAND -h`"
88
+ end
89
+
90
+ @env.ui.info(opts.help, :prefix => false)
91
+ end
92
+
93
+
94
+
95
+
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,40 @@
1
+ require 'optparse'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+ module Vagrant
4
+ module NodeMaster
5
+ class BoxDelete < Vagrant.plugin(2, :command)
6
+ def execute
7
+ options = {}
8
+
9
+ opts = OptionParser.new do |opts|
10
+ opts.banner = "Usage: vagrant remote box remove <node-name> <box-name> <box-provider>"
11
+ end
12
+
13
+
14
+ argv = parse_options(opts)
15
+
16
+ return if !argv
17
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 3
18
+
19
+
20
+
21
+ begin
22
+
23
+ RequestController.box_delete(argv[0],argv[1],argv[2])
24
+ @env.ui.info("Remote Client \"#{argv[0]}\": Box \"#{argv[1]}\" with provider \"#{argv[2]}\" removed")
25
+ rescue RestClient::ResourceNotFound => e
26
+ @env.ui.error("Remote Client \"#{argv[0]}\": Box \"#{argv[1]}\" with provider \"#{argv[2]}\" could not be found")
27
+ end
28
+
29
+
30
+ # @env.ui.info("Remote Client: #{argv[0]}", :prefix => false)
31
+ # boxes.each { |box| @env.ui.info(" * #{box["name"]} , (#{box["provider"]})", :prefix => false) }
32
+
33
+
34
+ 0
35
+ end
36
+
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,32 @@
1
+ require 'optparse'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+ module Vagrant
4
+ module NodeMaster
5
+ class BoxList < Vagrant.plugin(2, :command)
6
+ def execute
7
+ options = {}
8
+
9
+ opts = OptionParser.new do |opts|
10
+ opts.banner = "Usage: vagrant remote box list <node-name>"
11
+ end
12
+
13
+
14
+ argv = parse_options(opts)
15
+
16
+ return if !argv
17
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 1
18
+
19
+
20
+
21
+
22
+ boxes = RequestController.get_remote_boxes(argv[0])
23
+
24
+ @env.ui.info("Remote Client: #{argv[0]}", :prefix => false)
25
+ boxes.each { |box| @env.ui.info(" * #{box["name"]} , (#{box["provider"]})", :prefix => false) }
26
+
27
+
28
+ 0
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,66 @@
1
+ require 'optparse'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+ module Vagrant
4
+ module NodeMaster
5
+ class DestroyVM < Vagrant.plugin(2, :command)
6
+ def execute
7
+ options = {}
8
+ options[:force] = false
9
+
10
+ opts = OptionParser.new do |opts|
11
+
12
+ opts.banner = "Usage: vagrant remote destroy <node-name> [vm_name] [--force] [-h]"
13
+ opts.separator ""
14
+ opts.on("-f", "--force", "Destroy without confirmation") do |f|
15
+ options[:force] = f
16
+ end
17
+
18
+ end
19
+
20
+ argv = parse_options(opts)
21
+ return if !argv
22
+
23
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if (argv.length < 1 || argv.length > 2)
24
+
25
+ # begin
26
+
27
+ if (!options[:force])
28
+
29
+ message = "all virtual machines"
30
+
31
+ if (argv.length>1)
32
+ message = "virtual machine \"#{argv[1]}\""
33
+ end
34
+
35
+ choice = @env.ui.ask("Do you really want to destroy #{message} [N/Y]? ")
36
+
37
+ if (!choice || choice.upcase != "Y" )
38
+ return 0
39
+ end
40
+ end
41
+
42
+
43
+ #Destroy machines
44
+ machines=RequestController.vm_destroy(argv[0],argv[1])
45
+
46
+ @env.ui.info("Remote Client: #{argv[0]}", :prefix => false)
47
+ machines.each do |machine|
48
+ @env.ui.info(" * Virtual Machine '#{machine}' destroyed", :prefix => false)
49
+ end
50
+
51
+ @env.ui.info(" ")
52
+
53
+ # rescue RestClient::RequestFailed => e
54
+ # @env.ui.error("Remote Client \"#{argv[0]}\": Request Failed")
55
+ # rescue RestClient::ResourceNotFound => e
56
+ # @env.ui.error("Remote Client \"#{argv[0]}\": Virtual Machine \"#{argv[1]}\" could not be found")
57
+ # rescue RestClient::ExceptionWithResponse=> e
58
+ # @env.ui.error(e.response)
59
+ # rescue Exception => e
60
+ # @env.ui.error(e.message)
61
+ # end
62
+
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,48 @@
1
+ require 'optparse'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+ module Vagrant
4
+ module NodeMaster
5
+ class HaltVM < Vagrant.plugin(2, :command)
6
+ def execute
7
+ options = {}
8
+ options[:force] = false
9
+
10
+ opts = OptionParser.new do |opts|
11
+ opts.banner = "Usage: vagrant remote halt <node-name> [vm_name] [--force] [-h]"
12
+ opts.separator ""
13
+ opts.on("-f", "--force", "Force shut down") do |f|
14
+ options[:force] = f
15
+ end
16
+ end
17
+
18
+
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+
22
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if (argv.length < 1 || argv.length > 2)
23
+
24
+ # begin
25
+
26
+ machines=RequestController.vm_halt(argv[0],argv[1],options[:force])
27
+
28
+ machines.each do |machine|
29
+ @env.ui.info("Remote Client \"#{argv[0]}\": Virtual Machine \"#{machine}\" halted")
30
+ end
31
+
32
+
33
+ # rescue RestClient::RequestFailed => e
34
+ # @env.ui.error("Remote Client \"#{argv[0]}\": Request Failed")
35
+ # rescue RestClient::ResourceNotFound => e
36
+ # @env.ui.error("Remote Client \"#{argv[0]}\": Virtual Machine \"#{argv[1]}\" could not be found")
37
+ # rescue RestClient::ExceptionWithResponse=> e
38
+ # @env.ui.error(e.response)
39
+ # rescue Exception => e
40
+ # @env.ui.error(e.message)
41
+ # end
42
+
43
+ 0
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,43 @@
1
+ require 'optparse'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+ module Vagrant
4
+ module NodeMaster
5
+ class ProvisionVM < Vagrant.plugin(2, :command)
6
+ def execute
7
+ options = {}
8
+
9
+ opts = OptionParser.new do |opts|
10
+ opts.banner = "Usage: vagrant remote provision <node-name> [vm_name]"
11
+ end
12
+
13
+ argv = parse_options(opts)
14
+ return if !argv
15
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if (argv.length < 1 || argv.length > 2)
16
+
17
+ # begin
18
+
19
+
20
+ machines=RequestController.vm_provision(argv[0],argv[1])
21
+
22
+
23
+ machines.each do |machine|
24
+ @env.ui.info("Remote Client \"#{argv[0]}\": Virtual Machine \"#{machine}\" provisioned")
25
+ end
26
+
27
+ @env.ui.info(" ")
28
+
29
+ # rescue RestClient::RequestFailed => e
30
+ # @env.ui.error("Remote Client \"#{argv[0]}\": Request Failed")
31
+ # rescue RestClient::ResourceNotFound => e
32
+ # @env.ui.error("Remote Client \"#{argv[0]}\": Virtual Machine \"#{argv[1]}\" could not be found")
33
+ # rescue RestClient::ExceptionWithResponse=> e
34
+ # @env.ui.error(e.response)
35
+ # rescue Exception => e
36
+ # @env.ui.error(e.message)
37
+ # end
38
+
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,32 @@
1
+ require 'optparse'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+ module Vagrant
4
+ module NodeMaster
5
+ class ResumeVM < Vagrant.plugin(2, :command)
6
+ def execute
7
+ options = {}
8
+
9
+ opts = OptionParser.new do |opts|
10
+ opts.banner = "Usage: vagrant remote resume <node-name> [vm_name]"
11
+ end
12
+
13
+ argv = parse_options(opts)
14
+ return if !argv
15
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if (argv.length < 1 || argv.length > 2)
16
+
17
+
18
+ machines=RequestController.vm_resume(argv[0],argv[1])
19
+
20
+
21
+ machines.each do |machine|
22
+ @env.ui.info("Remote Client \"#{argv[0]}\":Virtual Machine \"#{machine}\" resumed")
23
+ end
24
+
25
+ @env.ui.info(" ")
26
+
27
+ 0
28
+ end
29
+
30
+ end
31
+ end
32
+ end