from parallels.core.migrated_subscription import MigratedSubscription
from parallels.core.registry import Registry


class PleskMigratedSubscription(MigratedSubscription):
    @property
    def mail_source_server(self):
        """Get source mail server for subscription (SourceServer object)"""
        global_context = Registry().get_instance().get_context()

        remote_smarter_mail_server = global_context.conn.get_remote_smarter_mail_server(self.mail_source_server_id)
        if remote_smarter_mail_server is not None:
            return remote_smarter_mail_server
        else:
            return super(PleskMigratedSubscription, self).mail_source_server

    @property
    def source_mail_ip(self):
        global_context = Registry().get_instance().get_context()

        remote_smarter_mail_ip = global_context.conn.get_remote_smarter_mail_ip(self.mail_source_server_id)

        if remote_smarter_mail_ip is not None:
            return remote_smarter_mail_ip
        else:
            return super(PleskMigratedSubscription, self).source_mail_ip
