public void BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod, IReportStatus status)
        {
            SessionToken token = null;
            try
            {
                token = LogIn();
                var deviceId = GetDeviceId(token);
                var server = GetServer(serverName, farm, token, deviceId);

                var suspend = new suspendServerfarmRserver
                {
                    deviceID = deviceId,
                    reason = "ConDep deployment",
                    sessionToken = token,
                    suspendState = GetSuspendState(suspendMethod),
                    rserver = server
                };

                _proxy.suspendServerfarmRserver(new suspendServerfarmRserverRequest { suspendServerfarmRserver = suspend});
            }
            finally
            {
                if (_loggedIn)
                {
                    LogOut(token);
                }
            }
        }
Esempio n. 2
0
        public void BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod, IReportStatus status)
        {
            SessionToken token = null;

            try
            {
                token = LogIn();
                var      deviceIds = GetDeviceIds(token);
                DeviceID deviceId;
                var      server = GetServer(serverName, farm, token, deviceIds, out deviceId);

                var suspend = new suspendServerfarmRserver
                {
                    deviceID     = deviceId,
                    reason       = "ConDep deployment",
                    sessionToken = token,
                    suspendState = GetSuspendState(suspendMethod),
                    rserver      = server
                };

                _proxy.suspendServerfarmRserver(new suspendServerfarmRserverRequest {
                    suspendServerfarmRserver = suspend
                });
            }
            finally
            {
                if (_loggedIn)
                {
                    LogOut(token);
                }
            }
        }
        public void BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod, IReportStatus status)
        {
            var result = ChangeServerState(serverName, farm, ServerState.Offline);

            if (!result.IsSuccessStatusCode)
                throw new ConDepLoadBalancerException(string.Format("Failed to take server {0} offline in loadbalancer. Returned status code was {1} with reason: {2}", serverName, result.StatusCode, result.ReasonPhrase));

            Logger.Verbose(string.Format("Waiting {0} seconds to give load balancer a chance to set server i maintenance mode.", _waitTimeInSecondsAfterSettingServerStateToOffline));
            Thread.Sleep(_waitTimeInSecondsAfterSettingServerStateToOffline * 1000);

            Logger.Verbose("Waiting for server connections to drain.");
            WaitForCurrentConnectionsToDrain(farm, serverName, _snmpEndpoint, _snmpPort, _snmpCommunity, DateTime.Now.AddSeconds(_config.TimeoutInSeconds));
        }
Esempio n. 4
0
        public Result BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod)
        {
            var result = ChangeServerState(serverName, farm, ServerState.Offline);

            if (!result.IsSuccessStatusCode)
            {
                throw new ConDepLoadBalancerException(string.Format("Failed to take server {0} offline in loadbalancer. Returned status code was {1} with reason: {2}", serverName, result.StatusCode, result.ReasonPhrase));
            }

            Logger.Verbose(string.Format("Waiting {0} seconds to give load balancer a chance to set server i maintenance mode.", _waitTimeInSecondsAfterSettingServerStateToOffline));
            Thread.Sleep(_waitTimeInSecondsAfterSettingServerStateToOffline * 1000);

            Logger.Verbose("Waiting for server connections to drain.");
            WaitForCurrentConnectionsToDrain(farm, serverName, _snmpEndpoint, _snmpPort, _snmpCommunity, DateTime.Now.AddSeconds(_config.TimeoutInSeconds));
            return(new Result(true, false));
        }
Esempio n. 5
0
        private SuspendState GetSuspendState(LoadBalancerSuspendMethod suspendMethod)
        {
            switch (suspendMethod)
            {
            case LoadBalancerSuspendMethod.Graceful:
                return(SuspendState.Graceful);

            case LoadBalancerSuspendMethod.Suspend:
                return(SuspendState.Suspend);

            case LoadBalancerSuspendMethod.SuspendClearConnections:
                return(SuspendState.Suspend_Clear_Connections);

            default:
                throw new ConDepLoadBalancerException("Suspend method not supported");
            }
        }
Esempio n. 6
0
        public Result BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod)
        {
            var credentials = GetCredentials(_config.CustomConfig);
            var endpoint    = GetEndpoint(_config.CustomConfig);

            var ec2Client = new AmazonEC2Client(credentials, endpoint);
            var client    = new AmazonElasticLoadBalancingClient(credentials, endpoint);

            var request = new DeregisterInstancesFromLoadBalancerRequest(farm, new List <Instance> {
                new Instance(GetInstanceId(ec2Client, serverName))
            });
            var response = client.DeregisterInstancesFromLoadBalancer(request);
            var result   = Result.SuccessChanged();

            result.Data.HttpStatusCode  = response.HttpStatusCode;
            result.Data.ActiveInstances = response.Instances;
            return(result);
        }
 private SuspendState GetSuspendState(LoadBalancerSuspendMethod suspendMethod)
 {
     switch(suspendMethod)
     {
         case LoadBalancerSuspendMethod.Graceful:
             return SuspendState.Graceful;
         case LoadBalancerSuspendMethod.Suspend:
             return SuspendState.Suspend;
         case LoadBalancerSuspendMethod.SuspendClearConnections:
             return SuspendState.Suspend_Clear_Connections;
         default:
             throw new Exception("Suspend method not supported");
     }
 }
Esempio n. 8
0
 public void BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod, IReportStatus status)
 {
     _onlineOfflineSequence.Add(new Tuple <string, string>(serverName, "offline"));
 }
Esempio n. 9
0
 public void BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod, IReportStatus status)
 {
 }
 public void BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod, IReportStatus status)
 {
     Execute(LoadBalanceState.Offline, serverName, status);
 }
 public Result BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod)
 {
     return(Result.SuccessUnChanged());
 }
Esempio n. 12
0
 public void BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod, IReportStatus status)
 {
     Logger.Warn("Warning: No load balancer is used. If this is not by intention, make sure you configure a provider for load balancing.");
 }
 public Result BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod)
 {
     return Result.SuccessUnChanged();
 }
Esempio n. 14
0
 public Result BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod)
 {
     _onlineOfflineSequence.Add(new Tuple <string, string>(serverName, "offline"));
     return(Result.SuccessChanged());
 }
Esempio n. 15
0
 public void BringOffline(string serverName, string farm, LoadBalancerSuspendMethod suspendMethod, IReportStatus status)
 {
     _onlineOfflineSequence.Add(new Tuple<string,string>(serverName, "offline"));
 }