Giter Site home page Giter Site logo

knife-vsphere's Introduction

knife vSphere

Gem Version Build status Inline docs

Umbrella Project: Knife

Project State: Active

Issues Response Time Maximum: 14 days

Pull Request Response Time Maximum: 14 days

Please refer to the CHANGELOG for version history and known issues.

Installation

This gem ships as part of Chef Workstation so the easiest way to get started is to install Chef Workstation

If you're using bundler as part of a project, add knife and knife-vsphere to your Gemfile:

gem 'knife'
gem 'knife-vsphere

Depending on your system's configuration, you may need to run this command with root privileges.

Configuration

For initial development, the plugin targets all communication at a vCenter instance rather than at specific hosts. Only named user authentication is currently supported; you can add the credentials to your knife.rb file:

knife[:vsphere_host] = "vcenter-hostname"
knife[:vsphere_user] = "privileged username" # Domain logins may need to be "[email protected]"
knife[:vsphere_pass] = "your password"       # or %Q(mypasswordwithfunnycharacters)
knife[:vsphere_dc] = "your-datacenter"

The vSphere password can also be stored in a base64 encoded version (to visually obfuscate it) by prepending 'base64:' to your encoded password. For example:

knife[:vsphere_pass] = "base64:Zm9vYmFyCg=="

If you get the following error, you may need to disable SSL certificate checking:

ERROR: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0
state=SSLv3 read server certificate B: certificate verify failed
knife[:vsphere_insecure] = true

Credentials can also be specified on the command line for multiple vSphere servers/data centers, or see dealing with multiple datacenters.

vCenter Permissions

You need the following permissions (at minimum) on your user to be able to use knife-vsphere.

  • Datastore
    • Allocate space ☑️
    • Browse datastore ☑️
  • Host
    • Local Operations
      • Create virtual machine ☑️
      • Delete virtual machine ☑️
      • Manage user groups ☑️
      • Reconfigure virtual machine ☑️
  • Network
    • Assign Network ☑️
  • Resource
    • Assign virtual machine to resource pool ☑️
  • Virtual Machine ☑️

Description:

This is an Chef Knife plugin to interact with VMware's vSphere. This plugin currently supports the following:

Listings:

  • VMs
  • Folders
  • Templates
  • Datastores
  • VLANs (currently requires distributed vswitch)
  • Resource Pools and Clusters
  • Customization Specifications
  • Hosts in a Pool or Cluster
  • Network cards and VLANs for a VM

VM Operations:

  • Power on/off
  • Clone (with optional chef bootstrap and run list)
  • Delete
  • VMDK addition
  • Migrate
  • Add network
  • Connect/disconnect network
  • Delete network
  • Change network
  • Enable VNC remote console

Clone-specific customization options (for Linux guests):

  • Destination folder
  • CPU core count
  • CPU cores per socket
  • Memory size
  • Memory reservation
  • DNS settings
  • Hostname / Domain name
  • IP addresses / default gateway
  • vlan (currently requires distributed vswitch)
  • datastore
  • resource pool

Note: For Windows guests we can run FIELDS

Basic Examples:

Here are some basic usage examples to help get you started.

  • This clones from a VMware template and bootstraps chef into it. It uses the generic DHCP options.
$ knife vsphere vm clone MACHINENAME --template TEMPLATENAME --bootstrap --cips dhcp
  • This clones a vm from a VMware template bootstraps chef, then uses a Customization template called "SPEC" to help bootstrap. Also calls a different SSH user and Password.
$ knife vsphere vm clone MACHINENAME --template TEMPLATENAME --bootstrap --cips dhcp \
  --cspec SPEC --connection-user USER --connection-password PASSWORD

Note: add a -f FOLDERNAME if you put your --template in someplace other then root folder, and use --dest-folder FOLDERNAME if you want your VM created in FOLDERNAME rather than the root.

A full basic example of cloning from a folder, and putting it in the "Datacenter Root" directory is the following:

$ knife vsphere vm clone MACHINENAME --template TEMPLATENAME -f LOCATIONOFTEMPLATE \
  --bootstrap --start --cips dhcp --dest-folder /
  • Listing the available VMware templates
$ knife vsphere template list
Template Name: ubuntu16-template
$ knife vsphere template list -f FOLDERNAME
Template Name: centos7-template
  • Deleting a machine.
$ knife vsphere vm delete MACHINENAME (-P will remove from the chef server)

Subcommands

This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a --help flag

knife vsphere vm list

Enumerates the Virtual Machines registered in the target datacenter. Only name is currently displayed.

-r, --recursive    - Recurse down through sub-folders to the specified folder
--only-folders     - Print only folder names. Implies recursive

knife vsphere vm find

Search for Virtual Machines matching criteria and display selected fields

CRITERIA: Note that all criteria must be satisfied for the VM to be returned

--match-ip IP                match ip
--match-name VMNAME          match name
--match-os OS                match os
--match-tools TOOLSSTATE     match tools state
--powered-off                Show only stopped machines
--powered-on                 Show only started machines

FIELDS:

--alarms                     show alarm status
--cpu                        Show cpu
--cpu-hot-add-enabled        Show cpu hot add enabled flag
--esx-disk                   Show esx disks
--full-path                  Show full folder path to the VM
--short-path                 Show the enclosing folder name
--hostname                   show hostname
--host_name                  Show name of the VM's host
--ip                         Show primary ip
--networks                   Show all networks and IPs
--os                         Show os details
--os-disks                   Show os disks
--ram                        Show ram
--memory-hot-add-enabled     Show memory hot add enabled flag
--snapshots                  Show snapshots
--tools                      show tools status

Example:

$ knife vsphere vm find --snapshots --full-path --cpu --ram --esx-disk \
    --os-disk --os --match-name my_machine_1 --alarms --tools --ip --ips \
    --match-ip 123 --match-tools toolsOk

knife vsphere vm state VMNAME

Manage power state of a virtual machine, aka turn it off and on

-s STATE, --state STATE    - The power state to transition the VM into; one of on|off|suspend|reboot
-w PORT, --wait-port PORT  - Wait for VM to be accessible on a port
-g, --shutdown             - Guest OS shutdown (format: -s off -g)
-r, --recursive            - Recurse down through sub-folders to the specified folder to find the VM

knife vsphere pool list

Enumerates the Resource Pools and Clusters registered in the target datacenter.

knife vsphere template list

Enumerates the VM Templates registered in the target datacenter. Only name is currently displayed.

-f FOLDER       - Look inside the designated folder, default is the root folder

knife vsphere customization list

Enumerates the customization specifications registered in the target datacenter. Only name is currently displayed.

knife vsphere vm clone

Clones an existing VM template into a new VM instance, optionally applying an existing customization specification. If customization arguments such as --chost and --cdomain are specified, or if the customization specification fetched from vSphere is considered, a default customization specification will be attempted.

  • For windows, a sysprep based unattended customization in workgroup mode will be attempted (host name being the VM name unless otherwise specified).

  • For Linux, a fixed named customization using the vmname as the host name unless otherwise specified.

This command has many options which which to customize your VM. The most important part of this is the initial template. We have some guidance on how to make a template

Chef bootstrap options

These options alter the way that your VM will be bootstrapped with Chef after it is created. It is not necessary to bootstrap the VM, but at the very least --bootstrap is required to do so.

--bootstrap - Bootstrap the VM after cloning. Implies --start
--bootstrap-ipv4 - Force using an IPv4 address when a NIC has both IPv4 and IPv6 addresses.
--bootstrap-msi-url URL - Location of the Chef Client MSI if not default from chef.io
--bootstrap-nic INTEGER - Network interface to use when multiple NICs are defined on a template.
--bootstrap-proxy PROXY_URL - The proxy server for the node being bootstrapped
--bootstrap-vault-file VAULT_FILE - A JSON file with a list of vault(s) and item(s) to be updated
--bootstrap-vault-item VAULT_ITEM - A single vault and item to update as "vault:item"
--bootstrap-vault-json VAULT_JSON - A JSON string with the vault(s) and item(s) to be updated
--bootstrap-version VERSION - The version of Chef to install
--fqdn SERVER_FQDN - Fully qualified hostname for bootstrapping
--hint HINT_NAME[=HINT_FILE] Specify Ohai Hint to be set on the bootstrap target.  Use multiple --hint options to specify multiple hints.
--ssh-identity-file IDENTITY_FILE - SSH identity file used for authentication
--json-attributes - A JSON string to be added to the first run of chef-client
--node-name NAME - The Chef node name for your new node
--ssh-verify-host-key - Verify host key. Default is 'always'. Available options are 'always' ,'accept_new accept_new_or_local_tunnel' and  'never'
--node-ssl-verify-mode [peer|none] - Whether or not to verify the SSL cert for all HTTPS requests
--prerelease - Install the pre-release chef gems
--run-list RUN_LIST - Comma separated list of roles/recipes to apply
--secret-file SECRET_FILE - A file containing the secret key to use to encrypt data bag item values
--connection-password PASSWORD - SSH password / winrm password
--connection-port PORT - SSH port / winrm port
--connection-user USERNAME - SSH username / winrm username
--sysprep_timeout TIMEOUT - Wait TIMEOUT seconds for sysprep event before continuing with bootstrap
--winrm-authentication-protocol AUTHENTICATION_PROTOCOL. The authentication protocol used during WinRM communication. The supported protocols are basic,negotiate,kerberos. Default is 'negotiate'.
--winrm-codepage Codepage    The codepage to use for the winrm cmd shell
--winrm-shell SHELL          The WinRM shell type. Valid choices are [cmd, powershell, elevated]. 'elevated' runs powershell in a scheduled task
--winrm-ssl-verify-mode SSL_VERIFY_MODE   The WinRM peer verification mode. Valid choices are [verify_peer, verify_none]
--winrm-ssl  User ssl WinRM transport type
--tags TAG1,TAG2 - Tag the node with the given list of tags

Customization options

These options are related to the customization of the VM by the vSphere agent. They include hardware settings and networking.

--ccpu CUST_CPU_COUNT - Number of CPUs
--ccorespersocket CUST_CPU_CORES_PER_SOCKET - Number of CPU Cores per Socket
--cdomain CUST_DOMAIN - Domain name for customization
--cgw CUST_GW - CIDR IP of gateway for customization
--cdnsips CUST_DNS_IPS - Comma-delimited list of DNS IP addresses
--cdnssuffix CUST_DNS_SUFFIXES - Comma-delimited list of DNS search suffixes
--chostname CUST_HOSTNAME - Unqualified hostname for customization
--cips CUST_IPS - Comma-delimited list of CIDR IPs for customization, or *dhcp* to configure that interface to use DHCP
--cmacs CUST_MACS - Comma-delimited list of MAC addresses, or *auto* to configure that interface to use automatically generated MAC address
--cplugin CUST_PLUGIN_PATH - Path to plugin that implements KnifeVspherePlugin.customize_clone_spec and/or KnifeVspherePlugin.reconfig_vm
--cplugin-data CUST_PLUGIN_DATA - String of data to pass to the plugin.  Use any format you wish.
--cram CUST_MEMORY_GB - Gigabytes of RAM
--cram_reservation CUST_MEMORY_RESERVATION_GB - Gigabytes of RAM
--cspec CUST_SPEC - The name of any customization specifications that are defined in vCenter to apply
--ctz CUST_TIMEZONE - Timezone in valid 'Area/Location' format
--cvlan CUST_VLANS - Comma-delimited list of VLAN names for the network adapters to join
--disable-customization - By default customizations will be applied to the customization specification (see below).  Disable these convention with this switch (default value is `false`)
--random-vmname - Creates a random VMNAME starts with vm-XXXXXXXX
--random-vmname-prefix - Change the VMNAME prefix

VMware options

These options alter the way the VM is created, such as to decide where it is placed.

--datastore STORE    - The datastore into which to put the cloned VM
--datastorecluster STORE - The datastorecluster into which to put the cloned VM
--dest-folder FOLDER - The folder into which to put the cloned VM
--resource-pool POOL|CLUSTER - The resource pool into which to put the cloned VM. Also accepts a cluster name.
--start - Start the VM after cloning.
--sw-uuid SWITCH_UUIDS - Comma-delimited list of virtual switch UUIDs to attach to the network adapters, or *auto* to automatically assign virtual switch
--template TEMPLATE - The source VM / Template to clone from

Examples

$ knife vsphere vm clone NewNode --template UbuntuTemplate --cspec StaticSpec \
    --cips 192.168.0.99/24,192.168.1.99/24 \
    --chostname NODENAME --cdomain NODEDOMAIN

The customization specification defaults can be disabled using the --disable-customization true switch. If you specify a --cspec with this option, that spec will still be applied.

NOTE: if you are specifying a --cspec and the cloning process appears to not be properly applying the spec as defined on vSphere, consider using --disable-customization true as the conventions described above could be erroneously interfering with the spec as defined on vSphere.

Customization specifications can also be specified in code using the --cplugin and/or --cplugin-data arguments. See the plugins section for examples.

The --bootstrap-vault-* options can be used to send chef-vault items to be updated during the hand-off to knife bootstrap.

Example using --bootstrap-vault-json:

$  knife vsphere vm clone NewNode UbuntuTemplate --cspec StaticSpec \
    --cips 192.168.0.99/24,192.168.1.99/24 \
    --chostname NODENAME --cdomain NODEDOMAIN \
    --start true --bootstrap true \
    --bootstrap-vault-json '{"passwords":"default","appvault":"credentials"}'

knife vsphere vm show VMNAME PROPERTY (PROPERTY)

Shows one or more properties of the VM.

See "http://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.VirtualMachine.html" for allowed values.

Please note that this command starts at the vm object, where the corresponding knife vsphere vm config command focuses entirely on a customization specification. This gives you more flexibility in what you can query, but means you need to do some translations if you want to read old values and make a change. For example, you would query config.hardware.numCPU with this command but set numCPUs.

Examples:

knife vsphere vm show myvirtualmachine config.hardware.memoryMB config.hardware.numCPU -F json

knife vsphere vm config VMNAME PROPERTY VALUE (PROPERTY VALUE)

Sets a vSphere property (or series of properties), such as CPU or disk, on a VM

See "http://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.vm.ConfigSpec.html" for allowed PROPERTY values (any property of type xs:string or numeric is supported)."

Examples:

$ knife vsphere vm config myvirtualmachine memoryMB 4096

knife vsphere vm toolsconfig VMNAME PROPERTY VALUE

--empty           - allows clearing string properties

Sets properties in tools property. See "https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.vm.ToolsConfigInfo.html" for available properties and types.

Examples:

$ knife vsphere vm toolsconfig myvirtualmachine syncTimeWithHost false
$ knife vsphere vm toolsconfig myvirtualmachine pendingCustomization -e

knife vsphere vm delete NAME

Deletes an existing VM, removing it from vSphere inventory and deleting from disk, optionally deleting it from Chef as well.

--purge|-P        - Delete the client and node from Chef as well
-N                - Specify the name of the node and client to delete if it differs from NAME (requires -P)

knife vsphere vm snapshot VMNAME

Manages the snapshots for an existing VM, allowing for creation, removal, and reverting of snapshots.

--list            - List the current tree of snapshots and include snapshot creation timestamp
--create SNAPSHOT - Create a new snapshot off of the current snapshot
--remove SNAPSHOT - Remove a named snapshot.
--revert SNAPSHOT - Revert to a named snapshot.
--revert-current  - Revert to current snapshot.
--start           - Starts the VM after a successful revert
--wait            - Wait for creation/removal to complete rather than returning immediately
--find            - Find the VM instead of specifying the folder with -F
--dump-memory     - Dump the memory when creating the snapshot (default: false)
--quiesce         - Quiesce the VM before snapshotting (default: false)
--snapshot-descr DESCR - Include a description when creating a snapshot

knife vsphere vm cdrom

--datastore DATASTORE - Datastore the image is stored in
--iso                 - Path and filename of the ISO
--attach              - Attach the iso immediately
--disconnect          - Disconnect any iso currently attached
--recursive           - Search for the VM recursively
--folder              - Search for the VM in the specified folder
--on_boot BOOL        - Set the Attach On Boot Boolean

knife vsphere vm disk extend

--diskname DISKNAME - The name of the disk that will be extended (use when vm has multiple disks)

Note: SIZE is in kilobytes

knife vsphere vm disk list

Lists the disks attached to VMNAME

knife vsphere datastore list

Lists all known datastores with capacity and usage

knife vsphere datastore maxfree

Gets the datastore with the most free space

--regex           - Pattern to match the datastore name
--vlan            - Require listed vlan available to datastore's parent
--pool            - Pool or Cluster to search for datastores in

knife vsphere datastore file

Uploads files to a datastore and downloads files from a datastore

--upload-file       - Upload specified local file to remote
--download-file     - Download specified remote file to local
--remote-file FILE  - Remote file name and path
--local-file FILE   - Local file name and path

knife vsphere datastorecluster list

Lists all known datastorecluster with capacity and usage

knife vsphere datastorecluster maxfree

Gets the datastorecluster with the most free space

--regex           - Pattern to match the datastore name

knife vsphere vm execute VMNAME COMMAND ARGS

Executes a program on the guest. Requires vCenter 5.0 or higher.

Command path must be absolute. For Linux guest operating systems, /bin/bash is used to start the program. For Solaris guest operating systems, /bin/bash is used to start the program if it exists. Otherwise /bin/sh is used.

Arguments are optional, and allow for redirection in Linux and Solaris.

--exec-user USERNAME - The username on the guest to execute as.
--exec-passwd PASSWD - The password for the user executing as.
--exec-dir DIRECTORY - Optional: Working directory to execute in. Will default to $HOME of user.

Example:

knife vsphere vm execute myvirtualmachine --exec-user root --exec-passwd 'password' -- /sbin/iptables -F

knife vsphere vm vnc set VMNAME

Enable VNC remote console.

Required arguments:

--vnc-port PORT           -Port to run VNC on
--vnc-password PASSWORD   -Password for connecting to VNC

knife vsphere vm vmdk add VMNAME DISKSIZE_GB

Adds VMDK to VMNAME, given a disk size in Gigabytes.

Optional arguments

--vmdk-type TYPE - VMDK type, "thick" or "thin", defaults to "thin"

knife vsphere vm markastemplate VMNAME

Will mark the VM as a template rather than a runnable VM. By default the search will start at the root folder. --folder should be specified if traversing should be in some other folder than the root. Once found the VM will be converted into a template. This means the VM will become a template and no longer be available as a Virtual Machine. The name given to the template will be the name of VM from which it was created.

knife vsphere hosts list --pool

Lists all hosts in given Pool

knife vsphere vm migrate VMNAME

Migrate VM to resource pool/datastore/host. Resource pool and datastore are mandatory.

--folder FOLDER             - folder in which to search for VM
--resource-pool POOL        - destination resource pool
--dest-host HOST            - destination host (optional)
--dest-datastore DATASTORE  - destination datastore, accessible to HOST
--priority PRIORITY         - migration priority (optional, default defaultPriority )

knife vsphere vm net STATE VMNAME

Set networking state for VMNAME by connecting/disconnecting network interfaces. Possible states are up and down.

knife vsphere vm network set VMNAME NETWORKNAME

Set NETWORKNAME on first interface of VMNAME. Works for both standard and distributed switches.

--nic INTEGER     - NIC to change (optional, default 0)

knife vsphere vm network set example1.test.com vlan123
knife vsphere vm network set example2.test.com vlan234 --nic 1

knife vsphere vm network add VMNAME NETWORKNAME

Add a network card to a VM and connect it to a network.

--adapter-type STRING      - Adapter type eg e1000,vmxnet3
--mac-address STRING       - Adapter MAC address eg. AA:BB:CC:DD:EE:FF

knife vsphere vm network list VMNAME

List the network cards and their VLAN that are connected to a VM.

knife vsphere vm network delete VMNAME NICNAME

Delete a network card from a VM.

knife vsphere vm wait sysprep VMNAME

Wait for vm finishing Sysprep

--sleep SLEEP      - The time in seconds to wait between queries for CustomizationSucceeded event. Default: 60 seconds
--timeout TIMEOUT  - The timeout in seconds before aborting. Default: 300 seconds

knife vsphere cpu ratio

Lists the ratio between assigned virtual CPUs and physical CPUs on all hosts.

Example:

$ knife vsphere cpu ratio
Output:
### Cluster Cluster1 ###
host1.domain.com: 1.8125
host2.domain.com: 2.40625
host3.domain.com: 1.8125

### Cluster Cluster2 ###
host4.domain.com: 1.8125
host5.domain.com: 2.40625

knife vsphere vm move VMNAME

Moves the VM to other datastores or to rename it.

--dest-name NAME      - Destination name of the VM or template
--dest-folder FOLDER  - The destination folder into which the VM or template should be moved
--datastore STORE     - The datastore into which to put the cloned VM
--thin-provision      - Indicates whether disk should be thin provisioned.
--thick-provision     - Indicates whether disk should be thick provisioned.

Recursively prints all the folders in the datacenter.

knife vsphere vm property get VMNAME PROPERTY

Gets a vApp property on VMNAME

knife vsphere vm property set VMNAME PROPERTY VALUE

Sets a vApp property on VMNAME to the given value

--ovf-environment-transport STRING  - Comma delimited string.  Configures the transports to use for properties. Supported values are: iso and com.vmware.guestInfo.

knife vsphere folder list

Recursively prints all the folders in the datacenter.

knife vsphere pool show POOLNAME QUERY

Shows information (hosts, networks, resources) about a pool/compute resource.

See "http://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.ComputeResource.html\" for allowed QUERY values.".

knife vsphere vlan list

Lists all the VLANs in the datacenter

knife vsphere vlan create NAME VID

Creates a vlan (port group on a distributed virtual switch) with the given name and VLAN ID. If you have multiple distributed switches then use the --switch option to set the switch

Developing, or using the latest code

The master version of this code may be ahead of the gem itself. If it's in master you can generally consider it ready to use. To use master instead of what's published on Ruby gems:

$ gem uninstall knife-vsphere
$ git clone [email protected]:chef/knife-vsphere.git # or your fork
$ cd knife-vsphere
$ rake build                                           # Take note of the version
$ gem install pkg/knife-vsphere-1.1.1.gem              # Use the version above

If you are doing development, then you can run the plugin out of a checked out copy of the source:

$ bundle install # only needs to be done once
$ bundle exec knife vsphere ...

Plugins

knife-vsphere supports some plugins, currently only for the clone operation.

Plugins let you write code to further customize the operation you are sending to vCenter.

The basic idea is that plugins expose well known methods to knife, which are then run at particular times. The values returned from your methods are passed directly to vSphere.

Below are examples of the potential implementations that would be saved to an rb file and passed in the --cplugin argument.

Getting help

If the software isn't behaving the way you think, or you're having trouble doing something, we're happy to help. Try this checklist:

  • Are you running the latest version? gem list knife-vsphere. You can always upgrade with gem install knife-vsphere
  • Try running the same command with -VV to add additional logging messages
  • Are there any errors in the vSphere console or logs?
  • Search for known issues at https://github.com/chef/knife-vsphere/issues

If you're still having problems, head on over to the issues page and create a new issue. Please include:

  • A description of what you are trying to do, what you are seeing
  • The version number of knife-vsphere and of vSphere itself
  • The exact command you're running and the output (sanitize anything you don't want public!)

License

Authors

Copyright
  Copyright © 2011-2013 Ezra Pagel
  Copyright © 2015-2017 Chef Software, Inc
VMware vSphere is a trademark of VMware, Inc.

Apache License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Software changes provided by Nicholas Brisebois at Dell SecureWorks. For more information on Dell SecureWorks security services please browse to http://www.secureworks.com

© Dell SecureWorks 2015

knife-vsphere's People

Contributors

andrewfraley avatar ashiqueps avatar bby-bishopclark avatar bdupras avatar bflad avatar btm avatar chef-ci avatar dependabot-preview[bot] avatar dhgwilliam avatar eklein avatar ezrapagel avatar iandelahorne avatar jcam avatar kbrowns avatar kirtfitzpatrick avatar kozmikyak avatar leeor avatar mheidenr avatar nammiesgal avatar rhadoo avatar sacx13 avatar scotthain avatar skeshari12 avatar swalberg avatar tas50 avatar tcicone avatar tduffield avatar tim95030 avatar troyready avatar warroyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knife-vsphere's Issues

Customization plugin call (issue) and windows cloning (solved)

Issue

Customization plugin cannot modify effecitvely vm customization object because it is called to early:

vsphere_vm_clone.rb line 359 and later:

      if customization_plugin && customization_plugin.respond_to?(:customize_clone_spec)
        clone_spec = customization_plugin.customize_clone_spec(src_config, clone_spec)
      end

      clone_spec.customization = cust_spec

Object is customized and then overwritten once again.

Solution

      clone_spec.customization = cust_spec

      if customization_plugin && customization_plugin.respond_to?(:customize_clone_spec)
        clone_spec = customization_plugin.customize_clone_spec(src_config, clone_spec)
      end

Just to put clone_spec asignment before customization.

Appliance

Thanks to lamont's idea in issue #74 I've solved windows clonning issue without significant effort in core clone file.

After trick described above, this is very simple to:

  1. Call knife-vsphere with customization plugin
  2. Write own customization plugin

Ad1.
Add directives to knife-vsphere call:

--cplugin /absolute_path_to_file/knife-windows-customization-plugin.rb --cplugin-data /absolute_path_to_file/knife-windows-customization-plugin-data.json

Ad2.
Write something like that (knife-windows-customization-plugin.rb)

require 'rbvmomi'

class KnifeVspherePlugin
        attr_accessor :data

        def customize_clone_spec(src_config, clone_spec)
        if File.exists? data
            customization_data = JSON.parse(IO.read(data))
        else
            abort "Customization plugin data file #{data} not accessible"
        end

                new_identity = RbVmomi::VIM.CustomizationSysprep

                new_identity.guiRunOnce = nil

                new_guiUnattended = RbVmomi::VIM.CustomizationGuiUnattended
                new_guiUnattended.autoLogon = false
                new_guiUnattended.autoLogonCount = 1
                new_guiUnattended.password = nil
                new_guiUnattended.timeZone = "#{customization_data['timeZone']}"

                new_identity.guiUnattended = new_guiUnattended

                new_identification = RbVmomi::VIM.CustomizationIdentification
                new_identification.domainAdmin = nil
                new_identification.domainAdminPassword = nil
                new_identification.joinDomain = nil

                new_identity.identification = new_identification

                new_hostName = RbVmomi::VIM.CustomizationFixedName
                new_hostName.name = "#{customization_data['host_name']}"

                new_userData = RbVmomi::VIM.CustomizationUserData
                new_userData.computerName = new_hostName
                new_userData.fullName = "#{customization_data['fullName']}"
                new_userData.orgName = "#{customization_data['orgName']}"
                new_userData.productId = "#{customization_data['windows_key']}"

                new_identity.userData = new_userData

                clone_spec.customization.identity = new_identity

                new_windowsOptions = RbVmomi::VIM.CustomizationWinOptions
                new_windowsOptions.changeSID = true
                new_windowsOptions.deleteAccounts = false

                clone_spec.customization.options = new_windowsOptions

                # puts "New clone_spec.customization object :\n #{YAML::dump(clone_spec.customization)}"

                clone_spec
        end

        def reconfig_vm (target_vm)
                puts "Hello, I am in reconfig_vm method"
        end
end

and

knife-windows-customization-plugin-data.rb

{
    "fullName": "ACME Co.",
    "orgName": "ACME Co.",
    "windows_key": "my fantastic Windows key (may be null)",
    "host_name": "myhostname",
    "timeZone": "100"
}

Works for Windows 2008 and Windows 2012.

Please note, that all switches including network settings are still working, because only "affected" part of customization is repaired.

It would be great to put assignment command switch to main line of code.

Clone WIndows VM (winrm) with Bootstrap Option ?

It seems like the --bootstrap option will not work when cloning a Windows VM that has winrm setup.

Waiting for sshd...DEBUG: value for config item ssh_port: 22
.DEBUG: value for config item ssh_port: 22
.DEBUG: value for config item ssh_port: 22
.DEBUG: value for config item ssh_port: 22

Debugging knife-vsphere

I realize this is probably the wrong forum for this question however I cannot find a better place to ask. I've asked in the IRC channel, read numerous documents and I still cannot find an answer. I'm looking to implement windows bootstrapping with the knife-vsphere plugin. I am shamelessly trying to integrate the code in the knife-vcloud source. I think I've gotten it to a point where I can start to test But this is where I'm having trouble. I can't seem to debug knife-vsphere properly and I can't find any documentation on how to debug a knife plugin. can anybody point me in the right direction. I'm currently using Eclipse IDE but I'm open to suggestions.

My current issue is when I run the script it dies before getting to the run method. I can only assume that this is implemented in the knife.rb file or a subset of that however I can't figure it out. Can anyone here point me in the right direction?

Do I have to have the chef/knife source in order to debug or is installing the gem enough? Can anyone provide any examples of Debug Configurations needed in Eclipse? Can I only Debug with UNIT testing and if so does anyone have a resource for getting this setup in Eclipse. I Don't have much experience with unit testing.

Thanks in advance to anyone that can help me out.

Nic

-cspec does not work with windows

I have created a custom spec in vcenter and passed the name, it said it is not supported for windows, I wanted to know fix or alternative or work around for doing the same

chef version conflict

I got a version conflict when installing this on a system with 10.12.0. Gem would install chef 0.10 as well and that made knife very unhappy.

I got around this by changing the chef version number in the gemspec and generating a new gem to use. So far things appear to be working ok with 10.12.0. Are you aware of any differences that have kept you from bumping the version in the gemspec?

--disable-customization results in RbVmomi::Fault: InvalidRequest:

I am trying to use the new --disable-customization flag but it the clone VMs because I've noticed that VMs cloned using the customization spec need to reboot twice before coming up cleanly. However the clone fails with the following error:

Bethanys-MacBook-Air:paperless-chef bethany$ knife vsphere vm clone "testing-deleteme01" --folder "templates" --template "mytemplate" --dest-folder "testing" --datastore "tier2a" --disable-customization -V
ERROR: RbVmomi::Fault: InvalidRequest:
Required property identity is missing from data object of type CustomizationSpec

while parsing serialized DataObject of type vim.vm.customization.Specification
at line 1, column 597

while parsing property "customization" of static type CustomizationSpec

while parsing serialized DataObject of type vim.vm.CloneSpec
at line 1, column 326

while parsing call information for method CloneVM_Task
at line 1, column 177

while parsing SOAP body
at line 1, column 167

while parsing SOAP envelope
at line 1, column 0

while parsing HTTP request for method clone
on object of type vim.VirtualMachine
at line 1, column 0

Our vCenter version is 5.1.0. /cc @sacx

knife vsphere template list displays nothing

I'm running Chef 11.10.4 and have been bootstrapping and deploying ec2 instances without issue. I now want to bootstrap vmware (Ubuntu and CentOS) templates that I've created (with vmtools installed). The knife vsphere vm list command works, but for some reason I cannot perform knife vsphere template list and therefore cannot launch an instance based upon my templates since chef doesnt see the templates. I'm running ESX 5.0 along with vCenter 5.0. I have the same issue with knife esx template list as well. Any ideas ? I did have to remove rbvmomi (1.8.1) to get rid of the compatibility messages

rbvmomi (1.5.1)
json (1.8.1, 1.5.5)
knife-ec2 (0.6.6)
knife-esx (0.3.5)
knife-vsphere (0.9.8)
knife-windows (0.5.14)

Can't clone template across resource pools

Within our datacenter we have two resources pools (DRS/HA clusters), DevQA and Production. All of our templates reside within the DevQA resource pool. I am not able to clone from the template with the destination pool being Production.

This works:

knife vsphere vm clone toddtest -f Templates --template RHLinux664 --vshost c3pivcenter1.corp.premierinc.com -u tcampbel --vsinsecure --resource-pool DevQA --dest-folder "DEVQA Linux Servers" --verbose --cips 10.32.32.248/24 --cgw 10.32.32.1 --chostname toddtest --ccpu 1 --cram 2 --cspec RHEL --cvlan "10.32.32 VM Net" --start

But when atttempting to use the Production resource pool (and Folder as well):

knife vsphere vm clone toddtest -f Templates --template RHLinux664 --vshost c3pivcenter1.corp.premierinc.com -u tcampbel --vsinsecure --resource-pool Production --dest-folder "Production Linux Servers" --verbose --cips 10.32.32.248/24 --cgw 10.32.32.1 --chostname toddtest --ccpu 1 --cram 2 --cspec RHEL --cvlan "10.32.32 VM Net" --start

It generates the error:

ERROR: RbVmomi::Fault: CannotAccessVmComponent: A component of the virtual machine is not accessible on the host.

This is our pool list:

knife vsphere pool list --vshost c3pivcenter1.corp.premierinc.com -u tcampbel --vsinsecure
Enter your password:
Folder:
ClusterComputeResource: DevQA
VirtualApp: DevQA/Resources/ProSphere
Unknown type VirtualApp, not enumerating
ClusterComputeResource: Production
ClusterComputeResource: StackTest
ClusterComputeResource: VDI

Assign mac address to multple nics

Hi,

I just started using knife-vsphere gem and I say that this is a life saver. So thanks for working on it! Since I am new to to this, I wanted to know how to assign mac addresses to clone vm with multiple nics? Is that even possible with knife vsphere clone command?

Thanks,
Robert

Spaces in datacenter names ok? datacenter not found

I'm getting "datacenter not found" when I try to run any commands. The only thing I can think of is that all of my datacenters have spaces in the names. Are the spaces an issue? Any other suggestions? I'm running vcenter 5.1

Cloning to Second Cluster in Datacenter Fails

I have a VSphere datacenter with two clusters. My ~/.chef /knife.rb file contains the info for connecting to my VCenter Server.

I am unable to 'knife vsphere vm clone' any templates to the hosts in the second cluster. I get this error whenever I attempt.

/Users/matt/.rvm/gems/ruby-1.9.3-p125/gems/rbvmomi-1.5.1/lib/rbvmomi/vim/Task.rb:11:in `wait_for_completion': CannotAccessVmComponent: A component of the virtual machine is not accessible on the host. (RbVmomi::Fault)
    from /Users/matt/.rvm/gems/ruby-1.9.3-p125/gems/knife-vsphere-0.3.0/lib/chef/knife/vsphere_vm_clone.rb:195:in `run'
    from /Users/matt/.rvm/gems/ruby-1.9.3-p125/gems/chef-10.16.2/lib/chef/knife.rb:408:in `run_with_pretty_exceptions'
    from /Users/matt/.rvm/gems/ruby-1.9.3-p125/gems/chef-10.16.2/lib/chef/knife.rb:168:in `run'
    from /Users/matt/.rvm/gems/ruby-1.9.3-p125/gems/chef-10.16.2/lib/chef/application/knife.rb:123:in `run'
    from /Users/matt/.rvm/gems/ruby-1.9.3-p125/gems/chef-10.16.2/bin/knife:25:in `<top (required)>'
    from /Users/matt/.rvm/gems/ruby-1.9.3-p125/bin/knife:23:in `load'
    from /Users/matt/.rvm/gems/ruby-1.9.3-p125/bin/knife:23:in `<main>'

I can clone the template from the VSphere Client and it works fine. If I migrate the template to the first cluster, then the 'knife vsphere vm clone' command works fine.

Is this an issue with RbVmomi?

Matt

Incorrect user or password

Here is my configuration In the knife.rb file:

knife[:vsphere_host] = "host.domain.com"
knife[:vsphere_user] = "WINDOWSDOMAIN\username"
knife[:vsphere_pass] = "PASSWORD"
knife[:vsphere_dc] = "DATA-CENTER"

I am getting the error:
ERROR: RbVmomi::Fault: InvalidLogin: Cannot complete login due to an incorrect user name or password.

My question is:
How do I format the value for knife[:vsphere_user] ? When I log into the vSphere client in Windows, I login using WINDOWSDOMAIN\username. Should it be different here? I have also tried username@WINDOWSDOMAIN. We use NT Authentication to log on to vCenter.

Thanks.

use of the "--distro" flag is required in verion 0.9.5 bootstrap cmd

FYI in testing v0.9.5 I am finding that to provision and bootstrap a node requires use of the --distro flag in the command. If this flag and a corresponding value is not set, I am seeing the following error:
Can not find bootstrap definition for
ERROR: Errno::ENOENT: No such file or directory
With verbose output enabled I am seeing that knife is looking for a bootstrap template.

This may be intended behavior as a default value for :distro was removed from lib/chef/knife/vsphere_vm_clone.rb
Perhaps this should be added to the README or otherwise noted.

Issue with odd error: RbVmomi::Fault: NotFound:

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rbvmomi-1.5.1/lib/rbvmomi/connection.rb:61:in parse_response': NotFound: The object or item referred to could not be found. (RbVmomi::Fault) from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rbvmomi-1.5.1/lib/rbvmomi/connection.rb:90:incall'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rbvmomi-1.5.1/lib/rbvmomi/basic_types.rb:203:in _call' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rbvmomi-1.5.1/lib/rbvmomi/basic_types.rb:74:inblock (2 levels) in init'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/knife-vsphere-0.9.5/lib/chef/knife/vsphere_vm_clone.rb:405:in find_customization' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/knife-vsphere-0.9.5/lib/chef/knife/vsphere_vm_clone.rb:309:ingenerate_clone_spec'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/knife-vsphere-0.9.5/lib/chef/knife/vsphere_vm_clone.rb:223:in run' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/knife.rb:466:inrun_with_pretty_exceptions'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/knife.rb:173:in run' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/application/knife.rb:123:inrun'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/bin/knife:25:in <top (required)>' from /usr/bin/knife:23:inload'
from /usr/bin/knife:23:in `

'

ERROR: RuntimeError: expected ResourcePool, got Folder for field "pool"

Thanks for this gem!!

The error

ERROR: RuntimeError: expected ResourcePool, got Folder for field "pool"

is given when using the "knife vsphere vm clone command". However, the --resource-pool option is not set and is not listed as required in the help listing.

I had used the --resource-pool option on my first command, misunderstanding what a resource pool was in vSphere. However, we don't use resource pools in our deployment of vSphere. So, I removed it, but this error persists.

I also tried moving the --folder and --dest-folder options around in the command order, but not change.

Here is my command with the sensitive information removed:

knife vsphere vm clone NEWVMNAME
--template OUR_TEMPLATE --datacenter OUR_DATACENTER --ssh-user root
--ssh-password PASSWORD --datastore OUR_DATASTORE
--folder _Templates --dest-folder Servers/Linux
--start STARTVM
--cspec "Ubuntu 10.04 (x64)"
--run-list 'role[base],role[mediawiki_database_master]'

I also tried the command like this, but it returned the same error.

knife vsphere vm clone NEWVMNAME --template OUR_TEMPLATE --folder _Templates

Thanks again for this gem and thanks for looking at this.

Kind regards,

Ian D. Rossi

Proper format for Resource Pool?

Get a list:
knife vsphere pool list

From the list we will try something with no spaces or other funky:
ResourcePool: Cluster01/Resources/VDI

knife vsphere vm clone autonfs ... --resource-pool "Cluster01/Resources/VDI" ....

Returns error as do variations on the tree (VDI, "VDI", Resources/VDI etc. etc):

no such pool Cluster01/Resources/VDI while looking for Resources
no such pool Resources/VDI while looking for Resources
no such pool VDI while looking for Resources

Is this the correct format?

knife --version
Chef: 10.16.2

gem list --local knife-vsphere
knife-vsphere (0.3.0)

** mis-typed usage example on first post. Corrected.

Computer name with only integers fails to clone

example (not all params provided): knife vsphere vm clone 201402281
errors out:
ERROR: RbVmomi::Fault: InvalidArgument: A specified parameter was not correct.
spec.identity.userData.computerName

failure is in vsphere_vm_clone.rb link 228:
task = src_vm.CloneVM_Task(:folder => dest_folder, :name => vmname, :spec => clone_spec)

Logging of VSphere events

As part of the logging options, perhaps when using debug, it would be very helpful if all all of the VSphere event logs pertaining to the knife action could be reported for a specified event log level. At this time, it would appear the only VSphere event log information that ever gets returned is in the case of a fatal error.

Vapp Support

$ knife vsphere pool list
Folder:
ClusterComputeResource: # New ESXi Hosts unConfigure
ClusterComputeResource: UCS1
VirtualApp: UCS1/Resources/TEST
Unknown type VirtualApp, not enumerating

--- Each folder below contains Vapps - Each Vapp contains 1-30 vm's -- they do not get enumerated.

$ knife vsphere vm list
Folder Name: Discovered virtual machine
Folder Name: Apps
Folder Name: Infrastructure
Folder Name: Enterprise Apps

vsphere clone vm

I'm trying to create a VM power it on and bootsrtap. This is the command and errors I am getting. The goal is to create VM and bootstrap after creating it.

_COMMAND_
knife vsphere vm clone new_vm --template centos64-24 --cdomain -VV --cips --cdnsip <dns_ip> --cdnssuffix <dns_suffix> --ssh-user -P --start --bootstrap true -N new_vm -s <IP_ADDRESS:443> --distro chef-client

_ERROR_

Cloning template centos64-24 to new VM new_vm
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rbvmomi-1.5.1/lib/rbvmomi/vim/Task.rb:11:in wait_for_completion': InvalidArgument: A specified parameter was not correct. (RbVmomi::Fault) spec.identity.hostName from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/knife-vsphere-0.9.8/lib/chef/knife/vsphere_vm_clone.rb:230:inrun'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/knife.rb:485:in run_with_pretty_exceptions' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/knife.rb:174:inrun'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/lib/chef/application/knife.rb:133:in run' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.8.2/bin/knife:25:in<top (required)>'
from /usr/bin/knife:23:in load' from /usr/bin/knife:23:in

'

Thanks for the help!

Trying to list templates throws an error

# knife vsphere template list -V -V
DEBUG: Using configuration from /root/.chef/knife.rb
/usr/lib64/ruby/gems/1.8/gems/rbvmomi-1.2.3/lib/rbvmomi/basic_types.rb:168:in `_get_property': unhandled exception
    from /usr/lib64/ruby/gems/1.8/gems/rbvmomi-1.2.3/lib/rbvmomi/basic_types.rb:34:in `config'
    from /usr/lib64/ruby/gems/1.8/gems/knife-vsphere-0.1.7/lib/chef/knife/vsphere_template_list.rb:26:in `run'
    from /usr/lib64/ruby/gems/1.8/gems/knife-vsphere-0.1.7/lib/chef/knife/vsphere_template_list.rb:25:in `select'
    from /usr/lib64/ruby/gems/1.8/gems/knife-vsphere-0.1.7/lib/chef/knife/vsphere_template_list.rb:25:in `run'
    from /usr/lib64/ruby/gems/1.8/gems/chef-0.10.8/lib/chef/knife.rb:391:in `run_with_pretty_exceptions'
    from /usr/lib64/ruby/gems/1.8/gems/chef-0.10.8/lib/chef/knife.rb:166:in `run'
    from /usr/lib64/ruby/gems/1.8/gems/chef-0.10.8/lib/chef/application/knife.rb:128:in `run'
    from /usr/lib64/ruby/gems/1.8/gems/chef-0.10.8/bin/knife:25
    from /usr/bin/knife:19:in `load'
    from /usr/bin/knife:19

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can image, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post aobut this project for more information.

Why does knife vsphere vm list returns details of only one esx. We manage 6 esx(hosts) through same V centre..

[root@b1cu029a chef-repo]# knife vsphere vm list
Folder Name: Discovered virtual machine
VM Name: hadrdv01 IP: x.x.x.x RAM: 256 State: off
VM Name: am-vfr-vm1 IP: x.x.x.x RAM: 4096 State: on
VM Name: temp1 IP: RAM: 256 State: off
VM Name: am-vfr-vm2 IP: x.x.x.x RAM: 4096 State: on
VM Name: hadrdv02 IP: x.x.x.x RAM: 256 State: off
VM Name: hadrdv03 IP: x.x.x.x RAM: 256 State: off
VM Name: new1 IP: RAM: 256 State: off
VM Name: hadrdv04 IP: x.x.x.x RAM: 256 State: off
VM Name: hadrdv05 IP: x.x.x.x RAM: 256 State: off

The CLI return details of only 1 host configured in v center. I have configured at least 6 esx in the same V centre.

Can some help??

Clone fails -- NicSettingMismatch

Ubuntu 12.04 x64

knife vsphere vm clone newvmname --template U1204x64 -f Templates -VV

Results in this:

Cloning template U1204x64 to new VM newvmname
/home/user/.rvm/gems/ruby-1.9.2-p318/gems/rbvmomi-1.5.1/lib/rbvmomi/vim/Task.rb:11:in 'wait_for_completion': NicSettingMismatch: fault.NicSettingMismatch.summary (RbVmomi::Fault)
from /home/user/.rvm/gems/ruby-1.9.2-p318/gems/knife-vsphere-0.1.8/lib/chef/knife/vsphere_vm_clone.rb:195:in 'run'
from /home/user/.rvm/gems/ruby-1.9.2-p318/gems/chef-0.10.8/lib/chef/knife.rb:391:in 'run_with_pretty_exceptions'
from /home/user/.rvm/gems/ruby-1.9.2-p318/gems/chef-0.10.8/lib/chef/knife.rb:166:in 'run'
from /home/user/.rvm/gems/ruby-1.9.2-p318/gems/chef-0.10.8/lib/chef/application/knife.rb:128:in 'run'
from /home/user/.rvm/gems/ruby-1.9.2-p318/gems/chef-0.10.8/bin/knife:25:in '<top (required)>'
from /home/user/.rvm/gems/ruby-1.9.2-p318/bin/knife:19:in 'load'
from /home/user/.rvm/gems/ruby-1.9.2-p318/bin/knife:19:in '

'

vm clone windows template?

Apologies if this more of a general question than an issue, but is it currently possible to clone a windows vm with any amount of spec customization? Or does anybody have an example of a custom spec plugin that does that? I keep getting the error "A specified parameter was not correct: spec.identity" and when I dumped the identity spec I see:

identity: CustomizationLinuxPrep(...

so i assume that's the root of my error.

What I'm looking to do is clone a windows VM, change the hostname and ip, regenerate the sid, change the admin password.

My (sanitized) command line is:
knife vsphere vm clone lamont-test --template W2008R2_STD_x64_template --chostname lamont-test --cdomain foo.xxxxxxx.com --cips yyy.zzz.67.106/24 --cvlan hav-guest-dev-4 --folder templates --resource-pool "poolfolder/realpool" --ccpu 2 --cram 2 --cdnsips "1.2.3.4,1.2.3.5" --cdnssuffix foo.xxxxxxxx.com

I'm running against vsphere 5.0.0, knife vsphere plugin 0.9.5.

Looking at the vmware api docs, it seems like I could swap the CustomizationLinuxPrep for CustomizationSysprepText and use that to write out the sysprep.inf file. Does that seem like a reasonable task to accomplish via a spec plugin?

Thank you.

Cannot manage VMs that are in vApps

If VMs are in a vApp....it doesn't look like they can be managed with knife vsphere. They don't appear with all VMs using this command.

knife vsphere vm list -r

They cannot be managed using this command because VMs in the vApp don't appear in the parent folder.

$ knife vsphere vm state testVM -f "Test and Dev"
VM testVM not found
$ knife vsphere vm state testVM -f "Test and Dev//vAppTest"
no such folder Test and Dev/vAppTest while looking for vAppTest

vm config does not work for DynamicData

I can set some parameters using config, but not others.

Setting cpuHotAddEnabled works.

knife vsphere vm query acicone-virt config.cpuHotAddEnabled --folder LAB --vsuser root

Enter your password:
true

knife vsphere vm config acicone-virt cpuHotAddEnabled false --folder LAB --vsuser root

Enter your password:

knife vsphere vm query acicone-virt config.cpuHotAddEnabled --folder LAB --vsuser root

Enter your password:
false

But, setting thinProvisioned does not.

knife vsphere vm query acicone-virt config.hardware.device[11].backing.thinProvisioned --folder LAB --vsuser root

Enter your password:
true

knife vsphere vm config acicone-virt thinProvisioned false --folder LAB --vsuser root

Enter your password:
ERROR: RuntimeError: unexpected property name thinProvisioned

knife vsphere vm config acicone-virt config.hardware.device[11].backing.thinProvisioned false --folder LAB --vsuser root

Enter your password:
ERROR: RuntimeError: unexpected property name config.hardware.device[11].backing.thinProvisioned

Do I need different syntax?

Thanks for your help.

chef-related switches ignored

Hi, I am cloning a VM and bootstrapping with chef and attempting to specify that chef 11.4.4 is used but it is apparently being ignored. I also noticed earlier that setting "--bootstrap FALSE" doesn't do anything either- it will still bootstrap. Is --disable-customization causing them to be ignored?

knife vsphere vm clone bork --template precise64-basebox-dhcp -VV --disable-customization --node-name bork --start STARTVM --ssh-user ubuntu --ssh-password nermal --bootstrap TRUE --bootstrap-version 11.4.4 --run-list recipe[getting-started]

Issue with knife-vsphere 0.9.8 and chef 11.4.4?

Since the update of the knife-vsphere from 0.9.7 to 0.9.8 (on my chef 11.4.4 installation on ubuntu) this problem occurs whenever I try to run knife at all:

builder@w1-sc-chef-dev-02:~$ knife help
/usr/lib/ruby/gems/1.9.1/gems/knife-vsphere-0.9.8/lib/chef/knife/vsphere_datastorecluster_maxfree.rb:30:in <class:VsphereDatastoreclusterMaxfree>': undefined method[]=' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/gems/1.9.1/gems/knife-vsphere-0.9.8/lib/chef/knife/vsphere_datastorecluster_maxfree.rb:22:in <top (required)>' from /usr/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/knife/core/subcommand_loader.rb:37:inload'
from /usr/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/knife/core/subcommand_loader.rb:37:in block in load_commands' from /usr/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/knife/core/subcommand_loader.rb:37:ineach'
from /usr/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/knife/core/subcommand_loader.rb:37:in load_commands' from /usr/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/knife.rb:119:inload_commands'
from /usr/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/knife.rb:167:in run' from /usr/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/application/knife.rb:123:inrun'
from /usr/lib/ruby/gems/1.9.1/gems/chef-11.4.4/bin/knife:25:in <top (required)>' from /usr/bin/knife:23:inload'
from /usr/bin/knife:23:in `

'

UncostomizableGuest for Linux spec

I set up a linux customization spec on vSphere, however, I am getting an error that the spec is not supported for customization:

UncustomizableGuest: Customization of the guest operating system 'other26xLinux64Guest' is not supported in this configuration. Microsoft Vista (TM) and Linux guests with Logical Volume Manager are supported only for recent ESX host and VMware Tools versions. Refer to vCenter documentation for supported configurations. (RbVmomi::Fault)

Is other26xLinux64Guest throwing this off, as it is expecting something else to declare it as a Linux spec?

openssl issue

I am getting this error.

knife vsphere vm list
ERROR: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

Please suggest.

Thanks

Clone fails with no --cspec provided.

Clone fails when trying to specify all information without the 'cspec':

# knife vsphere vm clone -VV testbox01 --folder templates --template CentOS_6.0-clean --cdomain eurodir.eu --cdnsips 81.93.162.172,81.93.166.172 --cdnssuffix eurodir.eu --chostname testbox01 --datacenter EDSA --cvlan ED-ORTUS-STAGE --cgw 10.29.34.1/24 --cips 10.29.34.9/24 --fqdn testbox01.eurodir.eu --dest-folder 'BAT/New VMs' --start STARTVM --bootstrap TRUE --distro centos6-clean --run-list 'role[VMware-BAT_base]' --ssh-user root --ssh-password xxxxxxxxx
DEBUG: Using configuration from /root/.chef/knife.rb
/usr/lib64/ruby/gems/1.8/gems/knife-vsphere-0.1.8/lib/chef/knife/vsphere_vm_clone.rb:248:in `generate_clone_spec': undefined method `config' for #<RbVmomi::VIM::Network:0x7f802a874798> (NoMethodError)
    from /usr/lib64/ruby/gems/1.8/gems/knife-vsphere-0.1.8/lib/chef/knife/vsphere_vm_clone.rb:187:in `run'
    from /usr/lib64/ruby/gems/1.8/gems/chef-0.10.8/lib/chef/knife.rb:391:in `run_with_pretty_exceptions'
    from /usr/lib64/ruby/gems/1.8/gems/chef-0.10.8/lib/chef/knife.rb:166:in `run'
    from /usr/lib64/ruby/gems/1.8/gems/chef-0.10.8/lib/chef/application/knife.rb:128:in `run'
    from /usr/lib64/ruby/gems/1.8/gems/chef-0.10.8/bin/knife:25
    from /usr/bin/knife:19:in `load'
    from /usr/bin/knife:19

I believe the issue lies in "vsphere_vm_clone.rb" around line 248 where it tries to determine the switch port.

switch_port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(:switchUuid => network.config.distributedVirtualSwitch.uuid ,:portgroupKey => network.key)

We don't utilise a distributed virtual switch. Is there a way around this?

knife vsphere vm execute run in undefined method 'processManager'

knife vsphere vm execute CloneTest -f folder "/usr/bin/uptime" -VV --exec-user root --exec-passwd xxx --exec-dir /root -u user

run in following error

DEBUG: value for config item exec_dir: /root
/var/lib/gems/1.9.1/gems/knife-vsphere-0.9.7/lib/chef/knife/vsphere_vm_execute.rb:63:in run': undefined methodprocessManager' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.9.1/gems/chef-11.8.2/lib/chef/knife.rb:485:in run_with_pretty_exceptions' from /var/lib/gems/1.9.1/gems/chef-11.8.2/lib/chef/knife.rb:174:inrun'
from /var/lib/gems/1.9.1/gems/chef-11.8.2/lib/chef/application/knife.rb:133:in run' from /var/lib/gems/1.9.1/gems/chef-11.8.2/bin/knife:25:in<top (required)>'
from /usr/local/bin/knife:23:in load' from /usr/local/bin/knife:23:in

'

--bootstrap with --distro <template name> doesn't appear to work

I've tried cloning a VM and bootstrapping with a single command but when it tries to bootstrap it seems to be ignoring my custom CentOS 6 bootstrap template and reverting to some Debian-based install.

$ knife vsphere vm clone server --folder templates --template CentOS_6.0-clean --cspec "cspec" --datacenter DC --cips 10.0.0.1/24 --fqdn server.example.com --dest-folder "New VMs" --start STARTVM --bootstrap --distro centos6-clean --run-list common_role --ssh-user root --ssh-password helloworld

    [...]

Cloning template CentOS_6.0-clean to new VM server
Finished creating virtual machine server
Powered on virtual machine server
Waiting for sshd......................done
Bootstrapping Chef on server.example.com
dtg-ortsrchqa01.eurodir.eu bash: line 3: apt-get: command not found
dtg-ortsrchqa01.eurodir.eu bash: line 4: apt-get: command not found
dtg-ortsrchqa01.eurodir.eu bash: line 6: wget: command not found
dtg-ortsrchqa01.eurodir.eu tar (child): rubygems-1.6.2.tgz: Cannot open: No such file or directory
dtg-ortsrchqa01.eurodir.eu tar (child): Error is not recoverable: exiting now
dtg-ortsrchqa01.eurodir.eu tar: Child returned status 2
dtg-ortsrchqa01.eurodir.eu tar: Error is not recoverable: exiting now
dtg-ortsrchqa01.eurodir.eu bash: line 8: cd: rubygems-1.6.2: No such file or directory
dtg-ortsrchqa01.eurodir.eu bash: line 9: ruby: command not found
dtg-ortsrchqa01.eurodir.eu bash: line 12: gem: command not found
dtg-ortsrchqa01.eurodir.eu bash: line 13: gem: command not found
dtg-ortsrchqa01.eurodir.eu bash: line 14: gem: command not found
dtg-ortsrchqa01.eurodir.eu bash: line 71: /usr/bin/chef-client: No such file or directory

Executing command on linux guest

While running
knife vsphere vm execute test2 -f LAB touch /tmp/1.tst --exec-user root --exec-passwd xxxxx --exec-dir /usr/bin - I receive an error

ERROR: RbVmomi::Fault: FileNotFound: File was not found

running with -VV

root@Chef:~# knife vsphere vm execute test2 -f LAB touch /tmp/1.tst --exec-user root --exec-passwd xxxxx --exec-dir /usr/bin -VV
DEBUG: Using configuration from /root/.chef/knife.rb
DEBUG: value for config item vsphere_host: vc.maishsk.local
DEBUG: value for config item vshere_path:
DEBUG: value for config item vsphere_port: 443
DEBUG: value for config item vsphere_nossl:
DEBUG: value for config item vsphere_user: maish
DEBUG: value for config item vsphere_pass: xxxxx
DEBUG: value for config item vsphere_insecure: true
DEBUG: value for config item vsphere_dc: LAB
DEBUG: value for config item folder: LAB
DEBUG: value for config item vsphere_dc: LAB
DEBUG: value for config item exec_dir: /usr/bin
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/rbvmomi-1.5.1/lib/rbvmomi/connection.rb:61:in parse_response': FileNotFound: File <unspecified filename> was not found (RbVmomi::Fault) from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/rbvmomi-1.5.1/lib/rbvmomi/connection.rb:90:incall'
from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/rbvmomi-1.5.1/lib/rbvmomi/basic_types.rb:203:in _call' from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/rbvmomi-1.5.1/lib/rbvmomi/basic_types.rb:74:inblock (2 levels) in init'
from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/knife-vsphere-0.3.0/lib/chef/knife/vsphere_vm_execute.rb:65:in run' from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/chef-10.16.2/lib/chef/knife.rb:408:inrun_with_pretty_exceptions'
from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/chef-10.16.2/lib/chef/knife.rb:168:in run' from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/chef-10.16.2/lib/chef/application/knife.rb:123:inrun'
from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/chef-10.16.2/bin/knife:25:in <top (required)>' from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/knife:19:inload'
from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/knife:19:in <main>' from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:ineval'
from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `

'

Datacenters in subfolders are no longer supported

As mentioned here: #69
Datacenters in subfolders cannot be found. I've patched this to traverse all folders looking for the specified datacenter.

Caveat: If you previously specified your datacenter in knife.rb as something like "North America/Texas DC", you should now only use "Texas DC". Obviously this won't work if you have two datacenters with the same name in different folders, but I'm not sure if VMWare even allows that.

Unable to set correct subnet for static IP

I am cloning a VM like so:

knife vsphere vm clone QA1T3NLABTC \
    --template QA1DOUBU1264 \
    --cips 50.33.152.11 \
    --chostname QA1T3NLABTC \
    --cdomain local \
    --folder T3NDEVOPSLAB \
    --resource-pool CLSTR01/T3NDEVOPSLAB \
    --cvlan vlan152_50.33.152 \
    --cgw 50.33.152.1 \
    --cram 4 \
    --ccpu 2 \
    --datastore QA1-2-SFIRE-05 \
    --cdnsips "50.33.1.26,50.33.1.27" \
    --start

I end up with a /etc/network/interfaces that looks like this:

iface lo inet loopback
auto lo

auto eth0
iface eth0 inet static
address 50.33.152.11
netmask 255.255.255.255
up route add default gw 50.33.152.1

I want the netmask to be 255.255.255.0 and until that is changed, the machine is unreachable.

Am I using the clone command incorrectly or is there a better way to accomplish this?

Thanks!

clone fails - No host specified

On Mac OS X using ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]

When attempting to clone:

sroldan$ knife vsphere vm clone d-test01 PersonalDev -VV
Cloning template PersonalDev to new VM d-test01
/Library/Ruby/Gems/1.8/gems/rbvmomi-1.2.3/lib/rbvmomi/vim/Task.rb:11:in wait_for_completion': InvalidArgument: A specified parameter was not correct. (RbVmomi::Fault) host from /Library/Ruby/Gems/1.8/gems/knife-vsphere-0.1.5/lib/chef/knife/vsphere_vm_clone.rb:123:inrun'
from /Library/Ruby/Gems/1.8/gems/chef-0.10.4/lib/chef/knife.rb:391:in run_with_pretty_exceptions' from /Library/Ruby/Gems/1.8/gems/chef-0.10.4/lib/chef/knife.rb:166:inrun'
from /Library/Ruby/Gems/1.8/gems/chef-0.10.4/lib/chef/application/knife.rb:128:in run' from /Library/Ruby/Gems/1.8/gems/chef-0.10.4/bin/knife:25 from /usr/bin/knife:19:inload'
from /usr/bin/knife:19

Network settings not being applied on top of custom spec

I have been working with custom specs in order to apply network settings as well as using the switches in the knife command to set the static IP and gateway. This has been working for me but today this changed. For some reason when I create a new guest VM with knife-vsphere the network settings in the CSpec and in the CL options are basically being ignored. The network settings are as they were on the VM that I am cloning. I didn't knowingly change my process or settings to cause the changed behavior so I am wondering if there is anything here that would indicate a problem:

sploosh:.chef$ knife vsphere vm clone arf --template precise64-basebox-dhcp -VV --node-name arf --start STARTVM --ssh-user ubuntu --ssh-password nonono --bootstrap TRUE --bootstrap-version 11.4.4 --cspec StaticIPSpec --cips 10.143.249.78/27 --cgw 10.143.249.93
DEBUG: value for config item bootstrap: true
DEBUG: value for config item distro: ubuntu10.04-gems
DEBUG: value for config item vsphere_host: w1-scvc-1.eng.vmware.com
DEBUG: value for config item vshere_path: 
DEBUG: value for config item vsphere_port: 443
DEBUG: value for config item vsphere_nossl: 
DEBUG: value for config item vsphere_user: root
DEBUG: value for config item vsphere_pass: yesyesyes
DEBUG: value for config item vsphere_insecure: true
DEBUG: value for config item vsphere_dc: WDC OP
DEBUG: value for config item folder: 
DEBUG: value for config item vsphere_dc: WDC OP
DEBUG: value for config item resource_pool: 
DEBUG: value for config item vsphere_dc: WDC OP
DEBUG: value for config item datastore: 
DEBUG: value for config item annotation: 
DEBUG: value for config item customization_cpucount: 
DEBUG: value for config item customization_memory: 
DEBUG: value for config item customization_vlan: 
DEBUG: value for config item customization_spec: StaticIPSpec
DEBUG: value for config item customization_spec: StaticIPSpec
DEBUG: value for config item customization_dns_ips: 
DEBUG: value for config item customization_dns_suffixes: 
DEBUG: value for config item customization_gw: 10.143.249.93
DEBUG: value for config item customization_gw: 10.143.249.93
DEBUG: value for config item disable_customization: 
DEBUG: value for config item customization_domain: 
DEBUG: value for config item customization_plugin: 
DEBUG: value for config item folder: 
DEBUG: value for config item vsphere_dc: WDC OP
Cloning template precise64-basebox-dhcp to new VM arf

It is at this point that I go to the console of the VM and reboot it so it takes the network settings that are on file (thanks to the CSpec and knife-vsphere) but this is where I see that none of the settings have been applied.

Clearly, I am doing something different (and wrong) and I am just not seeing it. I am 99% sure I am using the command I used previously. Also, the CSpec is also unchanged. If I could get a second set of eyes here I would be grateful because I am pulling my hair out.

vmdk add command failure

I get the below error when I try to add a virtual disk to my VM.

vkatikineni@vishal-vm1:~$ knife vsphere vm vishal-vm1.tnt17-zone1.aus1 vmdk add 10 -f tenant17/DBA --vmdk-type thick -VV
DEBUG: value for config item vsphere_host:
DEBUG: value for config item vshere_path:
DEBUG: value for config item vsphere_port: 443
DEBUG: value for config item vsphere_nossl:
DEBUG: value for config item vsphere_user: tenant17
DEBUG: value for config item vsphere_pass:
DEBUG: value for config item vsphere_insecure: true
DEBUG: value for config item folder: tenant17/DBA
DEBUG: value for config item vsphere_dc: MP1
DEBUG: value for config item vmdk_type: thick

Creating VMDK
Capacity: 10 GB
Disk: [ea29-p2k1-fs01-tnt17] vishal-vm1.tnt17-zone1.aus1/vishal-vm1.tnt17-zone1.aus1_1.vmdk
Datastore: Datastore("datastore-2360")
DEBUG: value for config item vsphere_dc: MP1
Attaching VMDK to vishal-vm1.tnt17-zone1.aus1
DEBUG: value for config item noop:
/usr/local/rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rbvmomi-1.5.1/lib/rbvmomi/vim/Task.rb:11:in wait_for_completion': InvalidType: The request refers to an unexpected or unknown type. (RbVmomi::Fault)
from /usr/local/rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/knife-vsphere-0.5.0/lib/chef/knife/vsphere_vm_vmdk_add.rb:71:inrun'
from /usr/local/rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/knife.rb:460:in run_with_pretty_exceptions'
from /usr/local/rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/knife.rb:173:inrun'
from /usr/local/rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/application/knife.rb:123:in run'
from /usr/local/rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/chef-11.4.4/bin/knife:25:in'
from /usr/local/rbenv/versions/1.9.2-p290/bin/knife:23:in load'
from /usr/local/rbenv/versions/1.9.2-p290/bin/knife:23:in'

ERROR: RbVmomi::Fault: NotSupported: The operation is not supported on the object

I'm running this:
knife vsphere vm clone test2 --template test --datastore generic

the datastore is found, I connect to the server properly, the template vm is found, the console outputs:
Cloning template test to new VM test2

The next line of vsphere_vm_clone.rb fails (roughly line 217):
task.wait_for_completion
console outputs:
ERROR: RbVmomi::Fault: NotSupported: The operation is not supported on the object

commenting out task.wait_for_completion does output the VM was created...but then I can't find it anywhere

Any ideas to debug?

Empty list error when there's no snapshots taken from a VM

Hi,
This is not really an issue of failure, but the error message made me think that this is a code issue. I had to spend some time to actually get any sense out of the error produced and what was actually causing it.

Case:
Trying to --revert to a snapshot with 'knife vsphere vm snapshot -f FOLDER/NAME --revert base_with_disks VM_NAME -VV', but the snapshot list is empty.

Output:
DEBUG: value for config item vsphere_host: SERVER_NAME
DEBUG: value for config item vshere_path:
DEBUG: value for config item vsphere_port: 443
DEBUG: value for config item vsphere_nossl:
DEBUG: value for config item vsphere_user: USER
DEBUG: value for config item vsphere_pass: PASSWORD
DEBUG: value for config item vsphere_insecure: true
DEBUG: value for config item proxy_host:
DEBUG: value for config item proxy_port:
DEBUG: value for config item folder: FOLDER/NAME
DEBUG: value for config item vsphere_dc: DC_NAME
/path/to/lib/chef/knife/vsphere_vm_snapshot.rb:106:in find_node': undefined methodeach' for nil:NilClass (NoMethodError)
from /path/to/gems/ruby-1.9.3-p448/gems/knife-vsphere-0.9.7/lib/chef/knife/vsphere_vm_snapshot.rb:95:in run' from /path/to/gems/ruby-1.9.3-p448/gems/chef-11.8.2/lib/chef/knife.rb:485:inrun_with_pretty_exceptions'
from /path/to/gems/ruby-1.9.3-p448/gems/chef-11.8.2/lib/chef/knife.rb:174:in run' from /path/to/gems/ruby-1.9.3-p448/gems/chef-11.8.2/lib/chef/application/knife.rb:133:inrun'
from /path/to/gems/ruby-1.9.3-p448/gems/chef-11.8.2/bin/knife:25:in <top (required)>' from /path/to/gems/ruby-1.9.3-p448/bin/knife:23:inload'
from /path/to/gems/ruby-1.9.3-p448/bin/knife:23:in `

'

Cause:
The snapshot list for the VM is empty.

Maybe just add error handling for this case and output the cause.

Br, Ari

vm clone command giving error

Hello,
I am new to using knife-vsphere.
I am executing the following command from my workstation

knife vsphere vm clone Openjunkiesvm-2 --template test_vm --cips <X.X.X.X> --cdomain --chostname Openjunkiesvm-2 --vshost --vsuser --vspass --vsinsecure

Where,
test_vm is a vm already created and is in OFF state.
Openjunkiesvm-vm2 is the new vm which i want to create.
X.X.X.X is the IP which i want to provide to the new Openjunkiesvm-vm2

But i get the following error

Cloning template test_vm to new VM Openjunkiesvm-2
ERROR: RbVmomi::Fault: NotSupported: The operation is not supported on the object.

What wrong am I doing here?

Also when I do a
knife vsphere template list
it does not list any templates. But I have .vmdk files in the directory
/vmfs/volumes/datastore1/test_vm/
This directory has both the test_vm-flat.vmdk and the test_vm.vmdk files

When providing this as a template options to the vm clone command the command says
VM/Template not found

Please assist.
Thank You.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.