Skip to content

Commit

Permalink
Release v1.4.0
Browse files Browse the repository at this point in the history
* master:
  Bump version to 1.4.0
  website: Fix "Install Packer" url
  Fix sidebar border
  website: Move media-related properties to _media_queries.less
  website: Fix indentation
  Fix footer at bottom
  Added website sources
  test/unit: Move common cases to the shared example
  driver: Use most recent DHCP lease when determining IP
  • Loading branch information
legal90 committed Jun 26, 2015
2 parents d4972c9 + e8ad516 commit d07d02a
Showing 61 changed files with 9,929 additions and 45 deletions.
10 changes: 7 additions & 3 deletions lib/vagrant-parallels/driver/base.rb
Original file line number Diff line number Diff line change
@@ -261,14 +261,15 @@ def read_forwarded_ports(global=false)
# Returns an IP of the virtual machine. It requires that Shared network
# adapter is configured for this VM and it obtains an IP via DHCP.
#
#
# @return [String] IP address leased by DHCP server in "Shared" network
def read_guest_ip
mac_addr = read_mac_address.downcase
leases_file = '/Library/Preferences/Parallels/parallels_dhcp_leases'
leases = {}
begin
File.open(leases_file).grep(/#{mac_addr}/) do |line|
return line[/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/]
_, ip, exp, dur, _, _ = line.split /([\d.]*)="(\d*),(\d*),(\w*),(\w*)".*/
leases[ip] = exp.to_i - dur.to_i
end
rescue Errno::EACCES
raise Errors::DhcpLeasesNotAccessible, :leases_file => leases_file.to_s
@@ -278,7 +279,10 @@ def read_guest_ip
return nil
end

nil
return nil if leases.empty?

# Get the most resent lease and return an associated IP
leases.sort_by { |_ip, lease_time| lease_time }.last.first
end

# Returns path to the Parallels Tools ISO file.
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module VagrantPlugins
module Parallels
VERSION = '1.4.0.rc1'
VERSION = '1.4.0'
end
end
20 changes: 0 additions & 20 deletions test/unit/driver/pd_8_test.rb
Original file line number Diff line number Diff line change
@@ -7,24 +7,4 @@
subject { VagrantPlugins::Parallels::Driver::Meta.new(uuid) }

it_behaves_like "parallels desktop driver"

describe "ssh_ip" do
let(:content) {'10.200.0.99="1394547632,1800,001c420000ff,01001c420000ff"'}

it "returns an IP address assigned to the specified MAC" do
driver.should_receive(:read_mac_address).and_return("001C420000FF")
File.should_receive(:open).with(an_instance_of(String)).
and_return(StringIO.new(content))

subject.ssh_ip.should == "10.200.0.99"
end

it "rises DhcpLeasesNotAccessible exception when file is not accessible" do
File.stub(:open).and_call_original
File.should_receive(:open).with(an_instance_of(String)).
and_raise(Errno::EACCES)
expect { subject.ssh_ip }.
to raise_error(VagrantPlugins::Parallels::Errors::DhcpLeasesNotAccessible)
end
end
end
21 changes: 0 additions & 21 deletions test/unit/driver/pd_9_test.rb
Original file line number Diff line number Diff line change
@@ -26,25 +26,4 @@
subject.set_power_consumption_mode(false)
end
end

describe "ssh_ip" do
let(:content) {'10.200.0.99="1394547632,1800,001c420000ff,01001c420000ff"'}

it "returns an IP address assigned to the specified MAC" do
driver.should_receive(:read_mac_address).and_return("001C420000FF")
File.should_receive(:open).with(an_instance_of(String)).
and_return(StringIO.new(content))

subject.ssh_ip.should == "10.200.0.99"
end

it "rises DhcpLeasesNotAccessible exception when file is not accessible" do
File.stub(:open).and_call_original
File.should_receive(:open).with(an_instance_of(String)).
and_raise(Errno::EACCES)
expect { subject.ssh_ip }.
to raise_error(VagrantPlugins::Parallels::Errors::DhcpLeasesNotAccessible)
end
end

end
21 changes: 21 additions & 0 deletions test/unit/support/shared/pd_driver_examples.rb
Original file line number Diff line number Diff line change
@@ -269,6 +269,27 @@
end
end

describe "ssh_ip" do
let(:content) {'10.200.0.100="1394546410,1800,001c420000ff,01001c420000ff
10.200.0.99="1394547632,1800,001c420000ff,01001c420000ff"'}

it "returns an IP address assigned to the specified MAC" do
driver.should_receive(:read_mac_address).and_return("001C420000FF")
File.should_receive(:open).with(an_instance_of(String)).
and_return(StringIO.new(content))

subject.ssh_ip.should == "10.200.0.99"
end

it "rises DhcpLeasesNotAccessible exception when file is not accessible" do
File.stub(:open).and_call_original
File.should_receive(:open).with(an_instance_of(String)).
and_raise(Errno::EACCES)
expect { subject.ssh_ip }.
to raise_error(VagrantPlugins::Parallels::Errors::DhcpLeasesNotAccessible)
end
end

describe "start" do
it "starts the VM" do
subprocess.should_receive(:execute).
1 change: 1 addition & 0 deletions vagrant-parallels.gemspec
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
root_path = File.dirname(__FILE__)
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
all_files.reject! { |file| file.start_with?("website/") }
gitignore_path = File.join(root_path, ".gitignore")
gitignore = File.readlines(gitignore_path)
gitignore.map! { |line| line.chomp.strip }
6 changes: 6 additions & 0 deletions website/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Website: docs
./build
./Rakefile

.DS_Store
.idea/
13 changes: 13 additions & 0 deletions website/docs/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source "https://rubygems.org"

gem "less", "~> 2.2.2"
gem "middleman", "~> 3.2.0"
gem "middleman-deploy", "~> 1.0"
gem "rack-contrib", "~> 1.1.0"
gem "redcarpet", "~> 2.2.2"
gem "therubyracer", "~> 0.12.0"
gem "thin", "~> 1.5.0"

group :development do
gem "highline", "~> 1.6.15"
end
1 change: 1 addition & 0 deletions website/docs/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bundle exec thin start -p $PORT
26 changes: 26 additions & 0 deletions website/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Vagrant Parallels Documentation

There are sources for documentation pages:
http://parallels.github.io/vagrant-parallels/docs/

This is a [Middleman](http://middlemanapp.com) project, which builds a static
site from these source files.

## Contributions Welcome!

If you find a typo or you feel like you can improve the HTML, CSS, or
JavaScript, we welcome contributions. Feel free to open issues or pull
requests like any normal GitHub project, and we'll merge it in.

## Running the Site Locally

Running the site locally is simple. Clone this repo and run the following
commands:

```
$ bundle
$ bundle exec middleman server
```

Then open up `localhost:4567`. Note that some URLs you may need to append
".html" to make them work (in the navigation and such).
1 change: 1 addition & 0 deletions website/docs/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'middleman-gh-pages'
25 changes: 25 additions & 0 deletions website/docs/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'

# Use the RedCarpet Markdown engine
set :markdown_engine, :redcarpet
set :markdown, fenced_code_blocks: true

set :relative_links, true

# Use relative URLs
activate :relative_assets

# Build-specific configuration
configure :build do
activate :asset_hash
activate :minify_css
activate :minify_javascript
end

activate :deploy do |deploy|
deploy.remote = "origin"
deploy.method = :git
deploy.branch = "gh-pages"
end
39 changes: 39 additions & 0 deletions website/docs/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require "rack"
require "rack/contrib/not_found"
require "rack/contrib/response_headers"
require "rack/contrib/static_cache"
require "rack/contrib/try_static"

require File.expand_path("../lib/redirect_to_docs", __FILE__)

# Properly compress the output if the client can handle it.
use Rack::Deflater

# Redirect the homepage to the latest documentation
use HashiCorp::Rack::RedirectToDocs

# Set the "forever expire" cache headers for these static assets. Since
# we hash the contents of the assets to determine filenames, this is safe
# to do.
use Rack::StaticCache,
root: "build",
urls: ["/images", "/javascripts", "/stylesheets"],
duration: 2,
versioning: false

# For anything that matches below this point, we set the surrogate key
# for Fastly so that we can quickly purge all the pages without touching
# the static assets.
use Rack::ResponseHeaders do |headers|
headers["Surrogate-Key"] = "page"
end

# Try to find a static file that matches our request, since Middleman
# statically generates everything.
use Rack::TryStatic,
root: "build",
urls: ["/"],
try: [".html", "index.html", "/index.html"]

# 404 if we reached this point. Sad times.
run Rack::NotFound.new(File.expand_path("../build/404.html", __FILE__))
20 changes: 20 additions & 0 deletions website/docs/helpers/sidebar_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module SidebarHelpers
# This helps by setting the "current" class for sidebar nav elements
# if the YAML frontmatter matches the expected value.
def sidebar_current(expected)
current = current_page.data.sidebar_current
if current == expected
#|| sidebar_section == expected
return " class=\"current\""
else
return ""
end
end

# This returns the overall section of the documentation we're on.
def sidebar_section
current = current_page.data.sidebar_current
return "" if !current
current.split("-")[0]
end
end
25 changes: 25 additions & 0 deletions website/docs/lib/redirect_to_docs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module HashiCorp
module Rack
# This redirects to the latest version of the docs.
class RedirectToDocs
def initialize(app)
@app = app
end

def call(env)
if env["PATH_INFO"] =~ /^\/$/
headers = {
"Content-Type" => "text/html",
"Location" => "/docs/",
"Surrogate-Key" => "page"
}
message = "Redirecting to new URL..."

return [301, headers, [message]]
end

@app.call(env)
end
end
end
end
7 changes: 7 additions & 0 deletions website/docs/source/404.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h2>Page Not Found</h4>

<p>
Sorry, the page you tried to visit doesn't exist. This could be our fault,
and if so we'll fix that up right away. Please go back, or go back
<a href="/">home</a> to get back on track.
</p>
81 changes: 81 additions & 0 deletions website/docs/source/docs/boxes/base.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
page_title: "Creating a Base Box"
sidebar_current: "boxes-base"
---

# Creating a Base Box

<div class="alert alert-warn">
<p>
<strong>Warning: Advanced Topic!</strong> Creating a base box can be a
time consuming and tedious process, and is not recommended for new
Vagrant users. If you're just getting started with Vagrant, we
recommend trying to find <a href="https://atlas.hashicorp.com/parallels">
existing base boxes</a> to use first.
</p>
</div>

This page documents the box format so that you can create your own base boxes
manually.

Prior to reading this page, please check out the [basics of the Vagrant
box file format](http://docs.vagrantup.com/v2/boxes/format.html).

## Contents
A Parallels base box is a compressed archive of the necessary contents of
a Parallels "pvm" file. Here is an example of what is contained in such a box:

```
$ tree
.
├── Vagrantfile
├── box.pvm
│   ├── NVRAM.dat
│   ├── VmInfo.pvi
│   ├── config.pvs
│   └── harddisk.hdd
│   └── ...
└── metadata.json
```

`config.pvs` and `.hdd` files are strictly required for a Parallels virtual
machine.

There is also the "metadata.json" file used by Vagrant itself. This file
contains nothing but the defaults which are documented on the [box format]
(http://docs.vagrantup.com/v2/boxes/format.html) page.

## Installed Software

Base boxes for the Parallels provider should have the following software
installed, as a bare minimum:

- SSH server with key-based authentication setup. If you want the box to work
with default Vagrant settings, the SSH user must be set to accept the [insecure
keypair](https://github.com/mitchellh/vagrant/blob/master/keys/vagrant.pub)
that ships with Vagrant.

- [Parallels Tools](http://download.parallels.com/desktop/v9/ga/docs/en_US/
Parallels%20Desktop%20User's%20Guide/32791.htm) so that things such as shared
folders can function. There are many other benefits to installing the tools,
such as networking configuration and device mapping.

## Optimizing the Box Size

Prior to packaging up a box, you should shrink the hard drives as much as
possible. This can be done with `prl_disk_tool`:

```
$ prl_disk_tool compact /path/to/harddisk.hdd
```

## Packaging

Remove any extraneous files from the "pvm" folder and package it. Be sure to
compress the tar with gzip (done below in a single command) since Parallels
hard disks are not compressed by default.

```
$ cd /path/to/my/box.pvm/..
$ tar cvzf custom.box ./box.pvm ./Vagrantfile ./metadata.json
```
Loading

0 comments on commit d07d02a

Please # to comment.