/// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IVirtualDiskOperations.
 /// </param>
 /// <param name='deviceId'>
 /// Required. device id
 /// </param>
 /// <param name='diskId'>
 /// Required. disk id
 /// </param>
 /// <param name='diskDetails'>
 /// Required. Parameters supplied to the update virtual disk operation.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// Info about the async task
 /// </returns>
 public static Task<TaskStatusInfo> UpdateAsync(this IVirtualDiskOperations operations, string deviceId, string diskId, VirtualDisk diskDetails, CustomRequestHeaders customRequestHeaders)
 {
     return operations.UpdateAsync(deviceId, diskId, diskDetails, customRequestHeaders, CancellationToken.None);
 }
        private List<VirtualDisk> ParseVolume(XmlDocument document)
        {
            List<VirtualDisk> virtualDiskList = new List<VirtualDisk>();
            XmlNodeList nodeList = document.SelectNodes(@"//Volume");
            foreach (XmlNode node in nodeList)
            {
                VirtualDisk virtualDisk = new VirtualDisk();
                virtualDisk.Name = node.Attributes["Name"].Value;
                virtualDisk.InstanceId = node.Attributes["Id"].Value;
                virtualDisk.DataContainerId = node.Attributes["ContainerId"].Value;
                virtualDisk.AccessType = (AccessType)Enum.Parse(typeof(AccessType), node.Attributes["Attr"].Value, true);
                virtualDisk.SizeInBytes = long.Parse(node.Attributes["BlockCount"].Value);
                virtualDisk.Online = Boolean.Parse(node.Attributes["Online"].Value);
                virtualDisk.AppType = (AppType)Enum.Parse(typeof(AppType), node.Attributes["Type"].Value, true);
                virtualDisk.VSN = node.Attributes["VSN"].Value;
                virtualDisk.AcrIdList = new List<string>();
                foreach (XmlNode childNode in node.ChildNodes)
                {
                    if ("ACRId" == childNode.Name)
                    {
                        virtualDisk.AcrIdList.Add(childNode.InnerText);
                    }
                }

                virtualDiskList.Add(virtualDisk);
            }

            return virtualDiskList;
        }
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IVirtualDiskOperations.
 /// </param>
 /// <param name='deviceId'>
 /// Required. device id
 /// </param>
 /// <param name='diskId'>
 /// Required. disk id
 /// </param>
 /// <param name='diskDetails'>
 /// Required. Parameters supplied to the update virtual disk operation.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// Info about the async task
 /// </returns>
 public static TaskStatusInfo Update(this IVirtualDiskOperations operations, string deviceId, string diskId, VirtualDisk diskDetails, CustomRequestHeaders customRequestHeaders)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IVirtualDiskOperations)s).UpdateAsync(deviceId, diskId, diskDetails, customRequestHeaders);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// The Begin updating Volume operation updates an existing volume.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IVirtualDiskOperations.
 /// </param>
 /// <param name='deviceId'>
 /// Required. device id
 /// </param>
 /// <param name='diskId'>
 /// Required. disk id
 /// </param>
 /// <param name='diskDetails'>
 /// Required. Parameters supplied to the update virtual disk operation.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// This is the Task Response for all Async Calls
 /// </returns>
 public static Task<GuidTaskResponse> BeginUpdatingAsync(this IVirtualDiskOperations operations, string deviceId, string diskId, VirtualDisk diskDetails, CustomRequestHeaders customRequestHeaders)
 {
     return operations.BeginUpdatingAsync(deviceId, diskId, diskDetails, customRequestHeaders, CancellationToken.None);
 }
        /// <summary>
        /// Parse virtual disk details
        /// </summary>
        private void ParseVirtualDisks()
        {
            volumeList = new List<VirtualDisk>();
            var volumesList = this.GetSubElements(doc.Root, "Volumes");
            foreach (var volumes in volumesList)
            {
                var diskList = this.GetSubElements(volumes, "Volume");
                foreach (var disk in diskList)
                {
                    VirtualDisk volume = new VirtualDisk();
                    foreach (var diskItem in disk.Elements())
                    {
                        switch (diskItem.Name.LocalName)
                        {
                            case "AccessControlList":
                            {
                                volume.AcrIdList = new List<string>();
                                foreach (var acrElement in diskItem.Elements())
                                {
                                    if ("VolumeAce" == acrElement.Name.LocalName)
                                    {
                                        foreach (var acr in acrElement.Elements())
                                        {
                                            if ("AccessControlGroupId" == acr.Name.LocalName)
                                            {
                                                volume.AcrIdList.Add(acr.Value);
                                            }
                                        }
                                    }
                                }

                                break;
                            }
                            case "Alias":
                            {
                                volume.Name = diskItem.Value;
                                break;
                            }
                            case "BlockCount":
                            {
                                volume.SizeInBytes = long.Parse(diskItem.Value)*SizeofBlockInBytes;
                                break;
                            }
                            case "CloudId":
                            {
                                volume.DataContainerId = diskItem.Value;
                                break;
                            }
                            case "Id":
                            {
                                volume.InstanceId = diskItem.Value;
                                break;
                            }
                            case "SerialNumber":
                            {
                                volume.VSN = diskItem.Value;
                                break;
                            }
                            case "Online":
                            {
                                volume.Online = bool.Parse(diskItem.Value);
                                break;
                            }
                            case "Attr":
                            {
                                volume.AccessType = AccessTypeMap[diskItem.Value];
                                break;
                            }
                            case "ChunkSize":
                            {
                                volume.AppType = AppTypeMap[diskItem.Value];
                                break;
                            }
                            case "Priority":
                            default:
                            {
                                break;
                            }

                        }
                    }

                    volume.DataContainer = null;
                    volume.InternalInstanceId = null;
                    volume.IsBackupEnabled = false;
                    volume.IsDefaultBackupEnabled = false;
                    volume.IsMonitoringEnabled = false;
                    volume.OperationInProgress = OperationInProgress.None;

                    // populate volume container
                    volumeList.Add(volume);
                }
            }
        }
 public GuidTaskResponse UpdateVolumeAsync(string deviceid, string diskid, VirtualDisk diskDetails)
 {
     return GetStorSimpleClient().VirtualDisk.BeginUpdating(deviceid, diskid, diskDetails,GetCustomRequestHeaders());
 }
 public TaskStatusInfo UpdateVolume(string deviceid, string diskid, VirtualDisk diskDetails)
 {
     return GetStorSimpleClient().VirtualDisk.Update(deviceid, diskid, diskDetails, GetCustomRequestHeaders());
 }