Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Environment and VM attributes #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# 0.3.7 (March 21, 2018)

* Add disks to a VM if provided.
* Apply custom name to new environmeht if provided.
* Add new environment to Project ID if provided.

# 0.3.6 (August 2, 2017)

* Parameterize some Gemfile entries for testing purposes.
* Fix bug which limited the number of guest VMs to 3 when the host is also a
* Fix bug which limited the number of guest VMs to 3 when the host is also a
Skytap VM.
* Fix a bug in timeout error handling.

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gemspec

VAGRANT_GEM_TAG = ENV['VAGRANT_GEM_TAG'] || 'v1.7.4'
VAGRANT_GEM_TAG = ENV['VAGRANT_GEM_TAG'] || 'v1.9.1'
# vagrant-spec made a change in 1d09951e which created a dependency conflict
# in our test environment. For now, default to the preceding revision.
VAGRANT_SPEC_GEM_REF = ENV['VAGRANT_SPEC_REF'] || '5006bc73'
Expand Down
119 changes: 64 additions & 55 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,93 +1,100 @@
PATH
remote: .
specs:
vagrant-skytap (0.2.5)
json_pure

PATH
remote: ../vagrant
GIT
remote: git://github.com/mitchellh/vagrant.git
revision: d8c2b2e5ababcdecc65b62b91e5dec21a4bc2d96
tag: v1.9.1
specs:
vagrant (1.8.1)
bundler (>= 1.5.2, <= 1.10.6)
vagrant (1.9.1)
childprocess (~> 0.5.0)
erubis (~> 2.7.0)
hashicorp-checkpoint (~> 0.1.1)
i18n (>= 0.6.0, <= 0.8.0)
listen (~> 3.0.2)
listen (~> 3.1.5)
log4r (~> 1.1.9, < 1.1.11)
net-scp (~> 1.1.0)
net-sftp (~> 2.1)
net-ssh (~> 3.0.1)
nokogiri (= 1.6.3.1)
nokogiri (= 1.6.7.1)
rb-kqueue (~> 0.2.0)
rest-client (>= 1.6.0, < 2.0)
rest-client (>= 1.6.0, < 3.0)
ruby_dep (<= 1.3.1)
wdm (~> 0.1.0)
winrm (~> 1.3)
winrm-fs (~> 0.2.2)
winrm (~> 1.6)
winrm-fs (~> 0.3.0)

PATH
remote: ../vagrant-spec
GIT
remote: https://github.com/mitchellh/vagrant-spec.git
revision: 5006bc73cd8796465ca09307d4774f8ec8375aa0
ref: 5006bc73
specs:
vagrant-spec (0.0.1)
childprocess (~> 0.5.0)
log4r (~> 1.1.9)
rspec (~> 2.14)
thor (~> 0.18.1)

PATH
remote: .
specs:
vagrant-skytap (0.3.7)
json_pure

GEM
remote: https://rubygems.org/
specs:
addressable (2.3.8)
builder (3.2.2)
childprocess (0.5.6)
builder (3.2.3)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
crack (0.4.2)
safe_yaml (~> 1.0.0)
diff-lcs (1.2.5)
domain_name (0.5.25)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
ffi (1.9.10)
ffi (1.9.23)
gssapi (1.2.0)
ffi (>= 1.0.1)
gyoku (1.3.1)
builder (>= 2.1.2)
hashicorp-checkpoint (0.1.4)
http-cookie (1.0.2)
hashicorp-checkpoint (0.1.5)
http-cookie (1.0.3)
domain_name (~> 0.5)
httpclient (2.7.0.1)
i18n (0.7.0)
json_pure (1.8.3)
listen (3.0.5)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
httpclient (2.8.3)
i18n (0.8.0)
json_pure (2.1.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
little-plugger (1.1.4)
log4r (1.1.10)
logging (1.8.2)
little-plugger (>= 1.1.3)
multi_json (>= 1.8.4)
mime-types (2.99)
mini_portile (0.6.0)
multi_json (1.11.2)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.0.0)
multi_json (1.13.1)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (3.0.1)
net-ssh (3.0.2)
netrc (0.11.0)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
nokogiri (1.6.7.1)
mini_portile2 (~> 2.0.0.rc2)
nori (2.6.0)
rake (10.4.2)
rb-fsevent (0.9.6)
rb-inotify (0.9.5)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rb-kqueue (0.2.5)
ffi (>= 0.5.0)
rb-kqueue (0.2.4)
ffi (>= 0.5.0)
rest-client (1.8.0)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
Expand All @@ -96,32 +103,31 @@ GEM
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rubyntlm (0.4.0)
rubyzip (1.1.7)
ruby_dep (1.3.1)
rubyntlm (0.6.2)
rubyzip (1.2.1)
safe_yaml (1.0.4)
thor (0.18.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
uuidtools (2.1.5)
unf_ext (0.0.7.5)
wdm (0.1.1)
webmock (1.21.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
winrm (1.3.6)
winrm (1.8.1)
builder (>= 2.1.2)
gssapi (~> 1.2)
gyoku (~> 1.0)
httpclient (~> 2.2, >= 2.2.0.2)
logging (>= 1.6.1, < 3.0)
nori (~> 2.0)
rubyntlm (~> 0.4.0)
uuidtools (~> 2.1.2)
winrm-fs (0.2.3)
rubyntlm (~> 0.6.0)
winrm-fs (0.3.2)
erubis (~> 2.7)
logging (~> 1.6, >= 1.6.1)
logging (>= 1.6.1, < 3.0)
rubyzip (~> 1.1)
winrm (~> 1.3.0)
winrm (~> 1.5)

PLATFORMS
ruby
Expand All @@ -135,3 +141,6 @@ DEPENDENCIES
vagrant-skytap!
vagrant-spec!
webmock (~> 1.20)

BUNDLED WITH
1.16.1
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ Before you begin, make sure you have:
config.vm.provider :skytap do |skytap, override|
skytap.username = "<username>"
skytap.api_token = "<api_token>"
skytap.environment_name = "<environment name>"
skytap.project_id = "<project id>"
end

config.vm.define "web" do |server|
server.vm.provider :skytap do |box|
box.vm_url = "https://cloud.skytap.com/vms/3157858"
box.cpus = 2
box.disks = [25600,51200]
end
end
end
Expand Down Expand Up @@ -177,6 +180,9 @@ For more information, see [https://www.vagrantup.com/docs/networking/forwarded_p
|ram | no | RAM (megabytes).|
|guestos | no | The VMware guest OS for the virtual machine.|
|vpn_url | no | The URL of the Skytap VPN to use when connecting to the VM.|
|disks | no | List of disk sizes to add to VM.|
|environment_name | no | Name to give the new environment.|
|project_id | no | Project to add new envrionment to.|

Notes:

Expand Down
14 changes: 14 additions & 0 deletions lib/vagrant-skytap/action/update_hardware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ def call(env)
@logger.info("Updating hardware properties: #{hardware_info}")
vm.update(hardware: hardware_info)
end

unless provider_config.disks.nil?
disks_info = Hash.new
disks_info[:new] = provider_config.disks
hardware_info = {
disks: disks_info,
}.reject{|k, v| v.nil? || v == vm.hardware[k.to_s]}

if hardware_info.present?
@logger.info("Updating hardware properties: #{hardware_info}")
vm.update(hardware: hardware_info)
vm.wait_for_runstate(:stopped)
end
end
end

@app.call(env)
Expand Down
7 changes: 7 additions & 0 deletions lib/vagrant-skytap/api/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@ def create!(env, vms)
check_vms_before_adding(vms)
vm = vms.first

provider_config = env[:machine].provider_config
args = {vm_ids: vms.collect(&:id)}.tap do |ret|
if vm.from_template?
ret[:template_id] = vm.template_id
else
ret[:configuration_id] = vm.configuration_id
end
unless provider_config.environment_name.nil?
ret[:name] = provider_config.environment_name
end
unless provider_config.project_id.nil?
ret[:project_id] = provider_config.project_id
end
end

resp = env[:api_client].post(RESOURCE_ROOT, JSON.dump(args))
Expand Down
23 changes: 23 additions & 0 deletions lib/vagrant-skytap/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ class Config < Vagrant.plugin("2", :config)
# @return [String]
attr_accessor :guestos

# The VMware guest OS setting for this machine.
#
# @return [Array]
attr_accessor :disks

# The Skytap Environment Name.
#
# @return [String]
attr_accessor :environment_name

# The Skytap Project to assign Environment.
#
# @return [String]
attr_accessor :project_id

def initialize(region_specific=false)
@username = UNSET_VALUE
@api_token = UNSET_VALUE
Expand All @@ -83,11 +98,14 @@ def initialize(region_specific=false)
@vpn_url = UNSET_VALUE
@instance_ready_timeout = UNSET_VALUE
@region = UNSET_VALUE
@environment_name = UNSET_VALUE
@project_id = UNSET_VALUE

@cpus = UNSET_VALUE
@cpuspersocket = UNSET_VALUE
@ram = UNSET_VALUE
@guestos = UNSET_VALUE
@disks = UNSET_VALUE
end

#-------------------------------------------------------------------
Expand All @@ -112,12 +130,17 @@ def finalize!
# Set the default timeout for runstate changes (e.g. running a VM)
@instance_ready_timeout = 300 if @instance_ready_timeout == UNSET_VALUE

# Environment Name and Project ID default to nil
@environment_name = nil if @environment_name == UNSET_VALUE
@project_id = nil if @project_id == UNSET_VALUE

# Hardware settings default to nil (will be obtained
# from the source VM)
@cpus = nil if @cpus == UNSET_VALUE
@cpuspersocket = nil if @cpuspersocket == UNSET_VALUE
@ram = nil if @ram == UNSET_VALUE
@guestos = nil if @guestos == UNSET_VALUE
@disks = nil if @disks == UNSET_VALUE

# Mark that we finalized
@__finalized = true
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-skytap/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@

module VagrantPlugins
module Skytap
VERSION = "0.3.6"
VERSION = "0.3.7"
end
end