-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* release/0.2.1: Version bumped to 0.2.1 Gemfile ang gemspec updated Added shortcuts for setting the CPU count and memory size [GH-71] Refactoring of actions 'Import', 'Export' and 'Package' 'config.rb': _detected_errors usage added 'actions.rb' refactoring Action 'SetName' added
- Loading branch information
Showing
12 changed files
with
158 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
require "log4r" | ||
|
||
module VagrantPlugins | ||
module Parallels | ||
module Action | ||
class SetName | ||
def initialize(app, env) | ||
@logger = Log4r::Logger.new("vagrant::action::vm::setname") | ||
@app = app | ||
end | ||
|
||
def call(env) | ||
name = env[:machine].provider_config.name | ||
|
||
# If we already set the name before, then don't do anything | ||
sentinel = env[:machine].data_dir.join("action_set_name") | ||
if !name && sentinel.file? | ||
@logger.info("Default name was already set before, not doing it again.") | ||
return @app.call(env) | ||
end | ||
|
||
# If no name was manually set, then use a default | ||
if !name | ||
prefix = "#{env[:root_path].basename.to_s}_#{env[:machine].name}" | ||
prefix.gsub!(/[^-a-z0-9_]/i, "") | ||
# milliseconds + random number suffix to allow for simultaneous `vagrant up` of the same box in different dirs | ||
name = prefix + "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}" | ||
end | ||
|
||
# Verify the name is not taken | ||
vms_names = env[:machine].provider.driver.read_all_names | ||
raise Vagrant::Errors::VMNameExists, :name => name if \ | ||
vms_names.has_key?(name) && vms_names[name] != env[:machine].id | ||
|
||
if vms_names.has_key?(name) | ||
@logger.info("Not setting the name because our name is already set.") | ||
else | ||
env[:ui].info(I18n.t( | ||
"vagrant.actions.vm.set_name.setting_name", name: name)) | ||
env[:machine].provider.driver.set_name(name) | ||
end | ||
|
||
# Create the sentinel | ||
sentinel.open("w") do |f| | ||
f.write(Time.now.to_i.to_s) | ||
end | ||
|
||
@app.call(env) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module VagrantPlugins | ||
module Parallels | ||
VERSION = "0.2.0" | ||
VERSION = "0.2.1" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require_relative "../unit/base" | ||
|
||
require VagrantPlugins::Parallels.source_root.join('lib/vagrant-parallels/config') | ||
|
||
describe VagrantPlugins::Parallels::Config do | ||
|
||
context "defaults" do | ||
before { subject.finalize! } | ||
|
||
it "should have one Shared adapter" do | ||
expect(subject.network_adapters).to eql({ | ||
0 => [:shared, []], | ||
}) | ||
end | ||
end | ||
|
||
describe "memory=" do | ||
it "configures memory size (in Mb)" do | ||
subject.memory=(1024) | ||
expect(subject.customizations).to include(["pre-boot", ["set", :id, "--memsize", '1024']]) | ||
end | ||
end | ||
|
||
describe "cpus=" do | ||
it "configures count of cpus" do | ||
subject.cpus=('4') | ||
expect(subject.customizations).to include(["pre-boot", ["set", :id, "--cpus", 4]]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,13 +10,13 @@ Gem::Specification.new do |spec| | |
spec.email = ["[email protected]"] | ||
spec.description = %q{Enables Vagrant to manage Parallels machines.} | ||
spec.summary = %q{Enables Vagrant to manage Parallels machines.} | ||
spec.homepage = "http://github.com/yshahin/vagrant-parallels" | ||
spec.homepage = "http://github.com/Parallels/vagrant-parallels" | ||
spec.license = "MIT" | ||
|
||
spec.required_rubygems_version = ">= 1.3.6" | ||
spec.rubyforge_project = "vagrant-parallels" | ||
|
||
spec.add_development_dependency "bundler", "~> 1.3" | ||
spec.add_development_dependency "bundler", "~> 1.5.2" | ||
spec.add_development_dependency "rake" | ||
spec.add_development_dependency "rspec", "~> 2.14.0" | ||
spec.add_development_dependency "i18n-tasks", "~> 0.2.14" | ||
|