from parallels.common.actions.base.subscription_backup_action import SubscriptionBackupAction
from parallels.common.actions.utils.logging_properties \
	import LoggingProperties
from parallels.common.target_panels import TargetPanels

class RemoveDomainKeys(SubscriptionBackupAction):
	"""Domain keys are not implemented on PPA side, remove them from backup""" 

	def get_description(self):
		return "Remove domains keys from backup"

	def get_failure_message(self, global_context, subscription):
		return "Failed to remove domain keys for subscription '%s'" % (subscription.name)

	def get_logging_properties(self):
		return LoggingProperties(info_log=False)

	def _run_subscription_backup(
		self, global_context, subscription, subscription_backup
	):
		if global_context.target_panel != TargetPanels.PPA:
			# applicable to PPA only, for Plesk we can restore domain keys
			# without any issues
			return

		if subscription_backup.mailsystem is not None:
			subscription_backup.mailsystem.remove_domainkeys()
