Merge ~ack/maas:snap-init-no-user-authconfig-params into maas:master

Proposed by Alberto Donato
Status: Merged
Approved by: Alberto Donato
Approved revision: 21b3a30125dea930623ad47e00dd6cadbd4aa4ae
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ack/maas:snap-init-no-user-authconfig-params
Merge into: maas:master
Diff against target: 210 lines (+63/-29)
2 files modified
src/maascli/init.py (+38/-12)
src/maascli/snappy.py (+25/-17)
Reviewer Review Type Date Requested Status
MAAS Lander Needs Fixing
Björn Tillenius Approve
Review via email: mp+384239@code.launchpad.net

Commit message

LP: #1871356 - snap: hide maas init parameters for creating admin and configuring auth

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

LANDING
-b snap-init-no-user-authconfig-params lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED BUILD
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/7556/consoleText

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b snap-init-no-user-authconfig-params lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/7557/console
COMMIT: 21b3a30125dea930623ad47e00dd6cadbd4aa4ae

review: Needs Fixing

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maascli/init.py b/src/maascli/init.py
2index 789dfca..ac36e6c 100644
3--- a/src/maascli/init.py
4+++ b/src/maascli/init.py
5@@ -55,68 +55,94 @@ def deprecated_for(new_option):
6 return DeprecatedAction
7
8
9-def add_candid_options(parser):
10+def add_candid_options(parser, suppress_help=False):
11 parser.add_argument(
12 "--candid-agent-file",
13- help="Agent file containing Candid authentication information",
14+ help=(
15+ argparse.SUPPRESS
16+ if suppress_help
17+ else "Agent file containing Candid authentication information"
18+ ),
19 )
20 parser.add_argument(
21 "--candid-domain",
22 default=None,
23 help=(
24- "The authentication domain to look up users in for the external "
25+ argparse.SUPPRESS
26+ if suppress_help
27+ else "The authentication domain to look up users in for the external "
28 "Candid server."
29 ),
30 )
31 parser.add_argument(
32 "--candid-admin-group",
33 default=None,
34- help="Group of users whose members are made admins in MAAS",
35+ help=(
36+ argparse.SUPPRESS
37+ if suppress_help
38+ else "Group of users whose members are made admins in MAAS"
39+ ),
40 )
41
42
43-def add_rbac_options(parser):
44+def add_rbac_options(parser, suppress_help=False):
45 parser.add_argument(
46 "--rbac-url",
47 default=None,
48- help="The URL for the Canonical RBAC service to use.",
49+ help=(
50+ argparse.SUPPRESS
51+ if suppress_help
52+ else "The URL for the Canonical RBAC service to use."
53+ ),
54 )
55 parser.add_argument(
56 "--rbac-service-name",
57 default=None,
58 help=(
59- "Optionally, the name of the RBAC service to register this MAAS "
60+ argparse.SUPPRESS
61+ if suppress_help
62+ else "Optionally, the name of the RBAC service to register this MAAS "
63 "as. If not provided, a list with services that the user can "
64 "register will be displayed, to choose from."
65 ),
66 )
67
68
69-def add_create_admin_options(parser):
70+def add_create_admin_options(parser, suppress_help=False):
71 parser.add_argument(
72 "--admin-username",
73 default=None,
74 metavar="USERNAME",
75- help="Username for the admin account.",
76+ help=argparse.SUPPRESS
77+ if suppress_help
78+ else "Username for the admin account.",
79 )
80 parser.add_argument(
81 "--admin-password",
82 default=None,
83 metavar="PASSWORD",
84- help="Force a given admin password instead of prompting.",
85+ help=(
86+ argparse.SUPPRESS
87+ if suppress_help
88+ else "Force a given admin password instead of prompting."
89+ ),
90 )
91 parser.add_argument(
92 "--admin-email",
93 default=None,
94 metavar="EMAIL",
95- help="Email address for the admin.",
96+ help=argparse.SUPPRESS
97+ if suppress_help
98+ else "Email address for the admin.",
99 )
100 parser.add_argument(
101 "--admin-ssh-import",
102 default=None,
103 metavar="LP_GH_USERNAME",
104 help=(
105- "Import SSH keys from Launchpad (lp:user-id) or "
106+ argparse.SUPPRESS
107+ if suppress_help
108+ else "Import SSH keys from Launchpad (lp:user-id) or "
109 "Github (gh:user-id) for the admin."
110 ),
111 )
112diff --git a/src/maascli/snappy.py b/src/maascli/snappy.py
113index a3ba92c..1507d52 100644
114--- a/src/maascli/snappy.py
115+++ b/src/maascli/snappy.py
116@@ -23,6 +23,7 @@ import signal
117 import string
118 import subprocess
119 import sys
120+from textwrap import dedent
121 import threading
122 import time
123
124@@ -623,6 +624,7 @@ def perform_work(msg, cmd, *args, **kwargs):
125 finally:
126 evnt.set()
127 t.join()
128+ clear_line()
129 return ret
130
131
132@@ -879,22 +881,17 @@ class cmd_init(SnappyCommand):
133 "--enable-candid",
134 default=False,
135 action="store_true",
136- help=(
137- "Enable configuring the use of an external Candid server. "
138- "This feature is currently experimental. "
139- "If this isn't enabled, all --candid-* arguments "
140- "will be ignored."
141- ),
142+ help=argparse.SUPPRESS,
143 )
144 for for_mode in ["region+rack", "region"]:
145- add_candid_options(subparsers_map[for_mode])
146- add_rbac_options(subparsers_map[for_mode])
147+ add_candid_options(subparsers_map[for_mode], suppress_help=True)
148+ add_rbac_options(subparsers_map[for_mode], suppress_help=True)
149 subparsers_map[for_mode].add_argument(
150- "--skip-admin",
151- action="store_true",
152- help="Skip the admin creation.",
153+ "--skip-admin", action="store_true", help=argparse.SUPPRESS
154+ )
155+ add_create_admin_options(
156+ subparsers_map[for_mode], suppress_help=True
157 )
158- add_create_admin_options(subparsers_map[for_mode])
159
160 def handle(self, options):
161 if os.getuid() != 0:
162@@ -1021,7 +1018,6 @@ class cmd_init(SnappyCommand):
163 migrate_db,
164 capture=sys.stdout.isatty(),
165 )
166- clear_line()
167 init_maas(options)
168 elif mode in ["region", "region+rack"]:
169 # When in 'region' or 'region+rack' the migrations for the database
170@@ -1031,8 +1027,22 @@ class cmd_init(SnappyCommand):
171 migrate_db,
172 capture=sys.stdout.isatty(),
173 )
174- else:
175- clear_line()
176+ print_msg(
177+ dedent(
178+ """\
179+ MAAS has been set up.
180+
181+ If you want to configure external authentication or use
182+ MAAS with Canonical RBAC, please run
183+
184+ sudo maas configauth
185+
186+ To create admins when not using external authentication, run
187+
188+ sudo maas createadmin
189+ """
190+ )
191+ )
192
193
194 class cmd_config(SnappyCommand):
195@@ -1315,7 +1325,6 @@ class cmd_config(SnappyCommand):
196 else "Stopping services",
197 sighup_supervisord,
198 )
199- clear_line()
200
201 # Perform migrations when switching to all.
202 if changed_to_all:
203@@ -1325,7 +1334,6 @@ class cmd_config(SnappyCommand):
204 migrate_db,
205 capture=sys.stdout.isatty(),
206 )
207- clear_line()
208
209
210 class cmd_status(SnappyCommand):

Subscribers

People subscribed via source and target branches