Skip to content

Commit

Permalink
Merge branch 'release/v0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
frapposelli committed Jun 16, 2014
2 parents c04ec8f + 283fb40 commit 3c15d77
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 153 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ gemspec
group :development do
gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git'
end

group :plugins do
gem "vagrant-vcenter", path: "."
end
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
[Vagrant](http://www.vagrantup.com) provider for VMware vCenter®
=============

[Version 0.1.1](../../releases/tag/v0.1.1) has been released!
[Version 0.2.0](../../releases/tag/v0.2.0) has been released!
-------------

Please note that this software is still Alpha/Beta quality and is not recommended for production usage.

Right now a [Precise32](http://vagrant.gosddc.com/boxes/precise32-vcenter.box) is available for use, or you can roll your own as you please, make sure to install VMware tools in it.

Changes in [version 0.2.0](../../releases/tag/v0.2.0) include:

New Features

- Add option to set the actual vm name
- Set some options in the vm via linux prep
- Static networking
- Hostname
- Add option to set vmnetwork name and backing
- Vagrant now uses builtin ```SyncedFolders``` helper to synchronize folders

Fixes

- Fix the read_ssh_info if the vm doesn't have a network yet at first try the later ssh's wont forever fail

Many thanks to @BarnacleBob for submitting PR #4 with all these new features!

Changes in [version 0.1.1](../../releases/tag/v0.1.1) include:

- Support for ```vagrant share``` [Fixes [#2](../../issues/2)]
Expand Down
6 changes: 2 additions & 4 deletions lib/vagrant-vcenter/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def self.action_boot
Vagrant::Action::Builder.new.tap do |b|
b.use PowerOn
b.use Provision
b.use SyncFolders
b.use SyncedFolders
end
end

Expand Down Expand Up @@ -114,7 +114,7 @@ def self.action_provision
next
end
b2.use Provision
b2.use SyncFolders
b2.use SyncedFolders
end
end
end
Expand Down Expand Up @@ -224,8 +224,6 @@ def self.action_up
action_root.join('resume')
autoload :Suspend,
action_root.join('suspend')
autoload :SyncFolders,
action_root.join('sync_folders')
end
end
end
67 changes: 64 additions & 3 deletions lib/vagrant-vcenter/action/build_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,73 @@ def call(env)
:location => relocate_spec,
:powerOn => false,
:template => false)

if config.vm_network_name or config.num_cpu or config.memory
config_spec = RbVmomi::VIM.VirtualMachineConfigSpec
config_spec.numCPUs = config.num_cpu if config.num_cpu
config_spec.memoryMB = config.memory if config.memory

if config.vm_network_name
# First we must find the specified network
network = dc.network.find { |f| f.name == config.vm_network_name } or
abort "Could not find network with name #{config.vm_network_name} to join vm to"
card = template.config.hardware.device.grep(
RbVmomi::VIM::VirtualEthernetCard).first or
abort "could not find network card to customize"
if config.vm_network_type == "DistributedVirtualSwitchPort"
switch_port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(
:switchUuid => network.config.distributedVirtualSwitch.uuid,
:portgroupKey => network.key)
card.backing = RbVmomi::VIM.VirtualEthernetCardDistributedVirtualPortBackingInfo(
:port => switch_port)
else
abort "vm network type of #{config.vm_network_type} is unknown"
end
dev_spec = RbVmomi::VIM.VirtualDeviceConfigSpec(:device => card, :operation => "edit")
config_spec.deviceChange = [dev_spec]
end

spec.config = config_spec
end

if config.enable_vm_customization or config.enable_vm_customization == 'true'
gIPSettings = RbVmomi::VIM.CustomizationGlobalIPSettings(
:dnsServerList => config.dns_server_list,
:dnsSuffixList => config.dns_suffix_list)

prep = RbVmomi::VIM.CustomizationLinuxPrep(
:domain => env[:machine].name,
:hostName => RbVmomi::VIM.CustomizationFixedName(
:name => env[:machine].name))

adapter = RbVmomi::VIM.CustomizationIPSettings(
:gateway => [config.gateway],
:ip => RbVmomi::VIM.CustomizationFixedIp(
:ipAddress => config.ipaddress),
:subnetMask => config.netmask)

nic_map = [RbVmomi::VIM.CustomizationAdapterMapping(
:adapter => adapter)]

cust_spec = RbVmomi::VIM.CustomizationSpec(
:globalIPSettings => gIPSettings,
:identity => prep,
:nicSettingMap => nic_map)

spec.customization = cust_spec
end

@logger.debug("Spec: #{spec.pretty_inspect}")

vm_target = "Vagrant-#{Etc.getlogin}-" +
"#{vm_name}-#{Socket.gethostname.downcase}-" +
"#{SecureRandom.hex(4)}"
@logger.debug("disable_auto_vm_name: #{config.disable_auto_vm_name}")

if config.disable_auto_vm_name or config.disable_auto_vm_name == 'true'
vm_target = vm_name.to_s
else
vm_target = "Vagrant-#{Etc.getlogin}-" +
"#{vm_name}-#{Socket.gethostname.downcase}-" +
"#{SecureRandom.hex(4)}"
end

@logger.debug("VM name: #{vm_target}")

Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-vcenter/action/power_on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def call(env)
# Poweron VM
env[:ui].info('Powering on VM...')
vm.PowerOnVM_Task.wait_for_completion
sleep(3) until env[:machine].communicate.ready?
sleep(20) until env[:machine].communicate.ready?
@app.call env
end
end
Expand Down
14 changes: 12 additions & 2 deletions lib/vagrant-vcenter/action/read_ssh_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,19 @@ def read_ssh_info(env)
root_vm_folder = dc.vmFolder
vm = root_vm_folder.findByUuid(env[:machine].id)

@logger.debug("IP Address: #{vm.guest.ipAddress}")
address = vm.guest.ipAddress
if not address or address == ''
address = vm.guest_ip
end

{ :host => vm.guest.ipAddress, :port => 22 }
if not address or address == ''
# if we can't find it right away just return nil. it will retry
# till the vmware tools supplies the ip address back to vcenter
@logger.debug('could not find booted guest ipaddress')
return nil
end

{ :host => address, :port => 22 }
end
end
end
Expand Down
135 changes: 0 additions & 135 deletions lib/vagrant-vcenter/action/sync_folders.rb

This file was deleted.

Loading

0 comments on commit 3c15d77

Please sign in to comment.