{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/comments/34608943","id":34608943,"diff_hunk":"@@ -99,6 +99,14 @@ def find_pool(poolname)\n       base\n     end\n \n+    def find_snapshot(vm, snapshotname)\n+      if vm.snapshot\n+        get_snapshot_list(vm.snapshot.rootSnapshotList, snapshotname)\n+      else\n+        raise \"VM #{vm.name} has no snapshots to revert to\"","path":"lib/vmpooler/vsphere_helper.rb","position":8,"original_position":8,"commit_id":"c106550eb431187d126ec06b43e60f7afc7d5d48","original_commit_id":"c106550eb431187d126ec06b43e60f7afc7d5d48","user":{"login":"colinPL","id":6528153,"avatar_url":"https://avatars.githubusercontent.com/u/6528153?v=3","gravatar_id":"","url":"https://api.github.com/users/colinPL","html_url":"https://github.com/colinPL","followers_url":"https://api.github.com/users/colinPL/followers","following_url":"https://api.github.com/users/colinPL/following{/other_user}","gists_url":"https://api.github.com/users/colinPL/gists{/gist_id}","starred_url":"https://api.github.com/users/colinPL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colinPL/subscriptions","organizations_url":"https://api.github.com/users/colinPL/orgs","repos_url":"https://api.github.com/users/colinPL/repos","events_url":"https://api.github.com/users/colinPL/events{/privacy}","received_events_url":"https://api.github.com/users/colinPL/received_events","type":"User","site_admin":false},"body":"What about just returning an empty list instead of `raise`? Is not having a snapshot a reason to throw an error?","created_at":"2015-07-14T19:30:04Z","updated_at":"2015-07-14T19:30:04Z","html_url":"https://github.com/puppetlabs/vmpooler/pull/117#discussion_r34608943","pull_request_url":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/117","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/comments/34608943"},"html":{"href":"https://github.com/puppetlabs/vmpooler/pull/117#discussion_r34608943"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/117"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/117","id":39944747,"html_url":"https://github.com/puppetlabs/vmpooler/pull/117","diff_url":"https://github.com/puppetlabs/vmpooler/pull/117.diff","patch_url":"https://github.com/puppetlabs/vmpooler/pull/117.patch","issue_url":"https://api.github.com/repos/puppetlabs/vmpooler/issues/117","number":117,"state":"open","locked":false,"title":"(QENG-2636) Host snapshots","user":{"login":"sschneid","id":20033,"avatar_url":"https://avatars.githubusercontent.com/u/20033?v=3","gravatar_id":"","url":"https://api.github.com/users/sschneid","html_url":"https://github.com/sschneid","followers_url":"https://api.github.com/users/sschneid/followers","following_url":"https://api.github.com/users/sschneid/following{/other_user}","gists_url":"https://api.github.com/users/sschneid/gists{/gist_id}","starred_url":"https://api.github.com/users/sschneid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sschneid/subscriptions","organizations_url":"https://api.github.com/users/sschneid/orgs","repos_url":"https://api.github.com/users/sschneid/repos","events_url":"https://api.github.com/users/sschneid/events{/privacy}","received_events_url":"https://api.github.com/users/sschneid/received_events","type":"User","site_admin":false},"body":"This PR introduces host (VM) snapshotting support.  Example workflow:\r\n\r\n1) Request a VM\r\n````\r\n$ curl -d '{\"debian-7-x86_64\":\"1\"}' --url vmpooler-dev/vm\r\n{\r\n  \"ok\": true,\r\n  \"debian-7-x86_64\": {\r\n    \"ok\": true,\r\n    \"hostname\": \"cxd6n45t1pd5s4j\"\r\n  },\r\n  \"domain\": \"delivery.puppetlabs.net\"\r\n}\r\n````\r\n\r\n2) Take a snapshot\r\n````\r\nThis command will return a snapshot ID (\"fjgd9l9okym8647gmjnznky5sklji0r3\")\r\n\r\n$ curl -d --url vmpooler-dev/vm/cxd6n45t1pd5s4j/snapshot\r\n{\r\n  \"ok\": true,\r\n  \"cxd6n45t1pd5s4j\": {\r\n    \"snapshot\": \"fjgd9l9okym8647gmjnznky5sklji0r3\"\r\n  }\r\n}\r\n````\r\n\r\n3) The vmpooler pooler_manager component sees the snapshot-creation task, and snapshots the VM in the background\r\n````\r\n[2015-05-01 12:35:02] [ ] [snapshot_manager] 'cxd6n45t1pd5s4j' is being snapshotted\r\n[2015-05-01 12:39:04] [+] [snapshot_manager] 'cxd6n45t1pd5s4j' snapshot created in 242.77 seconds\r\n````\r\n\r\n4) You can query the VM itself; the GET /vm/:hostname endpoint will show a snapshot once pool_manager has finished the snapshotting task\r\n````\r\n$ curl --url vmpooler-dev/vm/cxd6n45t1pd5s4j\r\n{\r\n  \"ok\": true,\r\n  \"cxd6n45t1pd5s4j\": {\r\n    \"template\": \"debian-7-x86_64\",\r\n    \"lifetime\": 1,\r\n    \"running\": 0.08,\r\n    \"snapshots\": [\r\n      \"fjgd9l9okym8647gmjnznky5sklji0r3\"\r\n    ],\r\n    \"domain\": \"delivery.puppetlabs.net\"\r\n  }\r\n}\r\n````\r\n\r\n4) Change something on the VM\r\n````\r\n$ ssh root@cxd6n45t1pd5s4j\r\nroot@cxd6n45t1pd5s4j's password:\r\nLinux debian-7-64 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1 x86_64 \r\n\r\nThe programs included with the Debian GNU/Linux system are free software;\r\nthe exact distribution terms for each program are described in the\r\nindividual files in /usr/share/doc/*/copyright. \r\n\r\nDebian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent\r\npermitted by applicable law.\r\nLast login: Tue Mar 31 08:33:05 2015\r\nroot@cxd6n45t1pd5s4j:~# echo \"This VM has been modified.\" >/etc/motd\r\nroot@cxd6n45t1pd5s4j:~# cat /etc/motd\r\nThis VM has been modified.\r\n````\r\n\r\n5) Revert the VM back to the snapshot we took earlier\r\n````\r\n$ curl -d --url vmpooler-dev/vm/cxd6n45t1pd5s4j/snapshot/fjgd9l9okym8647gmjnznky5sklji0r3\r\n{\r\n  \"ok\": true\r\n}\r\n````\r\n\r\n6) pool_manager reverts the VM\r\n````\r\n[2015-05-01 12:41:52] [ ] [snapshot_manager] 'cxd6n45t1pd5s4j' is being reverted to snapshot 'fjgd9l9okym8647gmjnznky5sklji0r3'\r\n[2015-05-01 12:41:58] [<] [snapshot_manager] 'cxd6n45t1pd5s4j' reverted to snapshot in 6.86 seconds\r\n````\r\n\r\n7) Verify that the changes in step 4 do not persist\r\n````\r\n$ ssh root@cxd6n45t1pd5s4j\r\nroot@cxd6n45t1pd5s4j's password:\r\nLinux debian-7-64 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1 x86_64 \r\n\r\nThe programs included with the Debian GNU/Linux system are free software;\r\nthe exact distribution terms for each program are described in the\r\nindividual files in /usr/share/doc/*/copyright. \r\n\r\nDebian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent\r\npermitted by applicable law.\r\nLast login: Tue Mar 31 08:33:05 2015\r\nroot@cxd6n45t1pd5s4j:~# cat /etc/motd \r\n\r\nThe programs included with the Debian GNU/Linux system are free software;\r\nthe exact distribution terms for each program are described in the\r\nindividual files in /usr/share/doc/*/copyright. \r\n\r\nDebian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent\r\npermitted by applicable law.\r\n````","created_at":"2015-07-14T18:09:57Z","updated_at":"2015-07-14T19:30:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d22f88b5983515345d4b2a52b0701e3f0cb0fc28","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/117/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/117/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/vmpooler/issues/117/comments","statuses_url":"https://api.github.com/repos/puppetlabs/vmpooler/statuses/c106550eb431187d126ec06b43e60f7afc7d5d48","head":{"label":"sschneid:host_snapshots","ref":"host_snapshots","sha":"c106550eb431187d126ec06b43e60f7afc7d5d48","user":{"login":"sschneid","id":20033,"avatar_url":"https://avatars.githubusercontent.com/u/20033?v=3","gravatar_id":"","url":"https://api.github.com/users/sschneid","html_url":"https://github.com/sschneid","followers_url":"https://api.github.com/users/sschneid/followers","following_url":"https://api.github.com/users/sschneid/following{/other_user}","gists_url":"https://api.github.com/users/sschneid/gists{/gist_id}","starred_url":"https://api.github.com/users/sschneid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sschneid/subscriptions","organizations_url":"https://api.github.com/users/sschneid/orgs","repos_url":"https://api.github.com/users/sschneid/repos","events_url":"https://api.github.com/users/sschneid/events{/privacy}","received_events_url":"https://api.github.com/users/sschneid/received_events","type":"User","site_admin":false},"repo":{"id":21907793,"name":"vmpooler","full_name":"sschneid/vmpooler","owner":{"login":"sschneid","id":20033,"avatar_url":"https://avatars.githubusercontent.com/u/20033?v=3","gravatar_id":"","url":"https://api.github.com/users/sschneid","html_url":"https://github.com/sschneid","followers_url":"https://api.github.com/users/sschneid/followers","following_url":"https://api.github.com/users/sschneid/following{/other_user}","gists_url":"https://api.github.com/users/sschneid/gists{/gist_id}","starred_url":"https://api.github.com/users/sschneid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sschneid/subscriptions","organizations_url":"https://api.github.com/users/sschneid/orgs","repos_url":"https://api.github.com/users/sschneid/repos","events_url":"https://api.github.com/users/sschneid/events{/privacy}","received_events_url":"https://api.github.com/users/sschneid/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sschneid/vmpooler","description":"Provide configurable 'pools' of available (running) virtual machines","fork":true,"url":"https://api.github.com/repos/sschneid/vmpooler","forks_url":"https://api.github.com/repos/sschneid/vmpooler/forks","keys_url":"https://api.github.com/repos/sschneid/vmpooler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sschneid/vmpooler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sschneid/vmpooler/teams","hooks_url":"https://api.github.com/repos/sschneid/vmpooler/hooks","issue_events_url":"https://api.github.com/repos/sschneid/vmpooler/issues/events{/number}","events_url":"https://api.github.com/repos/sschneid/vmpooler/events","assignees_url":"https://api.github.com/repos/sschneid/vmpooler/assignees{/user}","branches_url":"https://api.github.com/repos/sschneid/vmpooler/branches{/branch}","tags_url":"https://api.github.com/repos/sschneid/vmpooler/tags","blobs_url":"https://api.github.com/repos/sschneid/vmpooler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sschneid/vmpooler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sschneid/vmpooler/git/refs{/sha}","trees_url":"https://api.github.com/repos/sschneid/vmpooler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sschneid/vmpooler/statuses/{sha}","languages_url":"https://api.github.com/repos/sschneid/vmpooler/languages","stargazers_url":"https://api.github.com/repos/sschneid/vmpooler/stargazers","contributors_url":"https://api.github.com/repos/sschneid/vmpooler/contributors","subscribers_url":"https://api.github.com/repos/sschneid/vmpooler/subscribers","subscription_url":"https://api.github.com/repos/sschneid/vmpooler/subscription","commits_url":"https://api.github.com/repos/sschneid/vmpooler/commits{/sha}","git_commits_url":"https://api.github.com/repos/sschneid/vmpooler/git/commits{/sha}","comments_url":"https://api.github.com/repos/sschneid/vmpooler/comments{/number}","issue_comment_url":"https://api.github.com/repos/sschneid/vmpooler/issues/comments{/number}","contents_url":"https://api.github.com/repos/sschneid/vmpooler/contents/{+path}","compare_url":"https://api.github.com/repos/sschneid/vmpooler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sschneid/vmpooler/merges","archive_url":"https://api.github.com/repos/sschneid/vmpooler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sschneid/vmpooler/downloads","issues_url":"https://api.github.com/repos/sschneid/vmpooler/issues{/number}","pulls_url":"https://api.github.com/repos/sschneid/vmpooler/pulls{/number}","milestones_url":"https://api.github.com/repos/sschneid/vmpooler/milestones{/number}","notifications_url":"https://api.github.com/repos/sschneid/vmpooler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sschneid/vmpooler/labels{/name}","releases_url":"https://api.github.com/repos/sschneid/vmpooler/releases{/id}","created_at":"2014-07-16T16:07:36Z","updated_at":"2015-05-06T20:33:28Z","pushed_at":"2015-07-14T19:15:45Z","git_url":"git://github.com/sschneid/vmpooler.git","ssh_url":"git@github.com:sschneid/vmpooler.git","clone_url":"https://github.com/sschneid/vmpooler.git","svn_url":"https://github.com/sschneid/vmpooler","homepage":"","size":2648,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"puppetlabs:master","ref":"master","sha":"ea5c1aff3d5c0796004f9eae24538319348285b4","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":13072980,"name":"vmpooler","full_name":"puppetlabs/vmpooler","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/vmpooler","description":"Provide configurable 'pools' of available (running) virtual machines","fork":false,"url":"https://api.github.com/repos/puppetlabs/vmpooler","forks_url":"https://api.github.com/repos/puppetlabs/vmpooler/forks","keys_url":"https://api.github.com/repos/puppetlabs/vmpooler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/vmpooler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/vmpooler/teams","hooks_url":"https://api.github.com/repos/puppetlabs/vmpooler/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/vmpooler/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/vmpooler/events","assignees_url":"https://api.github.com/repos/puppetlabs/vmpooler/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/vmpooler/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/vmpooler/tags","blobs_url":"https://api.github.com/repos/puppetlabs/vmpooler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/vmpooler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/vmpooler/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/vmpooler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/vmpooler/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/vmpooler/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/vmpooler/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/vmpooler/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/vmpooler/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/vmpooler/subscription","commits_url":"https://api.github.com/repos/puppetlabs/vmpooler/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/vmpooler/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/vmpooler/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/vmpooler/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/vmpooler/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/vmpooler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/vmpooler/merges","archive_url":"https://api.github.com/repos/puppetlabs/vmpooler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/vmpooler/downloads","issues_url":"https://api.github.com/repos/puppetlabs/vmpooler/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/vmpooler/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/vmpooler/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/vmpooler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/vmpooler/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/vmpooler/releases{/id}","created_at":"2013-09-24T18:27:35Z","updated_at":"2015-06-10T23:21:42Z","pushed_at":"2015-07-14T19:15:46Z","git_url":"git://github.com/puppetlabs/vmpooler.git","ssh_url":"git@github.com:puppetlabs/vmpooler.git","clone_url":"https://github.com/puppetlabs/vmpooler.git","svn_url":"https://github.com/puppetlabs/vmpooler","homepage":"","size":2451,"stargazers_count":31,"watchers_count":31,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":9,"forks":10,"open_issues":9,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/117"},"html":{"href":"https://github.com/puppetlabs/vmpooler/pull/117"},"issue":{"href":"https://api.github.com/repos/puppetlabs/vmpooler/issues/117"},"comments":{"href":"https://api.github.com/repos/puppetlabs/vmpooler/issues/117/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/117/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/vmpooler/pulls/117/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/vmpooler/statuses/c106550eb431187d126ec06b43e60f7afc7d5d48"}}}}