{"action":"created","issue":{"url":"https://api.github.com/repos/csc/Hanlon/issues/379","labels_url":"https://api.github.com/repos/csc/Hanlon/issues/379/labels{/name}","comments_url":"https://api.github.com/repos/csc/Hanlon/issues/379/comments","events_url":"https://api.github.com/repos/csc/Hanlon/issues/379/events","html_url":"https://github.com/csc/Hanlon/pull/379","id":68174359,"number":379,"title":"Fixes #32 (Attempting to construct model with MK throws an exception)","user":{"login":"tjmcs","id":1375734,"avatar_url":"https://avatars.githubusercontent.com/u/1375734?v=3","gravatar_id":"","url":"https://api.github.com/users/tjmcs","html_url":"https://github.com/tjmcs","followers_url":"https://api.github.com/users/tjmcs/followers","following_url":"https://api.github.com/users/tjmcs/following{/other_user}","gists_url":"https://api.github.com/users/tjmcs/gists{/gist_id}","starred_url":"https://api.github.com/users/tjmcs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjmcs/subscriptions","organizations_url":"https://api.github.com/users/tjmcs/orgs","repos_url":"https://api.github.com/users/tjmcs/repos","events_url":"https://api.github.com/users/tjmcs/events{/privacy}","received_events_url":"https://api.github.com/users/tjmcs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-13T19:28:39Z","updated_at":"2015-04-13T19:37:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/csc/Hanlon/pulls/379","html_url":"https://github.com/csc/Hanlon/pull/379","diff_url":"https://github.com/csc/Hanlon/pull/379.diff","patch_url":"https://github.com/csc/Hanlon/pull/379.patch"},"body":"The issue referenced above is actually somewhat misleading.  The problem is actually that without the changes in this PR Hanlon tells the user that the image used when attempting to create an OS model using a MK image cannot be found, as can be seen in this output:\r\n```bash\r\n[root@ubuntu-server Hanlon (master ✗)]$ hanlon model add -t redhat_6 -l \"test model\" -o rhel6-model.yaml -i 1cW7cFPodqlUAnAHPkBqeO\r\n--- Building Model (redhat_6):\r\n\r\n[model] [add_model] <-Invalid Image UUID [1cW7cFPodqlUAnAHPkBqeO]\r\n\r\nCommand help:\r\nhanlon model add (options...)\r\n    -t, --template MODEL_TEMPLATE            The model template to use for the new model.\r\n    -l, --label MODEL_LABEL                  The label to use for the new model.\r\n    -i, --image-uuid IMAGE_UUID              The image UUID to use for the new model.\r\n    -o, --option YAML_FILE                   Use optional yaml file to create model\r\n    -h, --help                               Display this screen.\r\n[root@ubuntu-server Hanlon (master ✗)]$ \r\n```\r\nThe changes in this PR resolve this issue by separating out the loading of the image itself from the check of image type that is made during the model creation/update process. Previously, a call was made to the model slice's `verify_image` method to compare the image passed in by the user with the image type expected for the model being created/updated, but there were two errors that resulted in the same `nil` return value from this method (either that the image referenced by UUID did not exist or that the image existed but was not the correct type). The changes in this pull request remove this ambiguity and ensure that the correct error is thrown in both of these edge cases (as can be seen from the output shown, below):\r\n\r\n![catching-mk-model-errors](https://cloud.githubusercontent.com/assets/1375734/7123589/0e7e17a2-e1d8-11e4-9782-02d103d7c515.png)\r\n\r\nWith these changes in place, the issue referenced above is resolved completely."},"comment":{"url":"https://api.github.com/repos/csc/Hanlon/issues/comments/92473423","html_url":"https://github.com/csc/Hanlon/pull/379#issuecomment-92473423","issue_url":"https://api.github.com/repos/csc/Hanlon/issues/379","id":92473423,"user":{"login":"jcpowermac","id":5401402,"avatar_url":"https://avatars.githubusercontent.com/u/5401402?v=3","gravatar_id":"","url":"https://api.github.com/users/jcpowermac","html_url":"https://github.com/jcpowermac","followers_url":"https://api.github.com/users/jcpowermac/followers","following_url":"https://api.github.com/users/jcpowermac/following{/other_user}","gists_url":"https://api.github.com/users/jcpowermac/gists{/gist_id}","starred_url":"https://api.github.com/users/jcpowermac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcpowermac/subscriptions","organizations_url":"https://api.github.com/users/jcpowermac/orgs","repos_url":"https://api.github.com/users/jcpowermac/repos","events_url":"https://api.github.com/users/jcpowermac/events{/privacy}","received_events_url":"https://api.github.com/users/jcpowermac/received_events","type":"User","site_admin":false},"created_at":"2015-04-13T19:37:49Z","updated_at":"2015-04-13T19:37:49Z","body":"Code review - Looks good to me :+1: "}}