lab 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lab.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $:.unshift lib unless $:.include?(lib)
4
+ require 'lab/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "lab"
8
+ s.version = Lab::VERSION
9
+ s.authors = ["Jonathan Cran"]
10
+ s.email = ["jcran@rapid7.com"]
11
+ s.homepage = "http://www.github.com/rapid7/lab/wiki"
12
+ s.summary = %q{Manage VMs like a boss}
13
+ s.description = %q{Start/Stop/Revert and do other cool stuff w/ Vmware, Virtualbox, and ESXi vms. This gem wraps common CLI utilities and other gems to create a common inteface for vms. }
14
+
15
+ s.rubyforge_project = "lab"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ # specify any dependencies here; for example:
23
+ # s.add_development_dependency "rspec"
24
+ s.add_runtime_dependency "nokogiri"
25
+ s.add_runtime_dependency "net-ssh"
26
+ s.add_runtime_dependency "net-scp"
27
+ end
@@ -111,32 +111,39 @@ class VmDriver
111
111
 
112
112
  private
113
113
 
114
+ # The only reason we don't filter here is because we need
115
+ # the ability to still run clean (controlled entirely by us)
116
+ # command lines.
117
+ def system_command(command)
118
+ puts "DEBUG: system command #{command}"
119
+ system(command)
120
+ end
121
+
122
+ def remote_system_command(command)
123
+ puts "DEBUG: remote system command #{command} running with user #{@user}@#{@host}"
124
+ system_command("ssh #{@user}@#{@host} \"#{command}\"")
125
+ end
126
+
114
127
  def scp_to(local,remote)
115
- ::Net::SCP.start(@hostname, @vm_user, :password => @vm_pass) do |scp|
128
+ puts "DEBUG: copying #{local} to #{remote}"
129
+ Net::SCP.start(@hostname, @vm_user, :password => @vm_pass) do |scp|
116
130
  scp.upload!(from,to)
117
131
  end
118
-
119
- #system_command("scp #{local} #{@vm_user}@#{@hostname}:#{remote}")
120
132
  end
121
133
 
122
134
  def scp_from(local,remote)
123
135
  # download a file from a remote server
124
- ::Net::SCP.start(@hostname, @vm_user, :password => @vm_pass) do |scp|
136
+ puts "DEBUG: copying #{remote} to #{local}"
137
+ Net::SCP.start(@hostname, @vm_user, :password => @vm_pass) do |scp|
125
138
  scp.download!(from,to)
126
139
  end
127
-
128
- #system_command("scp #{@vm_user}@#{@hostname}:#{remote} #{local}")
129
140
  end
130
141
 
131
142
  def ssh_exec(command)
132
-
133
- puts "DEBUG: ssh command: #{command}"
134
-
143
+ puts "DEBUG: ssh command: #{command} on host #{hostname}"
135
144
  Net::SSH.start(@hostname, @vm_user, :password => @vm_pass) do |ssh|
136
145
  result = ssh.exec!(command)
137
146
  end
138
-
139
- `scp #{@vm_user}@#{@hostname} from to`
140
147
  end
141
148
 
142
149
  def filter_input(string)
@@ -160,19 +167,6 @@ private
160
167
 
161
168
  string
162
169
  end
163
-
164
- # The only reason we don't filter here is because we need
165
- # the ability to still run clean (controlled entirely by us)
166
- # command lines.
167
- def system_command(command)
168
- puts "DEBUG: system command #{command}"
169
- system(command)
170
- end
171
-
172
-
173
- def remote_system_command(command)
174
- system_command("ssh #{@user}@#{@host} \"#{command}\"")
175
- end
176
170
  end
177
171
 
178
172
  end
@@ -98,7 +98,7 @@ class WorkstationDriver < VmDriver
98
98
  output_file = "/tmp/lab_command_output_#{rand(1000000)}"
99
99
 
100
100
  scp_to(local_tempfile_path, remote_tempfile_path)
101
- ssh_exec(remote_run_command + "> #{output_file}")
101
+ ssh_exec(command + "> #{output_file}")
102
102
  scp_from(output_file, output_file)
103
103
 
104
104
  ssh_exec("rm #{output_file}")
data/lib/lab/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lab
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/lab.rb CHANGED
@@ -1,4 +1,2 @@
1
- # TODO - use autoload
2
-
3
1
  require 'lab/vm_controller'
4
2
  require 'lab/version'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &21378460 !ruby/object:Gem::Requirement
16
+ requirement: &9870560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21378460
24
+ version_requirements: *9870560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: net-ssh
27
- requirement: &21378040 !ruby/object:Gem::Requirement
27
+ requirement: &9870140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *21378040
35
+ version_requirements: *9870140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: net-scp
38
- requirement: &21377620 !ruby/object:Gem::Requirement
38
+ requirement: &9869720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *21377620
46
+ version_requirements: *9869720
47
47
  description: ! 'Start/Stop/Revert and do other cool stuff w/ Vmware, Virtualbox, and
48
48
  ESXi vms. This gem wraps common CLI utilities and other gems to create a common
49
49
  inteface for vms. '
@@ -58,6 +58,7 @@ files:
58
58
  - README.md
59
59
  - Rakefile
60
60
  - TODO
61
+ - lab.gemspec
61
62
  - lib/lab.rb
62
63
  - lib/lab/controller/dynagen_controller.rb
63
64
  - lib/lab/controller/fog_controller.rb