vagrant-nodemaster 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +95 -0
- data/lib/vagrant-nodemaster.rb +4 -2
- data/lib/vagrant-nodemaster/apidesc.rb +105 -1
- data/lib/vagrant-nodemaster/node/nodeadd.rb +4 -4
- data/lib/vagrant-nodemaster/node/nodedbmanager.rb +49 -33
- data/lib/vagrant-nodemaster/node/nodelist.rb +2 -2
- data/lib/vagrant-nodemaster/node/nodeoperationcommand.rb +85 -0
- data/lib/vagrant-nodemaster/node/nodeoperationlast.rb +47 -0
- data/lib/vagrant-nodemaster/node/nodeoperationshow.rb +39 -0
- data/lib/vagrant-nodemaster/node/noderemove.rb +3 -3
- data/lib/vagrant-nodemaster/node/nodestatus.rb +2 -2
- data/lib/vagrant-nodemaster/node/nodeupdate.rb +2 -2
- data/lib/vagrant-nodemaster/node/nodeupdatepw.rb +72 -0
- data/lib/vagrant-nodemaster/nodecommand.rb +14 -0
- data/lib/vagrant-nodemaster/remote/configmanager.rb +16 -0
- data/lib/vagrant-nodemaster/remote/remoteboxadd.rb +11 -8
- data/lib/vagrant-nodemaster/remote/remoteconfigaddvm.rb +46 -0
- data/lib/vagrant-nodemaster/remote/remoteconfigcommand.rb +110 -0
- data/lib/vagrant-nodemaster/remote/remoteconfigdeletevm.rb +37 -0
- data/lib/vagrant-nodemaster/remote/remoteconfigshow.rb +31 -0
- data/lib/vagrant-nodemaster/remote/remoteconfigupload.rb +34 -0
- data/lib/vagrant-nodemaster/remote/remotehalt.rb +14 -5
- data/lib/vagrant-nodemaster/remote/remoteprovision.rb +31 -23
- data/lib/vagrant-nodemaster/remote/remoteresume.rb +16 -9
- data/lib/vagrant-nodemaster/remote/remotesnapshotcommand.rb +8 -3
- data/lib/vagrant-nodemaster/remote/remotesnapshotdelete.rb +31 -0
- data/lib/vagrant-nodemaster/remote/remotesnapshotlist.rb +1 -0
- data/lib/vagrant-nodemaster/remote/remotesnapshotrestore.rb +17 -9
- data/lib/vagrant-nodemaster/remote/remotesnapshottake.rb +16 -6
- data/lib/vagrant-nodemaster/remote/remotesuspend.rb +15 -7
- data/lib/vagrant-nodemaster/remote/remoteup.rb +18 -22
- data/lib/vagrant-nodemaster/remote/remotevmstatus.rb +1 -1
- data/lib/vagrant-nodemaster/remotecommand.rb +18 -5
- data/lib/vagrant-nodemaster/requestcontroller.rb +321 -69
- data/lib/vagrant-nodemaster/version.rb +1 -1
- data/vagrant-nodemaster.gemspec +7 -2
- metadata +18 -7
- data/Readme.md +0 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
|
2
|
+
require 'vagrant/plugin'
|
3
|
+
|
4
|
+
|
5
|
+
module Vagrant
|
6
|
+
module NodeMaster
|
7
|
+
|
8
|
+
class ConfigCommand < 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
|
+
|
20
|
+
@subcommands.register(:show) do
|
21
|
+
require File.expand_path("../remoteconfigshow", __FILE__)
|
22
|
+
ConfigShow
|
23
|
+
end
|
24
|
+
|
25
|
+
# @subcommands.register(:load) do
|
26
|
+
# require File.expand_path("../remoteconfigload", __FILE__)
|
27
|
+
# ConfigShow
|
28
|
+
# end
|
29
|
+
|
30
|
+
@subcommands.register(:addvm) do
|
31
|
+
require File.expand_path("../remoteconfigaddvm", __FILE__)
|
32
|
+
AddVM
|
33
|
+
end
|
34
|
+
|
35
|
+
@subcommands.register(:deletevm) do
|
36
|
+
require File.expand_path("../remoteconfigdeletevm", __FILE__)
|
37
|
+
DeleteVM
|
38
|
+
end
|
39
|
+
|
40
|
+
@subcommands.register(:upload) do
|
41
|
+
require File.expand_path("../remoteconfigupload", __FILE__)
|
42
|
+
ConfigUpload
|
43
|
+
end
|
44
|
+
|
45
|
+
# @subcommands.register(:log) do
|
46
|
+
# require File.expand_path("../remotebackuplog", __FILE__)
|
47
|
+
# BackupLog
|
48
|
+
# end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def execute
|
54
|
+
# if @main_args.include?("-h") || @main_args.include?("--help")
|
55
|
+
# Print the help for all the box commands.
|
56
|
+
# return help
|
57
|
+
# end
|
58
|
+
|
59
|
+
# If we reached this far then we must have a subcommand. If not,
|
60
|
+
# then we also just print the help and exit.
|
61
|
+
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
|
62
|
+
return help if !command_class || !@sub_command
|
63
|
+
|
64
|
+
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
|
65
|
+
|
66
|
+
|
67
|
+
begin
|
68
|
+
# Initialize and execute the command class
|
69
|
+
command_class.new(@sub_args, @env).execute
|
70
|
+
rescue RestClient::ExceptionWithResponse=> e
|
71
|
+
@env.ui.error(e.response)
|
72
|
+
rescue RestClient::RequestFailed => e
|
73
|
+
@env.ui.error("Remote Client \"#{@sub_args[0]}\": Request Failed")
|
74
|
+
rescue RestClient::ResourceNotFound => e
|
75
|
+
@env.ui.error("Remote Client \"#{@sub_args[0]}\": Box \"#{@sub_args[1]}\" could not be found")
|
76
|
+
rescue Exception => e
|
77
|
+
@env.ui.error(e.message)
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
def help
|
84
|
+
opts = OptionParser.new do |opts|
|
85
|
+
opts.banner = "Usage: vagrant remote config <command> [<args>]"
|
86
|
+
opts.separator ""
|
87
|
+
opts.separator "Available subcommands:"
|
88
|
+
|
89
|
+
# Add the available subcommands as separators in order to print them
|
90
|
+
# out as well.
|
91
|
+
keys = []
|
92
|
+
@subcommands.each { |key, value| keys << key.to_s }
|
93
|
+
|
94
|
+
keys.sort.each do |key|
|
95
|
+
opts.separator " #{key}"
|
96
|
+
end
|
97
|
+
|
98
|
+
opts.separator ""
|
99
|
+
opts.separator "For help on any individual command run `vagrant remote COMMAND -h`"
|
100
|
+
end
|
101
|
+
|
102
|
+
@env.ui.info(opts.help, :prefix => false)
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'vagrant-nodemaster/requestcontroller'
|
3
|
+
module Vagrant
|
4
|
+
module NodeMaster
|
5
|
+
class DeleteVM < Vagrant.plugin(2, :command)
|
6
|
+
|
7
|
+
def execute
|
8
|
+
options = {}
|
9
|
+
options[:remove] = false
|
10
|
+
|
11
|
+
opts = OptionParser.new do |opts|
|
12
|
+
|
13
|
+
opts.banner = "Usage: vagrant remote config deletevm <node-name> <vm_name> [--remove]"
|
14
|
+
opts.separator ""
|
15
|
+
opts.on("-r", "--remove", "Deletes all information of the VM in the remote node") do |r|
|
16
|
+
options[:remove] = r
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
argv = parse_options(opts)
|
24
|
+
|
25
|
+
return if !argv
|
26
|
+
|
27
|
+
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if (argv.length != 2)
|
28
|
+
|
29
|
+
#Destroy machines
|
30
|
+
result=RequestController.vm_delete(argv[0],argv[1],options[:remove])
|
31
|
+
|
32
|
+
@env.ui.success("Operation successfully performed") if result
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'vagrant-nodemaster/requestcontroller'
|
3
|
+
|
4
|
+
|
5
|
+
module Vagrant
|
6
|
+
module NodeMaster
|
7
|
+
|
8
|
+
class ConfigShow < Vagrant.plugin(2, :command)
|
9
|
+
def execute
|
10
|
+
options = {}
|
11
|
+
|
12
|
+
opts = OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: vagrant remote config show <node-name> [-h]"
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
argv = parse_options(opts)
|
18
|
+
|
19
|
+
return if !argv
|
20
|
+
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 1
|
21
|
+
|
22
|
+
config_file=RequestController.node_config_show(argv[0])
|
23
|
+
@env.ui.info(config_file)
|
24
|
+
|
25
|
+
0
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'vagrant-nodemaster/requestcontroller'
|
3
|
+
module Vagrant
|
4
|
+
module NodeMaster
|
5
|
+
class ConfigUpload < Vagrant.plugin(2, :command)
|
6
|
+
|
7
|
+
def execute
|
8
|
+
|
9
|
+
|
10
|
+
opts = OptionParser.new do |opts|
|
11
|
+
|
12
|
+
opts.banner = "Usage: vagrant remote config upload <node-name> <config_file>"
|
13
|
+
opts.separator ""
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
argv = parse_options(opts)
|
20
|
+
|
21
|
+
return if !argv
|
22
|
+
|
23
|
+
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if (argv.length != 2)
|
24
|
+
|
25
|
+
#Add machines
|
26
|
+
result=RequestController.node_config_upload(argv[0],argv[1])
|
27
|
+
|
28
|
+
@env.ui.success("Operation successfully performed") if result
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -6,13 +6,17 @@ module Vagrant
|
|
6
6
|
def execute
|
7
7
|
options = {}
|
8
8
|
options[:force] = false
|
9
|
+
options[:async] = true
|
9
10
|
|
10
11
|
opts = OptionParser.new do |opts|
|
11
|
-
opts.banner = "Usage: vagrant remote halt <node-name> [vm_name] [--force] [-h]"
|
12
|
+
opts.banner = "Usage: vagrant remote halt <node-name> [vm_name] [--force] [--synchronous] [-h]"
|
12
13
|
opts.separator ""
|
13
14
|
opts.on("-f", "--force", "Force shut down") do |f|
|
14
15
|
options[:force] = f
|
15
16
|
end
|
17
|
+
opts.on("-s", "--synchronous", "Wait until the operation finishes") do |f|
|
18
|
+
options[:async] = false
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
22
|
|
@@ -23,11 +27,16 @@ module Vagrant
|
|
23
27
|
|
24
28
|
# begin
|
25
29
|
|
26
|
-
machines=RequestController.vm_halt(argv[0],argv[1],options[:force])
|
30
|
+
machines=RequestController.vm_halt(argv[0],argv[1],options[:force],options[:async])
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
if options[:async] == false
|
33
|
+
machines.each do |machine|
|
34
|
+
@env.ui.success("Remote Client \"#{argv[0]}\": Virtual Machine \"#{machine["vmname"]}\" halted")
|
35
|
+
end
|
36
|
+
else
|
37
|
+
@env.ui.info("Remote Client \"#{argv[0]}\": The operation ID is \"#{machines.gsub!(/\D/, "")}\"")
|
38
|
+
end
|
39
|
+
|
31
40
|
|
32
41
|
|
33
42
|
# rescue RestClient::RequestFailed => e
|
@@ -4,28 +4,36 @@ module Vagrant
|
|
4
4
|
module NodeMaster
|
5
5
|
class ProvisionVM < Vagrant.plugin(2, :command)
|
6
6
|
def execute
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
options = {}
|
8
|
+
options[:async] = true
|
9
|
+
|
10
|
+
opts = OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: vagrant remote provision <node-name> [vm_name] [--synchronous]"
|
12
|
+
opts.separator ""
|
13
|
+
opts.on("-s", "--synchronous", "Wait until the operation finishes") do |f|
|
14
|
+
options[:async] = false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
argv = parse_options(opts)
|
19
|
+
return if !argv
|
20
|
+
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if (argv.length < 1 || argv.length > 2)
|
21
|
+
|
17
22
|
# begin
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
|
24
|
+
|
25
|
+
machines=RequestController.vm_provision(argv[0],argv[1],options[:async])
|
26
|
+
|
27
|
+
if options[:async] == false
|
28
|
+
machines.each do |machine|
|
29
|
+
@env.ui.info("Remote Client \"#{argv[0]}\": Virtual Machine \"#{machine}\" provisioned")
|
30
|
+
end
|
31
|
+
@env.ui.info(" ")
|
32
|
+
else
|
33
|
+
@env.ui.info("Remote Client \"#{argv[0]}\": The operation ID is \"#{machines.gsub!(/\D/, "")}\"")
|
34
|
+
end
|
35
|
+
|
36
|
+
|
29
37
|
# rescue RestClient::RequestFailed => e
|
30
38
|
# @env.ui.error("Remote Client \"#{argv[0]}\": Request Failed")
|
31
39
|
# rescue RestClient::ResourceNotFound => e
|
@@ -35,8 +43,8 @@ module Vagrant
|
|
35
43
|
# rescue Exception => e
|
36
44
|
# @env.ui.error(e.message)
|
37
45
|
# end
|
38
|
-
|
39
|
-
|
46
|
+
|
47
|
+
end
|
40
48
|
|
41
49
|
end
|
42
50
|
end
|
@@ -5,9 +5,14 @@ module Vagrant
|
|
5
5
|
class ResumeVM < Vagrant.plugin(2, :command)
|
6
6
|
def execute
|
7
7
|
options = {}
|
8
|
+
options[:async] = true
|
8
9
|
|
9
10
|
opts = OptionParser.new do |opts|
|
10
|
-
opts.banner = "Usage: vagrant remote resume <node-name> [vm_name]"
|
11
|
+
opts.banner = "Usage: vagrant remote resume <node-name> [vm_name] [--synchronous]"
|
12
|
+
opts.separator ""
|
13
|
+
opts.on("-s", "--synchronous", "Wait until the operation finishes") do |f|
|
14
|
+
options[:async] = false
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
argv = parse_options(opts)
|
@@ -15,14 +20,16 @@ module Vagrant
|
|
15
20
|
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if (argv.length < 1 || argv.length > 2)
|
16
21
|
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
machines=RequestController.vm_resume(argv[0],argv[1],options[:async])
|
24
|
+
|
25
|
+
if options[:async] == false
|
26
|
+
machines.each do |machine|
|
27
|
+
@env.ui.info("Remote Client \"#{argv[0]}\":Virtual Machine \"#{machine["vmname"]}\" resumed")
|
28
|
+
end
|
29
|
+
else
|
30
|
+
@env.ui.info("Remote Client \"#{argv[0]}\": The operation ID is \"#{machines.gsub!(/\D/, "")}\"")
|
31
|
+
end
|
32
|
+
|
26
33
|
|
27
34
|
0
|
28
35
|
end
|
@@ -33,6 +33,11 @@ module Vagrant
|
|
33
33
|
SnapshotRestore
|
34
34
|
end
|
35
35
|
|
36
|
+
@subcommands.register(:delete) do
|
37
|
+
require File.expand_path("../remotesnapshotdelete", __FILE__)
|
38
|
+
SnapshotDelete
|
39
|
+
end
|
40
|
+
|
36
41
|
|
37
42
|
end
|
38
43
|
|
@@ -52,12 +57,12 @@ module Vagrant
|
|
52
57
|
begin
|
53
58
|
# Initialize and execute the command class
|
54
59
|
command_class.new(@sub_args, @env).execute
|
60
|
+
rescue RestClient::ExceptionWithResponse=> e
|
61
|
+
@env.ui.error(e.response)
|
55
62
|
rescue RestClient::RequestFailed => e
|
56
63
|
@env.ui.error("Remote Client \"#{@sub_args[0]}\": Request Failed")
|
57
64
|
rescue RestClient::ResourceNotFound => e
|
58
|
-
@env.ui.error("Remote Client \"#{@sub_args[0]}\": Virtual Machine \"#{@sub_args[1]}\" could not be found")
|
59
|
-
rescue RestClient::ExceptionWithResponse=> e
|
60
|
-
@env.ui.error(e.response)
|
65
|
+
@env.ui.error("Remote Client \"#{@sub_args[0]}\": Virtual Machine \"#{@sub_args[1]}\" could not be found")
|
61
66
|
rescue Exception => e
|
62
67
|
@env.ui.error(e.message)
|
63
68
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'vagrant-nodemaster/requestcontroller'
|
3
|
+
module Vagrant
|
4
|
+
module NodeMaster
|
5
|
+
|
6
|
+
class SnapshotDelete < Vagrant.plugin(2, :command)
|
7
|
+
def execute
|
8
|
+
options = {}
|
9
|
+
|
10
|
+
opts = OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: vagrant remote snapshot delete <node-name> <vmname> <uuid>"
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
argv = parse_options(opts)
|
16
|
+
|
17
|
+
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 3
|
18
|
+
|
19
|
+
RequestController.vm_snapshot_delete(argv[0],argv[1],argv[2])
|
20
|
+
|
21
|
+
|
22
|
+
@env.ui.success("Remote Client: #{argv[0]}: Snapshot with UUID #{argv[2]} succesfully deleted.", :prefix => false)
|
23
|
+
# @env.ui.success("Snapshot with UUID #{argv[2]} succesfully deleted.")
|
24
|
+
|
25
|
+
0
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -6,9 +6,14 @@ module Vagrant
|
|
6
6
|
class SnapshotRestore < Vagrant.plugin(2, :command)
|
7
7
|
def execute
|
8
8
|
options = {}
|
9
|
-
|
9
|
+
options[:async] = true
|
10
|
+
|
10
11
|
opts = OptionParser.new do |opts|
|
11
|
-
opts.banner = "Usage: vagrant remote snapshot restore <node-name> <vmname> <snapshot-uuid|snapshot-name]>"
|
12
|
+
opts.banner = "Usage: vagrant remote snapshot restore <node-name> <vmname> <snapshot-uuid|snapshot-name] [--synchronous]>"
|
13
|
+
opts.separator ""
|
14
|
+
opts.on("-s", "--synchronous", "Wait until the operation finishes") do |f|
|
15
|
+
options[:async] = false
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
19
|
|
@@ -17,14 +22,17 @@ module Vagrant
|
|
17
22
|
return if !argv
|
18
23
|
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 3
|
19
24
|
|
20
|
-
begin
|
21
|
-
snapshot = RequestController.vm_snapshot_restore(argv[0],argv[1],argv[2])
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@env.ui.
|
27
|
-
|
26
|
+
snapshot = RequestController.vm_snapshot_restore(argv[0],argv[1],argv[2],options[:async])
|
27
|
+
|
28
|
+
if options[:async] == false
|
29
|
+
@env.ui.info("Remote Client \"#{argv[0]}\": Virtual Machine \"#{argv[1]}\" => Restoring snapshot \"#{argv[2]}\"", :prefix => false)
|
30
|
+
else
|
31
|
+
@env.ui.info("Remote Client \"#{argv[0]}\": The operation ID is \"#{snapshot.gsub!(/\D/, "")}\"")
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
28
36
|
0
|
29
37
|
end
|
30
38
|
|