vagrant-node 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,11 @@ module Vagrant
24
24
  NodeServerStop
25
25
  end
26
26
 
27
+ @subcommands.register(:passwd) do
28
+ require File.expand_path("../nodeserverpasswd", __FILE__)
29
+ NodeServerPasswd
30
+ end
31
+
27
32
  # puts "MAIN ARGS #{@main_args}"
28
33
  # puts "SUB COMMAND #{@sub_command}"
29
34
  # puts "SUB ARGS #{@sub_args}"
@@ -66,6 +71,7 @@ module Vagrant
66
71
  opts.separator "Available subcommands:"
67
72
  opts.separator " start"
68
73
  opts.separator " stop"
74
+ opts.separator " passwd"
69
75
  opts.separator ""
70
76
  end
71
77
 
@@ -0,0 +1,75 @@
1
+ require 'optparse'
2
+ require 'vagrant-node/server'
3
+ require 'io/console'
4
+ require 'vagrant-node/dbmanager'
5
+
6
+ module Vagrant
7
+ module Node
8
+ class NodeServerPasswd < Vagrant.plugin(2, :command)
9
+ def execute
10
+ options = {}
11
+
12
+ opts = OptionParser.new do |opts|
13
+ opts.banner = "Usage: vagrant nodeserver passwd"
14
+ end
15
+
16
+ # argv = parse_options(opts)
17
+ # raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length > 1
18
+
19
+
20
+
21
+ # if (argv.length==0)
22
+
23
+
24
+
25
+ db = DB::DBManager.new(@env.data_dir)
26
+
27
+ #Checking if user knows the old password
28
+ if (db.node_password_set? && !db.node_default_password_set?)
29
+ print "Insert current password: "
30
+ old_password=STDIN.noecho(&:gets).chomp
31
+ print "\n"
32
+ if !db.node_check_password?(old_password)
33
+ @env.ui.error("Password failed!")
34
+ return 0
35
+ end
36
+ end
37
+
38
+ pass_m = "Insert your new password for this Node: "
39
+ confirm_m = "Please Insert again the new password: "
40
+
41
+
42
+ if STDIN.respond_to?(:noecho)
43
+ print pass_m
44
+ password=STDIN.noecho(&:gets).chomp
45
+ print "\n#{confirm_m}"
46
+ confirm=STDIN.noecho(&:gets).chomp
47
+ print "\n"
48
+ else
49
+ #FIXME Don't show password
50
+ password = @env.ui.ask(pass_m)
51
+ confirm = @env.ui.ask(confirm_m)
52
+ end
53
+
54
+ if (password==confirm)
55
+ db.node_password_set(password)
56
+ @env.ui.success("Password changed!")
57
+ else
58
+ @env.ui.error("Passwords does not match!")
59
+ end
60
+
61
+
62
+
63
+
64
+ # else
65
+ # puts "INTRODUCIDA EN TERMINAL"
66
+ # end
67
+
68
+
69
+
70
+ 0
71
+ end
72
+
73
+ end
74
+ end
75
+ end
@@ -4,20 +4,30 @@ module Vagrant
4
4
  module Node
5
5
  class NodeServerStart < Vagrant.plugin(2, :command)
6
6
  def execute
7
- options = {}
8
-
9
- opts = OptionParser.new do |opts|
10
- opts.banner = "Usage: vagrant nodeserver start [port=3333]"
11
- end
7
+ #FIXME EVLUAR SI MERECE LA PENA EL PASAR LA PASS POR LINEA DE COMANDOS
8
+ # options = {}
9
+ # options[:password]= ""
10
+
11
+ opts = OptionParser.new do |opts|
12
+ opts.banner = "Usage: vagrant nodeserver start [port=3333] -p password"
13
+ opts.separator ""
14
+ # opts.on("-p", "--passwd password", String, "Node Password") do |b|
15
+ # options[:password] = b
16
+ # end
17
+ end
12
18
 
13
- argv = parse_options(opts)
14
- return if !argv
15
- raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length > 1
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+ raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length > 1
16
22
 
17
- ServerAPI::ServerManager.run(File.dirname(@env.lock_path),@env.data_dir,argv[0].to_i)
23
+ begin
24
+ ServerAPI::ServerManager.run(File.dirname(@env.lock_path),@env.data_dir,argv[0].to_i)
25
+ rescue Exception => e
26
+ @env.ui.error(e.message)
27
+ end
18
28
 
19
- 0
20
- end
29
+ 0
30
+ end
21
31
 
22
32
  end
23
33
  end
@@ -4,19 +4,29 @@ module Vagrant
4
4
  module Node
5
5
  class NodeServerStop < Vagrant.plugin(2, :command)
6
6
  def execute
7
- options = {}
8
-
9
- opts = OptionParser.new do |opts|
10
- opts.banner = "Usage: vagrant nodeserver stop"
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
16
-
17
- ServerAPI::ServerManager.stop(File.dirname(@env.lock_path))
18
- 0
19
- end
7
+ # options = {}
8
+ # options[:password]= ""
9
+
10
+ opts = OptionParser.new do |opts|
11
+ opts.banner = "Usage: vagrant nodeserver stop --passwd password"
12
+ opts.separator ""
13
+ # opts.on("-p","--passwd password", String, "Node Password") do |p|
14
+ # options[:password] = p
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
21
+
22
+ begin
23
+ ServerAPI::ServerManager.stop(File.dirname(@env.lock_path),@env.data_dir)
24
+ rescue Exception => e
25
+ @env.ui.error(e.message)
26
+ end
27
+
28
+ 0
29
+ end
20
30
 
21
31
  end
22
32
  end
@@ -0,0 +1,23 @@
1
+ require 'vagrant-node/dbmanager'
2
+
3
+ module Vagrant
4
+ module Node
5
+ class PwManager
6
+ def initialize(db)
7
+ @dbmanager=db
8
+ end
9
+
10
+ #Token is a MD5 token
11
+ #challenge was the
12
+ def authorized?(token,challenge)
13
+ #FIXME REMOVE
14
+ # pp "CHECKING PASSWORD"
15
+ # pp "TOKEN = #{token}"
16
+ # pp "CHALLENGED = #{Digest::MD5.hexdigest(challenge+@dbmanager.node_password)}"
17
+ #pp "EN HEX DIGEST #{Digest::MD5.hexdigest(challenge+@dbmanager.node_password)}"
18
+ return token==Digest::MD5.hexdigest(challenge+@dbmanager.node_password)
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -2,8 +2,9 @@ require 'rubygems'
2
2
  require 'vagrant-node/api'
3
3
  require 'vagrant-node/pidfile'
4
4
  require 'webrick'
5
-
6
-
5
+ require 'vagrant-node/dbmanager'
6
+ require 'io/console'
7
+ #FIXME EVALUAR SI MERECE LA PENA HACER AUTENTICACION DE PASSWORD AQUI
7
8
  #FIXME Problema con el logging ya que únicamnete
8
9
  #vuelca al fichero todo cuando se acaba el proceso con el
9
10
  #vagrant server stop
@@ -15,13 +16,16 @@ module Vagrant
15
16
  DEFAULT_BIND_PORT = 3333
16
17
  BIND_ADDRESS = "0.0.0.0"
17
18
  LOG_FILE = "webrick.log"
18
- def self.run(pid_path,log_path,port=DEFAULT_BIND_PORT)
19
+ def self.run(pid_path,data_path,port=DEFAULT_BIND_PORT)
20
+
21
+ check_password(data_path);
22
+
19
23
  pid_file = File.join(pid_path,PIDFILENAME)
20
24
 
21
25
  pid = fork do
22
26
 
23
27
 
24
- log_file = File.open (log_path + LOG_FILE).to_s, 'a+'
28
+ log_file = File.open (data_path + LOG_FILE).to_s, 'a+'
25
29
 
26
30
  log = WEBrick::Log.new log_file
27
31
 
@@ -38,7 +42,7 @@ module Vagrant
38
42
  :AccessLog => access_log
39
43
  }
40
44
 
41
- begin
45
+ #begin
42
46
  server = WEBrick::HTTPServer.new(options)
43
47
 
44
48
  server.mount "/", Rack::Handler::WEBrick,ServerAPI::API.new
@@ -49,9 +53,9 @@ module Vagrant
49
53
  server.start
50
54
 
51
55
 
52
- rescue Exception => e
53
- puts e.message
54
- end
56
+ # rescue Exception => e
57
+ # puts e.message
58
+ # end
55
59
 
56
60
  #Alternative running mode
57
61
  # ServerAPI::API.run! :bind => '0.0.0.0', :port => 1234
@@ -59,8 +63,11 @@ module Vagrant
59
63
 
60
64
  end
61
65
 
62
- def self.stop(pid_path)
63
- begin
66
+ def self.stop(pid_path,data_path)
67
+
68
+
69
+ # check_password(data_path,passwd);
70
+
64
71
 
65
72
  pid_file = File.join(pid_path,PIDFILENAME)
66
73
 
@@ -81,12 +88,31 @@ module Vagrant
81
88
  Process.kill('KILL', pid)
82
89
  #Process.kill 9, pid
83
90
 
84
- rescue Exception => e
85
- puts e.message
86
- end
91
+
87
92
 
88
93
  end
89
94
 
95
+ private
96
+
97
+ def self.check_password(data_path)
98
+ @db = DB::DBManager.new(data_path)
99
+ if (!@db.node_password_set? || @db.node_default_password_set?)
100
+ raise "Please, set first a password with the command \"vagrant nodeserver passwd\""
101
+ # else
102
+ # if (password==nil || password.size==0)
103
+ # if STDIN.respond_to?(:noecho)
104
+ # print "Password: "
105
+ # password=STDIN.noecho(&:gets).chomp
106
+ # print "\n"
107
+ # end
108
+ # end
109
+
110
+ # if(!@db.node_check_password?(password))
111
+ # raise "Password failed!"
112
+ # end
113
+ end
114
+ true
115
+ end
90
116
 
91
117
 
92
118
  end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Node
3
- VERSION = "0.0.2"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -8,8 +8,12 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Vagrant::Node::VERSION
9
9
  spec.authors = ["Francisco Javier Lopez de San Pedro"]
10
10
  spec.email = ["fjsanpedro@gmail.com"]
11
- spec.description = "This Vagrant plugin allows you to configure a vm environment as a node in a client/server infraestructure. See vagrant-nodemaster"
12
- spec.summary = "ESCRIBIR SUMMARY"
11
+ spec.description = "This Vagrant plugin allows you to configure a vm environment as a node in a client/server infraestructure. See also vagrant-nodemaster"
12
+ spec.summary = "This plugin allows you to set a computer with a virtual environment configured with Vagrant to be controlled and managed remotely. The remote machine must have installed the controller plugin, Vagrant-NodeMaster.
13
+ With this plugin installed the Vagrant environment can perform requests, that you usually can execute locally, but commanded by a remote computer.
14
+
15
+ This plugin has been developed in the context of the Catedra SAES of the University of Murcia(Spain)."
16
+
13
17
  spec.homepage = "http://www.catedrasaes.org"
14
18
  spec.license = "GNU"
15
19
 
@@ -18,8 +22,10 @@ Gem::Specification.new do |spec|
18
22
  spec.add_dependency "sinatra"
19
23
  spec.add_dependency "json"
20
24
  spec.add_dependency "rack"
21
- spec.add_dependency "rubyzip"
25
+ spec.add_dependency "rubyzip", '< 1.0.0'
22
26
  spec.add_dependency "sqlite3"
27
+ spec.add_dependency "ruby2ruby", "~> 2.0.6"
28
+ spec.add_dependency "ruby_parser", "~> 3.2.2"
23
29
  #spec.add_dependency "sambal"
24
30
  #spec.add_dependency "rexml"
25
31
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-node
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
9
  - 0
9
- - 2
10
- version: 0.0.2
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Francisco Javier Lopez de San Pedro
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-06-25 00:00:00 Z
18
+ date: 2014-02-12 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: sinatra
@@ -65,12 +65,14 @@ dependencies:
65
65
  requirement: &id004 !ruby/object:Gem::Requirement
66
66
  none: false
67
67
  requirements:
68
- - - ">="
68
+ - - <
69
69
  - !ruby/object:Gem::Version
70
- hash: 3
70
+ hash: 23
71
71
  segments:
72
+ - 1
72
73
  - 0
73
- version: "0"
74
+ - 0
75
+ version: 1.0.0
74
76
  type: :runtime
75
77
  version_requirements: *id004
76
78
  - !ruby/object:Gem::Dependency
@@ -88,9 +90,41 @@ dependencies:
88
90
  type: :runtime
89
91
  version_requirements: *id005
90
92
  - !ruby/object:Gem::Dependency
91
- name: bundler
93
+ name: ruby2ruby
92
94
  prerelease: false
93
95
  requirement: &id006 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ~>
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 2
103
+ - 0
104
+ - 6
105
+ version: 2.0.6
106
+ type: :runtime
107
+ version_requirements: *id006
108
+ - !ruby/object:Gem::Dependency
109
+ name: ruby_parser
110
+ prerelease: false
111
+ requirement: &id007 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ~>
115
+ - !ruby/object:Gem::Version
116
+ hash: 11
117
+ segments:
118
+ - 3
119
+ - 2
120
+ - 2
121
+ version: 3.2.2
122
+ type: :runtime
123
+ version_requirements: *id007
124
+ - !ruby/object:Gem::Dependency
125
+ name: bundler
126
+ prerelease: false
127
+ requirement: &id008 !ruby/object:Gem::Requirement
94
128
  none: false
95
129
  requirements:
96
130
  - - ~>
@@ -101,11 +135,11 @@ dependencies:
101
135
  - 3
102
136
  version: "1.3"
103
137
  type: :development
104
- version_requirements: *id006
138
+ version_requirements: *id008
105
139
  - !ruby/object:Gem::Dependency
106
140
  name: rake
107
141
  prerelease: false
108
- requirement: &id007 !ruby/object:Gem::Requirement
142
+ requirement: &id009 !ruby/object:Gem::Requirement
109
143
  none: false
110
144
  requirements:
111
145
  - - ">="
@@ -115,8 +149,8 @@ dependencies:
115
149
  - 0
116
150
  version: "0"
117
151
  type: :development
118
- version_requirements: *id007
119
- description: This Vagrant plugin allows you to configure a vm environment as a node in a client/server infraestructure. See vagrant-nodemaster
152
+ version_requirements: *id009
153
+ description: This Vagrant plugin allows you to configure a vm environment as a node in a client/server infraestructure. See also vagrant-nodemaster
120
154
  email:
121
155
  - fjsanpedro@gmail.com
122
156
  executables: []
@@ -132,15 +166,21 @@ files:
132
166
  - README.md
133
167
  - Rakefile
134
168
  - lib/vagrant-node.rb
169
+ - lib/vagrant-node/actions/.svn/entries
170
+ - lib/vagrant-node/actions/.svn/text-base/snapshot.rb.svn-base
135
171
  - lib/vagrant-node/actions/snapshot.rb
136
172
  - lib/vagrant-node/api.rb
137
173
  - lib/vagrant-node/apidesc.rb
138
174
  - lib/vagrant-node/clientcontroller.rb
175
+ - lib/vagrant-node/configmanager.rb
139
176
  - lib/vagrant-node/dbmanager.rb
177
+ - lib/vagrant-node/exceptions.rb
140
178
  - lib/vagrant-node/nodeservercommand.rb
179
+ - lib/vagrant-node/nodeserverpasswd.rb
141
180
  - lib/vagrant-node/nodeserverstart.rb
142
181
  - lib/vagrant-node/nodeserverstop.rb
143
182
  - lib/vagrant-node/pidfile.rb
183
+ - lib/vagrant-node/pwmanager.rb
144
184
  - lib/vagrant-node/server.rb
145
185
  - lib/vagrant-node/version.rb
146
186
  - vagrant-node.gemspec
@@ -176,7 +216,7 @@ rubyforge_project: vagrant-node
176
216
  rubygems_version: 1.8.15
177
217
  signing_key:
178
218
  specification_version: 3
179
- summary: ESCRIBIR SUMMARY
219
+ summary: This plugin allows you to set a computer with a virtual environment configured with Vagrant to be controlled and managed remotely. The remote machine must have installed the controller plugin, Vagrant-NodeMaster. With this plugin installed the Vagrant environment can perform requests, that you usually can execute locally, but commanded by a remote computer. This plugin has been developed in the context of the Catedra SAES of the University of Murcia(Spain).
180
220
  test_files: []
181
221
 
182
222
  has_rdoc: