public Ec2Volume CreateVolume(int sizeGb, string name) { var volume = new Ec2Volume(this, name, sizeGb); volume.Logger = this.Logger; return(volume); }
public async Task <string> AttachVolumeAsync(Ec2Volume volume) { string mountPoint = null; await this.volumeMountPointLock.WaitAsync(); { mountPoint = mountPoints.Except((await this.GetAttachedVolumesAsync()).Select(x => x.Attachments.FirstOrDefault(y => y.InstanceId == this.InstanceId).Device)).FirstOrDefault(); if (mountPoint == null) { throw new Exception("Run out of mount points. You have too many volumes mounted!"); } this.Logger.Log("Attaching volume to instance {0}, device {1}", this.InstanceId, mountPoint); var attachVolumeResponse = await this.Client.AttachVolumeAsync(new AttachVolumeRequest() { InstanceId = this.InstanceId, VolumeId = volume.VolumeId, Device = mountPoint, }); } this.volumeMountPointLock.Release(); return(mountPoint); }
public Ec2Volume CreateVolume(string source, string name) { var volume = new Ec2Volume(this, source, name); volume.Logger = this.Logger; return(volume); }
public async Task DetachVolumeAsync(Ec2Volume volume) { if (volume.VolumeId == null) { return; } this.Logger.Log("Detaching volume {0}", volume.VolumeId); await this.Client.DetachVolumeAsync(new DetachVolumeRequest() { Force = true, InstanceId = this.InstanceId, VolumeId = volume.VolumeId, }); }
public async Task ReconnectAsync(Ec2Volume volume, InstanceClient client, CancellationToken? cancellationToken = null) { this.Client = client; this.Volume = volume; this.DisplayName = volume.Name; this.Volume.Logger = this.Logger; this.RunCommands = (await this.Client.GetRunCommandsAsync(this.Volume.MountPoint)).ToArray(); this.UserInstruction = (await this.Client.GetUserInstructionAsync(this.Volume.MountPoint)).Replace("<PUBLIC-IP>", this.Volume.Instance.PublicIp); this.Logger.Log("Reconnected to volume"); await this.UpdateScriptsAsync(); if (await this.Client.IsCommandSessionStartedAsync(this.Volume.MountPoint, cancellationToken)) { this.VolumeState = "started"; this.gameCts = new CancellationTokenSource(); await this.Client.ResumeSessionAsync(this.Volume.MountPoint, this.Logger, this.gameCts.Token); } else { this.VolumeState = "mounted"; } }
public async Task SetupAsync(Ec2Volume volume, InstanceClient client) { this.Client = client; this.Volume = volume; this.Volume.Logger = this.Logger; this.DisplayName = volume.Name; try { this.cancelCts = new CancellationTokenSource(); await this.Volume.SetupAsync(this.Client, this.cancelCts.Token); this.VolumeState = "mounted"; this.RunCommands = (await this.Client.GetRunCommandsAsync(this.Volume.MountPoint, this.cancelCts.Token)).ToArray(); this.UserInstruction = (await this.Client.GetUserInstructionAsync(this.Volume.MountPoint, this.cancelCts.Token)).Replace("<PUBLIC-IP>", this.Volume.Instance.PublicIp); await this.UpdateScriptsAsync(); } finally { this.CancelCts = null; } }
public async Task DetachVolumeAsync(Ec2Volume volume) { if (volume.VolumeId == null) return; this.Logger.Log("Detaching volume {0}", volume.VolumeId); await this.Client.DetachVolumeAsync(new DetachVolumeRequest() { Force = true, InstanceId = this.InstanceId, VolumeId = volume.VolumeId, }); }
public async Task<string> AttachVolumeAsync(Ec2Volume volume) { string mountPoint = null; await this.volumeMountPointLock.WaitAsync(); { mountPoint = mountPoints.Except((await this.GetAttachedVolumesAsync()).Select(x => x.Attachments.FirstOrDefault(y => y.InstanceId == this.InstanceId).Device)).FirstOrDefault(); if (mountPoint == null) throw new Exception("Run out of mount points. You have too many volumes mounted!"); this.Logger.Log("Attaching volume to instance {0}, device {1}", this.InstanceId, mountPoint); var attachVolumeResponse = await this.Client.AttachVolumeAsync(new AttachVolumeRequest() { InstanceId = this.InstanceId, VolumeId = volume.VolumeId, Device = mountPoint, }); } this.volumeMountPointLock.Release(); return mountPoint; }
public Ec2Volume CreateVolume(int sizeGb, string name) { var volume = new Ec2Volume(this, name, sizeGb); volume.Logger = this.Logger; return volume; }
public Ec2Volume CreateVolume(string source, string name) { var volume = new Ec2Volume(this, source, name); volume.Logger = this.Logger; return volume; }