Esempio n. 1
0
        public void AddDiskProcess()
        {
            AddAzureDiskCommand.AddAzureDiskCommand variable = null;
            string diskName;

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                try
                {
                    AddAzureDiskCommand.AddAzureDiskCommand variable1 = variable;
                    Disk disk = new Disk();
                    disk.Name      = this.DiskName;
                    disk.MediaLink = new Uri(this.MediaLocation);
                    disk.OS        = this.OS;
                    Disk disk1 = disk;
                    if (string.IsNullOrEmpty(this.Label))
                    {
                        diskName = this.DiskName;
                    }
                    else
                    {
                        diskName = this.Label;
                    }
                    disk1.Label    = diskName;
                    variable1.disk = disk;
                    CmdletExtensions.WriteVerboseOutputForObject(this, LambdaVar22);
                    Disk        disk2       = base.RetryCall <Disk>((string s) => base.Channel.CreateDisk(s, LambdaVar22));
                    DiskContext diskContext = new DiskContext();
                    diskContext.DiskName        = disk2.Name;
                    diskContext.Label           = disk2.Label;
                    diskContext.IsCorrupted     = disk2.IsCorrupted;
                    diskContext.AffinityGroup   = disk2.AffinityGroup;
                    diskContext.OS              = disk2.OS;
                    diskContext.Location        = disk2.Location;
                    diskContext.MediaLink       = disk2.MediaLink;
                    diskContext.DiskSizeInGB    = disk2.LogicalDiskSizeInGB;
                    diskContext.SourceImageName = disk2.SourceImageName;
                    diskContext.AttachedTo      = AddAzureDiskCommand.CreateRoleReference(disk2.AttachedTo);
                    DiskContext diskContext1 = diskContext;
                    Operation   operation    = base.WaitForOperation(base.CommandRuntime.ToString());
                    diskContext1.set_OperationDescription(base.CommandRuntime.ToString());
                    diskContext1.set_OperationId(operation.OperationTrackingId);
                    diskContext1.set_OperationStatus(operation.Status);
                    base.WriteObject(diskContext1, true);
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    this.WriteErrorDetails(communicationException);
                }
            }
        }
        public void UpdateDiskProcess()
        {
            string empty = string.Empty;

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                try
                {
                    Disk disk = new Disk();
                    disk.Name  = this.DiskName;
                    disk.Label = this.Label;
                    Disk disk1 = disk;
                    CmdletExtensions.WriteVerboseOutputForObject(this, disk1);
                    Disk disk2 = base.RetryCall <Disk>((string s) => base.Channel.UpdateDisk(s, this.DiskName, disk1));
                    if (disk2 != null)
                    {
                        DiskContext diskContext = new DiskContext();
                        diskContext.set_OperationId(empty);
                        diskContext.DiskName        = disk1.Name;
                        diskContext.Label           = disk1.Label;
                        diskContext.IsCorrupted     = disk1.IsCorrupted;
                        diskContext.AffinityGroup   = disk1.AffinityGroup;
                        diskContext.OS              = disk1.OS;
                        diskContext.Location        = disk1.Location;
                        diskContext.MediaLink       = disk1.MediaLink;
                        diskContext.DiskSizeInGB    = disk1.LogicalDiskSizeInGB;
                        diskContext.SourceImageName = disk1.SourceImageName;
                        diskContext.AttachedTo      = UpdateAzureDiskCommand.CreateRoleReference(disk1.AttachedTo);
                        DiskContext diskContext1 = diskContext;
                        Operation   operation    = base.WaitForOperation(base.CommandRuntime.ToString());
                        diskContext1.set_OperationDescription(base.CommandRuntime.ToString());
                        diskContext1.set_OperationId(operation.OperationTrackingId);
                        diskContext1.set_OperationStatus(operation.Status);
                        base.WriteObject(diskContext1, true);
                    }
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    this.WriteErrorDetails(communicationException);
                }
            }
        }
Esempio n. 3
0
 protected override void ProcessRecord()
 {
     try
     {
         base.ProcessRecord();
         Operation          operation   = null;
         IEnumerable <Disk> diskProcess = this.GetDiskProcess(out operation);
         if (diskProcess != null)
         {
             List <DiskContext> diskContexts = new List <DiskContext>();
             foreach (Disk disk in diskProcess)
             {
                 DiskContext diskContext = new DiskContext();
                 diskContext.set_OperationId(operation.OperationTrackingId);
                 diskContext.set_OperationDescription(base.CommandRuntime.ToString());
                 diskContext.set_OperationStatus(operation.Status);
                 diskContext.DiskName        = disk.Name;
                 diskContext.Label           = disk.Label;
                 diskContext.IsCorrupted     = disk.IsCorrupted;
                 diskContext.AffinityGroup   = disk.AffinityGroup;
                 diskContext.OS              = disk.OS;
                 diskContext.Location        = disk.Location;
                 diskContext.MediaLink       = disk.MediaLink;
                 diskContext.DiskSizeInGB    = disk.LogicalDiskSizeInGB;
                 diskContext.SourceImageName = disk.SourceImageName;
                 diskContext.AttachedTo      = GetAzureDiskCommand.CreateRoleReference(disk.AttachedTo);
                 diskContexts.Add(diskContext);
             }
             base.WriteObject(diskContexts, true);
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null));
     }
 }