예제 #1
0
        public VmDashboardInfo GetVm(string subscriptionId, int Id)
        {
            try
            {
                ICmpWapDb cwdb = new CmpWapDb();
                ICmpWapDbTenantRepository cwdbTenant = new CmpWapDb();

                var foundVmDepRequest = cwdb.FetchVmDepRequest(Id);
                var vmsizes           = cwdbTenant.FetchVmSizeInfoList(subscriptionId);
                if (null != foundVmDepRequest && null != foundVmDepRequest.CmpRequestID)
                {
                    var cmpi = new VMServiceRepository(_eventLog);

                    //when we solve the big 'method not returning' bug: uncomment line below, delete second line below
                    //var vm = cmpi.GetVm(Convert.ToInt32(foundVmDepRequest.CmpRequestID),
                    //    CmpInterfaceModel.Constants.FetchType.AzureStatus);
                    var vm = GetLocalvmDBI(foundVmDepRequest);
                    cwdb.UpdateVmIp(Id, vm.InternalIP);
                    vm.Cores = vmsizes.Where(x => x.Name == vm.RoleSize).Select(x => x.Cores).FirstOrDefault().ToString();
                    vm.OSVirtualHardDisk.Type = "OS Disk";
                    if (vm.DataVirtualHardDisks != null)
                    {
                        vm.DataVirtualHardDisks.Select(d => { d.Type = "Data Disk"; return(d); }).ToList();
                    }
                    return(vm);
                }
                return(null);
            }
            catch (Exception ex)
            {
                LogThis(ex, EventLogEntryType.Error, "CmpWapExtension.VmsController.GetVm()", 100, 1);
                throw;
            }
        }