Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 public void HandleNewObject(ZAwsObject TargetObject)
 {
     lock (myLock)
     {
         myTagetObjects.Enqueue(TargetObject);
         runnerEver.Set();
     }
 }
Esempio n. 3
0
 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);
     }
 }
Esempio n. 4
0
 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);
     }
 }
Esempio n. 5
0
 internal override bool WillHandle(ZAwsObject TargetObject)
 {
     return TargetObject.GetType() == typeof(ZAwsEc2) && TargetObject.Id == SpotRequest.InstanceId && ((ZAwsEc2)TargetObject).Status == ZAwsEc2.Ec2Status.Running;
 }
Esempio n. 6
0
 internal override void DoExecute(ZAwsObject TargetObject)
 {
     ((ZAwsEc2)TargetObject).SetName(Ec2NewName);
 }
Esempio n. 7
0
 internal override bool WillHandle(ZAwsObject TargetObject)
 {
     return TargetObject.GetType() == typeof(ZAwsElasticIp) && !((ZAwsElasticIp)TargetObject).Associated && Ec2.Status == ZAwsEc2.Ec2Status.Running;
 }
Esempio n. 8
0
 internal override bool WillHandle(ZAwsObject TargetObject)
 {
     return(TargetObject.GetType() == typeof(ZAwsSpotRequest) &&
            TargetObject.Id == SpotRequestId &&
            !string.IsNullOrWhiteSpace(((ZAwsSpotRequest)TargetObject).InstanceId));
 }
Esempio n. 9
0
 internal abstract bool WillHandle(ZAwsObject TargetObject);
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
 internal override void DoExecute(ZAwsObject TargetObject)
 {
     ((ZAwsEc2)TargetObject).SetName(Ec2NewName);
 }
Esempio n. 12
0
 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;
     }
 }
Esempio n. 13
0
 internal override void DoExecute(ZAwsObject TargetObject)
 {
     Ec2.PointUrl(Url);
 }
Esempio n. 14
0
 internal override bool WillHandle(ZAwsObject TargetObject)
 {
     return(TargetObject.GetType() == typeof(ZAwsElasticIp) && !((ZAwsElasticIp)TargetObject).Associated && Ec2.Status == ZAwsEc2.Ec2Status.Running);
 }
Esempio n. 15
0
 internal override void DoExecute(ZAwsObject TargetObject)
 {
     ((ZAwsElasticIp)TargetObject).Associate(Ec2);
 }
Esempio n. 16
0
 internal override bool WillHandle(ZAwsObject TargetObject)
 {
     return(TargetObject.GetType() == typeof(ZAwsEc2) && TargetObject.Id == SpotRequest.InstanceId && ((ZAwsEc2)TargetObject).Status == ZAwsEc2.Ec2Status.Running);
 }
Esempio n. 17
0
 public void HandleNewObject(ZAwsObject TargetObject)
 {
     lock (myLock)
     {
         myTagetObjects.Enqueue(TargetObject);
         runnerEver.Set();
     }
 }
Esempio n. 18
0
 internal override bool WillHandle(ZAwsObject TargetObject)
 {
     return TargetObject.GetType() == typeof(ZAwsSpotRequest)
         && TargetObject.Id == SpotRequestId
         && !string.IsNullOrWhiteSpace(((ZAwsSpotRequest)TargetObject).InstanceId);
 }
Esempio n. 19
0
 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);
     }
 }
Esempio n. 20
0
 internal override void DoExecute(ZAwsObject TargetObject)
 {
     MyQueue.AddTask(new ZAwsTaskHandleNewSpotRequestBasedEc2Instance((ZAwsSpotRequest)TargetObject, Ec2NewName));
 }
Esempio n. 21
0
 internal override void DoExecute(ZAwsObject TargetObject)
 {
     MyQueue.AddTask(new ZAwsTaskHandleNewSpotRequestBasedEc2Instance((ZAwsSpotRequest)TargetObject, Ec2NewName));
 }
Esempio n. 22
0
 abstract internal void DoExecute(ZAwsObject TargetObject);
Esempio n. 23
0
 internal override void DoExecute(ZAwsObject TargetObject)
 {
     Ec2.PointUrl(Url);
 }
Esempio n. 24
0
 abstract internal bool WillHandle(ZAwsObject TargetObject);
Esempio n. 25
0
 internal abstract void DoExecute(ZAwsObject TargetObject);
Esempio n. 26
0
        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();
        }
Esempio n. 27
0
 public ZAwsNewObjectEventArgs(ZAwsObject arg)
 {
     NewObject = arg;
 }
Esempio n. 28
0
 internal override void DoExecute(ZAwsObject TargetObject)
 {
     ((ZAwsElasticIp)TargetObject).Associate(Ec2);
 }