esx 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +12 -0
  2. data/bin/esx +2 -1
  3. data/lib/esx.rb +22 -11
  4. metadata +22 -22
data/README.md CHANGED
@@ -8,6 +8,18 @@ If you want a full VMWare vSphere API ruby implementation have a look at https:/
8
8
 
9
9
  # Installation
10
10
 
11
+ ## Ubuntu/Debian
12
+
13
+ apt-get install libxml2-dev libxslt-dev gcc make rubygems
14
+ gem install esx
15
+
16
+ ## RHEL/Fedora
17
+
18
+ yum install libxml2-devel libxslt-devel make gcc rubygems
19
+ gem install esx
20
+
21
+ ## MacOSX
22
+
11
23
  gem install esx
12
24
 
13
25
  # Usage
data/bin/esx CHANGED
@@ -78,6 +78,7 @@ class CreateVMCommand < BaseCommand
78
78
  option "--guest-id", "GUEST_ID", "GuestID value", :attribute_name => :guest_id, :default => 'otherGuest'
79
79
  option "--name", "VM NAME", "Virtual Machine name (required)"
80
80
  option "--memory", "MEMORY", "VM Memory size in MB", :default => 512
81
+ option "--mac-address", "MAC", "VM Nic1 MAC address", :default => nil
81
82
  option "--tmpdir", "TMP DIR", "tmp dir used to download files", :default => "/tmp"
82
83
  option "--datastore", "DATASTORE", "Datastore used to host the disk", :default => "datastore1"
83
84
  option "--poweron", :flag, "Power on the VM after creation"
@@ -132,7 +133,7 @@ class CreateVMCommand < BaseCommand
132
133
  vm = host.create_vm :vm_name => name,
133
134
  :disk_file => "#{name}/#{name}.vmdk",
134
135
  :datastore => datastore, :disk_type => :flat, :memory => memory,
135
- :guest_id => guest_id
136
+ :guest_id => guest_id, :mac_address => mac_address
136
137
  if poweron?
137
138
  vm.power_on
138
139
  end
data/lib/esx.rb CHANGED
@@ -6,7 +6,7 @@ require 'net/ssh'
6
6
 
7
7
  module ESX
8
8
 
9
- VERSION = '0.2'
9
+ VERSION = '0.2.1'
10
10
 
11
11
  class Host
12
12
 
@@ -124,16 +124,7 @@ module ESX
124
124
  },
125
125
  {
126
126
  :operation => :add,
127
- :device => RbVmomi::VIM.VirtualE1000(
128
- :key => 0,
129
- :deviceInfo => {
130
- :label => 'Network Adapter 1',
131
- :summary => 'VM Network'
132
- },
133
- :backing => RbVmomi::VIM.VirtualEthernetCardNetworkBackingInfo(
134
- :deviceName => 'VM Network'
135
- ),
136
- :addressType => 'generated')
127
+ :device => RbVmomi::VIM.VirtualE1000(create_net_dev(specification))
137
128
  }
138
129
  ],
139
130
  :extraConfig => [
@@ -150,6 +141,26 @@ module ESX
150
141
  VM.wrap(@_datacenter.vmFolder.CreateVM_Task(:config => vm_cfg, :pool => @_datacenter.hostFolder.children.first.resourcePool).wait_for_completion)
151
142
  end
152
143
 
144
+ def create_net_dev(spec)
145
+ h = {
146
+ :key => 0,
147
+ :deviceInfo => {
148
+ :label => 'Network Adapter 1',
149
+ :summary => 'VM Network'
150
+ },
151
+ :backing => RbVmomi::VIM.VirtualEthernetCardNetworkBackingInfo(
152
+ :deviceName => 'VM Network'
153
+ )
154
+ }
155
+ if spec[:mac_address]
156
+ h[:macAddress] = spec[:mac_address]
157
+ h[:addressType] = 'manual'
158
+ else
159
+ h[:addressType] = 'generated'
160
+ end
161
+ h
162
+ end
163
+
153
164
  # Return product info as an array of strings containing
154
165
  #
155
166
  # fullName, apiType, apiVersion, osType, productLineId, vendor, version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esx
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-20 00:00:00.000000000 Z
12
+ date: 2011-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &8606860 !ruby/object:Gem::Requirement
16
+ requirement: &16159880 !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: :development
23
23
  prerelease: false
24
- version_requirements: *8606860
24
+ version_requirements: *16159880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &8620220 !ruby/object:Gem::Requirement
27
+ requirement: &16158560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *8620220
35
+ version_requirements: *16158560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &8618780 !ruby/object:Gem::Requirement
38
+ requirement: &16157260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.5.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *8618780
46
+ version_requirements: *16157260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &8617480 !ruby/object:Gem::Requirement
49
+ requirement: &16155820 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *8617480
57
+ version_requirements: *16155820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: alchemist
60
- requirement: &8615740 !ruby/object:Gem::Requirement
60
+ requirement: &16154620 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *8615740
68
+ version_requirements: *16154620
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rbvmomi
71
- requirement: &8614480 !ruby/object:Gem::Requirement
71
+ requirement: &16153360 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *8614480
79
+ version_requirements: *16153360
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: terminal-table
82
- requirement: &8631960 !ruby/object:Gem::Requirement
82
+ requirement: &16176540 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *8631960
90
+ version_requirements: *16176540
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: net-ssh
93
- requirement: &8630540 !ruby/object:Gem::Requirement
93
+ requirement: &16175200 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *8630540
101
+ version_requirements: *16175200
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: net-scp
104
- requirement: &8629100 !ruby/object:Gem::Requirement
104
+ requirement: &16173960 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *8629100
112
+ version_requirements: *16173960
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: clamp
115
- requirement: &8627300 !ruby/object:Gem::Requirement
115
+ requirement: &16172640 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *8627300
123
+ version_requirements: *16172640
124
124
  description: Manage VMWare ESX hosts with ease
125
125
  email: rubiojr@frameos.org
126
126
  executables: