vixen 0.0.5 → 0.0.6
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 +122 -10
- data/lib/vixen/bridge.rb +10 -4
- data/vixen.gemspec +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -5,33 +5,145 @@ Getting Vixen
|
|
5
5
|
$ gem install vixen
|
6
6
|
```
|
7
7
|
|
8
|
+
Capabilities
|
9
|
+
------------
|
10
|
+
|
11
|
+
* View running VMs
|
12
|
+
* Control power state (on, off, suspend, reset) of VMs
|
13
|
+
* Viewing the current snapshot
|
14
|
+
* Creating snapshots
|
15
|
+
|
16
|
+
Limitations
|
17
|
+
-----------
|
18
|
+
Vixen currently only supports running on Mac OS X or Linux.
|
19
|
+
|
20
|
+
Windows support will require two libraries; one each from the 32-bit and 64-bit
|
21
|
+
versions of the Windows VMware VIX SDK. These will need to be placed into
|
22
|
+
`ext/windows/i386` and `ext/windows/x86_64` respectively, and `Vixen::Bridge`
|
23
|
+
will use [Facter](https://github.com/puppetlabs/facter) to determine which
|
24
|
+
operating system and architecture version of the library to load.
|
25
|
+
|
26
|
+
|
8
27
|
Using Vixen
|
9
28
|
===========
|
10
29
|
|
30
|
+
|
31
|
+
Connecting to a host
|
32
|
+
--------------------
|
33
|
+
|
34
|
+
If using Vixen on the same machine as the virtual machine host, you can simply
|
35
|
+
use `Vixen.local_connect`
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'vixen'
|
39
|
+
|
40
|
+
host = Vixen.local_connect
|
41
|
+
```
|
42
|
+
|
43
|
+
If using Vixen to connect to a remote host (VMware Server, ESXi, vSphere, etc),
|
44
|
+
use `Vixen.connect`
|
45
|
+
|
11
46
|
```ruby
|
12
47
|
require 'vixen'
|
13
48
|
|
14
|
-
|
49
|
+
server_type = Vixen::Constants::VixServiceProvider[:vmware_vi_server]
|
50
|
+
host = Vixen.connect server_type, <hostname>, <port>, <username>, <password>
|
15
51
|
```
|
16
52
|
|
53
|
+
Both of these will return a `Vixen::Model::Host` object.
|
54
|
+
|
55
|
+
Vixen::Model::Host
|
56
|
+
==================
|
57
|
+
|
58
|
+
`Host` currently supports the following actions:
|
59
|
+
|
60
|
+
* `open_vm`
|
61
|
+
* `running_vms`
|
62
|
+
* `paths_of_running_vms`
|
63
|
+
|
64
|
+
Currently running virtual machines
|
65
|
+
----------------------------------
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
require 'vixen'
|
69
|
+
|
70
|
+
host = Vixen.local_connect
|
71
|
+
machines = host.running_vms
|
72
|
+
|
73
|
+
machines.each do |vm|
|
74
|
+
puts "Current Snapshot: #{vm.current_snapshot}"
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
Opening a virtual machine
|
79
|
+
-------------------------
|
80
|
+
|
81
|
+
Opening a virtual machine does not _start_ the virtual machine, but creates
|
82
|
+
an object that you can use to interrogate properties of the virtual machine.
|
83
|
+
The virtual machine _could_ be started by using this object, (see
|
84
|
+
`Vixen::Model::VM#power_on`).
|
85
|
+
|
17
86
|
Vixen can also be used on virtual machines that are not currently active:
|
18
87
|
|
19
88
|
```ruby
|
20
89
|
require 'vixen'
|
90
|
+
|
91
|
+
host = Vixen.local_connect
|
92
|
+
|
21
93
|
path = '/Users/jeff/Documents/Virtual Machines/win2003sat.vmwarevm/Windows Server 2003 Enterprise x64 Edition.vmx'
|
22
|
-
|
94
|
+
|
95
|
+
vm = host.open_vm path
|
96
|
+
|
97
|
+
puts vm.current_snapshot
|
23
98
|
```
|
24
99
|
|
25
|
-
|
26
|
-
|
100
|
+
Paths of running virtual machines
|
101
|
+
---------------------------------
|
27
102
|
|
28
|
-
|
29
|
-
|
30
|
-
|
103
|
+
If all you are interested is the path (of the `.vmx` file) of the running
|
104
|
+
virtual machines, you may use `paths_of_running_vms`, which is much lighter
|
105
|
+
weight than `running_vms`.
|
31
106
|
|
32
|
-
|
33
|
-
|
34
|
-
|
107
|
+
```ruby
|
108
|
+
require 'vixen'
|
109
|
+
|
110
|
+
host = Vixen.local_connect
|
111
|
+
|
112
|
+
paths = host.paths_of_running_vms
|
113
|
+
|
114
|
+
paths.each do |path|
|
115
|
+
puts "Currently running: #{path}"
|
116
|
+
end
|
117
|
+
```
|
118
|
+
|
119
|
+
Vixen::Model::VM
|
120
|
+
================
|
121
|
+
|
122
|
+
`VM` currently supports the following actions:
|
123
|
+
|
124
|
+
* `current_snapshot`
|
125
|
+
* `create_snapshot`
|
126
|
+
* Power Operations
|
127
|
+
* `power_on`
|
128
|
+
* `power_off`
|
129
|
+
* `suspend`
|
130
|
+
* `resume`
|
131
|
+
* `reset`
|
132
|
+
* Querying current power state
|
133
|
+
* `powered_off?`
|
134
|
+
* `suspended?`
|
135
|
+
* `powered_on?`
|
136
|
+
* `current_power_states` - a VM may be concurrently have multiple power states
|
137
|
+
|
138
|
+
Vixen::Model::Snapshot
|
139
|
+
======================
|
140
|
+
|
141
|
+
`Snapshot` currently supports the following actions:
|
142
|
+
|
143
|
+
* `display_name` - the short text title given to a snapshot
|
144
|
+
* `description` - the lengthy text, if any, given to a snapshot
|
145
|
+
* `parent` - the parent snapshot, if any
|
146
|
+
* `full_name` - the full name of the snapshot (traverses parent hierarchy)
|
35
147
|
|
36
148
|
See Also
|
37
149
|
--------
|
data/lib/vixen/bridge.rb
CHANGED
@@ -45,6 +45,7 @@ module Vixen::Bridge
|
|
45
45
|
attach_function :VixSnapshot_GetParent, [:handle, :pointer], :int
|
46
46
|
attach_function :VixVM_PowerOn, [:handle, :int, :handle, :VixEventProc, :pointer], :handle
|
47
47
|
attach_function :VixVM_CreateSnapshot, [:handle, :string, :string, :int, :handle, :VixEventProc, :pointer], :handle
|
48
|
+
attach_function :VixJob_CheckCompletion, [:handle, :pointer], :int
|
48
49
|
|
49
50
|
def self.connect(hostType, hostname, port, username, password)
|
50
51
|
job_handle = VixHandle[:invalid]
|
@@ -90,6 +91,10 @@ module Vixen::Bridge
|
|
90
91
|
pointer_to :int, &block
|
91
92
|
end
|
92
93
|
|
94
|
+
def self.pointer_to_bool(&block)
|
95
|
+
(pointer_to :int, &block) != 0
|
96
|
+
end
|
97
|
+
|
93
98
|
def self.wait_for_async_job(operation, &block)
|
94
99
|
job_handle = yield
|
95
100
|
err = VixJob_Wait job_handle, VixPropertyId[:none]
|
@@ -131,10 +136,11 @@ module Vixen::Bridge
|
|
131
136
|
collect_proc,
|
132
137
|
nil)
|
133
138
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
139
|
+
while ( not pointer_to_bool do |bool_pointer|
|
140
|
+
sleep 0.01
|
141
|
+
VixJob_CheckCompletion(job_handle, bool_pointer)
|
142
|
+
end) do
|
143
|
+
end
|
138
144
|
|
139
145
|
Vix_ReleaseHandle job_handle
|
140
146
|
available_vms
|
data/vixen.gemspec
CHANGED