From dd56bba731e2bc2be0853901d4b9dbe3f38e280b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 4 Feb 2020 07:17:30 -0600 Subject: [PATCH] cephadm: check-host: add optional --expect-hostname Signed-off-by: Sage Weil --- src/cephadm/cephadm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 0c53578d9e9e1..5571db7e6d161 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2491,6 +2491,13 @@ def command_check_host(): if not check_time_sync(): raise Error('No time synchronization is active') + if args.expect_hostname: + if get_hostname() != args.expect_hostname: + raise Error('hostname "%s" does not match expected hostname "%s"' % ( + get_hostname(), args.expect_hostname)) + logger.info('Hostname "%s" matches what is expected.', + args.expect_hostname) + logger.info('Host looks OK') @@ -2831,6 +2838,9 @@ def _get_parser(): parser_check_host = subparsers.add_parser( 'check-host', help='check host configuration') parser_check_host.set_defaults(func=command_check_host) + parser_check_host.add_argument( + '--expect-hostname', + help='Check that hostname matches an expected value') return parser -- 2.39.5