From 26e01f7a2acf9713352f9b5e44a01d8ad84ca939 Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Mon, 19 Dec 2016 10:39:24 -0500 Subject: [PATCH 1/5] Remove unnecessary install-dependencies charm/charm-tools aren't used any longer. Signed-off-by: Adam Stokes --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 370059a0..92d2edab 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ VERSION := 2.0.2 .PHONY: install-dependencies install-dependencies: - sudo apt-get -yy install devscripts equivs pandoc bsdtar charm charm-tools jq libsystemd-dev + sudo apt-get -yy install devscripts equivs pandoc bsdtar jq libsystemd-dev sudo mk-build-deps -i -t "apt-get --no-install-recommends -y" debian/control .PHONY: uninstall-dependencies From f32bcc40ddfe89d8e6f26f3671f674d3ea55b13f Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Mon, 19 Dec 2016 10:41:31 -0500 Subject: [PATCH 2/5] Fixes #521 Signed-off-by: Adam Stokes --- conjureup/controllers/newcloud/gui.py | 2 +- conjureup/ui/views/lxdsetup.py | 21 +++++++++------------ conjureup/utils.py | 10 +++++++++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/conjureup/controllers/newcloud/gui.py b/conjureup/controllers/newcloud/gui.py index c02cc9d6..8521c9d1 100644 --- a/conjureup/controllers/newcloud/gui.py +++ b/conjureup/controllers/newcloud/gui.py @@ -147,7 +147,7 @@ def render(self): # information. if app.current_cloud == 'localhost': - if not utils.check_bridge_exists(): + if not utils.check_bridge_exists() or not utils.check_user_in_group('lxd'): return controllers.use('lxdsetup').render() app.log.debug("Found an IPv4 address, " diff --git a/conjureup/ui/views/lxdsetup.py b/conjureup/ui/views/lxdsetup.py index f9362af4..93c319ba 100644 --- a/conjureup/ui/views/lxdsetup.py +++ b/conjureup/ui/views/lxdsetup.py @@ -106,20 +106,17 @@ def buttons(self): def build_info(self): items = [ - Text("There was no LXD bridge found on your system " - "which usually means this is your first time running " - "LXD."), + Text("There was no LXD bridge found on your system or " + "you are not part of the LXD user group which usually " + "means this is your first time running LXD."), Padding.line_break(""), - # Text("If you wish to do so now pressing confirm will drop you out " # noqa - # "of the installer and walk you through configuring your " - # "network for LXD. Once complete the installer will " - # "start again from the beginning where you can choose " - # "to deploy the bundle via LXD.") Text("If you wish to do so now pressing confirm will drop you out " - "of the installer and you will be required to run " - "`lxd init` to configure the network for LXD. Once complete " - "re-run conjure-up and continue the installation.") - + "of the installer and you will be required to run the following: \n\n" + " $ sudo lxd init\n" + " $ newgrp lxd\n" + " $ lxc finger\n\n" + "If `lxc finger` does not fail with an error you are ready to re-run " + "conjure-up and continue the installation.") ] return Pile(items) diff --git a/conjureup/utils.py b/conjureup/utils.py index 278b21be..7d8e4965 100644 --- a/conjureup/utils.py +++ b/conjureup/utils.py @@ -135,6 +135,14 @@ def check_bridge_exists(): return True return False +def check_user_in_group(group): + """ Checks if a user is associated with `group` + """ + groups = run_script('id').stdout.decode() + if group in groups: + return True + return False + def check_deb_installed(pkg): """ Checks if a debian package is installed @@ -238,7 +246,7 @@ def slurp(path): def install_user(): - """ returns sudo user + """ returns current user """ user = os.getenv('USER', None) if user is None: From cd7915391ae54e7a2b36a46de44eb368433fd7df Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Mon, 19 Dec 2016 11:04:33 -0500 Subject: [PATCH 3/5] fix lint Signed-off-by: Adam Stokes --- conjureup/controllers/newcloud/gui.py | 3 ++- conjureup/ui/views/lxdsetup.py | 7 ++++--- conjureup/utils.py | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/conjureup/controllers/newcloud/gui.py b/conjureup/controllers/newcloud/gui.py index 8521c9d1..4564d1bd 100644 --- a/conjureup/controllers/newcloud/gui.py +++ b/conjureup/controllers/newcloud/gui.py @@ -147,7 +147,8 @@ def render(self): # information. if app.current_cloud == 'localhost': - if not utils.check_bridge_exists() or not utils.check_user_in_group('lxd'): + if not utils.check_bridge_exists() or \ + not utils.check_user_in_group('lxd'): return controllers.use('lxdsetup').render() app.log.debug("Found an IPv4 address, " diff --git a/conjureup/ui/views/lxdsetup.py b/conjureup/ui/views/lxdsetup.py index 93c319ba..b3ad772b 100644 --- a/conjureup/ui/views/lxdsetup.py +++ b/conjureup/ui/views/lxdsetup.py @@ -111,12 +111,13 @@ def build_info(self): "means this is your first time running LXD."), Padding.line_break(""), Text("If you wish to do so now pressing confirm will drop you out " - "of the installer and you will be required to run the following: \n\n" + "of the installer and you will be required to run the " + "following: \n\n" " $ sudo lxd init\n" " $ newgrp lxd\n" " $ lxc finger\n\n" - "If `lxc finger` does not fail with an error you are ready to re-run " - "conjure-up and continue the installation.") + "If `lxc finger` does not fail with an error you are ready " + "to re-run conjure-up and continue the installation.") ] return Pile(items) diff --git a/conjureup/utils.py b/conjureup/utils.py index 7d8e4965..30dca5cc 100644 --- a/conjureup/utils.py +++ b/conjureup/utils.py @@ -135,6 +135,7 @@ def check_bridge_exists(): return True return False + def check_user_in_group(group): """ Checks if a user is associated with `group` """ From 6245bb22adda29fb568b4a7f9af5abfebdfd7382 Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Mon, 19 Dec 2016 11:14:00 -0500 Subject: [PATCH 4/5] use groups instead Signed-off-by: Adam Stokes --- conjureup/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conjureup/utils.py b/conjureup/utils.py index 30dca5cc..51271528 100644 --- a/conjureup/utils.py +++ b/conjureup/utils.py @@ -139,8 +139,8 @@ def check_bridge_exists(): def check_user_in_group(group): """ Checks if a user is associated with `group` """ - groups = run_script('id').stdout.decode() - if group in groups: + groups = run_script('groups').stdout.decode() + if group in groups.split(): return True return False From 04b5db44be85a336a5682118105cf7b6bad52c98 Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Mon, 19 Dec 2016 11:17:09 -0500 Subject: [PATCH 5/5] be explicit in our error about not being in correct lxd group Signed-off-by: Adam Stokes --- conjureup/ui/views/lxdsetup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conjureup/ui/views/lxdsetup.py b/conjureup/ui/views/lxdsetup.py index b3ad772b..1fc5b598 100644 --- a/conjureup/ui/views/lxdsetup.py +++ b/conjureup/ui/views/lxdsetup.py @@ -107,7 +107,7 @@ def buttons(self): def build_info(self): items = [ Text("There was no LXD bridge found on your system or " - "you are not part of the LXD user group which usually " + "not part of the 'lxd' group which usually " "means this is your first time running LXD."), Padding.line_break(""), Text("If you wish to do so now pressing confirm will drop you out "