{"action":"created","issue":{"url":"https://api.github.com/repos/ManageIQ/wrapanapi/issues/240","repository_url":"https://api.github.com/repos/ManageIQ/wrapanapi","labels_url":"https://api.github.com/repos/ManageIQ/wrapanapi/issues/240/labels{/name}","comments_url":"https://api.github.com/repos/ManageIQ/wrapanapi/issues/240/comments","events_url":"https://api.github.com/repos/ManageIQ/wrapanapi/issues/240/events","html_url":"https://github.com/ManageIQ/wrapanapi/pull/240","id":308684551,"number":240,"title":"[WIP] Move VM and template operations into a class structure","user":{"login":"bsquizz","id":35474886,"avatar_url":"https://avatars1.githubusercontent.com/u/35474886?v=4","gravatar_id":"","url":"https://api.github.com/users/bsquizz","html_url":"https://github.com/bsquizz","followers_url":"https://api.github.com/users/bsquizz/followers","following_url":"https://api.github.com/users/bsquizz/following{/other_user}","gists_url":"https://api.github.com/users/bsquizz/gists{/gist_id}","starred_url":"https://api.github.com/users/bsquizz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsquizz/subscriptions","organizations_url":"https://api.github.com/users/bsquizz/orgs","repos_url":"https://api.github.com/users/bsquizz/repos","events_url":"https://api.github.com/users/bsquizz/events{/privacy}","received_events_url":"https://api.github.com/users/bsquizz/received_events","type":"User","site_admin":false},"labels":[{"id":374392182,"url":"https://api.github.com/repos/ManageIQ/wrapanapi/labels/WIP","name":"WIP","color":"ededed","default":false},{"id":310222709,"url":"https://api.github.com/repos/ManageIQ/wrapanapi/labels/needs-lint","name":"needs-lint","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-26T18:27:25Z","updated_at":"2018-03-28T20:36:33Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/ManageIQ/wrapanapi/pulls/240","html_url":"https://github.com/ManageIQ/wrapanapi/pull/240","diff_url":"https://github.com/ManageIQ/wrapanapi/pull/240.diff","patch_url":"https://github.com/ManageIQ/wrapanapi/pull/240.patch"},"body":"We'd like to get all of the \"_vm\" and \"_template\" methods out of the System class and move towards a workflow more like this when interacting with VM's, templates, etc.\r\n\r\n```\r\nprovider = AzureSystem(...)\r\nvm = provider.get_vm('some_vm_name')\r\nvm.start()\r\nvm.ensure_state(VMState.STOPPED)\r\nassert vm.state == VMState.STOPPED\r\nnew_vm = vm.clone('some_new_vm')\r\nvm.delete()\r\n```\r\n\r\nSo we'll have a new class structure as follows:\r\n* `BaseSystem` -- abstract definition for any system wrapanapi interacts with\r\n* `BaseVMSystem` -- abstract definition for any system wrapanapi interacts with that handles VMs/instances\r\n* `BaseEntity` -- abstract definition for anything with a name on a specific system that we want to represent as a class. Probably not directly implemented by anyone, but rather is used to define the required methods/properties that should exist for things like VM's, templates, etc. (anything with a name/uuid)\r\n* `BaseVM` -- abstract definition for a VM on a system\r\n* `BaseTemplate` -- abstract definition for a template on a system\r\n\r\nOther entities could be extended into classes if desired. I wouldn't bother until there's at least 3 workflows that need to be performed on a specific entity type.\r\n\r\nIt will be up to each system to define classes which implement BaseVMSystem, BaseVM, and BaseTemplate. The system methods like \"list_templates\" and \"list_vms\" should return instances of classes implementing BaseTemplate/BaseVM. If the system doesn't manage VMs, it will just implement BaseSystem. \r\n\r\nSo, for example:\r\n* AzureSystem will be implementing BaseVMSystem. The methods to list vm's, list templates, get system info, etc. will be implemented using the azure API calls\r\n* list_vms() would return a list of AzureInstance objects, which implement methods defined in BaseVM\r\n* list_templates() would return a list of AzureTemplate objects, which implement methods defined in BaseTemplate"},"comment":{"url":"https://api.github.com/repos/ManageIQ/wrapanapi/issues/comments/377027522","html_url":"https://github.com/ManageIQ/wrapanapi/pull/240#issuecomment-377027522","issue_url":"https://api.github.com/repos/ManageIQ/wrapanapi/issues/240","id":377027522,"user":{"login":"bsquizz","id":35474886,"avatar_url":"https://avatars1.githubusercontent.com/u/35474886?v=4","gravatar_id":"","url":"https://api.github.com/users/bsquizz","html_url":"https://github.com/bsquizz","followers_url":"https://api.github.com/users/bsquizz/followers","following_url":"https://api.github.com/users/bsquizz/following{/other_user}","gists_url":"https://api.github.com/users/bsquizz/gists{/gist_id}","starred_url":"https://api.github.com/users/bsquizz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsquizz/subscriptions","organizations_url":"https://api.github.com/users/bsquizz/orgs","repos_url":"https://api.github.com/users/bsquizz/repos","events_url":"https://api.github.com/users/bsquizz/events{/privacy}","received_events_url":"https://api.github.com/users/bsquizz/received_events","type":"User","site_admin":false},"created_at":"2018-03-28T20:36:33Z","updated_at":"2018-03-28T20:36:33Z","author_association":"CONTRIBUTOR","body":"Meh, already running into some kinks with the above factory approach. I think I'll stick with having \"get_*\", \"create_*\", \"find_*\", \"list_*\" methods that return the Entity objects once we get a response from the API."}}
{"actor":{"display_login":"bsquizz"}}