Esempio n. 1
0
        //*********************************************************************
        ///
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmpReq"></param>
        ///
        //*********************************************************************

        private CreateVm MarshallVmInfo(Models.CmpRequest cmpReq)
        {
            return(new CreateVm
            {
                Id = cmpReq.Id,
                //Id = VmList.Count,
                CmpRequestId = Convert.ToInt32(cmpReq.CmpRequestID),
                Name = cmpReq.TargetVmName,
                SubscriptionId = cmpReq.WapSubscriptionID,
                StatusCode = cmpReq.StatusCode,
                StatusMessage = cmpReq.StatusMessage,
                ExceptionMessage = cmpReq.ExceptionMessage,
                VmAppName = cmpReq.ParentAppName,
                VmDomain = cmpReq.Domain,
                VmAdminName = "",
                //VmAdminPassword = "",
                VmSourceImage = cmpReq.SourceImageName,
                VmSize = cmpReq.VmSize,
                VmRegion = cmpReq.TargetLocation,
                VmRole = "",
                VmDiskSpec = "",
                VmConfig = cmpReq.Config,
                VmTagData = cmpReq.TagData,
                AddressFromVm = cmpReq.AddressFromVm
                                //ExtensionData = ""
            });
        }
Esempio n. 2
0
        private void SyncWithCmp(List <CreateVm> vmlist)
        {
            var cmpi = new VMServiceRepository(_eventLog);
            var cwdb = WapDbContract;

            foreach (CreateVm vM in vmlist)
            {
                if (vM.StatusCode.Equals(CmpInterfaceModel.Constants.StatusEnum.Complete.ToString()))
                {
                    continue;
                }

                try
                {
                    //*** Access the CMP service ***
                    var fetchedVm = cmpi.FetchCmpRequest(vM.CmpRequestId);

                    //*** update CmpWapDb if status has changed ***
                    //if (!vM.StatusCode.Equals(fetchedVm.Status))

                    if (true)
                    {
                        vM.StatusCode    = fetchedVm.Status;
                        vM.StatusMessage = fetchedVm.StatusMessage;

                        var cmpWapReq = new Models.CmpRequest
                        {
                            StatusCode       = fetchedVm.Status,
                            StatusMessage    = GetStatusMessage(fetchedVm),
                            ExceptionMessage = fetchedVm.ExceptionMessage,
                            Id     = vM.Id,
                            Config = fetchedVm.Config
                        };

                        if (null != fetchedVm.Config)
                        {
                            var vmc = CmpInterfaceModel.Models.VmConfig.Deserialize(fetchedVm.Config);
                            if (null != vmc)
                            {
                                if (null != vmc.InfoFromVM)
                                {
                                    cmpWapReq.AddressFromVm = vmc.InfoFromVM.VmAddress;
                                }
                            }
                        }

                        cwdb.SetVmDepRequestStatus(cmpWapReq, null);
                    }
                }
                catch (Exception)
                {
                    vM.StatusCode    = "NoCmpContact";
                    vM.StatusMessage = "Temporarily unable to contact CMP for status";
                }
            }
        }