diff --git a/landscape/client/configuration.py b/landscape/client/configuration.py index 047588f8..7676623c 100644 --- a/landscape/client/configuration.py +++ b/landscape/client/configuration.py @@ -275,6 +275,20 @@ def make_parser(self): "Send a new registration request only if one has not been sent" ), ) + parser.add_argument( + "--actively-registered", + action="store_true", + help="Exit with code 0 (success) if client is " + "registered else returns {}. Displays " + "registration info.".format(EXIT_NOT_REGISTERED), + ) + parser.add_argument( + "--registration-sent", + action="store_true", + help="Exit with code 0 (success) if client is " + "registered else returns {}. Displays " + "registration info.".format(EXIT_NOT_REGISTERED), + ) return parser @@ -863,7 +877,7 @@ def get_secure_id(config): return identity.secure_id -def main(args, print=print): +def main(args, print=print): # noqa: C901 """Interact with the user and the server to set up client configuration.""" config = LandscapeSetupConfiguration() try: @@ -885,9 +899,9 @@ def main(args, print=print): "and force registration together.", ) - already_registered = actively_registered(config) + already_registered = is_registered(config) - if config.is_registered: + if config.is_registered or config.registration_sent: registration_status = already_registered @@ -899,6 +913,18 @@ def main(args, print=print): else: sys.exit(EXIT_NOT_REGISTERED) + currently_registered = actively_registered(config) + if config.actively_registered: + registration_status = currently_registered + + info_text = registration_info_text(config, registration_status) + print(info_text) + + if registration_status: + sys.exit(0) + else: + sys.exit(EXIT_NOT_REGISTERED) + if os.getuid() != 0: sys.exit("landscape-config must be run as root.") diff --git a/man/landscape-config.txt b/man/landscape-config.txt index 335ed2e7..5852c731 100644 --- a/man/landscape-config.txt +++ b/man/landscape-config.txt @@ -72,8 +72,8 @@ OPTIONS enter: ALL. --include-manager-plugins=PLUGINS A comma-separated list of manager plugins to load explicitly. - --manage-sources-list-d [MANAGE_SOURCES_LIST_D] Repository profiles manage - the files in ’etc/apt/sources.list.d'. (default: true) + --manage-sources-list-d [MANAGE_SOURCES_LIST_D] Repository profiles manage + the files in ’etc/apt/sources.list.d'. (default: true) -n, --no-start Don't start the client automatically. --ok-no-register Return exit code 0 instead of 2 if the client can't be registered. @@ -83,6 +83,12 @@ OPTIONS --is-registered Exit with code 0 (success) if client is registered else returns 5. Display registration info. + --registration-sent Exit with code 0 (success) if client + has sent registration request else returns 5. + Display registration sent info. + --actively-registered Exit with code 0 (success) if client + is registered else returns 5. Display + registration info. CLOUD