knife-vsphere 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/chef/knife/base_vsphere_command.rb +8 -5
- data/lib/chef/knife/vsphere_folder_list.rb +30 -30
- data/lib/chef/knife/vsphere_pool_list.rb +4 -2
- data/lib/chef/knife/vsphere_template_list.rb +32 -32
- data/lib/chef/knife/vsphere_vm_clone.rb +23 -18
- data/lib/chef/knife/vsphere_vm_list.rb +61 -61
- data/lib/knife-vsphere/version.rb +1 -1
- metadata +40 -58
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 5c6db46d0b70790bceee7a18c1649d07e5880bd5
         | 
| 4 | 
            +
              data.tar.gz: 75f42827a15800b4fef78a8f4db71205c86329c3
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 5a90ce096ba9a99b1a943d6939aa21df37f7614092c4301f9fffb5ea8ee454567afb3ce555ea29a259b52a3e0ea3d8164e97931aa66ed989db9dce612bc97bdf
         | 
| 7 | 
            +
              data.tar.gz: 5bc6f5f732f1f5bbca00a88d4a3f27f6f430b847ed33685294e6b32dad791e65e309ac4fc2c10dcf90e6b3dafe3a5cbfd6e506538ef19f8871d4ff1c2fefb63f
         | 
| @@ -6,6 +6,7 @@ | |
| 6 6 |  | 
| 7 7 | 
             
            require 'chef/knife'
         | 
| 8 8 | 
             
            require 'rbvmomi'
         | 
| 9 | 
            +
            require 'base64'
         | 
| 9 10 |  | 
| 10 11 | 
             
            # Base class for vsphere knife commands
         | 
| 11 12 | 
             
            class Chef
         | 
| @@ -101,10 +102,12 @@ class Chef | |
| 101 102 | 
             
                        :proxyPort => get_config(:proxy_port)
         | 
| 102 103 | 
             
                    }
         | 
| 103 104 |  | 
| 104 | 
            -
                     | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 105 | 
            +
                    if !conn_opts[:password]
         | 
| 106 | 
            +
                      # Password is not in the config file - grab it
         | 
| 107 | 
            +
                      # from the command line
         | 
| 107 108 | 
             
                      conn_opts[:password] = get_password
         | 
| 109 | 
            +
                    elsif conn_opts[:password].start_with?('base64:')
         | 
| 110 | 
            +
                      conn_opts[:password] = Base64.decode64(conn_opts[:password][7..-1]).chomp
         | 
| 108 111 | 
             
                    end
         | 
| 109 112 |  | 
| 110 113 | 
             
                    #    opt :debug, "Log SOAP messages", :short => 'd', :default => (ENV['RBVMOMI_DEBUG'] || false)
         | 
| @@ -204,7 +207,7 @@ class Chef | |
| 204 207 | 
             
                        if baseEntity.is_a? RbVmomi::VIM::Folder
         | 
| 205 208 | 
             
                          baseEntity = baseEntity.childEntity.find { |f| f.name == entityArrItem } or
         | 
| 206 209 | 
             
                              abort "no such pool #{poolName} while looking for #{entityArrItem}"
         | 
| 207 | 
            -
                        elsif baseEntity.is_a? RbVmomi::VIM::ClusterComputeResource or baseEntity.is_a? RbVmomi::VIM::ComputeResource | 
| 210 | 
            +
                        elsif baseEntity.is_a? RbVmomi::VIM::ClusterComputeResource or baseEntity.is_a? RbVmomi::VIM::ComputeResource
         | 
| 208 211 | 
             
                          baseEntity = baseEntity.resourcePool.resourcePool.find { |f| f.name == entityArrItem } or
         | 
| 209 212 | 
             
                              abort "no such pool #{poolName} while looking for #{entityArrItem}"
         | 
| 210 213 | 
             
                        elsif baseEntity.is_a? RbVmomi::VIM::ResourcePool
         | 
| @@ -273,7 +276,7 @@ class Chef | |
| 273 276 | 
             
                  end
         | 
| 274 277 |  | 
| 275 278 | 
             
                  def find_datastorecluster(dsName, folder = nil)
         | 
| 276 | 
            -
                    if ! folder | 
| 279 | 
            +
                    if ! folder
         | 
| 277 280 | 
             
                      dc = get_datacenter
         | 
| 278 281 | 
             
                      folder = dc.datastoreFolder
         | 
| 279 282 | 
             
                    end
         | 
| @@ -1,30 +1,30 @@ | |
| 1 | 
            -
            #
         | 
| 2 | 
            -
            # Author:: Ezra Pagel (<ezra@cpan.org>)
         | 
| 3 | 
            -
            # License:: Apache License, Version 2.0
         | 
| 4 | 
            -
            #
         | 
| 5 | 
            -
            require 'chef/knife'
         | 
| 6 | 
            -
            require 'chef/knife/base_vsphere_command'
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            # Lists all vm folders
         | 
| 9 | 
            -
            class Chef::Knife::VsphereFolderList < Chef::Knife::BaseVsphereCommand
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              banner "knife vsphere folder list"
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              get_common_options
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              def traverse_folders(folder, indent_level)
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                puts "#{"  " * indent_level} #{ui.color("Folder", :cyan)}: " + folder.name
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                folders = find_all_in_folder(folder, RbVmomi::VIM::Folder)
         | 
| 20 | 
            -
                folders.each do |child|
         | 
| 21 | 
            -
                  traverse_folders(child, indent_level  + 1)
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
              end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
              def run
         | 
| 26 | 
            -
                vim = get_vim_connection
         | 
| 27 | 
            -
                baseFolder = find_folder(get_config(:folder));
         | 
| 28 | 
            -
                traverse_folders(baseFolder, 0)
         | 
| 29 | 
            -
              end
         | 
| 30 | 
            -
            end
         | 
| 1 | 
            +
            #
         | 
| 2 | 
            +
            # Author:: Ezra Pagel (<ezra@cpan.org>)
         | 
| 3 | 
            +
            # License:: Apache License, Version 2.0
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            require 'chef/knife'
         | 
| 6 | 
            +
            require 'chef/knife/base_vsphere_command'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            # Lists all vm folders
         | 
| 9 | 
            +
            class Chef::Knife::VsphereFolderList < Chef::Knife::BaseVsphereCommand
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              banner "knife vsphere folder list"
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              get_common_options
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def traverse_folders(folder, indent_level)
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                puts "#{"  " * indent_level} #{ui.color("Folder", :cyan)}: " + folder.name
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                folders = find_all_in_folder(folder, RbVmomi::VIM::Folder)
         | 
| 20 | 
            +
                folders.each do |child|
         | 
| 21 | 
            +
                  traverse_folders(child, indent_level  + 1)
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              def run
         | 
| 26 | 
            +
                vim = get_vim_connection
         | 
| 27 | 
            +
                baseFolder = find_folder(get_config(:folder));
         | 
| 28 | 
            +
                traverse_folders(baseFolder, 0)
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
            end
         | 
| @@ -15,8 +15,10 @@ class Chef::Knife::VspherePoolList < Chef::Knife::BaseVsphereCommand | |
| 15 15 | 
             
              def traverse_folders(folder)
         | 
| 16 16 | 
             
                return if folder.is_a? RbVmomi::VIM::VirtualApp
         | 
| 17 17 |  | 
| 18 | 
            -
                 | 
| 19 | 
            -
                  folder. | 
| 18 | 
            +
                if folder.is_a? RbVmomi::VIM::ResourcePool
         | 
| 19 | 
            +
                  pools = folder.path[3..-1].reject { |p| p.last == "Resources" }
         | 
| 20 | 
            +
                  puts "#{ui.color("Pool", :cyan)}: " + pools.map(&:last).join('/')
         | 
| 21 | 
            +
                end
         | 
| 20 22 |  | 
| 21 23 | 
             
                folders = find_all_in_folder(folder, RbVmomi::VIM::ManagedObject) || []
         | 
| 22 24 | 
             
                folders.each do |child|
         | 
| @@ -1,32 +1,32 @@ | |
| 1 | 
            -
            #
         | 
| 2 | 
            -
            # Author:: Ezra Pagel (<ezra@cpan.org>)
         | 
| 3 | 
            -
            # License:: Apache License, Version 2.0
         | 
| 4 | 
            -
            #
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            require 'chef/knife'
         | 
| 7 | 
            -
            require 'chef/knife/base_vsphere_command'
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            # Lists all known VM templates in the configured datacenter
         | 
| 10 | 
            -
            class Chef::Knife::VsphereTemplateList < Chef::Knife::BaseVsphereCommand
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              banner "knife vsphere template list"
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              get_common_options
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              def run
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                $stdout.sync = true
         | 
| 19 | 
            -
                $stderr.sync = true
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                vim = get_vim_connection
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                baseFolder = find_folder(get_config(:folder));
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                vms = find_all_in_folder(baseFolder, RbVmomi::VIM::VirtualMachine).
         | 
| 26 | 
            -
                    select { |v| !v.config.nil? && v.config.template == true }
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                vms.each do |vm|
         | 
| 29 | 
            -
                  puts "#{ui.color("Template Name", :cyan)}: #{vm.name}"
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
            end
         | 
| 1 | 
            +
            #
         | 
| 2 | 
            +
            # Author:: Ezra Pagel (<ezra@cpan.org>)
         | 
| 3 | 
            +
            # License:: Apache License, Version 2.0
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            require 'chef/knife'
         | 
| 7 | 
            +
            require 'chef/knife/base_vsphere_command'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # Lists all known VM templates in the configured datacenter
         | 
| 10 | 
            +
            class Chef::Knife::VsphereTemplateList < Chef::Knife::BaseVsphereCommand
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              banner "knife vsphere template list"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              get_common_options
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              def run
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                $stdout.sync = true
         | 
| 19 | 
            +
                $stderr.sync = true
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                vim = get_vim_connection
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                baseFolder = find_folder(get_config(:folder));
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                vms = find_all_in_folder(baseFolder, RbVmomi::VIM::VirtualMachine).
         | 
| 26 | 
            +
                    select { |v| !v.config.nil? && v.config.template == true }
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                vms.each do |vm|
         | 
| 29 | 
            +
                  puts "#{ui.color("Template Name", :cyan)}: #{vm.name}"
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
| @@ -74,8 +74,8 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand | |
| 74 74 | 
             
                     :description => "String of data to pass to the plugin.  Use any format you wish."
         | 
| 75 75 |  | 
| 76 76 | 
             
              option :customization_vlan,
         | 
| 77 | 
            -
                     :long => "--cvlan  | 
| 78 | 
            -
                     :description => "VLAN  | 
| 77 | 
            +
                     :long => "--cvlan CUST_VLANS",
         | 
| 78 | 
            +
                     :description => "Comma-delimited list of VLAN names for network adapters to join"
         | 
| 79 79 |  | 
| 80 80 | 
             
              option :customization_ips,
         | 
| 81 81 | 
             
                     :long => "--cips CUST_IPS",
         | 
| @@ -190,8 +190,8 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand | |
| 190 190 |  | 
| 191 191 | 
             
              option :secret_file,
         | 
| 192 192 | 
             
                     :long => "--secret-file SECRET_FILE",
         | 
| 193 | 
            -
                     :description => "A file containing the secret key to use to encrypt data bag item values"
         | 
| 194 | 
            -
             | 
| 193 | 
            +
                     :description => "A file containing the secret key to use to encrypt data bag item values",
         | 
| 194 | 
            +
                     :proc => lambda { |secret_file| Chef::Config[:knife][:secret_file] = secret_file }
         | 
| 195 195 |  | 
| 196 196 | 
             
              option :hint,
         | 
| 197 197 | 
             
                     :long => "--hint HINT_NAME[=HINT_FILE]",
         | 
| @@ -379,18 +379,23 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand | |
| 379 379 | 
             
                end
         | 
| 380 380 |  | 
| 381 381 | 
             
                if get_config(:customization_vlan)
         | 
| 382 | 
            -
                   | 
| 383 | 
            -
                   | 
| 384 | 
            -
             | 
| 385 | 
            -
                   | 
| 386 | 
            -
             | 
| 387 | 
            -
             | 
| 388 | 
            -
             | 
| 389 | 
            -
                     | 
| 390 | 
            -
             | 
| 382 | 
            +
                  vlan_list = get_config(:customization_vlan).split(',')
         | 
| 383 | 
            +
                  networks = vlan_list.map { |vlan| find_network(vlan) }
         | 
| 384 | 
            +
             | 
| 385 | 
            +
                  cards = src_config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard)
         | 
| 386 | 
            +
             | 
| 387 | 
            +
                  networks.each_with_index do |network, index|
         | 
| 388 | 
            +
                    card = cards[index] or abort "Can't find source network card to customize for vlan #{vlan_list[index]}"
         | 
| 389 | 
            +
                    begin
         | 
| 390 | 
            +
                      switch_port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(:switchUuid => network.config.distributedVirtualSwitch.uuid, :portgroupKey => network.key)
         | 
| 391 | 
            +
                      card.backing.port = switch_port
         | 
| 392 | 
            +
                    rescue
         | 
| 393 | 
            +
                      # not connected to a distibuted switch?
         | 
| 394 | 
            +
                      card.backing = RbVmomi::VIM::VirtualEthernetCardNetworkBackingInfo(:network => network, :deviceName => network.name)
         | 
| 395 | 
            +
                    end
         | 
| 396 | 
            +
                    dev_spec = RbVmomi::VIM.VirtualDeviceConfigSpec(:device => card, :operation => "edit")
         | 
| 397 | 
            +
                    clone_spec.config.deviceChange.push dev_spec
         | 
| 391 398 | 
             
                  end
         | 
| 392 | 
            -
                  dev_spec = RbVmomi::VIM.VirtualDeviceConfigSpec(:device => card, :operation => "edit")
         | 
| 393 | 
            -
                  clone_spec.config.deviceChange.push dev_spec
         | 
| 394 399 | 
             
                end
         | 
| 395 400 |  | 
| 396 401 | 
             
                if get_config(:customization_spec)
         | 
| @@ -495,15 +500,15 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand | |
| 495 500 | 
             
              end
         | 
| 496 501 |  | 
| 497 502 | 
             
              # Generates a CustomizationAdapterMapping (currently only single IPv4 address) object
         | 
| 498 | 
            -
              # @param ip [String] Any static IP address to use,  | 
| 503 | 
            +
              # @param ip [String] Any static IP address to use, or "dhcp" for DHCP
         | 
| 499 504 | 
             
              # @param gw [String] If static, the gateway for the interface, otherwise network address + 1 will be used
         | 
| 500 505 | 
             
              # @return [RbVmomi::VIM::CustomizationIPSettings]
         | 
| 501 506 | 
             
              def generate_adapter_map (ip=nil, gw=nil, dns1=nil, dns2=nil, domain=nil)
         | 
| 502 507 |  | 
| 503 508 | 
             
                settings = RbVmomi::VIM.CustomizationIPSettings
         | 
| 504 509 |  | 
| 505 | 
            -
                if ip.nil?
         | 
| 506 | 
            -
                  settings.ip = RbVmomi::VIM::CustomizationDhcpIpGenerator
         | 
| 510 | 
            +
                if ip.nil? || ip.downcase == "dhcp"
         | 
| 511 | 
            +
                  settings.ip = RbVmomi::VIM::CustomizationDhcpIpGenerator.new
         | 
| 507 512 | 
             
                else
         | 
| 508 513 | 
             
                  cidr_ip = NetAddr::CIDR.create(ip)
         | 
| 509 514 | 
             
                  settings.ip = RbVmomi::VIM::CustomizationFixedIp(:ipAddress => cidr_ip.ip)
         | 
| @@ -1,61 +1,61 @@ | |
| 1 | 
            -
            #
         | 
| 2 | 
            -
            # Author:: Ezra Pagel (<ezra@cpan.org>)
         | 
| 3 | 
            -
            # License:: Apache License, Version 2.0
         | 
| 4 | 
            -
            #
         | 
| 5 | 
            -
            require 'chef/knife'
         | 
| 6 | 
            -
            require 'chef/knife/base_vsphere_command'
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            # Lists all known virtual machines in the configured datacenter
         | 
| 9 | 
            -
            class Chef::Knife::VsphereVmList < Chef::Knife::BaseVsphereCommand
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              banner "knife vsphere vm list"
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              get_common_options
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              option :recursive,
         | 
| 16 | 
            -
                     :long => "--recursive",
         | 
| 17 | 
            -
                     :short => "-r",
         | 
| 18 | 
            -
                     :description => "Recurse into sub-folders"
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              def traverse_folders(folder, is_top = false, recurse = false)
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                vms = find_all_in_folder(folder, RbVmomi::VIM::VirtualMachine).select {|v| v.config && !v.config.template }
         | 
| 23 | 
            -
                if vms.any?
         | 
| 24 | 
            -
                  puts "#{ui.color("Folder", :cyan)}: "+(folder.path[3..-1].map { |x| x[1] }.* '/')
         | 
| 25 | 
            -
                  vms.each { |v|  print_vm(v) }
         | 
| 26 | 
            -
                elsif is_top
         | 
| 27 | 
            -
                  puts "#{ui.color("No VMs", :cyan)}"
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                if (recurse)
         | 
| 31 | 
            -
                  folders = find_all_in_folder(folder, RbVmomi::VIM::Folder)
         | 
| 32 | 
            -
                  folders.each do |child|
         | 
| 33 | 
            -
                    traverse_folders(child, false, recurse)
         | 
| 34 | 
            -
                  end
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
              end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
              def print_vm(vm)
         | 
| 40 | 
            -
                state = case vm.runtime.powerState
         | 
| 41 | 
            -
                        when PsOn
         | 
| 42 | 
            -
                          ui.color("on", :green)
         | 
| 43 | 
            -
                        when PsOff
         | 
| 44 | 
            -
                          ui.color("off", :red)
         | 
| 45 | 
            -
                        when PsSuspended
         | 
| 46 | 
            -
                          ui.color("suspended", :yellow)
         | 
| 47 | 
            -
                        end
         | 
| 48 | 
            -
                puts "\t#{ui.color("VM Name:", :cyan)} #{vm.name}"
         | 
| 49 | 
            -
                     "\t\t#{ui.color("IP:", :magenta)} #{vm.guest.ipAddress}"
         | 
| 50 | 
            -
                     "\t\t#{ui.color("RAM:", :magenta)} #{vm.summary.config.memorySizeMB}"
         | 
| 51 | 
            -
                     "\t\t#{ui.color("State:", :cyan)} #{state}"
         | 
| 52 | 
            -
              end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
              def run
         | 
| 55 | 
            -
                vim = get_vim_connection
         | 
| 56 | 
            -
                baseFolder = find_folder(get_config(:folder));
         | 
| 57 | 
            -
                recurse =  get_config(:recursive)
         | 
| 58 | 
            -
                is_top = true
         | 
| 59 | 
            -
                traverse_folders(baseFolder, is_top, recurse)
         | 
| 60 | 
            -
              end
         | 
| 61 | 
            -
            end
         | 
| 1 | 
            +
            #
         | 
| 2 | 
            +
            # Author:: Ezra Pagel (<ezra@cpan.org>)
         | 
| 3 | 
            +
            # License:: Apache License, Version 2.0
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            require 'chef/knife'
         | 
| 6 | 
            +
            require 'chef/knife/base_vsphere_command'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            # Lists all known virtual machines in the configured datacenter
         | 
| 9 | 
            +
            class Chef::Knife::VsphereVmList < Chef::Knife::BaseVsphereCommand
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              banner "knife vsphere vm list"
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              get_common_options
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              option :recursive,
         | 
| 16 | 
            +
                     :long => "--recursive",
         | 
| 17 | 
            +
                     :short => "-r",
         | 
| 18 | 
            +
                     :description => "Recurse into sub-folders"
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              def traverse_folders(folder, is_top = false, recurse = false)
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                vms = find_all_in_folder(folder, RbVmomi::VIM::VirtualMachine).select {|v| v.config && !v.config.template }
         | 
| 23 | 
            +
                if vms.any?
         | 
| 24 | 
            +
                  puts "#{ui.color("Folder", :cyan)}: "+(folder.path[3..-1].map { |x| x[1] }.* '/')
         | 
| 25 | 
            +
                  vms.each { |v|  print_vm(v) }
         | 
| 26 | 
            +
                elsif is_top
         | 
| 27 | 
            +
                  puts "#{ui.color("No VMs", :cyan)}"
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                if (recurse)
         | 
| 31 | 
            +
                  folders = find_all_in_folder(folder, RbVmomi::VIM::Folder)
         | 
| 32 | 
            +
                  folders.each do |child|
         | 
| 33 | 
            +
                    traverse_folders(child, false, recurse)
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def print_vm(vm)
         | 
| 40 | 
            +
                state = case vm.runtime.powerState
         | 
| 41 | 
            +
                        when PsOn
         | 
| 42 | 
            +
                          ui.color("on", :green)
         | 
| 43 | 
            +
                        when PsOff
         | 
| 44 | 
            +
                          ui.color("off", :red)
         | 
| 45 | 
            +
                        when PsSuspended
         | 
| 46 | 
            +
                          ui.color("suspended", :yellow)
         | 
| 47 | 
            +
                        end
         | 
| 48 | 
            +
                puts "\t#{ui.color("VM Name:", :cyan)} #{vm.name}"
         | 
| 49 | 
            +
                     "\t\t#{ui.color("IP:", :magenta)} #{vm.guest.ipAddress}"
         | 
| 50 | 
            +
                     "\t\t#{ui.color("RAM:", :magenta)} #{vm.summary.config.memorySizeMB}"
         | 
| 51 | 
            +
                     "\t\t#{ui.color("State:", :cyan)} #{state}"
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              def run
         | 
| 55 | 
            +
                vim = get_vim_connection
         | 
| 56 | 
            +
                baseFolder = find_folder(get_config(:folder));
         | 
| 57 | 
            +
                recurse =  get_config(:recursive)
         | 
| 58 | 
            +
                is_top = true
         | 
| 59 | 
            +
                traverse_folders(baseFolder, is_top, recurse)
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,123 +1,105 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: knife-vsphere
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 5 | 
            -
              prerelease: 
         | 
| 4 | 
            +
              version: 1.0.1
         | 
| 6 5 | 
             
            platform: ruby
         | 
| 7 6 | 
             
            authors:
         | 
| 8 7 | 
             
            - Ezra Pagel
         | 
| 9 8 | 
             
            autorequire: 
         | 
| 10 9 | 
             
            bindir: bin
         | 
| 11 10 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 11 | 
            +
            date: 2015-03-19 00:00:00.000000000 Z
         | 
| 13 12 | 
             
            dependencies:
         | 
| 14 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 14 | 
             
              name: netaddr
         | 
| 16 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            -
                 | 
| 18 | 
            -
                 | 
| 19 | 
            -
                - - ~>
         | 
| 16 | 
            +
                requirements: &1
         | 
| 17 | 
            +
                - - "~>"
         | 
| 20 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            -
                    version: 1.5 | 
| 19 | 
            +
                    version: '1.5'
         | 
| 22 20 | 
             
              type: :runtime
         | 
| 23 21 | 
             
              prerelease: false
         | 
| 24 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            -
                 | 
| 26 | 
            -
                requirements:
         | 
| 27 | 
            -
                - - ~>
         | 
| 28 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: 1.5.0
         | 
| 23 | 
            +
                requirements: *1
         | 
| 30 24 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 31 25 | 
             
              name: chef
         | 
| 32 26 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            -
                 | 
| 34 | 
            -
                 | 
| 35 | 
            -
                - - ! '>='
         | 
| 27 | 
            +
                requirements: &2
         | 
| 28 | 
            +
                - - ">="
         | 
| 36 29 | 
             
                  - !ruby/object:Gem::Version
         | 
| 37 30 | 
             
                    version: 0.10.0
         | 
| 38 31 | 
             
              type: :runtime
         | 
| 39 32 | 
             
              prerelease: false
         | 
| 40 33 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            -
                 | 
| 42 | 
            -
                requirements:
         | 
| 43 | 
            -
                - - ! '>='
         | 
| 44 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            -
                    version: 0.10.0
         | 
| 34 | 
            +
                requirements: *2
         | 
| 46 35 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 47 36 | 
             
              name: rbvmomi
         | 
| 48 37 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            -
                 | 
| 50 | 
            -
                 | 
| 51 | 
            -
                - - ~>
         | 
| 38 | 
            +
                requirements: &3
         | 
| 39 | 
            +
                - - "~>"
         | 
| 52 40 | 
             
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            -
                    version: 1. | 
| 41 | 
            +
                    version: '1.8'
         | 
| 54 42 | 
             
              type: :runtime
         | 
| 55 43 | 
             
              prerelease: false
         | 
| 56 44 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            -
                 | 
| 58 | 
            -
                requirements:
         | 
| 59 | 
            -
                - - ~>
         | 
| 60 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: 1.5.1
         | 
| 45 | 
            +
                requirements: *3
         | 
| 62 46 | 
             
            description: VMware vSphere Support for Chef's Knife Command
         | 
| 63 47 | 
             
            email: ezra@cpan.org
         | 
| 64 48 | 
             
            executables: []
         | 
| 65 49 | 
             
            extensions: []
         | 
| 66 50 | 
             
            extra_rdoc_files: []
         | 
| 67 51 | 
             
            files:
         | 
| 68 | 
            -
            - lib/chef/knife/ | 
| 52 | 
            +
            - lib/chef/knife/base_vsphere_command.rb
         | 
| 53 | 
            +
            - lib/chef/knife/vshpere_vm_migrate.rb
         | 
| 54 | 
            +
            - lib/chef/knife/vshpere_vm_move.rb
         | 
| 55 | 
            +
            - lib/chef/knife/vshpere_vm_net.rb
         | 
| 69 56 | 
             
            - lib/chef/knife/vsphere_cpu_ratio.rb
         | 
| 57 | 
            +
            - lib/chef/knife/vsphere_customization_list.rb
         | 
| 58 | 
            +
            - lib/chef/knife/vsphere_datastore_list.rb
         | 
| 59 | 
            +
            - lib/chef/knife/vsphere_datastore_maxfree.rb
         | 
| 70 60 | 
             
            - lib/chef/knife/vsphere_datastorecluster_list.rb
         | 
| 71 61 | 
             
            - lib/chef/knife/vsphere_datastorecluster_maxfree.rb
         | 
| 72 | 
            -
            - lib/chef/knife/ | 
| 73 | 
            -
            - lib/chef/knife/vsphere_vm_property_get.rb
         | 
| 74 | 
            -
            - lib/chef/knife/vsphere_vm_state.rb
         | 
| 75 | 
            -
            - lib/chef/knife/vshpere_vm_net.rb
         | 
| 76 | 
            -
            - lib/chef/knife/vsphere_vm_execute.rb
         | 
| 62 | 
            +
            - lib/chef/knife/vsphere_folder_list.rb
         | 
| 77 63 | 
             
            - lib/chef/knife/vsphere_hosts_list.rb
         | 
| 78 | 
            -
            - lib/chef/knife/ | 
| 79 | 
            -
            - lib/chef/knife/ | 
| 80 | 
            -
            - lib/chef/knife/vsphere_vm_markastemplate.rb
         | 
| 81 | 
            -
            - lib/chef/knife/vsphere_vm_clone.rb
         | 
| 82 | 
            -
            - lib/chef/knife/base_vsphere_command.rb
         | 
| 83 | 
            -
            - lib/chef/knife/vsphere_vm_vmdk_add.rb
         | 
| 84 | 
            -
            - lib/chef/knife/vsphere_customization_list.rb
         | 
| 64 | 
            +
            - lib/chef/knife/vsphere_pool_list.rb
         | 
| 65 | 
            +
            - lib/chef/knife/vsphere_pool_query.rb
         | 
| 85 66 | 
             
            - lib/chef/knife/vsphere_template_list.rb
         | 
| 86 | 
            -
            - lib/chef/knife/vsphere_vm_delete.rb
         | 
| 87 | 
            -
            - lib/chef/knife/vsphere_datastore_list.rb
         | 
| 88 | 
            -
            - lib/chef/knife/vsphere_vm_config.rb
         | 
| 89 67 | 
             
            - lib/chef/knife/vsphere_vlan_list.rb
         | 
| 90 | 
            -
            - lib/chef/knife/ | 
| 68 | 
            +
            - lib/chef/knife/vsphere_vm_clone.rb
         | 
| 69 | 
            +
            - lib/chef/knife/vsphere_vm_config.rb
         | 
| 70 | 
            +
            - lib/chef/knife/vsphere_vm_delete.rb
         | 
| 71 | 
            +
            - lib/chef/knife/vsphere_vm_execute.rb
         | 
| 91 72 | 
             
            - lib/chef/knife/vsphere_vm_list.rb
         | 
| 92 | 
            -
            - lib/chef/knife/ | 
| 93 | 
            -
            - lib/chef/knife/ | 
| 94 | 
            -
            - lib/chef/knife/vsphere_pool_list.rb
         | 
| 95 | 
            -
            - lib/chef/knife/vsphere_folder_list.rb
         | 
| 73 | 
            +
            - lib/chef/knife/vsphere_vm_markastemplate.rb
         | 
| 74 | 
            +
            - lib/chef/knife/vsphere_vm_property_get.rb
         | 
| 96 75 | 
             
            - lib/chef/knife/vsphere_vm_property_set.rb
         | 
| 76 | 
            +
            - lib/chef/knife/vsphere_vm_query.rb
         | 
| 77 | 
            +
            - lib/chef/knife/vsphere_vm_snapshot.rb
         | 
| 78 | 
            +
            - lib/chef/knife/vsphere_vm_state.rb
         | 
| 79 | 
            +
            - lib/chef/knife/vsphere_vm_toolsconfig.rb
         | 
| 80 | 
            +
            - lib/chef/knife/vsphere_vm_vmdk_add.rb
         | 
| 97 81 | 
             
            - lib/knife-vsphere/version.rb
         | 
| 98 82 | 
             
            homepage: http://github.com/ezrapagel/knife-vsphere
         | 
| 99 83 | 
             
            licenses:
         | 
| 100 84 | 
             
            - Apache
         | 
| 85 | 
            +
            metadata: {}
         | 
| 101 86 | 
             
            post_install_message: 
         | 
| 102 87 | 
             
            rdoc_options: []
         | 
| 103 88 | 
             
            require_paths:
         | 
| 104 89 | 
             
            - lib
         | 
| 105 90 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 106 | 
            -
              none: false
         | 
| 107 91 | 
             
              requirements:
         | 
| 108 | 
            -
              -  | 
| 92 | 
            +
              - &4
         | 
| 93 | 
            +
                - ">="
         | 
| 109 94 | 
             
                - !ruby/object:Gem::Version
         | 
| 110 95 | 
             
                  version: '0'
         | 
| 111 96 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 112 | 
            -
              none: false
         | 
| 113 97 | 
             
              requirements:
         | 
| 114 | 
            -
              -  | 
| 115 | 
            -
                - !ruby/object:Gem::Version
         | 
| 116 | 
            -
                  version: '0'
         | 
| 98 | 
            +
              - *4
         | 
| 117 99 | 
             
            requirements: []
         | 
| 118 100 | 
             
            rubyforge_project: 
         | 
| 119 | 
            -
            rubygems_version:  | 
| 101 | 
            +
            rubygems_version: 2.2.2
         | 
| 120 102 | 
             
            signing_key: 
         | 
| 121 | 
            -
            specification_version:  | 
| 103 | 
            +
            specification_version: 4
         | 
| 122 104 | 
             
            summary: vSphere Support for Knife
         | 
| 123 105 | 
             
            test_files: []
         |