Repository: conjure-up/conjure-up

Issue:
conjure-up error: Unable to find credentials for cloud looking for local-host
Please outline the hardware you're running conjure-up on, including number of cpus, amount of memory, amount of storage space available: i7 4-core CPU, 16MB of RAM, ~450GB free disk space.



What spell was selected?: kubernetes-core



What cloud provider was selected (this includes both MAAS and localhost)?: localhost




Please outline what commands were run to install and execute conjure-up: snap refresh --channel edge conjure-up




Please post **~/.cache/conjure-up/conjure-up.log**: 

[conjure-up.log.zip](https://github.com/conjure-up/conjure-up/files/906201/conjure-up.log.zip)

Error occurred on 2017-04-07 I see no errors in the log for this day.w





Provide the output of the following commands:

```
mbruzek@pandora:~$ which -a juju
/snap/bin/juju
mbruzek@pandora:~$ which -a conjure-up
/snap/bin/conjure-up
mbruzek@pandora:~$ which -a lxd
/usr/bin/lxd
mbruzek@pandora:~$ juju version
2.2-beta3-yakkety-amd64
mbruzek@pandora:~$ conjure-up --version
conjure-up 2.2-beta3
mbruzek@pandora:~$ lxd --version
2.12
mbruzek@pandora:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.10
DISTRIB_CODENAME=yakkety
DISTRIB_DESCRIPTION="Ubuntu 16.10"
```


Summary of problem:
I tried to conjure-up kubernetes core from the edge channel and got an error about credentials.
![conjure-up-2 1 2-beta3_error](https://cloud.githubusercontent.com/assets/6385185/24810517/1662beaa-1b88-11e7-90bd-d7aaa9b865e7.png)


Discussion:
mbruzek: +1
johnsca: PR updated to fix test.

Patch:
diff --git a/conjureup/controllers/newcloud/gui.py b/conjureup/controllers/newcloud/gui.py
index c143f03..7a8c603 100644
--- a/conjureup/controllers/newcloud/gui.py
+++ b/conjureup/controllers/newcloud/gui.py
@@ -177,21 +177,12 @@ class NewCloudController:
         # information.
 
         cloud_type = juju.get_cloud_types_by_name()[app.current_cloud]
-        try:
-            if cloud_type == 'lxd':
-                lxd = common.is_lxd_ready()
-                if not lxd['ready']:
-                    return controllers.use('lxdsetup').render(lxd['msg'])
-                self.__do_bootstrap()
-                return
-        except LookupError as e:
-            # TODO: Add vsphere once lp bug 1671650 is resolved
-            if cloud_type in ['maas']:
-                app.log.debug(
-                    "Not a cloud, using provider type: {}".format(
-                        app.current_cloud))
-            else:
-                raise Exception(e)
+        if cloud_type == 'localhost':
+            lxd = common.is_lxd_ready()
+            if not lxd['ready']:
+                return controllers.use('lxdsetup').render(lxd['msg'])
+            self.__do_bootstrap()
+            return
 
         # XXX: always prompt for maas information for now as there is no way to
         # logically store the maas server ip for future sessions.
diff --git a/conjureup/controllers/newcloud/tui.py b/conjureup/controllers/newcloud/tui.py
index dce8e7d..a4c4a99 100644
--- a/conjureup/controllers/newcloud/tui.py
+++ b/conjureup/controllers/newcloud/tui.py
@@ -43,8 +43,8 @@ class NewCloudController:
         return controllers.use('deploy').render()
 
     def render(self):
-        cloud = juju.get_cloud(app.current_cloud)
-        if cloud['type'] != 'lxd':
+        cloud_type = juju.get_cloud_types_by_name()[app.current_cloud]
+        if cloud_type != 'localhost':
             if not common.try_get_creds(app.current_cloud):
                 utils.warning("You attempted to do an install against a cloud "
                               "that requires credentials that could not be "
@@ -54,7 +54,7 @@ class NewCloudController:
                               "{}`.".format(app.current_cloud))
                 sys.exit(1)
 
-        if cloud['type'] == 'lxd':
+        if cloud_type == 'localhost':
             lxd = common.is_lxd_ready()
             if not lxd['ready']:
                 return controllers.use('lxdsetup').render(lxd['msg'])


Test patch:
diff --git a/test/test_controllers_newcloud_gui.py b/test/test_controllers_newcloud_gui.py
index 33491aa..322004c 100644
--- a/test/test_controllers_newcloud_gui.py
+++ b/test/test_controllers_newcloud_gui.py
@@ -47,7 +47,7 @@ class NewCloudGUIRenderTestCase(unittest.TestCase):
         self.mock_common = self.common_patcher.start()
         self.mock_juju = self.juju_patcher.start()
         self.mock_juju.get_cloud_types_by_name.return_value = {'localhost':
-                                                               'lxd'}
+                                                               'localhost'}
         self.track_screen_patcher = patch(
             'conjureup.controllers.newcloud.gui.track_screen')
         self.mock_track_screen = self.track_screen_patcher.start()