/// <summary>
        /// Gets the provider type with which the service client calls are to made to contact the backend service. 
        /// This can be determined by the container type in case of certain containers such as those of the type AzureVM.
        /// </summary>
        /// <param name="containerType">Type of the container</param>
        /// <returns></returns>
        public static string GetServiceClientProviderType(CmdletModel.ContainerType containerType)
        {
            string providerType = string.Empty;

            switch (containerType)
            {
                case CmdletModel.ContainerType.AzureVM:
                    providerType = ServiceClientModel.BackupManagementType.AzureIaasVM.ToString();
                    break;
                default:
                    break;
            }

            return providerType;
        }
        /// <summary>
        /// Gets the provider type with which the service client calls are to made to contact the backend service. 
        /// This is determined by the workload type in case of certain containers such as those of the type AzureVM.
        /// </summary>
        /// <param name="workloadType"></param>
        /// <returns></returns>
        public static string GetServiceClientProviderType(CmdletModel.WorkloadType workloadType)
        {
            string providerType = string.Empty;

            switch (workloadType)
            {
                case CmdletModel.WorkloadType.AzureVM:
                    providerType = ServiceClientModel.BackupManagementType.AzureIaasVM.ToString();
                    break;
                case CmdletModel.WorkloadType.AzureSQLDatabase:
                    providerType = ServiceClientModel.BackupManagementType.AzureSql.ToString();
                    break;
                default:
                    break;
            }

            return providerType;
        }
 private void ValidateAzureVMContainerType(CmdletModel.ContainerType type)
 {
     if (type != CmdletModel.ContainerType.AzureVM)
     {
         throw new ArgumentException(string.Format(Resources.UnExpectedContainerTypeException,
                                     CmdletModel.ContainerType.AzureVM.ToString(),
                                     type.ToString()));
     }
 }
 private void ValidateAzureVMWorkloadType(CmdletModel.WorkloadType itemWorkloadType,
     CmdletModel.WorkloadType policyWorkloadType)
 {
     ValidateAzureVMWorkloadType(itemWorkloadType);
     ValidateAzureVMWorkloadType(policyWorkloadType);
     if (itemWorkloadType != policyWorkloadType)
     {
         throw new ArgumentException(string.Format(Resources.UnExpectedWorkLoadTypeException,
                                     CmdletModel.WorkloadType.AzureVM.ToString(),
                                     itemWorkloadType.ToString()));
     }
 }
        private void CopyScheduleTimeToRetentionTimes(CmdletModel.LongTermRetentionPolicy retPolicy,
                                                      CmdletModel.SimpleSchedulePolicy schPolicy)
        {
            // schedule runTimes is already validated if in UTC/not during validate()
            // now copy times from schedule to retention policy
            if (retPolicy.IsDailyScheduleEnabled && retPolicy.DailySchedule != null)
            {
                retPolicy.DailySchedule.RetentionTimes = schPolicy.ScheduleRunTimes;
            }

            if (retPolicy.IsWeeklyScheduleEnabled && retPolicy.WeeklySchedule != null)
            {
                retPolicy.WeeklySchedule.RetentionTimes = schPolicy.ScheduleRunTimes;
            }

            if (retPolicy.IsMonthlyScheduleEnabled && retPolicy.MonthlySchedule != null)
            {
                retPolicy.MonthlySchedule.RetentionTimes = schPolicy.ScheduleRunTimes;
            }

            if (retPolicy.IsYearlyScheduleEnabled && retPolicy.YearlySchedule != null)
            {
                retPolicy.YearlySchedule.RetentionTimes = schPolicy.ScheduleRunTimes;
            }
        }
        /// <summary>
        /// Gets the service client specific workload type given the PS workload type
        /// </summary>
        /// <param name="workloadType"></param>
        /// <returns></returns>
        public static string GetServiceClientWorkloadType(CmdletModel.WorkloadType workloadType)
        {
            string serviceClientWorkloadType = string.Empty;

            switch (workloadType)
            {
                case CmdletModel.WorkloadType.AzureVM:
                    serviceClientWorkloadType = ServiceClientModel.WorkloadType.VM.ToString();
                    break;
                default:
                    break;
            }

            return serviceClientWorkloadType;
        }
        /// <summary>
        /// Gets the service client specific container type given the PS container type
        /// </summary>
        /// <param name="containerType">PS container type</param>
        /// <returns></returns>
        public static string GetServiceClientContainerType(CmdletModel.ContainerType containerType)
        {
            string serviceClientContainerType = string.Empty;

            switch (containerType)
            {
                case CmdletModel.ContainerType.AzureVM:
                    serviceClientContainerType = ServiceClientModel.ContainerType.IaasVMContainer.ToString();
                    break;
                default:
                    break;
            }

            return serviceClientContainerType;
        }
 private void ValidateAzureSqlWorkloadType(CmdletModel.WorkloadType type)
 {
     if (type != CmdletModel.WorkloadType.AzureSQLDatabase)
     {
         throw new ArgumentException(
             string.Format(
                 Resources.UnExpectedWorkLoadTypeException,
                 CmdletModel.WorkloadType.AzureSQLDatabase.ToString(),
                 type.ToString()));
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Helper function to get job type from ps backup management type.
 /// </summary>
 public static string GetJobTypeForService(CmdletModel.BackupManagementType mgmtType)
 {
     switch (mgmtType)
     {
         case CmdletModel.BackupManagementType.AzureVM:
             return BackupManagementType.AzureIaasVM.ToString();
         default:
             throw new Exception("Invalid BackupManagementType provided: " + mgmtType);
     }
 }