コード例 #1
0
        /// <summary>
        /// Syncs the collections on a PSJobSpecification with its wrapped OM object
        /// </summary>
        internal static void JobSpecificationSyncCollections(PSJobSpecification specification)
        {
            if (specification != null)
            {
                specification.omObject.CommonEnvironmentSettings = CreateSyncedDict(
                    specification.CommonEnvironmentSettings,
                    ConvertEnvironmentSetting);

                if (specification.JobManagerTask != null)
                {
                    JobManagerTaskSyncCollections(specification.JobManagerTask);
                }

                if (specification.JobPreparationTask != null)
                {
                    JobPreparationTaskSyncCollections(specification.JobPreparationTask);
                }

                if (specification.JobReleaseTask != null)
                {
                    JobReleaseTaskSyncCollections(specification.JobReleaseTask);
                }

                specification.omObject.Metadata = CreateSyncedDict(specification.Metadata, ConvertMetadataItem);

                if (specification.PoolInformation != null)
                {
                    PoolInformationSyncCollections(specification.PoolInformation);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates a test job schedule for use in Scenario tests.
        /// </summary>
        public static void CreateTestJobSchedule(BatchController controller, BatchAccountContext context, string jobScheduleId, TimeSpan?recurrenceInterval)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();

            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient           client    = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            PSJobSpecification jobSpecification = new PSJobSpecification();

            jobSpecification.PoolInformation        = new PSPoolInformation();
            jobSpecification.PoolInformation.PoolId = SharedPool;
            PSSchedule schedule = new PSSchedule();

            if (recurrenceInterval != null)
            {
                schedule = new PSSchedule();
                schedule.RecurrenceInterval = recurrenceInterval;
            }

            NewJobScheduleParameters parameters = new NewJobScheduleParameters(context, jobScheduleId, behaviors)
            {
                JobSpecification = jobSpecification,
                Schedule         = schedule
            };

            client.CreateJobSchedule(parameters);
        }
コード例 #3
0
ファイル: Utils.cs プロジェクト: vreddi/azure-powershell
 /// <summary>
 /// Syncs the collections on a PSJobSpecification with its wrapped OM object
 /// </summary>
 internal static void JobSpecificationSyncCollections(PSJobSpecification specification)
 {
     if (specification != null)
     {
         if (specification.JobManager != null)
         {
             JobManagerSyncCollections(specification.JobManager);
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// Syncs the collections on a PSJobSpecification with its wrapped OM object
        /// </summary>
        internal static void JobSpecificationSyncCollections(PSJobSpecification specification)
        {
            if (specification != null)
            {
                specification.omObject.CommonEnvironmentSettings = CreateSyncedList(specification.CommonEnvironmentSettings,
                                                                                    (e) =>
                {
                    EnvironmentSetting envSetting = new EnvironmentSetting(e.Name, e.Value);
                    return(envSetting);
                });

                if (specification.JobManagerTask != null)
                {
                    JobManagerTaskSyncCollections(specification.JobManagerTask);
                }

                if (specification.JobPreparationTask != null)
                {
                    JobPreparationTaskSyncCollections(specification.JobPreparationTask);
                }

                if (specification.JobReleaseTask != null)
                {
                    JobReleaseTaskSyncCollections(specification.JobReleaseTask);
                }

                specification.omObject.Metadata = CreateSyncedList(specification.Metadata,
                                                                   (m) =>
                {
                    MetadataItem metadata = new MetadataItem(m.Name, m.Value);
                    return(metadata);
                });

                if (specification.PoolInformation != null)
                {
                    PoolInformationSyncCollections(specification.PoolInformation);
                }
            }
        }
コード例 #5
0
        public void SetBatchJobScheduleParametersGetPassedToRequestTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            cmdlet.JobSchedule = new PSCloudJobSchedule(BatchTestHelpers.CreateFakeBoundJobSchedule(context));

            // Make changes to the job schedule
            PSJobSpecification jobSpec = new PSJobSpecification()
            {
                DisplayName = "job display name",
                CommonEnvironmentSettings = new List <PSEnvironmentSetting>()
                {
                    new PSEnvironmentSetting("common1", "val1"),
                    new PSEnvironmentSetting("common2", "val2")
                },
                JobManagerTask     = new PSJobManagerTask("job manager", "cmd /c echo job manager"),
                JobPreparationTask = new PSJobPreparationTask("cmd /c echo job prep"),
                JobReleaseTask     = new PSJobReleaseTask("cmd /c echo job release"),
                PoolInformation    = new PSPoolInformation()
                {
                    PoolId = "myPool"
                }
            };

            cmdlet.JobSchedule.JobSpecification = jobSpec;

            PSSchedule schedule = new PSSchedule()
            {
                DoNotRunAfter      = DateTime.Now.AddYears(1),
                DoNotRunUntil      = DateTime.Now.AddDays(1),
                RecurrenceInterval = TimeSpan.FromDays(1),
                StartWindow        = TimeSpan.FromHours(1)
            };

            cmdlet.JobSchedule.Schedule = schedule;

            cmdlet.JobSchedule.Metadata = new List <PSMetadataItem>()
            {
                new PSMetadataItem("metadata1", "value1")
            };

            // Store the request parameters
            JobScheduleUpdateParameter requestParameters = null;
            RequestInterceptor         interceptor       = BatchTestHelpers.CreateFakeServiceResponseInterceptor <
                JobScheduleUpdateParameter,
                JobScheduleUpdateOptions,
                AzureOperationHeaderResponse <JobScheduleUpdateHeaders> >(requestAction: (r) =>
            {
                requestParameters = r.Parameters;
            });

            cmdlet.AdditionalBehaviors = new BatchClientBehavior[] { interceptor };
            cmdlet.ExecuteCmdlet();

            // Verify that the request parameters contain the updated properties
            Assert.Equal(jobSpec.CommonEnvironmentSettings.Count, requestParameters.JobSpecification.CommonEnvironmentSettings.Count);
            Assert.Equal(jobSpec.CommonEnvironmentSettings[0].Name, requestParameters.JobSpecification.CommonEnvironmentSettings[0].Name);
            Assert.Equal(jobSpec.CommonEnvironmentSettings[0].Value, requestParameters.JobSpecification.CommonEnvironmentSettings[0].Value);
            Assert.Equal(jobSpec.CommonEnvironmentSettings[1].Name, requestParameters.JobSpecification.CommonEnvironmentSettings[1].Name);
            Assert.Equal(jobSpec.CommonEnvironmentSettings[1].Value, requestParameters.JobSpecification.CommonEnvironmentSettings[1].Value);
            Assert.Equal(jobSpec.JobManagerTask.Id, requestParameters.JobSpecification.JobManagerTask.Id);
            Assert.Equal(jobSpec.JobPreparationTask.CommandLine, requestParameters.JobSpecification.JobPreparationTask.CommandLine);
            Assert.Equal(jobSpec.JobReleaseTask.CommandLine, requestParameters.JobSpecification.JobReleaseTask.CommandLine);
            Assert.Equal(jobSpec.PoolInformation.PoolId, requestParameters.JobSpecification.PoolInfo.PoolId);
            Assert.Equal(schedule.DoNotRunAfter, requestParameters.Schedule.DoNotRunAfter);
            Assert.Equal(schedule.DoNotRunUntil, requestParameters.Schedule.DoNotRunUntil);
            Assert.Equal(schedule.RecurrenceInterval, requestParameters.Schedule.RecurrenceInterval);
            Assert.Equal(schedule.StartWindow, requestParameters.Schedule.StartWindow);
            Assert.Equal(cmdlet.JobSchedule.Metadata.Count, requestParameters.Metadata.Count);
            Assert.Equal(cmdlet.JobSchedule.Metadata[0].Name, requestParameters.Metadata[0].Name);
            Assert.Equal(cmdlet.JobSchedule.Metadata[0].Value, requestParameters.Metadata[0].Value);
        }