Add a status option to ipa-acme-manage

It's handy in general and good for testing to be able to
detect the current ACME status without having to revert
to using curl.

https://pagure.io/freeipa/issue/8524

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Mohammad Rizwan <myusuf@redhat.com>
This commit is contained in:
Rob Crittenden
2020-10-14 13:20:16 -04:00
parent 92c3ea4e29
commit 69ae48c8b6
3 changed files with 41 additions and 4 deletions

View File

@@ -69,11 +69,12 @@ class acme_state(RestClient):
class Command(enum.Enum):
ENABLE = 'enable'
DISABLE = 'disable'
STATUS = 'status'
class IPAACMEManage(AdminTool):
command_name = "ipa-acme-manage"
usage = "%prog [enable|disable]"
usage = "%prog [enable|disable|status]"
description = "Manage the IPA ACME service"
def validate_options(self):
@@ -108,6 +109,10 @@ class IPAACMEManage(AdminTool):
ca_api.enable()
elif self.command == Command.DISABLE:
ca_api.disable()
elif self.command == Command.STATUS:
status = "enabled" if dogtag.acme_status() else "disabled"
print("ACME is {}".format(status))
return 0
else:
raise RuntimeError('programmer error: unhandled enum case')