vixen 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -5
- data/lib/vixen/command_line.rb +10 -35
- data/lib/vixen/command_line/base.rb +24 -0
- data/lib/vixen/command_line/halt.rb +7 -0
- data/lib/vixen/command_line/resume.rb +7 -0
- data/lib/vixen/command_line/snapshot.rb +7 -0
- data/lib/vixen/command_line/status.rb +20 -0
- data/lib/vixen/command_line/suspend.rb +7 -0
- data/lib/vixen/command_line/up.rb +7 -0
- data/vixen.gemspec +1 -1
- metadata +8 -1
data/README.md
CHANGED
@@ -5,6 +5,23 @@ Getting Vixen
|
|
5
5
|
$ gem install vixen
|
6
6
|
```
|
7
7
|
|
8
|
+
Running Vixen
|
9
|
+
=============
|
10
|
+
|
11
|
+
Currently, the `vixen` executable only lists the currently running virtual
|
12
|
+
machines. Much work on the executable remains.
|
13
|
+
|
14
|
+
```shell
|
15
|
+
[~]$ vixen
|
16
|
+
[00:00:00] Connecting to local host
|
17
|
+
[00:00:00] centos-5.8-pe-2.5.3-vmware.vmx
|
18
|
+
[00:00:01] CentOS 5.6 64-bit.vmx
|
19
|
+
[00:00:01] Found 2 running virtual machines
|
20
|
+
```
|
21
|
+
|
22
|
+
Library Usage
|
23
|
+
=============
|
24
|
+
|
8
25
|
Capabilities
|
9
26
|
------------
|
10
27
|
|
@@ -23,11 +40,6 @@ versions of the Windows VMware VIX SDK. These will need to be placed into
|
|
23
40
|
will use [Facter](https://github.com/puppetlabs/facter) to determine which
|
24
41
|
operating system and architecture version of the library to load.
|
25
42
|
|
26
|
-
|
27
|
-
Using Vixen
|
28
|
-
===========
|
29
|
-
|
30
|
-
|
31
43
|
Connecting to a host
|
32
44
|
--------------------
|
33
45
|
|
data/lib/vixen/command_line.rb
CHANGED
@@ -1,44 +1,19 @@
|
|
1
1
|
require 'vixen'
|
2
2
|
|
3
3
|
class Vixen::CommandLine
|
4
|
-
attr_reader :start
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@start = Time.now
|
8
|
-
end
|
9
|
-
|
10
|
-
def elapsed_time
|
11
|
-
"[%s]" % (Time.at(Time.now - start).utc.strftime '%T')
|
12
|
-
end
|
13
|
-
|
14
4
|
def execute
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
vms = host.paths_of_running_vms do |job_handle, event_type, more_event_info, client_data|
|
19
|
-
print " <searching> "
|
20
|
-
if event_type == Vixen::Constants::VixEventType[:find_item]
|
21
|
-
path = Vixen::Bridge.get_string_property more_event_info, Vixen::Constants::VixPropertyId[:found_item_location]
|
22
|
-
if path
|
23
|
-
new_line_after { print File.basename path }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
5
|
+
command = ARGV.shift
|
6
|
+
command ||= 'status'
|
27
7
|
|
28
|
-
|
29
|
-
|
8
|
+
begin
|
9
|
+
require "vixen/command_line/#{command}"
|
30
10
|
|
31
|
-
|
32
|
-
|
33
|
-
puts
|
34
|
-
val
|
35
|
-
end
|
11
|
+
klass = self.class.const_get(command.split('_').map {|s| s.capitalize }.join)
|
12
|
+
raise "Couldn't find #{command}" unless klass
|
36
13
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
14
|
+
klass.new.execute
|
15
|
+
rescue LoadError
|
16
|
+
puts "Unknown command: #{command}"
|
17
|
+
end
|
41
18
|
end
|
42
|
-
|
43
|
-
|
44
19
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Vixen::CommandLine::Base
|
2
|
+
attr_reader :start
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@start = Time.now
|
6
|
+
end
|
7
|
+
|
8
|
+
def elapsed_time
|
9
|
+
"[%s]" % (Time.at(Time.now - start).utc.strftime '%T')
|
10
|
+
end
|
11
|
+
|
12
|
+
def new_line_after
|
13
|
+
val = yield if block_given?
|
14
|
+
puts
|
15
|
+
val
|
16
|
+
end
|
17
|
+
|
18
|
+
def print(message, *args)
|
19
|
+
timed_message = "\r \r#{elapsed_time} " + message
|
20
|
+
$stdout.print timed_message, args
|
21
|
+
$stdout.flush
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'vixen/command_line/base'
|
2
|
+
|
3
|
+
class Vixen::CommandLine::Status < Vixen::CommandLine::Base
|
4
|
+
def execute
|
5
|
+
new_line_after { print "Connecting to local host" }
|
6
|
+
host = Vixen.local_connect
|
7
|
+
|
8
|
+
vms = host.paths_of_running_vms do |job_handle, event_type, more_event_info, client_data|
|
9
|
+
print " <searching> "
|
10
|
+
if event_type == Vixen::Constants::VixEventType[:find_item]
|
11
|
+
path = Vixen::Bridge.get_string_property more_event_info, Vixen::Constants::VixPropertyId[:found_item_location]
|
12
|
+
if path
|
13
|
+
new_line_after { print File.basename path }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
new_line_after { print "Found #{vms.size} running virtual machines" }
|
19
|
+
end
|
20
|
+
end
|
data/vixen.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vixen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -63,6 +63,13 @@ files:
|
|
63
63
|
- lib/vixen.rb
|
64
64
|
- lib/vixen/bridge.rb
|
65
65
|
- lib/vixen/command_line.rb
|
66
|
+
- lib/vixen/command_line/base.rb
|
67
|
+
- lib/vixen/command_line/halt.rb
|
68
|
+
- lib/vixen/command_line/resume.rb
|
69
|
+
- lib/vixen/command_line/snapshot.rb
|
70
|
+
- lib/vixen/command_line/status.rb
|
71
|
+
- lib/vixen/command_line/suspend.rb
|
72
|
+
- lib/vixen/command_line/up.rb
|
66
73
|
- lib/vixen/constants.rb
|
67
74
|
- lib/vixen/model/base.rb
|
68
75
|
- lib/vixen/model/host.rb
|