{"action":"created","issue":{"url":"https://api.github.com/repos/F5Networks/f5-common-python/issues/245","repository_url":"https://api.github.com/repos/F5Networks/f5-common-python","labels_url":"https://api.github.com/repos/F5Networks/f5-common-python/issues/245/labels{/name}","comments_url":"https://api.github.com/repos/F5Networks/f5-common-python/issues/245/comments","events_url":"https://api.github.com/repos/F5Networks/f5-common-python/issues/245/events","html_url":"https://github.com/F5Networks/f5-common-python/issues/245","id":139356457,"number":245,"title":"iApp create_template and template_exists function arguments inconsistent","user":{"login":"cmutzel","id":2043678,"avatar_url":"https://avatars.githubusercontent.com/u/2043678?v=3","gravatar_id":"","url":"https://api.github.com/users/cmutzel","html_url":"https://github.com/cmutzel","followers_url":"https://api.github.com/users/cmutzel/followers","following_url":"https://api.github.com/users/cmutzel/following{/other_user}","gists_url":"https://api.github.com/users/cmutzel/gists{/gist_id}","starred_url":"https://api.github.com/users/cmutzel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmutzel/subscriptions","organizations_url":"https://api.github.com/users/cmutzel/orgs","repos_url":"https://api.github.com/users/cmutzel/repos","events_url":"https://api.github.com/users/cmutzel/events{/privacy}","received_events_url":"https://api.github.com/users/cmutzel/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/F5Networks/f5-common-python/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"cmutzel","id":2043678,"avatar_url":"https://avatars.githubusercontent.com/u/2043678?v=3","gravatar_id":"","url":"https://api.github.com/users/cmutzel","html_url":"https://github.com/cmutzel","followers_url":"https://api.github.com/users/cmutzel/followers","following_url":"https://api.github.com/users/cmutzel/following{/other_user}","gists_url":"https://api.github.com/users/cmutzel/gists{/gist_id}","starred_url":"https://api.github.com/users/cmutzel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmutzel/subscriptions","organizations_url":"https://api.github.com/users/cmutzel/orgs","repos_url":"https://api.github.com/users/cmutzel/repos","events_url":"https://api.github.com/users/cmutzel/events{/privacy}","received_events_url":"https://api.github.com/users/cmutzel/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/F5Networks/f5-common-python/milestones/3","html_url":"https://github.com/F5Networks/f5-common-python/milestones/v0.1.1","labels_url":"https://api.github.com/repos/F5Networks/f5-common-python/milestones/3/labels","id":1542063,"number":3,"title":"v0.1.1","description":"Initial release of the common code\r\n* Dynamic attributes\r\n* Object/addtribute representation of the F5 iControl REST API","creator":{"login":"swormke","id":12940387,"avatar_url":"https://avatars.githubusercontent.com/u/12940387?v=3","gravatar_id":"","url":"https://api.github.com/users/swormke","html_url":"https://github.com/swormke","followers_url":"https://api.github.com/users/swormke/followers","following_url":"https://api.github.com/users/swormke/following{/other_user}","gists_url":"https://api.github.com/users/swormke/gists{/gist_id}","starred_url":"https://api.github.com/users/swormke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swormke/subscriptions","organizations_url":"https://api.github.com/users/swormke/orgs","repos_url":"https://api.github.com/users/swormke/repos","events_url":"https://api.github.com/users/swormke/events{/privacy}","received_events_url":"https://api.github.com/users/swormke/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":21,"state":"open","created_at":"2016-01-25T16:23:57Z","updated_at":"2016-03-08T21:03:25Z","due_on":"2016-03-31T06:00:00Z","closed_at":null},"comments":1,"created_at":"2016-03-08T18:32:51Z","updated_at":"2016-03-08T21:09:06Z","closed_at":null,"body":"The following behavior is confusing:\r\n1) User deploys an iApp template onto BIG-IP using the create_template() method in f5.bigip.interfaces.iapp using parameter name='foo_name', with name='foo_name' in the JSON body\r\n2) User checks to see whether the template exists using method template_exists from same interface (i.e. they check for existence of using parameter name='foo_name')\r\n\r\nAbove fails unless they have set the name of the template in JSON payload to 'uuid_foo_name'.\r\n\r\n**Example below....**\r\n\r\n```\r\nimport logging\r\nlogging.basicConfig(level=logging.DEBUG)\r\n\r\nimport json, requests\r\niapp_template = json.loads(requests.get(\"https://s3.amazonaws.com/custom-cfn-ex-bigip-cluster/http_backport_template.json\").text)\r\n\r\nfrom f5.bigip.bigip import BigIP\r\nbigip = BigIP(\"52.3.11.221\", \"admin\", \"GoF5!\")\r\n\r\n# attempt 1 - name argument is not consistent between create_template and template_exists APIs, due to appending of 'uuid' string in front\r\nname = iapp_template[\"name\"]\r\nprint \"Template has name: %s \" % name\r\nprint \"iApp template '%s' exists : %s \" % (name, bigip.iapp.template_exists(name=name))\r\n\r\n# try creating the template\r\nprint \"Creating template '%s': %s\" % (name, bigip.iapp.create_template(name=name, template=iapp_template))\r\nprint \"iApp template '%s' exists : %s \" % (name, bigip.iapp.template_exists(name=name))\r\n\r\n## attempt 2 - getting it to work....append uuid to the value for key 'name' in the template JSON payload\r\nname = iapp_template[\"name\"] = 'uuid_%s' % iapp_template[\"name\"]\r\n\r\nprint \"Template has name: %s \" % name\r\nprint \"iApp template '%s' exists : %s \" % (name, bigip.iapp.template_exists(name=name))\r\n\r\n# try creating the template\r\nprint \"Creating template '%s': %s\" % (name, bigip.iapp.create_template(name=name, template=iapp_template))\r\nprint \"iApp template '%s' exists : %s \" % (name, bigip.iapp.template_exists(name=name))\r\n```\r\n\r\n**Relevant logs** (large JSON http responses ...._truncated_....):\r\nINFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): s3.amazonaws.com\r\nDEBUG:requests.packages.urllib3.connectionpool:\"GET /custom-cfn-ex-bigip-cluster/http_backport_template.json HTTP/1.1\" 200 167969\r\nTemplate has name: f5.http.backport.1.1.2 \r\nDEBUG:f5.bigip.interfaces:IApp::template_exists called with args: () kwargs: {'name': u'uuid_f5.http.backport.1.1.2'}\r\nINFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): 52.3.11.221\r\niApp template 'f5.http.backport.1.1.2' exists : False \r\nDEBUG:requests.packages.urllib3.connectionpool:\"GET /mgmt/tm/sys/application/template/~Common~uuid_f5.http.backport.1.1.2?$select=name HTTP/1.1\" 404 140\r\nDEBUG:f5.bigip.interfaces:IApp::create_template called with args: () kwargs: {'name': u'uuid_f5.http.backport.1.1.2', 'template': ...._truncated_....\r\nDEBUG:f5.bigip.interfaces:IApp::template_exists called with args: () kwargs: {'folder': 'Common', 'name': u'uuid_f5.http.backport.1.1.2'}\r\nDEBUG:requests.packages.urllib3.connectionpool:\"GET /mgmt/tm/sys/application/template/~Common~uuid_f5.http.backport.1.1.2?$select=name HTTP/1.1\" 404 140\r\nCreating template 'f5.http.backport.1.1.2': True\r\nDEBUG:requests.packages.urllib3.connectionpool:\"POST /mgmt/tm/sys/application/template/ HTTP/1.1\" 409 156\r\nDEBUG:f5.bigip.interfaces:IApp::template_exists called with args: () kwargs: {'name': u'uuid_f5.http.backport.1.1.2'}\r\nDEBUG:requests.packages.urllib3.connectionpool:\"GET /mgmt/tm/sys/application/template/~Common~uuid_f5.http.backport.1.1.2?$select=name HTTP/1.1\" 404 140\r\niApp template 'f5.http.backport.1.1.2' exists : False \r\nDEBUG:f5.bigip.interfaces:IApp::template_exists called with args: () kwargs: {'name': u'uuid_f5.http.backport.1.1.2'}\r\nTemplate has name: uuid_f5.http.backport.1.1.2 \r\niApp template 'uuid_f5.http.backport.1.1.2' exists : False \r\nDEBUG:requests.packages.urllib3.connectionpool:\"GET /mgmt/tm/sys/application/template/~Common~uuid_f5.http.backport.1.1.2?$select=name HTTP/1.1\" 404 140\r\nDEBUG:f5.bigip.interfaces:IApp::create_template called with args: () kwargs: {'name': u'uuid_f5.http.backport.1.1.2', 'template': ...._truncated_....\r\nDEBUG:f5.bigip.interfaces:IApp::template_exists called with args: () kwargs: {'folder': 'Common', 'name': u'uuid_f5.http.backport.1.1.2'}\r\nDEBUG:requests.packages.urllib3.connectionpool:\"GET /mgmt/tm/sys/application/template/~Common~uuid_f5.http.backport.1.1.2?$select=name HTTP/1.1\" 404 140\r\nDEBUG:requests.packages.urllib3.connectionpool:\"POST /mgmt/tm/sys/application/template/ HTTP/1.1\" 200 578\r\nDEBUG:f5.bigip.interfaces:IApp::template_exists called with args: () kwargs: {'name': u'uuid_f5.http.backport.1.1.2'}\r\nCreating template 'uuid_f5.http.backport.1.1.2': True\r\nDEBUG:requests.packages.urllib3.connectionpool:\"GET /mgmt/tm/sys/application/template/~Common~uuid_f5.http.backport.1.1.2?$select=name HTTP/1.1\" 200 38\r\niApp template 'uuid_f5.http.backport.1.1.2' exists : True"},"comment":{"url":"https://api.github.com/repos/F5Networks/f5-common-python/issues/comments/193967245","html_url":"https://github.com/F5Networks/f5-common-python/issues/245#issuecomment-193967245","issue_url":"https://api.github.com/repos/F5Networks/f5-common-python/issues/245","id":193967245,"user":{"login":"pjbreaux","id":14225800,"avatar_url":"https://avatars.githubusercontent.com/u/14225800?v=3","gravatar_id":"","url":"https://api.github.com/users/pjbreaux","html_url":"https://github.com/pjbreaux","followers_url":"https://api.github.com/users/pjbreaux/followers","following_url":"https://api.github.com/users/pjbreaux/following{/other_user}","gists_url":"https://api.github.com/users/pjbreaux/gists{/gist_id}","starred_url":"https://api.github.com/users/pjbreaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjbreaux/subscriptions","organizations_url":"https://api.github.com/users/pjbreaux/orgs","repos_url":"https://api.github.com/users/pjbreaux/repos","events_url":"https://api.github.com/users/pjbreaux/events{/privacy}","received_events_url":"https://api.github.com/users/pjbreaux/received_events","type":"User","site_admin":false},"created_at":"2016-03-08T21:09:06Z","updated_at":"2016-03-08T21:09:06Z","body":"@cmutzel:\r\n\r\nYou can now use the refactored version of this repo. You can install it by doing ```pip install git+https://github.com/F5Networks/f5-common-python.git``` or you could clone the repo and checkout the *0.1* branch. Refer to the main readme for examples on how to use it and the api docs.\r\n\r\nI'm assigning this ticket back to you. Please close if you the refactored code works for you. Thanks."}}