from parallels.core.workflow.shared_hosting_workflow import SharedHostingWorkflow
from parallels.core.actions.base.legacy_action \
	import LegacyAction
from parallels.source.helm3.actions.hosting_settings.convert.dns \
	import DNS as ActionHostingSettingsConvertDNS
from parallels.source.helm3.actions.replace_db_server_ip \
	import ReplaceDbServerIp
from parallels.source.helm3.actions.content.web.copy_windows_content \
	import CopyWindowsWebContent
from parallels.source.plesk.actions.content.web.reset_permissions \
	import ResetPermissions
from parallels.source.helm3.actions.hosting_settings.transfer_virtual_directories \
	import TransferVirtualDirectories
from parallels.source.helm3.actions.hosting_settings.transfer_mime_types \
	import TransferMIMETypes
from parallels.source.helm3.actions.hosting_settings.convert.ftp_user_login \
	import FTPUserLogin

from parallels.core.utils.backup_adapter import SubscriptionBackup

class FromHelm3Workflow(SharedHostingWorkflow):
	def __init__(self):
		super(FromHelm3Workflow, self).__init__()

		self.get_shared_action('fetch-source').insert_action(
			'fetch-data', LegacyAction(
				description='Fetch data from source Helm',
				function=lambda ctx: ctx.migrator._fetch_data(
					ctx.options, ctx.options.reload_source_data
				)
			)
		)
		self.get_shared_action('fetch-source').insert_action(
			'replace-db-server-ip',
			ReplaceDbServerIp()
		)

		self.get_shared_action('convert-hosting').replace(
			'convert-dns', ActionHostingSettingsConvertDNS()
		)
		self.get_shared_action('convert-hosting').insert_action(
			'change-ftp-logins', FTPUserLogin(SubscriptionBackup()),
			before='save-backup'
		)
		self.get_shared_action('copy-web-files').insert_action(
			'copy-files', CopyWindowsWebContent()
		)
		self.get_shared_action('sync-web-content-assets').insert_action(
			'reset-permissions', ResetPermissions()
		)
		self.get_shared_action('sync-web-content-assets').insert_action(
			'transfer-virtual-directories', TransferVirtualDirectories()
		)
		self.get_shared_action('sync-web-content-assets').insert_action(
			'transfer-mime-types', TransferMIMETypes()
		)
