vagrant-nodemaster 0.0.2 → 1.0.0
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/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
@@ -16,10 +16,10 @@ module Vagrant
|
|
16
16
|
return if !argv
|
17
17
|
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 0
|
18
18
|
|
19
|
-
|
19
|
+
#
|
20
20
|
|
21
21
|
@env.ui.info("#{"NODE".ljust(25)} ADDRESS (PORT) ",:prefix => false)
|
22
|
-
|
22
|
+
DB::NodeDBManager.get_nodes.each do |entry|
|
23
23
|
@env.ui.info("#{entry[:name].ljust(25)} #{entry[:address]}(#{entry[:port]})", :prefix => false)
|
24
24
|
end
|
25
25
|
@env.ui.info(" ", :prefix => false)
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'vagrant/plugin'
|
2
|
+
require 'sqlite3'
|
3
|
+
|
4
|
+
|
5
|
+
module Vagrant
|
6
|
+
module NodeMaster
|
7
|
+
|
8
|
+
class NodeOperationCommand < Vagrant.plugin(2, :command)
|
9
|
+
|
10
|
+
def initialize(argv, env)
|
11
|
+
super
|
12
|
+
|
13
|
+
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
14
|
+
|
15
|
+
|
16
|
+
@subcommands = Vagrant::Registry.new
|
17
|
+
|
18
|
+
@subcommands.register(:show) do
|
19
|
+
require File.expand_path("../nodeoperationshow", __FILE__)
|
20
|
+
NodeOperationShow
|
21
|
+
end
|
22
|
+
|
23
|
+
@subcommands.register(:last) do
|
24
|
+
require File.expand_path("../nodeoperationlast", __FILE__)
|
25
|
+
NodeOperationLast
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
def execute
|
35
|
+
if @main_args.include?("-h") || @main_args.include?("--help")
|
36
|
+
# Print the help for all the box commands.
|
37
|
+
return help
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
# If we reached this far then we must have a subcommand. If not,
|
43
|
+
# then we also just print the help and exit.
|
44
|
+
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
|
45
|
+
return help if !command_class || !@sub_command
|
46
|
+
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
|
47
|
+
|
48
|
+
begin
|
49
|
+
# Initialize and execute the command class
|
50
|
+
command_class.new(@sub_args, @env).execute
|
51
|
+
rescue Exception => e
|
52
|
+
@env.ui.error(e.message)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
0
|
57
|
+
end
|
58
|
+
|
59
|
+
def help
|
60
|
+
opts = OptionParser.new do |opts|
|
61
|
+
opts.banner = "Usage: vagrant node <command> [<args>]"
|
62
|
+
opts.separator ""
|
63
|
+
opts.separator "Available subcommands:"
|
64
|
+
|
65
|
+
# Add the available subcommands as separators in order to print them
|
66
|
+
# out as well.
|
67
|
+
keys = []
|
68
|
+
@subcommands.each { |key, value| keys << key.to_s }
|
69
|
+
|
70
|
+
keys.sort.each do |key|
|
71
|
+
opts.separator " #{key}"
|
72
|
+
end
|
73
|
+
|
74
|
+
opts.separator ""
|
75
|
+
opts.separator "For help on any individual command run `vagrant node COMMAND -h`"
|
76
|
+
end
|
77
|
+
|
78
|
+
@env.ui.info(opts.help, :prefix => false)
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'vagrant-nodemaster/node/nodedbmanager'
|
2
|
+
require 'vagrant-nodemaster/requestcontroller'
|
3
|
+
|
4
|
+
module Vagrant
|
5
|
+
module NodeMaster
|
6
|
+
|
7
|
+
class NodeOperationLast < Vagrant.plugin(2, :command)
|
8
|
+
|
9
|
+
def execute
|
10
|
+
|
11
|
+
options = {}
|
12
|
+
|
13
|
+
opts = OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: vagrant node operation last <node-name>"
|
15
|
+
end
|
16
|
+
|
17
|
+
argv = parse_options(opts)
|
18
|
+
return if !argv
|
19
|
+
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 1
|
20
|
+
|
21
|
+
result = RequestController.node_operation_queued_last(argv[0])
|
22
|
+
|
23
|
+
|
24
|
+
if (result.empty?)
|
25
|
+
@env.ui.info("Operation queue is empty");
|
26
|
+
|
27
|
+
else
|
28
|
+
@env.ui.info("-------------------------------------------------------------------------------------")
|
29
|
+
@env.ui.info("| RESULT CODE | RESUL T INFO |")
|
30
|
+
@env.ui.info("-------------------------------------------------------------------------------------")
|
31
|
+
|
32
|
+
result.each do |operation|
|
33
|
+
@env.ui.info("| #{operation[0]} |#{operation[1].ljust(5)}")
|
34
|
+
@env.ui.info("-------------------------------------------------------------------------------------")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
0
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'vagrant-nodemaster/node/nodedbmanager'
|
2
|
+
require 'vagrant-nodemaster/requestcontroller'
|
3
|
+
|
4
|
+
module Vagrant
|
5
|
+
module NodeMaster
|
6
|
+
|
7
|
+
class NodeOperationShow < Vagrant.plugin(2, :command)
|
8
|
+
|
9
|
+
def execute
|
10
|
+
|
11
|
+
options = {}
|
12
|
+
|
13
|
+
opts = OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: vagrant node operation show <node-name> <operation-id>"
|
15
|
+
end
|
16
|
+
|
17
|
+
argv = parse_options(opts)
|
18
|
+
return if !argv
|
19
|
+
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 2
|
20
|
+
|
21
|
+
result = RequestController.node_operation_queued(argv[0],argv[1])
|
22
|
+
|
23
|
+
|
24
|
+
case result[0]
|
25
|
+
when 100
|
26
|
+
@env.ui.info("The operation #{argv[1]} is \"IN PROGRESS\"")
|
27
|
+
when 200
|
28
|
+
@env.ui.success("The operation #{argv[1]} succeeded.")
|
29
|
+
else
|
30
|
+
@env.ui.error("The operation #{argv[1]} failed. The result is:\n#{result[1]}")
|
31
|
+
end
|
32
|
+
|
33
|
+
0
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -24,12 +24,12 @@ module Vagrant
|
|
24
24
|
return if !argv
|
25
25
|
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if (argv.length < 1 && !options[:clean]) || (argv.length >1)
|
26
26
|
|
27
|
-
dbmanager=DB::NodeDBManager.new
|
27
|
+
#dbmanager=DB::NodeDBManager.new
|
28
28
|
|
29
29
|
if (options[:clean])
|
30
|
-
|
30
|
+
DB::NodeDBManager.remove_nodes
|
31
31
|
elsif
|
32
|
-
|
32
|
+
DB::NodeDBManager.remove_node(argv[0])
|
33
33
|
end
|
34
34
|
|
35
35
|
0
|
@@ -19,13 +19,13 @@ module Vagrant
|
|
19
19
|
return if !argv
|
20
20
|
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 0
|
21
21
|
|
22
|
-
dbmanager=DB::NodeDBManager.new
|
22
|
+
#dbmanager=DB::NodeDBManager.new
|
23
23
|
|
24
24
|
status = {}
|
25
25
|
|
26
26
|
|
27
27
|
|
28
|
-
|
28
|
+
DB::NodeDBManager.get_nodes.each do |entry|
|
29
29
|
status[entry[:name]]=ERROR
|
30
30
|
if port_open?(entry[:address],entry[:port])
|
31
31
|
status[entry[:name]]=OK
|
@@ -27,10 +27,10 @@ module Vagrant
|
|
27
27
|
return if !argv
|
28
28
|
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 3
|
29
29
|
|
30
|
-
dbmanager=DB::NodeDBManager.new
|
30
|
+
#dbmanager=DB::NodeDBManager.new
|
31
31
|
|
32
32
|
|
33
|
-
|
33
|
+
DB::NodeDBManager.update_node(argv[0],argv[1],argv[2].to_i,options[:dns])
|
34
34
|
|
35
35
|
0
|
36
36
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'vagrant-nodemaster/node/nodedbmanager'
|
2
|
+
require 'vagrant-nodemaster/requestcontroller'
|
3
|
+
|
4
|
+
module Vagrant
|
5
|
+
module NodeMaster
|
6
|
+
|
7
|
+
class NodeUpdatePw < Vagrant.plugin(2, :command)
|
8
|
+
def execute
|
9
|
+
|
10
|
+
options = {}
|
11
|
+
options[:remote] = false
|
12
|
+
|
13
|
+
opts = OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: vagrant node updatepw <node-name> --remote"
|
15
|
+
opts.on("--remote", "Change also remote node pasword") do |r|
|
16
|
+
options[:remote] = r
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
argv = parse_options(opts)
|
22
|
+
|
23
|
+
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 1
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
pass_m = "Insert your new password for the Node #{argv[0]}: "
|
29
|
+
confirm_m = "Please Insert again the new password: "
|
30
|
+
|
31
|
+
if STDIN.respond_to?(:noecho)
|
32
|
+
print pass_m
|
33
|
+
password=STDIN.noecho(&:gets).chomp
|
34
|
+
print "\n#{confirm_m}"
|
35
|
+
confirm=STDIN.noecho(&:gets).chomp
|
36
|
+
print "\n"
|
37
|
+
else
|
38
|
+
password = @env.ui.ask(pass_m)
|
39
|
+
confirm = @env.ui.ask(confirm_m)
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
raise "Passwords does not match!" if (password!=confirm)
|
44
|
+
|
45
|
+
|
46
|
+
#First, change Password at remote node
|
47
|
+
if (options[:remote])
|
48
|
+
if (!RequestController.node_password_change(argv[0],password))
|
49
|
+
@env.ui.error("Remote password change failed! No changes have been comitted locally")
|
50
|
+
return
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
#If everything is ok then change the password locally
|
55
|
+
#db=DB::NodeDBManager.new
|
56
|
+
DB::NodeDBManager.update_node_password(argv[0],password)
|
57
|
+
|
58
|
+
if options[:remote]
|
59
|
+
@env.ui.success("Password change performed successfully locally and remotely")
|
60
|
+
else
|
61
|
+
@env.ui.success("Password change performed successfully locally")
|
62
|
+
end
|
63
|
+
|
64
|
+
0
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'vagrant/plugin'
|
2
2
|
require 'sqlite3'
|
3
|
+
require 'vagrant-nodemaster/node/nodedbmanager'
|
3
4
|
|
4
5
|
module Vagrant
|
5
6
|
module NodeMaster
|
@@ -11,6 +12,9 @@ module Vagrant
|
|
11
12
|
|
12
13
|
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
13
14
|
|
15
|
+
#Initializing db structure
|
16
|
+
DB::NodeDBManager.new(@env.data_dir)
|
17
|
+
|
14
18
|
# puts "MAIN ARGS #{@main_args}"
|
15
19
|
# puts "SUB COMMAND #{@sub_command}"
|
16
20
|
# puts "SUB ARGS #{@sub_args}"
|
@@ -36,12 +40,22 @@ module Vagrant
|
|
36
40
|
require File.expand_path("../node/nodeupdate", __FILE__)
|
37
41
|
NodeUpdate
|
38
42
|
end
|
43
|
+
|
44
|
+
@subcommands.register(:updatepw) do
|
45
|
+
require File.expand_path("../node/nodeupdatepw", __FILE__)
|
46
|
+
NodeUpdatePw
|
47
|
+
end
|
39
48
|
|
40
49
|
@subcommands.register(:status) do
|
41
50
|
require File.expand_path("../node/nodestatus", __FILE__)
|
42
51
|
NodeStatus
|
43
52
|
end
|
44
53
|
|
54
|
+
@subcommands.register(:operation) do
|
55
|
+
require File.expand_path("../node/nodeoperationcommand", __FILE__)
|
56
|
+
NodeOperationCommand
|
57
|
+
end
|
58
|
+
|
45
59
|
end
|
46
60
|
|
47
61
|
|
@@ -5,9 +5,14 @@ module Vagrant
|
|
5
5
|
class BoxAdd < 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 box add <node-name> <box-name> <url>"
|
11
|
+
opts.banner = "Usage: vagrant remote box add <node-name> <box-name> <url> [--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
|
|
@@ -17,14 +22,12 @@ module Vagrant
|
|
17
22
|
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 3
|
18
23
|
|
19
24
|
|
20
|
-
|
21
|
-
# begin
|
25
|
+
res = RequestController.box_add(argv[0],argv[1],argv[2],options[:async])
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
# end
|
27
|
+
@env.ui.success("Remote Client \"#{argv[0]}\": Box \"#{argv[1]}\" added") if options[:async]==false
|
28
|
+
|
29
|
+
@env.ui.info("Remote Client \"#{argv[0]}\": The operation ID is \"#{res.gsub!(/\D/, "")}\"") if options[:async]==true
|
30
|
+
|
28
31
|
|
29
32
|
0
|
30
33
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'vagrant-nodemaster/requestcontroller'
|
3
|
+
module Vagrant
|
4
|
+
module NodeMaster
|
5
|
+
class AddVM < Vagrant.plugin(2, :command)
|
6
|
+
|
7
|
+
def execute
|
8
|
+
options = {}
|
9
|
+
options[:rename] = false
|
10
|
+
|
11
|
+
opts = OptionParser.new do |opts|
|
12
|
+
|
13
|
+
opts.banner = "Usage: vagrant remote config addvm <node-name> <vm_config_file> [--rename]"
|
14
|
+
opts.separator ""
|
15
|
+
opts.on("-r", "--rename", "Rename VM automatically if another VM with the same name exists") do |r|
|
16
|
+
options[:rename] = 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
|
+
#Add machines
|
30
|
+
result=RequestController.vm_add(argv[0],argv[1],options[:rename])
|
31
|
+
|
32
|
+
@env.ui.success("Operation successfully performed") if result
|
33
|
+
|
34
|
+
|
35
|
+
# @env.ui.info("Remote Client: #{argv[0]}", :prefix => false)
|
36
|
+
# machines.each do |machine|
|
37
|
+
# @env.ui.info(" * Virtual Machine '#{machine}' destroyed", :prefix => false)
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# @env.ui.info(" ")
|
41
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|