Esempio n. 1
0
 public ServerListModel(Ec2UtilityInstance ec2UtilityInstance)
 {
     ServerId = ec2UtilityInstance.InstanceId;
     ServerName = ec2UtilityInstance.InstanceName;
     ServerType = ec2UtilityInstance.InstanceType;
     ServerStatus = ec2UtilityInstance.Status.ToString();
 }
Esempio n. 2
0
 public StartServerModel(Ec2UtilityInstance ec2UtilityInstance)
 {
     ServerId = ec2UtilityInstance.InstanceId;
     ServerName = ec2UtilityInstance.InstanceName;
     ServerStatus = ec2UtilityInstance.Status.ToString();
     ServerType = ec2UtilityInstance.InstanceType;
     AvailableServerTypes = new List<string>();
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public List<Ec2UtilityInstance> GetInstances()
        {
            _logger.Debug("Get Instances Start.");

            Ec2Key ec2Key = _configResourceAccess.GetEc2Key();
            DescribeInstancesResult ec2Instances = _ec2ResourceAccess.GetInstances(ec2Key);

            var returnInstances = new List<Ec2UtilityInstance>();
            foreach (var reservation in ec2Instances.Reservation)
            {
                foreach (var runningInstance in reservation.RunningInstance)
                {
                    var returnInstance = new Ec2UtilityInstance();

                    returnInstance.InstanceId = runningInstance.InstanceId;
                    returnInstance.InstanceName = runningInstance.Tag.GetTagValueByKey("Name");
                    returnInstance.Status = (Ec2UtilityInstanceStatus)Enum.Parse(typeof(Ec2UtilityInstanceStatus), runningInstance.InstanceState.Name, true);
                    returnInstance.DefaultIp = runningInstance.Tag.GetTagValueByKey("DefaultIp");
                    returnInstance.InstanceType = runningInstance.InstanceType;
                    returnInstance.ImageId = runningInstance.ImageId;

                    returnInstances.Add(returnInstance);
                }
            }

            _logger.Debug("Get Instances End.");

            return returnInstances;
        }