示例#1
0
 public UnmountParams GetUnmountExeAndArgs(VolumeEntry volumeEntry)
 {
     return(new UnmountParams()
     {
         Exe = UnmountExeName,
         Arguments = volumeEntry.Mountpoint
     });
 }
示例#2
0
        bool DoUnmount(VolumeEntry volumeEntry)
        {
            try
            {
                //
                // TODO: Change to syscall instead of process create for better diagnostics.
                //
                var unmountParams = this.mountManager.GetUnmountExeAndArgs(volumeEntry);
                TraceWriter.WriteInfoWithId(
                    TraceType,
                    this.serviceContext.TraceId,
                    $"{unmountParams.Exe} {unmountParams.Arguments}");
                using (Process exeProcess = new Process())
                {
                    exeProcess.StartInfo.UseShellExecute        = false;
                    exeProcess.StartInfo.RedirectStandardOutput = true;
                    exeProcess.StartInfo.RedirectStandardError  = true;
                    exeProcess.StartInfo.FileName  = unmountParams.Exe;
                    exeProcess.StartInfo.Arguments = unmountParams.Arguments;
                    exeProcess.Start();
                    if (!exeProcess.WaitForExit(defaultProcessRuntimeMs))
                    {
                        TraceWriter.WriteErrorWithId(
                            TraceType,
                            this.serviceContext.TraceId,
                            $"unmount didnt complete in the required time. Output:{exeProcess.StandardOutput.ReadToEnd()} Error:{exeProcess.StandardError.ReadToEnd()}");
                        exeProcess.Kill();
                        return(false);
                    }
                    if (exeProcess.ExitCode != 0)
                    {
                        TraceWriter.WriteErrorWithId(
                            TraceType,
                            this.serviceContext.TraceId,
                            $"Error {exeProcess.ExitCode} encountered during unmount. Output:{exeProcess.StandardOutput.ReadToEnd()} Error:{exeProcess.StandardError.ReadToEnd()}");
                        return(false);
                    }
                    else
                    {
                        TraceWriter.WriteInfoWithId(
                            TraceType,
                            this.serviceContext.TraceId,
                            $"unmount complete. Output:{exeProcess.StandardOutput.ReadToEnd()} Error:{exeProcess.StandardError.ReadToEnd()}");
                    }
                }
            }
            catch (Exception e)
            {
                TraceWriter.WriteErrorWithId(
                    TraceType,
                    this.serviceContext.TraceId,
                    $"unmount failed with exception {e}.");
                return(false);
            }

            return(true);
        }
        public UnmountParams GetUnmountExeAndArgs(VolumeEntry volumeEntry)
        {
            string mountPoint         = volumeEntry.Mountpoint;
            string shareName          = volumeEntry.VolumeOptions[Constants.ShareNameOption].Trim();
            string storageAccountFQDN = Utilities.GetStorageAccountFQDN(volumeEntry.VolumeOptions);
            string storageAccountName = Utilities.GetStorageAccountName(volumeEntry.VolumeOptions);
            string remoteShare        = $"\\\\{storageAccountFQDN}\\{shareName}";
            string scriptArgs         = $"{this.unmapScriptPath} -RemotePath {remoteShare} -LocalPath {mountPoint}";

            return(new UnmountParams()
            {
                Exe = ExeName,
                Arguments = scriptArgs
            });
        }
        public MountParams GetMountExeAndArgs(string name, VolumeEntry volumeEntry)
        {
            string mountPoint = Path.Combine(this.mountPointBase, name);

            string shareName          = volumeEntry.VolumeOptions[Constants.ShareNameOption].Trim();
            string storageAccountFQDN = Utilities.GetStorageAccountFQDN(volumeEntry.VolumeOptions);
            string storageAccountName = Utilities.GetStorageAccountName(volumeEntry.VolumeOptions);
            string key            = Utilities.GetStorageAccountKey(volumeEntry.VolumeOptions);
            string remoteShare    = $"\\\\{storageAccountFQDN}\\{shareName}";
            string scriptArgs     = $"{this.mapScriptPath} -RemotePath {remoteShare} -StorageAccountName {storageAccountName} -StorageAccountKey {key} -LocalPath {mountPoint}";
            string argsForLogging = $"{this.mapScriptPath} -RemotePath {remoteShare} -StorageAccountName {storageAccountName} -StorageAccountKey <hidden> -LocalPath {mountPoint}";

            return(new MountParams()
            {
                Exe = ExeName,
                Arguments = scriptArgs,
                ArgumentsForLog = argsForLogging,
                MountPoint = mountPoint
            });
        }
示例#5
0
        public MountParams GetMountExeAndArgs(string name, VolumeEntry volumeEntry)
        {
            string mountPoint = Path.Combine(this.mountPointBase, name);

            Utilities.EnsureFolder(mountPoint);

            string shareName          = volumeEntry.VolumeOptions[Constants.ShareNameOption].Trim();
            string storageAccountFQDN = Utilities.GetStorageAccountFQDN(volumeEntry.VolumeOptions);
            string storageAccountName = Utilities.GetStorageAccountName(volumeEntry.VolumeOptions);
            string key            = Utilities.GetStorageAccountKey(volumeEntry.VolumeOptions);
            string mountArgs      = $"-t cifs //{storageAccountFQDN}/{shareName} {mountPoint} -o vers=3.0,username={storageAccountName},password={key},dir_mode=0770,file_mode=0770,serverino";
            string argsForLogging = $"-t cifs //{storageAccountFQDN}/{shareName} {mountPoint} -o vers=3.0,username={storageAccountName},password=<hidden>,dir_mode=0770,file_mode=0770,serverino";

            return(new MountParams()
            {
                Exe = MountExeName,
                Arguments = mountArgs,
                ArgumentsForLog = argsForLogging,
                MountPoint = mountPoint
            });
        }