/// <summary>
        /// Configures the import session at the beginning of an import
        /// </summary>
        /// <param name="configParameters">The configuration parameters supplied to this management agent</param>
        /// <param name="types">The schema types that apply to this import run</param>
        /// <param name="importRunStep">The definition of the current run step</param>
        /// <returns>Results of the import setup</returns>
        OpenImportConnectionResults IMAExtensible2CallImport.OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
        {
            try
            {
                ManagementAgent.MAParameters = new MAParameters(configParameters);
                Logger.LogPath = ManagementAgent.MAParameters.LogPath;
                Logger.WriteSeparatorLine('*');
                Logger.WriteLine("Starting Import");

                MAConfig.Load(ManagementAgent.MAParameters.MAConfigurationFilePath);

                SshConnection.OpenSshConnection(ManagementAgent.MAParameters);
                OperationBase operation;
                this.ImportType     = importRunStep.ImportType;
                this.schemaTypes    = types.Types;
                this.importPageSize = importRunStep.PageSize;

                if (importRunStep.ImportType == OperationType.Delta)
                {
                    operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ImportDeltaStartOperation);
                }
                else
                {
                    operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ImportFullStartOperation);
                }

                if (operation != null)
                {
                    try
                    {
                        SshConnection.ExecuteOperation(operation);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform import start operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Import start operation failed", ex);
                    }
                }

                this.importEnumerator = CSEntryImport.GetObjects(this.schemaTypes, importRunStep.ImportType).GetEnumerator();
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the open import connection operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the open import connection operation", ex);
            }

            OpenImportConnectionResults results = new OpenImportConnectionResults();

            return(new OpenImportConnectionResults());
        }
        /// <summary>
        /// Validates the host parameters and ensures a connection can be made to the server
        /// </summary>
        /// <param name="configParameters">The configuration parameters from the user interface</param>
        /// <param name="page">The configuration page</param>
        /// <returns>A ParameterValidationResult containing the validation status</returns>
        public static ParameterValidationResult ValidateHost(KeyedCollection <string, ConfigParameter> configParameters, ConfigParameterPage page)
        {
            ParameterValidationResult myResults = new ParameterValidationResult();

            if (string.IsNullOrWhiteSpace(configParameters[MAParameterNames.HostName].Value))
            {
                myResults.Code           = ParameterValidationResultCode.Failure;
                myResults.ErrorMessage   = "The hostname cannot be blank";
                myResults.ErrorParameter = MAParameterNames.HostName;
                return(myResults);
            }

            int result = 0;

            if (!int.TryParse(configParameters[MAParameterNames.Port].Value, out result))
            {
                myResults.Code           = ParameterValidationResultCode.Failure;
                myResults.ErrorMessage   = "The port number must be an integer";
                myResults.ErrorParameter = MAParameterNames.Port;
                return(myResults);
            }
            else if (result <= 0)
            {
                myResults.Code           = ParameterValidationResultCode.Failure;
                myResults.ErrorMessage   = "The port number must be an integer greater than 0";
                myResults.ErrorParameter = MAParameterNames.Port;
                return(myResults);
            }

            try
            {
                SshConnection.OpenSshConnection(new MAParameters(configParameters));
                SshConnection.CloseSshConnection();
            }
            catch (Exception ex)
            {
                myResults.Code           = ParameterValidationResultCode.Failure;
                myResults.ErrorMessage   = "Could not connect to the target server\n" + ex.Message;
                myResults.ErrorParameter = MAParameterNames.HostName;
                return(myResults);
            }

            myResults.Code = ParameterValidationResultCode.Success;

            return(myResults);
        }
        /// <summary>
        /// Begins a password connection to the server
        /// </summary>
        /// <param name="configParameters">The collection of configuration parameters</param>
        /// <param name="partition">The partition details on which the password operation should occur</param>
        void IMAExtensible2Password.OpenPasswordConnection(KeyedCollection <string, ConfigParameter> configParameters, Partition partition)
        {
            try
            {
                ManagementAgent.MAParameters = new MAParameters(configParameters);
                Logger.LogPath = ManagementAgent.MAParameters.LogPath;
                Logger.WriteSeparatorLine('*');
                Logger.WriteLine("Starting password operation");

                MAConfig.Load(ManagementAgent.MAParameters.MAConfigurationFilePath);

                SshConnection.OpenSshConnection(ManagementAgent.MAParameters);

                OperationBase operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is PasswordStartOperation);

                if (operation != null)
                {
                    try
                    {
                        SshConnection.ExecuteOperation(operation);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform password start operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Password start operation failed", ex);
                    }
                }
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the open password connection operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the open password connection operation", ex);
            }
        }
        /// <summary>
        /// Begins an export session
        /// </summary>
        /// <param name="configParameters">The configuration parameters supplied to this management agent</param>
        /// <param name="types">The schema types that apply to this export run</param>
        /// <param name="exportRunStep">The definition of the current run step</param>
        void IMAExtensible2CallExport.OpenExportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenExportConnectionRunStep exportRunStep)
        {
            try
            {
                ManagementAgent.MAParameters = new MAParameters(configParameters);
                Logger.LogPath = ManagementAgent.MAParameters.LogPath;
                Logger.WriteSeparatorLine('*');
                Logger.WriteLine("Starting Export");

                MAConfig.Load(ManagementAgent.MAParameters.MAConfigurationFilePath);

                SshConnection.OpenSshConnection(ManagementAgent.MAParameters);

                OperationBase operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ExportStartOperation);

                if (operation != null)
                {
                    try
                    {
                        SshConnection.ExecuteOperation(operation);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform export start operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Export start operation failed", ex);
                    }
                }
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the open export connection operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the open export connection operation", ex);
            }
        }