public void PatchSnapshot() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); using (MockContext context = MockContext.Start(this.GetType().FullName)) { var netAppMgmtClient = NetAppTestUtilities.GetNetAppManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); // create the account ResourceUtils.CreateSnapshot(netAppMgmtClient); var dict = new Dictionary <string, string>(); dict.Add("Tag1", "Value1"); // Now try and modify it var snapshotPatch = new SnapshotPatch() { Tags = dict }; var resource = netAppMgmtClient.Snapshots.Update(snapshotPatch, ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1, ResourceUtils.snapshotName1); Assert.True(resource.Tags.ToString().Contains("Tag1") && resource.Tags.ToString().Contains("Value1")); // cleanup - remove the account ResourceUtils.DeleteSnapshot(netAppMgmtClient); ResourceUtils.DeleteVolume(netAppMgmtClient); ResourceUtils.DeletePool(netAppMgmtClient); ResourceUtils.DeleteAccount(netAppMgmtClient); } }
public SnapshotPatch DeSerialize(BinaryReader reader, out SnapshotHeader header) { header = new SnapshotHeader(); header.DeSerialize(reader); SnapshotPatch patch = SnapshotPatch.Allocate(); patch.DeSerialize(reader, _serializerManager); return(patch); }
public SnapshotPatch DeSerialize(BinaryReader reader, out SnapshotHeader header) { header = new SnapshotHeader(); string version = header.DeSerialize(reader); if (!version.Equals(_version)) { _logger.ErrorFormat("ComponentSerializer Hash {0} Not Equal{1}", _version, version); } SnapshotPatch patch = SnapshotPatch.Allocate(); patch.DeSerialize(reader, _serializerManager); return(patch); }
public void Serialize(ISnapshot baseSnap, ISnapshot snap, Stream stream) { // _binaryWriter = new MyBinaryWriter(stream); _binaryWriter = MyBinaryWriter.Allocate(stream); Reset(); snap.Header.Serialize(_binaryWriter, _version); var baseMap = baseSnap.EntityMap; var currentMap = snap.EntityMap; SnapshotPatchGenerator handler = new SnapshotPatchGenerator(_serializerManager); EntityMapComparator.Diff(baseMap, currentMap, handler, "serialize"); SnapshotPatch patch = handler.Detach(); patch.BaseSnapshotSeq = baseSnap.SnapshotSeq; patch.Serialize(_binaryWriter, _serializerManager); _binaryWriter.ReleaseReference(); patch.ReleaseReference(); }
public ISnapshot DeSerializeSnapshot(BinaryReader reader) { SnapshotHeader header; SnapshotPatch patch = _snapSerializer.DeSerialize(reader, out header); ClearOldSnapshot(patch.BaseSnapshotSeq, header.SnapshotSeq); var baseSnap = SnapshotCloner.Clone(GetBaseSnapshot(patch.BaseSnapshotSeq)); baseSnap.Header = header; patch.ApplyPatchTo(baseSnap, _snapSerializer.GetSerializerManager()); patch.ReleaseReference(); if (_receivedSnapMap.ContainsKey(baseSnap.SnapshotSeq)) { Logger.ErrorFormat("SnapSHotSeq {0} exist", baseSnap.SnapshotSeq); } else { _receivedSnapMap.Add(baseSnap.SnapshotSeq, baseSnap); } baseSnap.AcquireReference(); return(baseSnap); }
public virtual ArmOperation <SnapshotResource> Update(WaitUntil waitUntil, SnapshotPatch patch, CancellationToken cancellationToken = default) { Argument.AssertNotNull(patch, nameof(patch)); using var scope = _snapshotClientDiagnostics.CreateScope("SnapshotResource.Update"); scope.Start(); try { var response = _snapshotRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); var operation = new ComputeArmOperation <SnapshotResource>(new SnapshotOperationSource(Client), _snapshotClientDiagnostics, Pipeline, _snapshotRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public void PatchSnapshot() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); using (MockContext context = MockContext.Start(this.GetType())) { var netAppMgmtClient = NetAppTestUtilities.GetNetAppManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); // create the snapshot ResourceUtils.CreateSnapshot(netAppMgmtClient); var dict = new Dictionary <string, string>(); dict.Add("Tag1", "Value1"); // Now try and modify it var snapshotPatch = new SnapshotPatch() { Tags = dict }; try { netAppMgmtClient.Snapshots.Update(snapshotPatch, ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1, ResourceUtils.snapshotName1); Assert.True(false); } catch (Exception ex) { Assert.Contains("Patch operation is not supported", ex.Message); } // cleanup ResourceUtils.DeleteSnapshot(netAppMgmtClient); ResourceUtils.DeleteVolume(netAppMgmtClient); ResourceUtils.DeletePool(netAppMgmtClient); ResourceUtils.DeleteAccount(netAppMgmtClient); } }
/// <summary> /// Update a snapshot /// </summary> /// <remarks> /// Patch a snapshot /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// Snapshot object supplied in the body of the operation. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='accountName'> /// The name of the NetApp account /// </param> /// <param name='poolName'> /// The name of the capacity pool /// </param> /// <param name='volumeName'> /// The name of the volume /// </param> /// <param name='snapshotName'> /// The name of the mount target /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <Snapshot> UpdateAsync(this ISnapshotsOperations operations, SnapshotPatch body, string resourceGroupName, string accountName, string poolName, string volumeName, string snapshotName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(body, resourceGroupName, accountName, poolName, volumeName, snapshotName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Update a snapshot /// </summary> /// <remarks> /// Patch a snapshot /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// Snapshot object supplied in the body of the operation. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='accountName'> /// The name of the NetApp account /// </param> /// <param name='poolName'> /// The name of the capacity pool /// </param> /// <param name='volumeName'> /// The name of the volume /// </param> /// <param name='snapshotName'> /// The name of the mount target /// </param> public static Snapshot Update(this ISnapshotsOperations operations, SnapshotPatch body, string resourceGroupName, string accountName, string poolName, string volumeName, string snapshotName) { return(operations.UpdateAsync(body, resourceGroupName, accountName, poolName, volumeName, snapshotName).GetAwaiter().GetResult()); }