{"action":"created","issue":{"url":"https://api.github.com/repos/vmware/pyvcloud/issues/85","labels_url":"https://api.github.com/repos/vmware/pyvcloud/issues/85/labels{/name}","comments_url":"https://api.github.com/repos/vmware/pyvcloud/issues/85/comments","events_url":"https://api.github.com/repos/vmware/pyvcloud/issues/85/events","html_url":"https://github.com/vmware/pyvcloud/issues/85","id":124285318,"number":85,"title":"Assumes at least one edge gateway exists: Can't login; list index out of range","user":{"login":"ckamps","id":1332810,"avatar_url":"https://avatars.githubusercontent.com/u/1332810?v=3","gravatar_id":"","url":"https://api.github.com/users/ckamps","html_url":"https://github.com/ckamps","followers_url":"https://api.github.com/users/ckamps/followers","following_url":"https://api.github.com/users/ckamps/following{/other_user}","gists_url":"https://api.github.com/users/ckamps/gists{/gist_id}","starred_url":"https://api.github.com/users/ckamps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckamps/subscriptions","organizations_url":"https://api.github.com/users/ckamps/orgs","repos_url":"https://api.github.com/users/ckamps/repos","events_url":"https://api.github.com/users/ckamps/events{/privacy}","received_events_url":"https://api.github.com/users/ckamps/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-30T00:08:44Z","updated_at":"2016-01-03T13:35:38Z","closed_at":null,"body":"Symptoms and proposed fix are documented in the following issue within the `vca-cli` project:\r\n\r\nhttps://github.com/vmware/vca-cli/issues/30\r\n\r\nIn addition to the can't login issue, here's another failure example that helped point us in the right direction:\r\n\r\n```python\r\n(cloudify)[root@localhost yum.repos.d]# vca --insecure vdc use --vdc devcloud\r\n/etc/yum.repos.d/cloudify/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:730: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html (This warning will only appear once by default.)\r\n  InsecureRequestWarning)\r\nUsing vdc 'devcloud' in profile 'default'\r\nTraceback (most recent call last):\r\n  File \"/etc/yum.repos.d/cloudify/bin/vca\", line 9, in <module>\r\n    load_entry_point('vca-cli==1.1', 'console_scripts', 'vca')()\r\n  File \"/etc/yum.repos.d/cloudify/lib/python2.7/site-packages/click/core.py\", line 700, in __call__\r\n    return self.main(*args, **kwargs)\r\n  File \"/etc/yum.repos.d/cloudify/lib/python2.7/site-packages/click/core.py\", line 680, in main\r\n    rv = self.invoke(ctx)\r\n  File \"/etc/yum.repos.d/cloudify/lib/python2.7/site-packages/click/core.py\", line 1027, in invoke\r\n    return _process_result(sub_ctx.command.invoke(sub_ctx))\r\n  File \"/etc/yum.repos.d/cloudify/lib/python2.7/site-packages/click/core.py\", line 873, in invoke\r\n    return ctx.invoke(self.callback, **ctx.params)\r\n  File \"/etc/yum.repos.d/cloudify/lib/python2.7/site-packages/click/core.py\", line 508, in invoke\r\n    return callback(*args, **kwargs)\r\n  File \"/etc/yum.repos.d/cloudify/lib/python2.7/site-packages/click/decorators.py\", line 16, in new_func\r\n    return f(get_current_context(), *args, **kwargs)\r\n  File \"/etc/yum.repos.d/cloudify/lib/python2.7/site-packages/vca_cli/vca_cli.py\", line 322, in vdc\r\n    print_vdc_details(ctx, the_vdc, vca.get_gateways(vdc))\r\n  File \"/etc/yum.repos.d/cloudify/lib/python2.7/site-packages/pyvcloud/vcloudair.py\", line 400, in get_gateways\r\n    response = requests.get(link[0].get_href(), headers=self.vcloud_session.get_vcloud_headers(), verify=self.verify)\r\nIndexError: list index out of range\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/vmware/pyvcloud/issues/comments/168499419","html_url":"https://github.com/vmware/pyvcloud/issues/85#issuecomment-168499419","issue_url":"https://api.github.com/repos/vmware/pyvcloud/issues/85","id":168499419,"user":{"login":"ckamps","id":1332810,"avatar_url":"https://avatars.githubusercontent.com/u/1332810?v=3","gravatar_id":"","url":"https://api.github.com/users/ckamps","html_url":"https://github.com/ckamps","followers_url":"https://api.github.com/users/ckamps/followers","following_url":"https://api.github.com/users/ckamps/following{/other_user}","gists_url":"https://api.github.com/users/ckamps/gists{/gist_id}","starred_url":"https://api.github.com/users/ckamps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckamps/subscriptions","organizations_url":"https://api.github.com/users/ckamps/orgs","repos_url":"https://api.github.com/users/ckamps/repos","events_url":"https://api.github.com/users/ckamps/events{/privacy}","received_events_url":"https://api.github.com/users/ckamps/received_events","type":"User","site_admin":false},"created_at":"2016-01-03T13:35:38Z","updated_at":"2016-01-03T13:35:38Z","body":"Here's the fix as copied from the `vca-cli` issue:\r\n\r\nWith the help of Yoram of Gigaspaces, we tracked down one cause of this error to the `pyvcloud` library assuming that at least one gateway always exists. In our case, we have zero gateways.\r\n\r\nSee the following section in `pyvcloud/vcloudair.py` where we added this line:\r\n\r\n```python\r\nif not link: return gateways\r\n```\r\nSo that when `link` is empty, the ensuing code does not try to use it.\r\n\r\n```python\r\ndef get_gateways(self, vdc_name):\r\n    \"\"\"\r\n    Request a list of the Gateways within a Virtual Data Center.\r\n \r\n    :param vdc_name: (str): The virtual data center name.\r\n    :return: (list of Gateway)  A list of :class:`.pyvcloud.gateway.Gateway` objects describing the available gateways\r\n \r\n    **service type:** ondemand, subscription, vcd\r\n    \"\"\"\r\n    gateways = []\r\n    vdc = self.get_vdc(vdc_name)\r\n    if not vdc: return gateways\r\n    link = filter(lambda link: link.get_rel() == \"edgeGateways\", vdc.get_Link())\r\n    if not link: return gateways\r\n    self.response = Http.get(link[0].get_href(), headers=self.vcloud_session.get_vcloud_headers(), verify=self.verify, logger=self.logger)\r\n    if self.response.status_code == requests.codes.ok:\r\n    ...\r\n```\r\n\r\n"}}