11
11
from insights .client .config import InsightsConfig
12
12
from insights .client .constants import InsightsConstants as constants
13
13
from insights .client .support import InsightsSupport
14
- from insights .client .utilities import validate_remove_file , print_egg_versions
14
+ from insights .client .utilities import validate_remove_file , print_egg_versions , _get_rhsm_identity
15
15
from insights .client .schedule import get_scheduler
16
16
17
17
logger = logging .getLogger (__name__ )
@@ -56,10 +56,6 @@ def get_phases():
56
56
@phase
57
57
def pre_update (client , config ):
58
58
59
- # Check if BASIC auth is used to print a WARNING message
60
- if config .authmethod == 'BASIC' :
61
- logger .warning ('WARN: BASIC authentication method is being deprecated. Please consider using CERT authentication method.' )
62
-
63
59
if config .version :
64
60
logger .info (constants .version )
65
61
sys .exit (constants .sig_kill_ok )
@@ -165,6 +161,30 @@ def post_update(client, config):
165
161
166
162
# -------delete everything below this line-------
167
163
if config .legacy_upload :
164
+ if config .offline or config .no_upload or config .module :
165
+ # create a machine id first thing. we'll need it for all uploads
166
+ logger .debug ('Machine ID: %s' , client .get_machine_id ())
167
+ logger .debug ("CONFIG: %s" , config )
168
+ if config .offline :
169
+ logger .debug ('Running client in offline mode. Bypassing registration.' )
170
+ elif config .no_upload :
171
+ logger .debug ("Running client without uploading. Bypassing registration." )
172
+ else :
173
+ logger .debug ('Running a specified module. Bypassing registration.' )
174
+ return
175
+
176
+ if not _get_rhsm_identity ():
177
+ logger .error (
178
+ "This host is unregistered, please ensure that "
179
+ "the system is registered with subscription-manager "
180
+ "and then with insights-client.\n "
181
+ "\n 1. Register with subscription-manager"
182
+ "\n # subscription-manager register\n "
183
+ "\n 2. Register with insights-client"
184
+ "\n # insights-client --register"
185
+ )
186
+ sys .exit (constants .sig_kill_bad )
187
+
168
188
if config .status :
169
189
reg_check = client .get_registration_status ()
170
190
for msg in reg_check ['messages' ]:
@@ -182,16 +202,6 @@ def post_update(client, config):
182
202
else :
183
203
sys .exit (constants .sig_kill_bad )
184
204
185
- if config .offline or config .no_upload :
186
- # create a machine id first thing. we'll need it for all uploads
187
- logger .debug ('Machine ID: %s' , client .get_machine_id ())
188
- logger .debug ("CONFIG: %s" , config )
189
- if config .offline :
190
- logger .debug ('Running client in offline mode. Bypassing registration.' )
191
- else :
192
- logger .debug ("Running client without uploading. Bypassing registration." )
193
- return
194
-
195
205
if config .display_name and not config .register :
196
206
# setting display name independent of registration
197
207
if client .set_display_name (config .display_name ):
@@ -217,16 +227,18 @@ def post_update(client, config):
217
227
return
218
228
# -------delete everything above this line-------
219
229
220
- if config .offline or config .no_upload or config .payload :
230
+ if config .offline or config .no_upload or config .payload or config . module :
221
231
# create a machine id first thing. we'll need it for all uploads
222
232
logger .debug ('Machine ID: %s' , client .get_machine_id ())
223
233
logger .debug ("CONFIG: %s" , config )
224
234
if config .offline :
225
235
logger .debug ('Running client in offline mode. Bypassing registration.' )
226
236
elif config .no_upload :
227
237
logger .debug ("Running client without uploading. Bypassing registration." )
228
- else :
238
+ elif config . payload :
229
239
logger .debug ('Uploading a specified archive. Bypassing registration.' )
240
+ else :
241
+ logger .debug ('Running a specified module. Bypassing registration.' )
230
242
return
231
243
232
244
# check registration status before anything else
@@ -251,8 +263,9 @@ def post_update(client, config):
251
263
252
264
# halt here if unregistered
253
265
if not reg_check and not config .register :
254
- logger .info ('This host has not been registered. '
255
- 'Use --register to register this host.' )
266
+ logger .error ("This host is unregistered. "
267
+ "Use --register to register this host.\n "
268
+ "# insights-client --register" )
256
269
sys .exit (constants .sig_kill_bad )
257
270
258
271
# --register was called
0 commit comments