vagrant-nodemaster 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,9 +4,17 @@ module RestRoutes
4
4
 
5
5
  class RouteManager
6
6
 
7
+ def self.node_info_route
8
+ NODE_INFO
9
+ end
10
+
7
11
  def self.box_list_route
8
12
  BOX_LIST_ROUTE
9
13
  end
14
+
15
+ def self.box_download_route
16
+ BOX_DOWNLOAD_ROUTE
17
+ end
10
18
 
11
19
  def self.box_delete_route
12
20
  BOX_DELETE_ROUTE
@@ -37,8 +45,8 @@ module RestRoutes
37
45
  end
38
46
 
39
47
  def self.vm_add_route
40
- VM_ADD_ROUTE
41
- end
48
+ VM_ADD_ROUTE
49
+ end
42
50
 
43
51
  def self.vm_status_route
44
52
  VM_STATUS_ROUTE
@@ -69,12 +77,12 @@ module RestRoutes
69
77
  end
70
78
 
71
79
  def self.vm_snapshot_delete_route
72
- VM_SNAPSHOT_DELETE_ROUTE
73
- end
80
+ VM_SNAPSHOT_DELETE_ROUTE
81
+ end
74
82
 
75
83
  def self.vm_delete_route
76
- VM_DELETE_ROUTE
77
- end
84
+ VM_DELETE_ROUTE
85
+ end
78
86
 
79
87
  def self.vm_snapshot_restore_route
80
88
  VM_SNAPSHOT_RESTORE_ROUTE
@@ -85,10 +93,12 @@ module RestRoutes
85
93
  end
86
94
 
87
95
  def self.node_password_change_route
88
- NODE_PASSWORD_CHANGE
89
- end
90
-
96
+ NODE_PASSWORD_CHANGE
97
+ end
91
98
 
99
+ def self.vm_info_route
100
+ VM_INFO_ROUTE
101
+ end
92
102
 
93
103
  def self.vm_backup_log_route
94
104
  VM_BACKUP_LOG_ROUTE
@@ -96,12 +106,12 @@ module RestRoutes
96
106
 
97
107
 
98
108
  def self.config_show_route
99
- NODE_CONFIG_SHOW_ROUTE
100
- end
109
+ NODE_CONFIG_SHOW_ROUTE
110
+ end
101
111
 
102
- def self.config_upload_route
103
- NODE_CONFIG_UPLOAD_ROUTE
104
- end
112
+ def self.config_upload_route
113
+ NODE_CONFIG_UPLOAD_ROUTE
114
+ end
105
115
 
106
116
 
107
117
  def self.login_route
@@ -113,12 +123,18 @@ module RestRoutes
113
123
  end
114
124
 
115
125
  def self.node_queue_last_route
116
- NODE_QUEUE_LAST_ROUTE
117
- end
118
-
126
+ NODE_QUEUE_LAST_ROUTE
127
+ end
119
128
 
120
129
 
130
+
131
+ def self.node_info_url(host,port)
132
+ "http://#{host}:#{port}#{node_info_route}"
133
+ end
121
134
 
135
+ def self.box_download_url(host,port)
136
+ "http://#{host}:#{port}#{box_download_route}"
137
+ end
122
138
 
123
139
  def self.box_list_url(host,port)
124
140
  "http://#{host}:#{port}#{box_list_route}"
@@ -145,11 +161,12 @@ module RestRoutes
145
161
  url="http://#{host}:#{port}#{url}"
146
162
  end
147
163
 
148
- def self.node_queue_last_url(host,port)
149
- "http://#{host}:#{port}#{node_queue_last_route}"
150
- end
164
+ def self.node_queue_last_url(host,port)
165
+ "http://#{host}:#{port}#{node_queue_last_route}"
166
+ end
151
167
 
152
168
  def self.login_url(host,port)
169
+
153
170
  "http://#{host}:#{port}#{login_route}"
154
171
  end
155
172
 
@@ -182,7 +199,12 @@ module RestRoutes
182
199
  end
183
200
 
184
201
 
185
-
202
+ def self.vm_info_url(host,port,vmname)
203
+ url="http://#{host}:#{port}#{vm_info_route}"
204
+ url=String.new(vm_info_route)
205
+ url[":vm"]=vmname
206
+ url="http://#{host}:#{port}#{url}"
207
+ end
186
208
 
187
209
  def self.vm_status_url(host,port,vmname=nil)
188
210
  url="http://#{host}:#{port}#{vm_status_all_route}"
@@ -285,8 +307,11 @@ module RestRoutes
285
307
 
286
308
  private
287
309
  BOX_LIST_ROUTE = "/api/box/list"
310
+ BOX_DOWNLOAD_ROUTE = "/api/box/download"
288
311
  BOX_DELETE_ROUTE = "/api/box/:box/:provider/delete"
289
312
  BOX_ADD_ROUTE = "/api/box/add"
313
+
314
+ NODE_INFO = "/api/info"
290
315
 
291
316
  VM_UP_ROUTE = "/api/vm/up"
292
317
  VM_HALT_ROUTE = "/api/vm/halt"
@@ -298,6 +323,7 @@ module RestRoutes
298
323
  VM_PROVISION_ROUTE = "/api/vm/provision"
299
324
  VM_STATUS_ALL_ROUTE = "/api/vm/status"
300
325
  VM_STATUS_ROUTE = "/api/vm/:vm/status"
326
+ VM_INFO_ROUTE = "/api/vm/:vm/info"
301
327
  SSH_CONFIG_ROUTE = "/api/vm/:vm/sshconfig"
302
328
 
303
329
  SNAPSHOTS_ALL_ROUTE = "/api/vm/snapshots"
@@ -0,0 +1,58 @@
1
+ require 'vagrant-nodemaster/node/nodedbmanager'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+
4
+ module Vagrant
5
+ module NodeMaster
6
+
7
+ class NodeInfo < Vagrant.plugin(2, :command)
8
+
9
+ def execute
10
+
11
+ options = {}
12
+
13
+ opts = OptionParser.new do |opts|
14
+ opts.banner = "Usage: vagrant node info <node-name>"
15
+
16
+ end
17
+
18
+ argv = parse_options(opts)
19
+
20
+
21
+ return if !argv
22
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 1
23
+
24
+
25
+
26
+ begin
27
+ result=RequestController.node_info(argv[0])
28
+ #@env.ui.info(result)
29
+ @env.ui.info("Node '#{argv[0]}' Information:")
30
+ @env.ui.info("#{"Operating System:".ljust(25)} #{result[:lsbdistdescription]}")
31
+ @env.ui.info("#{"Processor Count:".ljust(25)} #{result[:physicalprocessorcount]}")
32
+ @env.ui.info("#{"Architecture:".ljust(25)} #{result[:architecture]}")
33
+ @env.ui.info("#{"Core Count:".ljust(25)} #{result[:processorcount]}")
34
+
35
+ for i in 0..(result[:processorcount].to_i-1)
36
+ puts "processor #{i} => "+result[("processor"+i.to_s).to_sym]
37
+ end
38
+
39
+ @env.ui.info("#{"CPU Average:".ljust(25)} #{result[:cpuaverage][0]}% (1 Minute) #{result[:cpuaverage][1]}% (5 Minutes) #{result[:cpuaverage][2]}% (15 Minutes)")
40
+ @env.ui.info("#{"Memory Size:".ljust(25)} #{result[:memorysize]} (#{result[:memoryfree]} Free)")
41
+ @env.ui.info("#{"Disk Used:".ljust(25)}#{result[:diskusage]} GB")
42
+
43
+ interfaces = result[:interfaces].split(",")
44
+
45
+ interfaces.each do |i|
46
+ interface=("ipaddress_"+i).to_sym
47
+ puts "Interface #{i} => "+result[interface] if result[interface]
48
+ end
49
+
50
+ end
51
+
52
+ 0
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+ end
@@ -8,14 +8,14 @@ module Vagrant
8
8
 
9
9
  def execute
10
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
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
19
  raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 1
20
20
 
21
21
  result = RequestController.node_operation_queued_last(argv[0])
@@ -25,14 +25,14 @@ module Vagrant
25
25
  @env.ui.info("Operation queue is empty");
26
26
 
27
27
  else
28
- @env.ui.info("-------------------------------------------------------------------------------------")
29
- @env.ui.info("| RESULT CODE | RESUL T INFO |")
30
- @env.ui.info("-------------------------------------------------------------------------------------")
28
+ @env.ui.info("-------------------------------------------------------------------------------------")
29
+ @env.ui.info("| RESULT CODE | RESUL T INFO |")
30
+ @env.ui.info("-------------------------------------------------------------------------------------")
31
31
 
32
- result.each do |operation|
33
- @env.ui.info("| #{operation[0]} |#{operation[1].ljust(5)}")
34
- @env.ui.info("-------------------------------------------------------------------------------------")
35
- end
32
+ result.each do |operation|
33
+ @env.ui.info("| #{operation[0]} |#{operation[1].ljust(5)}")
34
+ @env.ui.info("-------------------------------------------------------------------------------------")
35
+ end
36
36
  end
37
37
 
38
38
 
@@ -25,12 +25,12 @@ module Vagrant
25
25
 
26
26
  argv = parse_options(opts)
27
27
  return if !argv
28
- raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 3
28
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 3
29
+
29
30
 
30
- #dbmanager=DB::NodeDBManager.new
31
31
 
32
32
 
33
- DB::NodeDBManager.update_node(argv[0],argv[1],argv[2].to_i,options[:dns])
33
+ DB::NodeDBManager.update_node(argv[0],argv[1],argv[2].to_i,options[:dns])
34
34
 
35
35
  0
36
36
  end
@@ -40,6 +40,11 @@ module Vagrant
40
40
  require File.expand_path("../node/nodeupdate", __FILE__)
41
41
  NodeUpdate
42
42
  end
43
+
44
+ @subcommands.register(:info) do
45
+ require File.expand_path("../node/nodeinfo", __FILE__)
46
+ NodeInfo
47
+ end
43
48
 
44
49
  @subcommands.register(:updatepw) do
45
50
  require File.expand_path("../node/nodeupdatepw", __FILE__)
@@ -35,6 +35,11 @@ module Vagrant
35
35
  require File.expand_path("../remoteboxadd", __FILE__)
36
36
  BoxAdd
37
37
  end
38
+
39
+ @subcommands.register(:downloads) do
40
+ require File.expand_path("../remoteboxdownload", __FILE__)
41
+ BoxDownload
42
+ end
38
43
 
39
44
  end
40
45
 
@@ -0,0 +1,44 @@
1
+ require 'optparse'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+ module Vagrant
4
+ module NodeMaster
5
+ class BoxDownload < Vagrant.plugin(2, :command)
6
+ def execute
7
+ options = {}
8
+ options[:async] = false
9
+
10
+ opts = OptionParser.new do |opts|
11
+ opts.banner = "Usage: vagrant remote box downloads <node-name>"
12
+ opts.separator ""
13
+ end
14
+
15
+
16
+ argv = parse_options(opts)
17
+
18
+ return if !argv
19
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length != 1
20
+
21
+
22
+ res = RequestController.box_downloads(argv[0])
23
+
24
+
25
+ #@env.ui.info("Remote Client \"#{argv[0]}\": Box \"#{argv[1]}\" added") if options[:async]==false
26
+ @env.ui.info("----------------------------------------------------------------------------------------------")
27
+ @env.ui.info("| BOX NAME | BOX URL | PROGRESS | TIME REMAINING |")
28
+ @env.ui.info("----------------------------------------------------------------------------------------------")
29
+
30
+ res.each do |operation|
31
+ @env.ui.info("| #{operation[:box_name].rjust(5)} | #{operation[:box_url]} | #{operation[:box_progress]} |#{operation[:box_remaining]}")
32
+ @env.ui.info("--------------------------------------------------------------------------------------------")
33
+ end
34
+
35
+ #@env.ui.info("Remote Client \"#{argv[0]}\": The operation ID is \"#{res.gsub!(/\D/, "")}\"") if options[:async]==true
36
+
37
+
38
+ 0
39
+ end
40
+
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,54 @@
1
+ require 'optparse'
2
+ require 'vagrant-nodemaster/requestcontroller'
3
+ module Vagrant
4
+ module NodeMaster
5
+ class InfoVM < Vagrant.plugin(2, :command)
6
+ def execute
7
+ options = {}
8
+
9
+ opts = OptionParser.new do |opts|
10
+ opts.banner = "Usage: vagrant remote info <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 != 2)
16
+
17
+
18
+ vmstatus=RequestController.vm_info(argv[0],argv[1])
19
+
20
+ @env.ui.info("Remote Client: #{argv[0]}", :prefix => false)
21
+
22
+ #pp vmstatus
23
+
24
+
25
+
26
+ @env.ui.info(" #{"Operating System:".ljust(25)} #{vmstatus["ostype"].ljust(25)}", :prefix => false)
27
+ @env.ui.info(" #{"Num. CPUS:".ljust(25)} #{vmstatus["cpus"]}", :prefix => false)
28
+ @env.ui.info(" #{"CPU Limit:".ljust(25)} #{vmstatus["cpuexecutioncap"]}%", :prefix => false)
29
+ @env.ui.info(" #{"PAE:".ljust(25)} #{vmstatus["pae"]}", :prefix => false)
30
+ @env.ui.info(" #{"3D acceleration:".ljust(25)} #{vmstatus["accelerate3d"]}", :prefix => false)
31
+ @env.ui.info(" #{"2D acceleration:".ljust(25)} #{vmstatus["accelerate2dvideo"]}", :prefix => false)
32
+ @env.ui.info(" #{"Memory:".ljust(25)} #{vmstatus["memory"]} MB", :prefix => false)
33
+ @env.ui.info(" #{"Boot Order:".ljust(25)} #{vmstatus["boot1"]}, #{vmstatus["boot2"]}, #{vmstatus["boot3"]}, #{vmstatus["boot4"]}", :prefix => false)
34
+ @env.ui.info(" #{"Clipboard:".ljust(25)} #{vmstatus["clipboard"]}", :prefix => false)
35
+ @env.ui.info(" #{"Remote Desktop:".ljust(25)} #{vmstatus["vrde"]}", :prefix => false)
36
+ @env.ui.info(" #{"USB:".ljust(25)} #{vmstatus["usb"]}", :prefix => false)
37
+ (1..8).each {|key|
38
+ #If interface exists
39
+ if vmstatus.has_key?("nic#{key}") && !vmstatus["nic#{key}"].eql?("none")
40
+ @env.ui.info(" ")
41
+ @env.ui.info(" #{"Interface:".ljust(25)} nic#{key}", :prefix => false)
42
+ @env.ui.info(" #{"Network Type:".ljust(25)} #{vmstatus["nic#{key}"]}", :prefix => false)
43
+ @env.ui.info(" #{"MAC Address:".ljust(25)} #{vmstatus["macaddress#{key}"]}", :prefix => false)
44
+ @env.ui.info(" #{"Cable connected:".ljust(25)} #{vmstatus["cableconnected#{key}"]}", :prefix => false)
45
+ end
46
+ }
47
+
48
+ @env.ui.info(" ")
49
+
50
+ 0
51
+ end
52
+ end
53
+ end
54
+ end
@@ -29,69 +29,74 @@ module Vagrant
29
29
  # BoxList
30
30
  # end
31
31
 
32
- @subcommands.register(:box) do
33
- require File.expand_path("../remote/remoteboxcommand", __FILE__)
34
- BoxCommand
35
- end
36
-
37
- @subcommands.register(:up) do
38
- require File.expand_path("../remote/remoteup", __FILE__)
39
- UpVM
40
- end
41
-
42
- @subcommands.register(:halt) do
43
- require File.expand_path("../remote/remotehalt", __FILE__)
44
- HaltVM
45
- end
32
+ @subcommands.register(:box) do
33
+ require File.expand_path("../remote/remoteboxcommand", __FILE__)
34
+ BoxCommand
35
+ end
36
+
37
+ @subcommands.register(:up) do
38
+ require File.expand_path("../remote/remoteup", __FILE__)
39
+ UpVM
40
+ end
41
+
42
+ @subcommands.register(:halt) do
43
+ require File.expand_path("../remote/remotehalt", __FILE__)
44
+ HaltVM
45
+ end
46
46
 
47
47
  # @subcommands.register(:add) do
48
48
  # require File.expand_path("../remote/remoteadd", __FILE__)
49
49
  # AddVM
50
50
  # end
51
51
 
52
- @subcommands.register(:suspend) do
53
- require File.expand_path("../remote/remotesuspend", __FILE__)
54
- SuspendVM
55
- end
56
-
57
- @subcommands.register(:resume) do
58
- require File.expand_path("../remote/remoteresume", __FILE__)
59
- ResumeVM
60
- end
61
-
62
- @subcommands.register(:status) do
63
- require File.expand_path("../remote/remotevmstatus", __FILE__)
64
- StatusVM
65
- end
66
-
67
- @subcommands.register(:destroy) do
68
- require File.expand_path("../remote/remotedestroy", __FILE__)
69
- DestroyVM
70
- end
71
-
72
- @subcommands.register(:provision) do
73
- require File.expand_path("../remote/remoteprovision", __FILE__)
74
- ProvisionVM
75
- end
52
+ @subcommands.register(:suspend) do
53
+ require File.expand_path("../remote/remotesuspend", __FILE__)
54
+ SuspendVM
55
+ end
56
+
57
+ @subcommands.register(:resume) do
58
+ require File.expand_path("../remote/remoteresume", __FILE__)
59
+ ResumeVM
60
+ end
61
+
62
+ @subcommands.register(:status) do
63
+ require File.expand_path("../remote/remotevmstatus", __FILE__)
64
+ StatusVM
65
+ end
66
+
67
+ @subcommands.register(:destroy) do
68
+ require File.expand_path("../remote/remotedestroy", __FILE__)
69
+ DestroyVM
70
+ end
71
+
72
+ @subcommands.register(:provision) do
73
+ require File.expand_path("../remote/remoteprovision", __FILE__)
74
+ ProvisionVM
75
+ end
76
76
 
77
- @subcommands.register(:ssh) do
78
- require File.expand_path("../remote/remotessh", __FILE__)
79
- SSHVM
80
- end
77
+ @subcommands.register(:info) do
78
+ require File.expand_path("../remote/remotevminfo", __FILE__)
79
+ InfoVM
80
+ end
81
81
 
82
- @subcommands.register(:snapshot) do
83
- require File.expand_path("../remote/remotesnapshotcommand", __FILE__)
84
- SnapshotCommand
85
- end
86
-
87
- @subcommands.register(:backup) do
88
- require File.expand_path("../remote/remotebackupcommand", __FILE__)
89
- BackupCommand
90
- end
91
-
92
- @subcommands.register(:config) do
93
- require File.expand_path("../remote/remoteconfigcommand", __FILE__)
94
- ConfigCommand
82
+ @subcommands.register(:ssh) do
83
+ require File.expand_path("../remote/remotessh", __FILE__)
84
+ SSHVM
85
+ end
86
+
87
+ @subcommands.register(:snapshot) do
88
+ require File.expand_path("../remote/remotesnapshotcommand", __FILE__)
89
+ SnapshotCommand
90
+ end
91
+
92
+ @subcommands.register(:backup) do
93
+ require File.expand_path("../remote/remotebackupcommand", __FILE__)
94
+ BackupCommand
95
+ end
96
+
97
+ @subcommands.register(:config) do
98
+ require File.expand_path("../remote/remoteconfigcommand", __FILE__)
99
+ ConfigCommand
95
100
  end
96
101
 
97
102
  end