Exemple #1
0
        protected PSArgument[] CreateVirtualMachineOSImageUpdateParameters()
        {
            string imageName = string.Empty;
            VirtualMachineOSImageUpdateParameters parameters = new VirtualMachineOSImageUpdateParameters();

            return(ConvertFromObjectsToArguments(new string[] { "ImageName", "Parameters" }, new object[] { imageName, parameters }));
        }
Exemple #2
0
        protected void ExecuteVirtualMachineOSImageUpdateMethod(object[] invokeMethodInputParameters)
        {
            string imageName = (string)ParseParameter(invokeMethodInputParameters[0]);
            VirtualMachineOSImageUpdateParameters parameters = (VirtualMachineOSImageUpdateParameters)ParseParameter(invokeMethodInputParameters[1]);

            var result = VirtualMachineOSImageClient.Update(imageName, parameters);

            WriteObject(result);
        }
        public void UpdateVMImageProcess()
        {
            var parameters = new VirtualMachineOSImageUpdateParameters
            {
                Label = this.Label,
                Eula = this.Eula,
                Description = this.Description,
                ImageFamily = this.ImageFamily,
                PublishedDate = this.PublishedDate,
                PrivacyUri = this.PrivacyUri,
                RecommendedVMSize = this.RecommendedVMSize
            };

            this.ExecuteClientActionNewSM(
                null,
                this.CommandRuntime.ToString(),
                () => this.ComputeClient.VirtualMachineOSImages.Update(this.ImageName, parameters),
                (s, response) => this.ContextFactory<VirtualMachineOSImageUpdateResponse, OSImageContext>(response, s));
        }
        public void UpdateVMImageProcess()
        {
            var parameters = new VirtualMachineOSImageUpdateParameters
            {
                Label             = this.Label,
                Eula              = this.Eula,
                Description       = this.Description,
                ImageFamily       = this.ImageFamily,
                PublishedDate     = this.PublishedDate,
                PrivacyUri        = this.PrivacyUri,
                RecommendedVMSize = this.RecommendedVMSize
            };

            this.ExecuteClientActionNewSM(
                null,
                this.CommandRuntime.ToString(),
                () => this.ComputeClient.VirtualMachineOSImages.Update(this.ImageName, parameters),
                (s, response) => this.ContextFactory <VirtualMachineOSImageUpdateResponse, OSImageContext>(response, s));
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            var  imageType = new VirtualMachineImageHelper(this.ComputeClient).GetImageType(this.ImageName);
            bool isOSImage = imageType.HasFlag(VirtualMachineImageType.OSImage);
            bool isVMImage = imageType.HasFlag(VirtualMachineImageType.VMImage);

            if (isOSImage && isVMImage)
            {
                WriteErrorWithTimestamp(
                    string.Format(Resources.DuplicateNamesFoundInBothVMAndOSImages, this.ImageName));
            }
            else if (isOSImage)
            {
                var parameters = new VirtualMachineOSImageUpdateParameters
                {
                    Label             = this.Label,
                    Eula              = this.Eula,
                    Description       = this.Description,
                    ImageFamily       = this.ImageFamily,
                    PublishedDate     = this.PublishedDate,
                    PrivacyUri        = this.PrivacyUri,
                    RecommendedVMSize = this.RecommendedVMSize,
                    Language          = this.Language,
                    IconUri           = this.IconUri,
                    SmallIconUri      = this.SmallIconUri
                };

                this.ExecuteClientActionNewSM(
                    null,
                    this.CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachineOSImages.Update(this.ImageName, parameters),
                    (s, response) => this.ContextFactory <VirtualMachineOSImageUpdateResponse, OSImageContext>(response, s));
            }
            else
            {
                var osDiskConfig    = DiskConfig == null ? null : DiskConfig.OSDiskConfiguration;
                var dataDiskConfigs = DiskConfig == null ? null : DiskConfig.DataDiskConfigurations.ToList();

                var parameters = new VirtualMachineVMImageUpdateParameters
                {
                    Label                  = this.Label,
                    Eula                   = this.Eula,
                    Description            = this.Description,
                    ImageFamily            = this.ImageFamily,
                    PublishedDate          = this.PublishedDate,
                    PrivacyUri             = this.PrivacyUri,
                    RecommendedVMSize      = this.RecommendedVMSize,
                    OSDiskConfiguration    = Mapper.Map <OSDiskConfigurationUpdateParameters>(osDiskConfig),
                    DataDiskConfigurations = dataDiskConfigs == null ? null : dataDiskConfigs.Select(d => new DataDiskConfigurationUpdateParameters
                    {
                        HostCaching       = d.HostCaching,
                        LogicalUnitNumber = d.Lun,
                        Name = d.Name
                    }).ToList(),
                    Language     = this.Language,
                    IconUri      = this.IconUri,
                    SmallIconUri = this.SmallIconUri,
                    ShowInGui    = this.ShowInGui.IsPresent ? (bool?)this.ShowInGui : null
                };

                this.ExecuteClientActionNewSM(
                    null,
                    this.CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachineVMImages.Update(this.ImageName, parameters));
            }
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            var imageType = new VirtualMachineImageHelper(this.ComputeClient).GetImageType(this.ImageName);
            bool isOSImage = imageType.HasFlag(VirtualMachineImageType.OSImage);
            bool isVMImage = imageType.HasFlag(VirtualMachineImageType.VMImage);

            if (isOSImage && isVMImage)
            {
                WriteErrorWithTimestamp(
                    string.Format(Resources.DuplicateNamesFoundInBothVMAndOSImages, this.ImageName));
            }
            else if (isOSImage)
            {
                var parameters = new VirtualMachineOSImageUpdateParameters
                {
                    Label             = this.Label,
                    Eula              = this.Eula,
                    Description       = this.Description,
                    ImageFamily       = this.ImageFamily,
                    PublishedDate     = this.PublishedDate,
                    PrivacyUri        = this.PrivacyUri,
                    RecommendedVMSize = this.RecommendedVMSize,
                    Language          = this.Language,
                    IconUri           = this.IconUri,
                    SmallIconUri      = this.SmallIconUri
                };

                this.ExecuteClientActionNewSM(
                    null,
                    this.CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachineOSImages.Update(this.ImageName, parameters),
                    (s, response) => this.ContextFactory<VirtualMachineOSImageUpdateResponse, OSImageContext>(response, s));
            }
            else
            {
                var osDiskConfig    = DiskConfig == null ? null : DiskConfig.OSDiskConfiguration;
                var dataDiskConfigs = DiskConfig == null ? null : DiskConfig.DataDiskConfigurations.ToList();

                var parameters = new VirtualMachineVMImageUpdateParameters
                {
                    Label                  = this.Label,
                    Eula                   = this.Eula,
                    Description            = this.Description,
                    ImageFamily            = this.ImageFamily,
                    PublishedDate          = this.PublishedDate,
                    PrivacyUri             = this.PrivacyUri,
                    RecommendedVMSize      = this.RecommendedVMSize,
                    OSDiskConfiguration    = Mapper.Map<OSDiskConfigurationUpdateParameters>(osDiskConfig),
                    DataDiskConfigurations = dataDiskConfigs == null ? null : dataDiskConfigs.Select(d => new DataDiskConfigurationUpdateParameters
                    {
                        HostCaching       = d.HostCaching,
                        LogicalUnitNumber = d.Lun,
                        Name              = d.Name
                    }).ToList(),
                    Language               = this.Language,
                    IconUri                = this.IconUri,
                    SmallIconUri           = this.SmallIconUri,
                    ShowInGui              = this.ShowInGui.IsPresent ? (bool?)this.ShowInGui : null
                };

                this.ExecuteClientActionNewSM(
                    null,
                    this.CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachineVMImages.Update(this.ImageName, parameters));
            }
        }
Exemple #7
0
 /// <summary>
 /// The Update OS Image operation updates an OS image that in your
 /// image repository.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157198.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IVirtualMachineOSImageOperations.
 /// </param>
 /// <param name='imageName'>
 /// Required. The name of the virtual machine image to be updated.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Virtual Machine Image
 /// operation.
 /// </param>
 /// <returns>
 /// Parameters returned from the Create Virtual Machine Image operation.
 /// </returns>
 public static Task <VirtualMachineOSImageUpdateResponse> UpdateAsync(this IVirtualMachineOSImageOperations operations, string imageName, VirtualMachineOSImageUpdateParameters parameters)
 {
     return(operations.UpdateAsync(imageName, parameters, CancellationToken.None));
 }
Exemple #8
0
 /// <summary>
 /// The Update OS Image operation updates an OS image that in your
 /// image repository.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157198.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IVirtualMachineOSImageOperations.
 /// </param>
 /// <param name='imageName'>
 /// Required. The name of the virtual machine image to be updated.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Virtual Machine Image
 /// operation.
 /// </param>
 /// <returns>
 /// Parameters returned from the Create Virtual Machine Image operation.
 /// </returns>
 public static VirtualMachineOSImageUpdateResponse Update(this IVirtualMachineOSImageOperations operations, string imageName, VirtualMachineOSImageUpdateParameters parameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IVirtualMachineOSImageOperations)s).UpdateAsync(imageName, parameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }