Exemplo n.º 1
0
        public OSImage UpdateVMImageProcess(out string operationId)
        {
            operationId = string.Empty;
            OSImage oSImage = null;

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                try
                {
                    OSImage imageName = new OSImage();
                    imageName.Name  = this.ImageName;
                    imageName.Label = this.Label;
                    OSImage oSImage1 = imageName;
                    CmdletExtensions.WriteVerboseOutputForObject(this, oSImage1);
                    oSImage = base.RetryCall <OSImage>((string s) => base.Channel.UpdateOSImage(s, this.ImageName, oSImage1));
                    Operation operation = base.WaitForOperation(base.CommandRuntime.ToString());
                    ManagementOperationContext managementOperationContext = new ManagementOperationContext();
                    managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString());
                    managementOperationContext.set_OperationId(operation.OperationTrackingId);
                    managementOperationContext.set_OperationStatus(operation.Status);
                    ManagementOperationContext managementOperationContext1 = managementOperationContext;
                    base.WriteObject(managementOperationContext1, true);
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    this.WriteErrorDetails(communicationException);
                }
            }
            return(oSImage);
        }
Exemplo n.º 2
0
 protected override void ProcessRecord()
 {
     try
     {
         base.ProcessRecord();
         string  empty   = string.Empty;
         OSImage oSImage = this.UpdateVMImageProcess(out empty);
         if (oSImage != null)
         {
             OSImageContext oSImageContext = new OSImageContext();
             oSImageContext.set_OperationId(empty);
             oSImageContext.AffinityGroup = oSImage.AffinityGroup;
             oSImageContext.Category      = oSImage.Category;
             oSImageContext.Label         = oSImage.Label;
             oSImageContext.Location      = oSImage.Location;
             oSImageContext.MediaLink     = oSImage.MediaLink;
             oSImageContext.ImageName     = oSImage.Name;
             oSImageContext.OS            = oSImage.OS;
             OSImageContext oSImageContext1 = oSImageContext;
             base.WriteObject(oSImageContext1, true);
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null));
     }
 }
Exemplo n.º 3
0
        public IEnumerable <OSImage> GetVMImageProcess(out Operation operation)
        {
            IEnumerable <OSImage>      oSImages;
            Func <string, OSImage>     func  = null;
            Func <string, OSImageList> func1 = null;

            operation = null;
            IEnumerable <OSImage> oSImages1 = null;

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                try
                {
                    if (string.IsNullOrEmpty(this.ImageName))
                    {
                        GetAzureVMImageCommand getAzureVMImageCommand = this;
                        if (func1 == null)
                        {
                            func1 = (string s) => base.Channel.ListOSImages(s);
                        }
                        oSImages1 = ((CmdletBase <IServiceManagement>)getAzureVMImageCommand).RetryCall <OSImageList>(func1);
                    }
                    else
                    {
                        OSImage[] oSImageArray  = new OSImage[1];
                        OSImage[] oSImageArray1 = oSImageArray;
                        int       num           = 0;
                        GetAzureVMImageCommand getAzureVMImageCommand1 = this;
                        if (func == null)
                        {
                            func = (string s) => base.Channel.GetOSImage(s, this.ImageName);
                        }
                        oSImageArray1[num] = ((CmdletBase <IServiceManagement>)getAzureVMImageCommand1).RetryCall <OSImage>(func);
                        oSImages1          = oSImageArray;
                    }
                    operation = base.WaitForOperation(base.CommandRuntime.ToString());
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    if (communicationException as EndpointNotFoundException == null || base.IsVerbose())
                    {
                        this.WriteErrorDetails(communicationException);
                    }
                    else
                    {
                        oSImages = null;
                        return(oSImages);
                    }
                }
                return(oSImages1);
            }
            return(oSImages);
        }
        public void RemoveVMImageProcess()
        {
            Func <string, OSImage> func   = null;
            Action <string>        action = null;

            try
            {
                Uri             mediaLink = null;
                SwitchParameter deleteVHD = this.DeleteVHD;
                if (deleteVHD.IsPresent)
                {
                    using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
                    {
                        RemoveAzureVMImageCommand removeAzureVMImageCommand = this;
                        if (func == null)
                        {
                            func = (string s) => base.Channel.GetOSImage(s, this.ImageName);
                        }
                        OSImage oSImage = ((CmdletBase <IServiceManagement>)removeAzureVMImageCommand).RetryCall <OSImage>(func);
                        mediaLink = oSImage.MediaLink;
                    }
                }
                using (OperationContextScope operationContextScope1 = new OperationContextScope((IContextChannel)base.Channel))
                {
                    RemoveAzureVMImageCommand removeAzureVMImageCommand1 = this;
                    if (action == null)
                    {
                        action = (string s) => base.Channel.DeleteOSImage(s, this.ImageName);
                    }
                    ((CmdletBase <IServiceManagement>)removeAzureVMImageCommand1).RetryCall(action);
                    Operation operation = base.WaitForOperation(base.CommandRuntime.ToString());
                    ManagementOperationContext managementOperationContext = new ManagementOperationContext();
                    managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString());
                    managementOperationContext.set_OperationId(operation.OperationTrackingId);
                    managementOperationContext.set_OperationStatus(operation.Status);
                    ManagementOperationContext managementOperationContext1 = managementOperationContext;
                    base.WriteObject(managementOperationContext1, true);
                }
                SwitchParameter switchParameter = this.DeleteVHD;
                if (switchParameter.IsPresent)
                {
                    Disks.RemoveVHD(base.Channel, base.get_CurrentSubscription().get_SubscriptionId(), mediaLink);
                }
            }
            catch (CommunicationException communicationException1)
            {
                CommunicationException communicationException = communicationException1;
                this.WriteErrorDetails(communicationException);
            }
        }
Exemplo n.º 5
0
        public void AddVMImageProcess()
        {
            AddAzureVMImageCommand.AddAzureVMImageCommand variable = null;
            string imageName;

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                try
                {
                    AddAzureVMImageCommand.AddAzureVMImageCommand variable1 = variable;
                    OSImage oSImage = new OSImage();
                    oSImage.Name      = this.ImageName;
                    oSImage.MediaLink = new Uri(this.MediaLocation);
                    OSImage oSImage1 = oSImage;
                    if (string.IsNullOrEmpty(this.Label))
                    {
                        imageName = this.ImageName;
                    }
                    else
                    {
                        imageName = this.Label;
                    }
                    oSImage1.Label  = imageName;
                    oSImage.OS      = this.OS;
                    variable1.image = oSImage;
                    CmdletExtensions.WriteVerboseOutputForObject(this, LambdaVar23);
                    OSImage        oSImage2       = base.RetryCall <OSImage>((string s) => base.Channel.CreateOSImage(s, LambdaVar23));
                    OSImageContext oSImageContext = new OSImageContext();
                    oSImageContext.AffinityGroup = oSImage2.AffinityGroup;
                    oSImageContext.Category      = oSImage2.Category;
                    oSImageContext.Label         = oSImage2.Label;
                    oSImageContext.Location      = oSImage2.Location;
                    oSImageContext.MediaLink     = oSImage2.MediaLink;
                    oSImageContext.ImageName     = oSImage2.Name;
                    oSImageContext.OS            = oSImage2.OS;
                    OSImageContext oSImageContext1 = oSImageContext;
                    Operation      operation       = base.WaitForOperation(base.CommandRuntime.ToString());
                    oSImageContext1.set_OperationDescription(base.CommandRuntime.ToString());
                    oSImageContext1.set_OperationId(operation.OperationTrackingId);
                    oSImageContext1.set_OperationStatus(operation.Status);
                    base.WriteObject(oSImageContext1, true);
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    this.WriteErrorDetails(communicationException);
                }
            }
        }
Exemplo n.º 6
0
        public void ExecuteCommand()
        {
            var image = new OSImage
            {
                Name              = this.ImageName,
                MediaLink         = new Uri(this.MediaLocation),
                Label             = string.IsNullOrEmpty(this.Label) ? this.ImageName : this.Label,
                OS                = this.OS,
                Eula              = this.Eula,
                Description       = this.Description,
                ImageFamily       = this.ImageFamily,
                PublishedDate     = this.PublishedDate,
                PrivacyUri        = this.PrivacyUri,
                RecommendedVMSize = this.RecommendedVMSize
            };

            ExecuteClientActionInOCS(
                image,
                CommandRuntime.ToString(),
                s => this.Channel.CreateOSImage(s, image),
                (op, responseImage) => new OSImageContext
            {
                AffinityGroup        = responseImage.AffinityGroup,
                Category             = responseImage.Category,
                Label                = responseImage.Label,
                Location             = responseImage.Location,
                MediaLink            = responseImage.MediaLink,
                ImageName            = responseImage.Name,
                OS                   = responseImage.OS,
                LogicalSizeInGB      = responseImage.LogicalSizeInGB,
                Eula                 = responseImage.Eula,
                Description          = responseImage.Description,
                ImageFamily          = responseImage.ImageFamily,
                PublishedDate        = responseImage.PublishedDate,
                IsPremium            = responseImage.IsPremium,
                PrivacyUri           = responseImage.PrivacyUri,
                PublisherName        = responseImage.PublisherName,
                RecommendedVMSize    = responseImage.RecommendedVMSize,
                OperationDescription = CommandRuntime.ToString(),
                OperationId          = op.OperationTrackingId,
                OperationStatus      = op.Status
            });
        }
        public void UpdateVMImageProcess()
        {
            var image = new OSImage
            {
                Name = this.ImageName,
                Label = this.Label,
                Eula = this.Eula,
                Description = this.Description,
                ImageFamily = this.ImageFamily,
                PublishedDate = this.PublishedDate,
                PrivacyUri = this.PrivacyUri,
                RecommendedVMSize = this.RecommendedVMSize
            };

            ExecuteClientActionInOCS(
                image,
                CommandRuntime.ToString(),
                s => this.Channel.UpdateOSImage(s, this.ImageName, image),
                WaitForOperation,
                (op, responseImage) => new OSImageContext
                {
                    AffinityGroup = responseImage.AffinityGroup,
                    Category = responseImage.Category,
                    Label = responseImage.Label,
                    Location = responseImage.Location,
                    MediaLink = responseImage.MediaLink,
                    ImageName = responseImage.Name,
                    OS = responseImage.OS,
                    LogicalSizeInGB = responseImage.LogicalSizeInGB,
                    Eula = responseImage.Eula,
                    Description = responseImage.Description,
                    ImageFamily = responseImage.ImageFamily,
                    PublishedDate = responseImage.PublishedDate,
                    IsPremium = responseImage.IsPremium,
                    PrivacyUri = responseImage.PrivacyUri,
                    PublisherName = responseImage.PublisherName,
                    RecommendedVMSize = responseImage.RecommendedVMSize,
                    OperationDescription = CommandRuntime.ToString(),
                    OperationId = op.OperationTrackingId,
                    OperationStatus = op.Status
                });
        }
 public static OSImage UpdateOSImage(this IServiceManagement proxy, string subscriptionID, string imageName, OSImage image)
 {
     return(proxy.EndUpdateOSImage(proxy.BeginUpdateOSImage(subscriptionID, imageName, image, null, null)));
 }
 public static OSImage CreateOSImage(this IServiceManagement proxy, string subscriptionID, OSImage image)
 {
     return(proxy.EndCreateOSImage(proxy.BeginCreateOSImage(subscriptionID, image, null, null)));
 }
 public static OSImage UpdateOSImage(this IServiceManagement proxy, string subscriptionID, string imageName, OSImage image)
 {
     return proxy.EndUpdateOSImage(proxy.BeginUpdateOSImage(subscriptionID, imageName, image, null, null));
 }
 public static OSImage CreateOSImage(this IServiceManagement proxy, string subscriptionID, OSImage image)
 {
     return proxy.EndCreateOSImage(proxy.BeginCreateOSImage(subscriptionID, image, null, null));
 }
 public IAsyncResult BeginCreateOSImage(string subscriptionID, OSImage image, AsyncCallback callback, object state)
 {
     throw new NotImplementedException();
 }