{"action":"created","issue":{"url":"https://api.github.com/repos/puppetlabs/vmpooler/issues/129","labels_url":"https://api.github.com/repos/puppetlabs/vmpooler/issues/129/labels{/name}","comments_url":"https://api.github.com/repos/puppetlabs/vmpooler/issues/129/comments","events_url":"https://api.github.com/repos/puppetlabs/vmpooler/issues/129/events","html_url":"https://github.com/puppetlabs/vmpooler/issues/129","id":105034506,"number":129,"title":"vmpooler throwing exceptions","user":{"login":"timidri","id":1586813,"avatar_url":"https://avatars.githubusercontent.com/u/1586813?v=3","gravatar_id":"","url":"https://api.github.com/users/timidri","html_url":"https://github.com/timidri","followers_url":"https://api.github.com/users/timidri/followers","following_url":"https://api.github.com/users/timidri/following{/other_user}","gists_url":"https://api.github.com/users/timidri/gists{/gist_id}","starred_url":"https://api.github.com/users/timidri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timidri/subscriptions","organizations_url":"https://api.github.com/users/timidri/orgs","repos_url":"https://api.github.com/users/timidri/repos","events_url":"https://api.github.com/users/timidri/events{/privacy}","received_events_url":"https://api.github.com/users/timidri/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-05T15:57:07Z","updated_at":"2015-09-24T12:03:09Z","closed_at":null,"body":"Hi,\r\n\r\nWe have problems using vmpooler.\r\n\r\nSymptoms are best explained with this code snippet (exception handling code added by me):\r\n\r\n```ruby\r\nbegin\r\n  vm[vm['template']] = $vsphere[vm['template']].find_folder(templatefolders.join('/')).find(vm['template'])\r\nrescue Exception => e\r\n  $logger.log('d', \"exception caught, class: #{e.class} description: #{e.backtrace.inspect} \")\r\nend\r\n```\r\n\r\nThe following exception is thrown: \r\n ```\r\nException caught, class: NoMethodError description: [\"/root/vmpooler/lib/vmpooler/pool_manager.rb:181:in `block in clone_vm'\"]\r\n```\r\n\r\nThe object $vsphere[vm['template']] actually was nil during execution, so method calls on that object failed. We found that out by adding exception handling code to the call (would be a good idea to add that for all API calls IMHO).\r\n\r\nSee https://gist.github.com/tvlieg/d2f65c45e1ea63e3f77f for our diffs. Hence the 'helper' object I am creating. Not sure why the API object is nil and whether that is connected to 8 VMs being (re)created simultaneously despite a poolsize of 1...\r\n\r\nOur vmpooler.yaml:\r\n\r\n```yaml\r\n:vsphere:\r\n  server: 'swuhtv021.it.mgt'\r\n  username: 'IT\\srvcVMpooler'\r\n  password: '<password>'\r\n\r\n:redis:\r\n  server : 'localhost'\r\n\r\n:config:\r\n  site_name: 'vmpooler'\r\n  logfile: '/var/log/vmpooler.log'\r\n  task_limit: 10\r\n  timeout: 15\r\n  vm_checktime: 15\r\n  vm_lifetime: 24\r\n  vm_lifetime_auth: 24\r\n\r\n\r\n:graphite:\r\n  server : ''\r\n\r\n:pools:\r\n  - name: 'centos-6-x64'\r\n    template: 'Template/TLRHEL6B114R2'\r\n    folder: 'PuppetModuleTests/centos-6-x64'\r\n    clone_target: 'CT2_V0_S01_Y_01'\r\n    pool: 'CT2_V0_S01_Y_01'\r\n    datastore: 'CT2_NFS_Y_N_01_01'\r\n    size: 3\r\n    timeout: 15\r\n    ready_ttl: 1440\r\n```"},"comment":{"url":"https://api.github.com/repos/puppetlabs/vmpooler/issues/comments/142910460","html_url":"https://github.com/puppetlabs/vmpooler/issues/129#issuecomment-142910460","issue_url":"https://api.github.com/repos/puppetlabs/vmpooler/issues/129","id":142910460,"user":{"login":"tvlieg","id":13644613,"avatar_url":"https://avatars.githubusercontent.com/u/13644613?v=3","gravatar_id":"","url":"https://api.github.com/users/tvlieg","html_url":"https://github.com/tvlieg","followers_url":"https://api.github.com/users/tvlieg/followers","following_url":"https://api.github.com/users/tvlieg/following{/other_user}","gists_url":"https://api.github.com/users/tvlieg/gists{/gist_id}","starred_url":"https://api.github.com/users/tvlieg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tvlieg/subscriptions","organizations_url":"https://api.github.com/users/tvlieg/orgs","repos_url":"https://api.github.com/users/tvlieg/repos","events_url":"https://api.github.com/users/tvlieg/events{/privacy}","received_events_url":"https://api.github.com/users/tvlieg/received_events","type":"User","site_admin":false},"created_at":"2015-09-24T12:03:09Z","updated_at":"2015-09-24T12:03:09Z","body":"Hi!\r\n\r\nWe finally figured out why it didn't work out for us. In the code a reference to `$vsphere[vm['template']]` is made, which is supposed to refer to a `Vmpooler::VsphereHelper` object. However, there are only two such objects created in the vmpooler code:\r\n\r\n```\r\n# grep -r 'Vmpooler::VsphereHelper.new' .\r\n./lib/vmpooler/pool_manager.rb:      $vsphere['snapshot_manager'] ||= Vmpooler::VsphereHelper.new\r\n./lib/vmpooler/pool_manager.rb:      $vsphere[pool['name']] ||= Vmpooler::VsphereHelper.new\r\n```\r\n\r\nIn the example configuration file, the values for the pool name and VM template happen to be identical, so `$vsphere[pool['name']]` and `$vsphere[vm['template']]` both refer to the same object. In our configuration file, however, we had different values for those variables. This resulted in an empty object for `$vsphere[pool['name']]`, and failing code.\r\n\r\nAnother thing we found out, is that the 'template' must actually be a VM (and not a vsphere template), which is quite confusing. It could be an idea to change the code to alse accept templates, or to change the terminology.\r\n\r\nWe're happy to have vmpooler running, and I hope these remarks help to make vmpooler even better.\r\n\r\nRegards, Tjebbe"}}