Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/v0.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
frapposelli committed Aug 8, 2014
2 parents bb9bc20 + 2d60600 commit 052444d
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 102 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Vagrant](http://www.vagrantup.com) provider for VMware vCloud Director®
=============

[Version 0.4.0](../../releases/tag/v0.4.0) has been released!
[Version 0.4.1](../../releases/tag/v0.4.1) has been released!
-------------

Please note that this software is still Alpha/Beta quality and is not recommended for production usage.
Expand All @@ -23,6 +23,15 @@ Vagrant will download all the required gems during the installation process.

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

Upgrade
-------------

If you already have vagrant-vcloud installed you can update to the latest version available by issuing:

```vagrant plugin update vagrant-vcloud```

Vagrant will take care of the upgrade process.

Configuration
-------------

Expand Down
1 change: 1 addition & 0 deletions lib/vagrant-vcloud/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def self.action_boot
b2.use ForwardPorts
end
end
b.use WaitForCommunicator, [:starting, :running]
b.use Provision
b.use SyncFolders
end
Expand Down
37 changes: 27 additions & 10 deletions lib/vagrant-vcloud/driver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def send_request(params, payload = nil, content_type = nil)
extheader = {}
extheader['accept'] = "application/*+xml;version=#{@api_version}"

if !content_type.nil?
unless content_type.nil?
extheader['Content-Type'] = content_type
end

Expand Down Expand Up @@ -331,9 +331,16 @@ def send_request(params, payload = nil, content_type = nil)
extheader
)

if !response.ok?
raise "Warning: unattended code #{response.status}" +
" #{response.reason}"
unless response.ok?
if response.code == 400
error_message = Nokogiri.parse(response.body)
error = error_message.css('Error')
fail Errors::InvalidRequestError,
:message => error.first['message'].to_s
else
fail Errors::UnattendedCodeError,
:message => response.status
end
end

nicexml = Nokogiri.XML(response.body)
Expand All @@ -343,7 +350,7 @@ def send_request(params, payload = nil, content_type = nil)
if @logger.level == 1
ap "[#{Time.now.ctime}] <- RECV #{response.status}"
# Just avoid the task spam.
if !url.index('/task/')
unless url.index('/task/')
ap 'RECV HEADERS'
ap response.headers
ap 'RECV BODY'
Expand All @@ -352,10 +359,8 @@ def send_request(params, payload = nil, content_type = nil)
end

[Nokogiri.parse(response.body), response.headers]
rescue SocketError
raise 'Impossible to connect, verify endpoint'
rescue Errno::EADDRNOTAVAIL
raise 'Impossible to connect, verify endpoint'
rescue SocketError, Errno::EADDRNOTAVAIL
raise Errors::EndpointUnavailable, :endpoint => @api_url
end
end

Expand Down Expand Up @@ -432,8 +437,20 @@ def upload_file(upload_url, upload_file, vapp_template, config = {})
'Content-Length' => range_len.to_s
}

upload_request = "#{@host_url}#{upload_url}"

# Massive debug when LOG=DEBUG
# Using awesome_print to get nice XML output for better readability
if @logger.level == 1
ap "[#{Time.now.ctime}] -> SEND PUT #{upload_request}"
ap 'SEND HEADERS'
ap extheader
ap 'SEND BODY'
ap '<data omitted>'
end

begin
upload_request = "#{@host_url}#{upload_url}"

# FIXME: Add debug on the return status of "connection"
# to enhance troubleshooting for this upload process.
# (tsugliani)
Expand Down
16 changes: 8 additions & 8 deletions lib/vagrant-vcloud/driver/meta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,14 @@ def get_api_version(host_url)
# Suppress SSL depth message
clnt.ssl_config.verify_callback = proc { |ok, ctx|; true }

url = "#{host_url}/api/versions"
uri = URI(host_url)
url = "#{uri.scheme}://#{uri.host}:#{uri.port}/api/versions"

begin
response = clnt.request('GET', url, nil, nil, nil)
if !response.ok?
raise "Warning: unattended code #{response.status} " +
"#{response.reason}"
unless response.ok?
fail Errors::UnattendedCodeError,
:message => response.status + ' ' + response.reason
end

version_info = Nokogiri.parse(response.body)
Expand All @@ -154,10 +155,9 @@ def get_api_version(host_url)

api_version_supported

rescue SocketError
raise Errors::HostNotFound, :message => host_url
rescue Errno::EADDRNOTAVAIL
raise Errors::HostNotFound, :message => host_url
rescue SocketError, Errno::EADDRNOTAVAIL
raise Errors::EndpointUnavailable,
:endpoint => "#{uri.scheme}://#{uri.host}:#{uri.port}/api"
end
end
end
Expand Down
Loading

0 comments on commit 052444d

Please sign in to comment.