Sha256: ffd5a11acf784b889eaedd7e4a16a25d6dfea5f5011dd1653bdcae34efb71a73

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 KB

Contents

# Copyright (c) 2011-2017 VMware, Inc.  All Rights Reserved.
# SPDX-License-Identifier: MIT

require 'trollop'
require 'rbvmomi'
require 'rbvmomi/trollop'

VIM = RbVmomi::VIM
CMDS = %w(list set)

opts = Trollop.options do
  banner <<-EOS
View and modify VM extraConfig options.

Usage:
    extraConfig.rb [options] VM list
    extraConfig.rb [options] VM set key=value [key=value...]

Commands: #{CMDS * ' '}

VIM connection options:
    EOS

    rbvmomi_connection_opts

    text <<-EOS

VM location options:
    EOS

    rbvmomi_datacenter_opt

    text <<-EOS

Other options:
  EOS

  stop_on CMDS
end

vm_name = ARGV[0] or Trollop.die("no VM name given")
cmd = ARGV[1] or Trollop.die("no command given")
abort "invalid command" unless CMDS.member? cmd
Trollop.die("must specify host") unless opts[:host]

vim = VIM.connect opts

dc = vim.serviceInstance.find_datacenter(opts[:datacenter]) or abort "datacenter not found"
vm = dc.find_vm(vm_name) or abort "VM not found"

case cmd
when 'list'
  vm.config.extraConfig.each { |x| puts "#{x.key}: #{x.value}" }
when 'set'
  extraConfig = ARGV[2..-1].map { |x| x.split("=", 2) }.map { |k,v| { :key => k, :value => v } }
  vm.ReconfigVM_Task(:spec => VIM.VirtualMachineConfigSpec(:extraConfig => extraConfig)).wait_for_completion
end

Version data entries

15 entries across 13 versions & 2 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/rbvmomi-1.13.0/examples/extraConfig.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rbvmomi-1.13.0/examples/extraConfig.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/rbvmomi-1.13.0/examples/extraConfig.rb
rbvmomi-1.13.0 examples/extraConfig.rb
rbvmomi-1.12.0 examples/extraConfig.rb
rbvmomi-1.11.7 examples/extraConfig.rb
rbvmomi-1.11.6 examples/extraConfig.rb
rbvmomi-1.11.5 examples/extraConfig.rb
rbvmomi-1.11.4 examples/extraConfig.rb
rbvmomi-1.11.3 examples/extraConfig.rb
rbvmomi-1.11.2 examples/extraConfig.rb
rbvmomi-1.11.1 examples/extraConfig.rb
rbvmomi-1.11.0 examples/extraConfig.rb
rbvmomi-1.10.0 examples/extraConfig.rb
rbvmomi-1.9.5 examples/extraConfig.rb