Skip to content

Commit

Permalink
Merge branch 'release/v0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
frapposelli committed May 28, 2014
2 parents 1f0ef7e + c804829 commit 30101d5
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 14 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
[Vagrant](http://www.vagrantup.com) provider for VMware vCenter®
=============

[Version 0.1.0](../../releases/tag/v0.1.0) has been released!
[Version 0.1.1](../../releases/tag/v0.1.1) 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.1.1](../../releases/tag/v0.1.1) include:

- Support for ```vagrant share``` [Fixes [#2](../../issues/2)]
- Support for [Vagrant Cloud](http://vagrantcloud.com) boxes [Fixes [#1](../../issues/1)]

Install
-------------

Expand All @@ -17,6 +22,12 @@ Latest version can be easily installed by running the following command:

Vagrant will download all the required gems during the installation process.

If you already have the plugin installed you can use:

```vagrant plugin upgrade vagrant-vcenter```

To perform an upgrade to the latest version.

After the install has completed a ```vagrant up --provider=vcenter``` will trigger the newly installed provider.

Configuration
Expand Down
12 changes: 10 additions & 2 deletions lib/vagrant-vcenter/action/build_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ def call(env)
dc = config.vcenter_cnx.serviceInstance.find_datacenter(
config.datacenter_name) or abort 'datacenter not found'

if env[:machine].box.name.to_s.include? '/'
box_file = env[:machine].box.name.rpartition('/').last.to_s
box_name = env[:machine].box.name.to_s.gsub(/\//, '-')
else
box_file = env[:machine].box.name.to_s
box_name = box_file
end

if config.template_folder_name.nil?
box_to_search = env[:machine].box.name.to_s
box_to_search = box_name
else
box_to_search = config.template_folder_name + '/' +
env[:machine].box.name.to_s
box_name
end

# FIXME: Raise a correct exception
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-vcenter/action/connect_vcenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def call(env)

@logger.debug("config.hostname: #{config.hostname}")
@logger.debug("config.username: #{config.username}")
@logger.debug("config.password: #{config.password}")
@logger.debug('config.password: <hidden>')

# FIXME: fix the insecure flag, catch the exception
config.vcenter_cnx = RbVmomi::VIM.connect(
Expand Down
31 changes: 23 additions & 8 deletions lib/vagrant-vcenter/action/inventory_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ def vcenter_upload_box(env)
config = env[:machine].provider_config

box_dir = env[:machine].box.directory.to_s
box_file = env[:machine].box.name.to_s

if env[:machine].box.name.to_s.include? '/'
box_file = env[:machine].box.name.rpartition('/').last.to_s
box_name = env[:machine].box.name.to_s.gsub(/\//, '-')
else
box_file = env[:machine].box.name.to_s
box_name = box_file
end

box_ovf = "file://#{box_dir}/#{box_file}.ovf"

Expand All @@ -35,7 +42,7 @@ def vcenter_upload_box(env)

@logger.debug("OVF File: #{box_ovf}")

env[:ui].info("Adding [#{env[:machine].box.name.to_s}]")
env[:ui].info("Adding [#{box_name}]")

# FIXME: Raise a correct exception
dc = config.vcenter_cnx.serviceInstance.find_datacenter(
Expand All @@ -51,7 +58,7 @@ def vcenter_upload_box(env)
config.template_folder_name,
RbVmomi::VIM::Folder)

template_name = box_file
template_name = box_name

# FIXME: Raise a correct exception
datastore = dc.find_datastore(
Expand Down Expand Up @@ -91,28 +98,36 @@ def vcenter_check_inventory(env)
dc = config.vcenter_cnx.serviceInstance.find_datacenter(
config.datacenter_name) or fail 'datacenter not found'

if env[:machine].box.name.to_s.include? '/'
box_file = env[:machine].box.name.rpartition('/').last.to_s
box_name = env[:machine].box.name.to_s.gsub(/\//, '-')
else
box_file = env[:machine].box.name.to_s
box_name = box_file
end

if config.template_folder_name.nil?
box_to_search = env[:machine].box.name.to_s
box_to_search = box_name
else
box_to_search = config.template_folder_name +
'/' + env[:machine].box.name.to_s
'/' + box_name
end

@logger.debug("This is the box we're looking for: #{box_to_search}")

config.template_id = dc.find_vm(box_to_search)

if config.template_id.nil?
env[:ui].warn("Template [#{env[:machine].box.name.to_s}] " +
env[:ui].warn("Template [#{box_name}] " +
'does not exist!')

user_input = env[:ui].ask(
"Would you like to upload the [#{env[:machine].box.name.to_s}]" +
"Would you like to upload the [#{box_name}]" +
" box?\nChoice (yes/no): "
)

if user_input.downcase == 'yes' || user_input.downcase == 'y'
env[:ui].info("Uploading [#{env[:machine].box.name.to_s}]...")
env[:ui].info("Uploading [#{box_name}]...")
vcenter_upload_box(env)
else
env[:ui].error('Template not uploaded, exiting...')
Expand Down
18 changes: 18 additions & 0 deletions lib/vagrant-vcenter/cap/public_address.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module VagrantPlugins
module VCenter
module Cap
module PublicAddress
def self.public_address(machine)
# Initial try for vagrant share feature.
# It seems ssh_info[:port] is given automatically.
# I think this feature was built planning that the port forwarding
# and networking was done on the vagrant machine, which isn't the
# case in vagrant-vcloud

ssh_info = machine.ssh_info
ssh_info[:host]
end
end
end
end
end
8 changes: 7 additions & 1 deletion lib/vagrant-vcenter/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module VagrantPlugins
module VCenter
# Initialize Vagrant Plugin
class Plugin < Vagrant.plugin('2')
name 'vCenter'
name 'VMware vCenter Provider'
description 'Allows Vagrant to manage machines with VMware vCenter (R)'

config(:vcenter, :provider) do
Expand All @@ -29,6 +29,12 @@ class Plugin < Vagrant.plugin('2')
Provider
end

# Add vagrant share support
provider_capability('vcenter', 'public_address') do
require_relative 'cap/public_address'
Cap::PublicAddress
end

def self.setup_i18n
I18n.load_path << File.expand_path('locales/en.yml',
VCenter.source_root)
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-vcenter/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module VagrantPlugins
# Set version for vagrant-vcenter gem.
module VCenter
VERSION = '0.1.0'
VERSION = '0.1.1'
end
end

0 comments on commit 30101d5

Please sign in to comment.