internal override bool WillHandle(ZAwsObject TargetObject) { return(TargetObject.GetType() == typeof(ZAwsEc2) && ((ZAwsEc2)TargetObject).Id == Ec2.Id && ((ZAwsEc2)TargetObject).AssociatedIP != null && ((ZAwsEc2)TargetObject).Status == ZAwsEc2.Ec2Status.Running); }
public void HandleNewObject(ZAwsObject TargetObject) { lock (myLock) { myTagetObjects.Enqueue(TargetObject); runnerEver.Set(); } }
internal override void DoExecute(ZAwsObject TargetObject) { if (AppsToInstall != null) { foreach (var app in AppsToInstall) { ((ZAwsEc2)TargetObject).InstallApp(app.AppName, app.AppUrl, app.AppLocation, app.TypeIsRails ? ZAwsEc2.ApplicationType.RAILS_APP : ZAwsEc2.ApplicationType.GENERIC, app.CreateUrlRecords, app.DefaultServerApp); } ((ZAwsEc2)TargetObject).Reboot(); Thread.Sleep(5000); } }
internal override bool WillHandle(ZAwsObject TargetObject) { if (TargetObject.GetType() == typeof(ZAwsEc2) && TargetObject.Name == Ec2Name && ((ZAwsEc2)TargetObject).Status == ZAwsEc2.Ec2Status.Running) { try { ((ZAwsEc2)TargetObject).SshClient.SendLine("echo \"Testing if SSH is ready.\""); return(true); } catch { Program.TraceLine("Fail, will try again very soon."); return(false); } } else { return(false); } }
internal override bool WillHandle(ZAwsObject TargetObject) { return TargetObject.GetType() == typeof(ZAwsEc2) && TargetObject.Id == SpotRequest.InstanceId && ((ZAwsEc2)TargetObject).Status == ZAwsEc2.Ec2Status.Running; }
internal override void DoExecute(ZAwsObject TargetObject) { ((ZAwsEc2)TargetObject).SetName(Ec2NewName); }
internal override bool WillHandle(ZAwsObject TargetObject) { return TargetObject.GetType() == typeof(ZAwsElasticIp) && !((ZAwsElasticIp)TargetObject).Associated && Ec2.Status == ZAwsEc2.Ec2Status.Running; }
internal override bool WillHandle(ZAwsObject TargetObject) { return(TargetObject.GetType() == typeof(ZAwsSpotRequest) && TargetObject.Id == SpotRequestId && !string.IsNullOrWhiteSpace(((ZAwsSpotRequest)TargetObject).InstanceId)); }
internal abstract bool WillHandle(ZAwsObject TargetObject);
internal override bool WillHandle(ZAwsObject TargetObject) { return TargetObject.GetType() == typeof(ZAwsEc2) && ((ZAwsEc2)TargetObject).Id == Ec2.Id && ((ZAwsEc2)TargetObject).AssociatedIP != null && ((ZAwsEc2)TargetObject).Status == ZAwsEc2.Ec2Status.Running; }
internal override bool WillHandle(ZAwsObject TargetObject) { if (TargetObject.GetType() == typeof(ZAwsEc2) && TargetObject.Name == Ec2Name && ((ZAwsEc2)TargetObject).Status == ZAwsEc2.Ec2Status.Running) { try { ((ZAwsEc2)TargetObject).SshClient.SendLine("echo \"Testing if SSH is ready.\""); return true; } catch { Program.TraceLine("Fail, will try again very soon."); return false; } } else { return false; } }
internal override void DoExecute(ZAwsObject TargetObject) { Ec2.PointUrl(Url); }
internal override bool WillHandle(ZAwsObject TargetObject) { return(TargetObject.GetType() == typeof(ZAwsElasticIp) && !((ZAwsElasticIp)TargetObject).Associated && Ec2.Status == ZAwsEc2.Ec2Status.Running); }
internal override void DoExecute(ZAwsObject TargetObject) { ((ZAwsElasticIp)TargetObject).Associate(Ec2); }
internal override bool WillHandle(ZAwsObject TargetObject) { return(TargetObject.GetType() == typeof(ZAwsEc2) && TargetObject.Id == SpotRequest.InstanceId && ((ZAwsEc2)TargetObject).Status == ZAwsEc2.Ec2Status.Running); }
internal override bool WillHandle(ZAwsObject TargetObject) { return TargetObject.GetType() == typeof(ZAwsSpotRequest) && TargetObject.Id == SpotRequestId && !string.IsNullOrWhiteSpace(((ZAwsSpotRequest)TargetObject).InstanceId); }
internal override void DoExecute(ZAwsObject TargetObject) { MyQueue.AddTask(new ZAwsTaskHandleNewSpotRequestBasedEc2Instance((ZAwsSpotRequest)TargetObject, Ec2NewName)); }
abstract internal void DoExecute(ZAwsObject TargetObject);
abstract internal bool WillHandle(ZAwsObject TargetObject);
internal abstract void DoExecute(ZAwsObject TargetObject);
internal ZAwsTaskHandler(ZAwsEc2Controller controller) { myController = controller; handlerThread = new Thread(new ThreadStart(delegate { Thread.CurrentThread.Name = "TaskHandler"; while (runner) { ZAwsObject currentObject = null; lock (myLock) { try { currentObject = myTagetObjects.Dequeue(); } catch (System.InvalidOperationException) { if (!runner) { return; } runnerEver.Reset(); } } if (currentObject == null) { //Now wait for the next object to be added runnerEver.WaitOne(3000); continue; } while (true) { ZAwsTask currentTask = null; lock (myLock) { for (int i = 0; i < myTaskList.Count; i++) { if (myTaskList[i].WillHandle(currentObject)) { //remove this task from list currentTask = myTaskList[i]; myTaskList.RemoveAt(i); break; } } } if (currentTask == null) { break; } if (sleepEvent.WaitOne(currentTask.DelayBeforeTaskStart * 1000)) { //This event is only set by the Close function, so if this returns true, you should close right away return; } Program.TraceLine(currentTask.StartMessage); try { currentTask.DoExecute(currentObject); Program.TraceLine(currentTask.SuccessMessage); } catch (Exception ex) { Program.TraceLine(currentTask.ExceptionMessage, ex); } } } })); handlerThread.Start(); }
public ZAwsNewObjectEventArgs(ZAwsObject arg) { NewObject = arg; }