Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add cpu_mmu_type configuration
  • Loading branch information
Ethan Lynn committed Dec 23, 2016
commit f0da97224d296e4bc4b31286a64dd26f036de69d
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ This provider has the following settings, all are required unless noted:
* `memory_mb` - _Optional_ Configure the amount of memory (in MB) for the new VM
* `cpu_count` - _Optional_ Configure the number of CPUs for the new VM
* `cpu_reservation` - _Optional_ Configure the CPU time (in MHz) to reserve for this VM
* `cpu_mmu_type` - _Optional_ Configure CPU and MMU virtualization support type
* `mem_reservation` - _Optional_ Configure the memory (in MB) to reserve for this VM
* `custom_attribute` - _Optional_ Add a
[custom attribute](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB4QFjAAahUKEwiWwbWX59jHAhVBC5IKHa3HAEU&url=http%3A%2F%2Fpubs.vmware.com%2Fvsphere-51%2Ftopic%2Fcom.vmware.vsphere.vcenterhost.doc%2FGUID-25244732-D473-4857-A471-579257B6D95F.html&usg=AFQjCNGTSl4cauFrflUJpBeTBb0Yv7R13g&sig2=a9he6W2qVvBSZ5lCiXnENA)
Expand Down
21 changes: 21 additions & 0 deletions lib/vSphere/action/clone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def call(env)
add_custom_extra_config(spec, config.extra_config) unless config.extra_config.empty?
add_custom_notes(spec, config.notes) unless config.notes.nil?

env[:ui].info "Setting custom cpu_mmu_type: #{config.cpu_mmu_type}" unless config.cpu_mmu_type.nil?
add_custom_mmu(template, spec, config.cpu_mmu_type) unless config.cpu_mmu_type.nil?

if !config.clone_from_vm && ds.is_a?(RbVmomi::VIM::StoragePod)

storage_mgr = connection.serviceContent.storageResourceManager
Expand Down Expand Up @@ -401,6 +404,24 @@ def add_custom_extra_config(spec, extra_config = {})
def add_custom_notes(spec, notes)
spec[:config][:annotation] = notes
end

def add_custom_mmu(template, spec, mmu)
flags = template.config.flags.dup
if mmu == 'software'
flags.virtualMmuUsage = 'off'
flags.virtualExecUsage = 'hvOff'
elsif mmu == 'hardware'
flags.virtualMmuUsage = 'on'
flags.virtualExecUsage = 'hvOn'
elsif mmu == 'half'
flags.virtualMmuUsage = 'off'
flags.virtualExecUsage = 'hvOn'
else
flags.virtualMmuUsage = 'automatic'
flags.virtualExecUsage = 'hvAuto'
end
spec[:config][:flags] = flags
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/vSphere/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Config < Vagrant.plugin('2', :config)
attr_accessor :networks
attr_accessor :disks
attr_accessor :ssh_cidr
attr_accessor :cpu_mmu_type

attr_reader :custom_attributes

Expand Down