Ejemplo n.º 1
0
        public ActionResult StartServer(StartServerModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var command = new StartServerCommand
                {
                    InstanceId = model.ServerId,
                    RequestedInstanceType = model.ServerType,
                    NotificationEmailAddress = model.EmailAddress
                };

                Ec2UtilitiesWebApp.Bus.Send(command);

                InstanceData.SetStatus(model.ServerId, ServerStartUpStatus.Initialized);

                return RedirectToAction("ServerStartUp");
            }

            // If we got this far, something failed, redisplay form
            return StartServer(model.ServerId);
        }
Ejemplo n.º 2
0
        public ActionResult StartServer(string instanceId)
        {
            var instanceManager = ObjectFactory.GetInstance<IInstanceManager>();

            Ec2UtilityInstance ec2UtilityInstance;
            var instanceSizes = new List<string>();

            try
            {
                ec2UtilityInstance = instanceManager.GetInstance(instanceId);
                instanceSizes = instanceManager.GetAvailableInstanceSizes(instanceId);
            }
            catch (ResourceAccessException)
            {
                var errMsg = string.Format("An error has occurred while retrieving the detals for instance id {0}. See server log file for details.", instanceId);
                ModelState.AddModelError("", errMsg);
                ec2UtilityInstance = new Ec2UtilityInstance {Status = Ec2UtilityInstanceStatus.Indeterminate};
            }

            var startServerModel = new StartServerModel(ec2UtilityInstance) {AvailableServerTypes = instanceSizes};

            return View(startServerModel);
        }