public override void ExecuteCmdlet() { if (!string.IsNullOrEmpty(ResourceGroupName) && !string.IsNullOrEmpty(Name)) { var registry = RegistryClient.GetRegistry(ResourceGroupName, Name); WriteObject(new PSContainerRegistry(registry)); } else { List <PSContainerRegistry> list = new List <PSContainerRegistry>(); var registries = RegistryClient.ListRegistries(ResourceGroupName); foreach (Registry registry in registries) { list.Add(new PSContainerRegistry(registry)); } while (!string.IsNullOrEmpty(registries.NextPageLink)) { registries = RegistryClient.ListRegistriesUsingNextLink(ResourceGroupName, registries.NextPageLink); foreach (Registry registry in registries) { list.Add(new PSContainerRegistry(registry)); } } WriteObject(list, true); } }
public AzureContainers(PipeAzureCfg azureCfg, SemVersion version, RegistryClient registryClient) { AzureCfg = azureCfg; Version = version; RegistryClient = registryClient; Az = new Lazy <IAzure>(azureCfg.GetAzure); }
public async Task TestPullAsync() { // Pulls the busybox image. localRegistry.PullAndPushToLocal("busybox", "busybox"); RegistryClient registryClient = RegistryClient.CreateFactory(EventHandlers.NONE, "localhost:5000", "busybox") .SetAllowInsecureRegistries(true) .NewRegistryClient(); V21ManifestTemplate manifestTemplate = await registryClient.PullManifestAsync <V21ManifestTemplate>("latest").ConfigureAwait(false); DescriptorDigest realDigest = manifestTemplate.GetLayerDigests().First(); // Pulls a layer BLOB of the busybox image. LongAdder totalByteCount = new LongAdder(); LongAdder expectedSize = new LongAdder(); IBlob pulledBlob = registryClient.PullBlob( realDigest, size => { Assert.AreEqual(0, expectedSize.Sum()); expectedSize.Add(size); }, totalByteCount.Add); BlobDescriptor blobDescriptor = await pulledBlob.WriteToAsync(Stream.Null).ConfigureAwait(false); Assert.AreEqual(realDigest, blobDescriptor.GetDigest()); Assert.IsTrue(expectedSize.Sum() > 0); Assert.AreEqual(expectedSize.Sum(), totalByteCount.Sum()); }
public async Task <RegistryClient> RegistryConnectAsync() { (var config, var context) = Configuration.Load(this); if (!Uri.TryCreate(RegistryServer ?? context.RegistryUri ?? string.Empty, UriKind.Absolute, out Uri serverUri)) { throw new Exception("Registry Config Server URI missing/invalid"); } var connection = new RegistryClient(serverUri); if (context.RegistryUserKey == null) { throw new Exception("Config missing UserKey"); } if (context.RegistryPassword == null) { throw new Exception("Config missing Password"); } await connection.User.AuthenticateAsync(new UserIdentifier { UserKey = RegistryUserKey ?? context.RegistryUserKey }, RegistryPassword ?? context.RegistryPassword); return(connection); }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, RegistryObjectParameterSet)) { ResourceGroupName = Registry.ResourceGroupName; RegistryName = Registry.Name; } else if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName)) { WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; RegistryName = registryName; } var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true); if (string.IsNullOrEmpty(Name)) { Name = Location.Replace(" ", string.Empty).ToLower(); } if (ShouldProcess(Name, "Create a replication for the container registry")) { var replication = RegistryClient.CreateReplication(ResourceGroupName, RegistryName, Name, Location, tags); WriteObject(new PSContainerRegistryReplication(replication)); } }
public async Task TestPull_unknownBlobAsync() { localRegistry.PullAndPushToLocal("busybox", "busybox"); DescriptorDigest nonexistentDigest = DescriptorDigest.FromHash( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); RegistryClient registryClient = RegistryClient.CreateFactory(EventHandlers.NONE, "localhost:5000", "busybox") .SetAllowInsecureRegistries(true) .NewRegistryClient(); try { await registryClient .PullBlob(nonexistentDigest, _ => { }, _ => { }) .WriteToAsync(Stream.Null).ConfigureAwait(false); Assert.Fail("Trying to pull nonexistent blob should have errored"); } catch (IOException ex) when(ex.InnerException is RegistryErrorException) { StringAssert.Contains( ex.Message, "pull BLOB for localhost:5000/busybox with digest " + nonexistentDigest); } }
private void SetRegistryDetials(PSContainerRegistry registry) { if (!string.IsNullOrEmpty(registry.ResourceGroupName) && !string.IsNullOrEmpty(registry.Name)) { registry.Usages = RegistryClient.ListRegistryUsage(registry.ResourceGroupName, registry.Name)?.Value; } }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, RegistryObjectParameterSet)) { ResourceGroupName = Registry.ResourceGroupName; Name = Registry.Name; } else if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName)) { WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; Name = registryName; } if (ShouldProcess(Name, string.Format("Update Container Registry Credential '{0}'", PasswordName))) { var credentials = RegistryClient.RegenerateRegistryCredential(ResourceGroupName, Name, PasswordName); WriteObject(new PSContainerRegistryCredential(credentials)); } }
public override void ExecuteCmdlet() { if (ShouldProcess(Name, "Create Container Registry")) { var registryNameStatus = RegistryClient.CheckRegistryNameAvailability(Name); if (registryNameStatus?.NameAvailable != null && !registryNameStatus.NameAvailable.Value) { throw new InvalidOperationException(registryNameStatus.Message); } var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true); if (Location == null) { Location = ResourceManagerClient.GetResourceGroupLocation(ResourceGroupName); } DeploymentExtended result = ResourceManagerClient.CreateRegistry( ResourceGroupName, Name, Location, Sku, EnableAdminUser, StorageAccountName, tags); if (result.Properties.ProvisioningState == DeploymentState.Succeeded.ToString()) { var registry = RegistryClient.GetRegistry(ResourceGroupName, Name); WriteObject(new PSContainerRegistry(registry)); } } }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, ReplicationObjectParameterSet)) { ResourceId = Replicatoin.Id; } if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName) || string.IsNullOrEmpty(childResourceName)) { WriteInvalidResourceIdError(InvalidReplicationResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; RegistryName = registryName; Name = childResourceName; } if (ShouldProcess(Name, "Delete the replication from the container registry. This will also delete all the webhooks in this replication.")) { RegistryClient.DeleteReplication(ResourceGroupName, RegistryName, Name); if (PassThru) { WriteObject(true); } } }
public async Task <BlobDescriptor> CallAsync() { Authorization authorization = await authenticatePushStep.GetFuture().ConfigureAwait(false); using (ProgressEventDispatcher progressEventDispatcher = progressEventDipatcherFactory.Create( "pushing blob " + blobDescriptor.GetDigest(), blobDescriptor.GetSize())) using (TimerEventDispatcher ignored = new TimerEventDispatcher( buildConfiguration.GetEventHandlers(), DESCRIPTION + blobDescriptor)) using (ThrottledAccumulatingConsumer throttledProgressReporter = new ThrottledAccumulatingConsumer(progressEventDispatcher.DispatchProgress)) { RegistryClient registryClient = buildConfiguration .NewTargetImageRegistryClientFactory() .SetAuthorization(authorization) .NewRegistryClient(); // check if the BLOB is available if (await registryClient.CheckBlobAsync(blobDescriptor).ConfigureAwait(false)) { buildConfiguration .GetEventHandlers() .Dispatch(LogEvent.Info("BLOB : " + blobDescriptor + " already exists on registry")); return(blobDescriptor); } // todo: leverage cross-repository mounts await registryClient.PushBlobAsync(blobDescriptor.GetDigest(), blob, null, throttledProgressReporter.Accept).ConfigureAwait(false); return(blobDescriptor); } }
public override void ExecuteCmdlet() { if (ShouldProcess(Name, "Update Container Registry")) { var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true); bool?adminUserEnabled = null; if (EnableAdminUser || DisableAdminUser) { adminUserEnabled = EnableAdminUser || !DisableAdminUser; } string storageAccountResourceGroup = null; if (StorageAccountName != null) { storageAccountResourceGroup = ResourceManagerClient.GetStorageAccountResourceGroup(StorageAccountName); } var registry = RegistryClient.UpdateRegistry( ResourceGroupName, Name, adminUserEnabled, StorageAccountName, storageAccountResourceGroup, tags); WriteObject(new PSContainerRegistry(registry)); } }
/// <summary> /// Builds a deserializer for a specific schema. /// </summary> /// <param name="id"> /// The ID of the schema that should be used to deserialize data. /// </param> /// <param name="tombstoneBehavior"> /// The behavior of the deserializer on tombstone records. /// </param> /// <exception cref="AggregateException"> /// Thrown when the type is incompatible with the retrieved schema. /// </exception> public virtual async Task <IDeserializer <T> > Build <T>( int id, TombstoneBehavior tombstoneBehavior = TombstoneBehavior.None ) { return(Build <T>(id, await RegistryClient.GetSchemaAsync(id).ConfigureAwait(false), tombstoneBehavior)); }
public async Task TestPush_missingBlobsAsync() { localRegistry.PullAndPushToLocal("busybox", "busybox"); RegistryClient registryClient = RegistryClient.CreateFactory(EVENT_HANDLERS, "gcr.io", "distroless/java").NewRegistryClient(); IManifestTemplate manifestTemplate = await registryClient.PullManifestAsync("latest").ConfigureAwait(false); registryClient = RegistryClient.CreateFactory(EVENT_HANDLERS, "localhost:5000", "busybox") .SetAllowInsecureRegistries(true) .NewRegistryClient(); try { await registryClient.PushManifestAsync((V22ManifestTemplate)manifestTemplate, "latest").ConfigureAwait(false); Assert.Fail("Pushing manifest without its BLOBs should fail"); } catch (RegistryErrorException ex) { HttpResponseMessage httpResponse = ex.Cause; Assert.AreEqual( HttpStatusCode.BadRequest, httpResponse.StatusCode); } }
/// <summary> /// Deserialize a message. (See <see cref="IAsyncDeserializer{T}.DeserializeAsync(ReadOnlyMemory{byte}, bool, SerializationContext)" />.) /// </summary> public virtual async Task <T> DeserializeAsync(ReadOnlyMemory <byte> data, bool isNull, SerializationContext context) { using (var stream = new MemoryStream(data.ToArray(), false)) { var bytes = new byte[4]; if (stream.ReadByte() != 0x00 || stream.Read(bytes, 0, bytes.Length) != bytes.Length) { throw new InvalidDataException("Data does not conform to the Confluent wire format."); } if (BitConverter.IsLittleEndian) { Array.Reverse(bytes); } var @delegate = await(_cache.GetOrAdd(BitConverter.ToInt32(bytes, 0), async id => { var json = await RegistryClient.GetSchemaAsync(id).ConfigureAwait(false); var schema = SchemaReader.Read(json); return(DeserializerBuilder.BuildDelegate <T>(schema)); })).ConfigureAwait(false); return(@delegate(stream)); } }
public override void ExecuteCmdlet() { if (ShouldProcess(Name, "Create Container Registry")) { var registryNameStatus = RegistryClient.CheckRegistryNameAvailability(Name); if (registryNameStatus?.NameAvailable != null && !registryNameStatus.NameAvailable.Value) { throw new InvalidOperationException(registryNameStatus.Message); } var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true); if (Location == null) { Location = ResourceManagerClient.GetResourceGroupLocation(ResourceGroupName); } var registry = new Registry { Sku = new Microsoft.Azure.Management.ContainerRegistry.Models.Sku(Sku), AdminUserEnabled = EnableAdminUser, Tags = tags, Location = Location }; var createdRegistry = RegistryClient.CreateRegistry(ResourceGroupName, Name, registry); WriteObject(new PSContainerRegistry(createdRegistry)); } }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, ListWebhookEventsByWebhookObjectParameterSet)) { ResourceId = Webhook.Id; } if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName) || string.IsNullOrEmpty(childResourceName)) { WriteInvalidResourceIdError(InvalidWebhookResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; WebhookName = childResourceName; RegistryName = registryName; } var webhookEvents = RegistryClient.ListAllWebhookEvent(ResourceGroupName, RegistryName, WebhookName); WriteObject(webhookEvents, true); }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, RegistryObjectParameterSet)) { ResourceGroupName = Registry.ResourceGroupName; Name = Registry.Name; } else if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName)) { WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; Name = registryName; } if (ShouldProcess(Name, "Remove Container Registry")) { RegistryClient.DeleteRegistry(ResourceGroupName, Name); if (PassThru) { WriteObject(true); } } }
public async Task <BuildResult> CallAsync() { IReadOnlyList <BlobDescriptor> baseImageDescriptors = await pushBaseImageLayersStep.GetFuture().ConfigureAwait(false); IReadOnlyList <BlobDescriptor> appLayerDescriptors = await pushApplicationLayersStep.GetFuture().ConfigureAwait(false); BlobDescriptor containerConfigurationBlobDescriptor = await pushContainerConfigurationStep.GetFuture().ConfigureAwait(false); ImmutableHashSet <string> targetImageTags = buildConfiguration.GetAllTargetImageTags(); using (var progressEventDispatcher = progressEventDispatcherFactory.Create("pushing image manifest", this.Index)) using (var factory = progressEventDispatcher.NewChildProducer()("[child progress]pushing image manifest", targetImageTags.Count)) using (TimerEventDispatcher ignored = new TimerEventDispatcher(buildConfiguration.GetEventHandlers(), DESCRIPTION)) { RegistryClient registryClient = buildConfiguration .NewTargetImageRegistryClientFactory() .SetAuthorization(await authenticatePushStep.GetFuture().ConfigureAwait(false)) .NewRegistryClient(); // Constructs the image. ImageToJsonTranslator imageToJsonTranslator = new ImageToJsonTranslator(await buildImageStep.GetFuture().ConfigureAwait(false)); // Gets the image manifest to push. IBuildableManifestTemplate manifestTemplate = imageToJsonTranslator.GetManifestTemplate( buildConfiguration.GetTargetFormat(), containerConfigurationBlobDescriptor); // Pushes to all target image tags. IList <Task <DescriptorDigest> > pushAllTagsFutures = new List <Task <DescriptorDigest> >(); var idx = 0; ProgressEventDispatcher.Factory progressEventDispatcherFactory = factory.NewChildProducer(); foreach (string tag in targetImageTags) { idx++; using (progressEventDispatcherFactory.Create("tagging with " + tag, idx)) { buildConfiguration.GetEventHandlers().Dispatch(LogEvent.Info("Tagging with " + tag + "...")); pushAllTagsFutures.Add(registryClient.PushManifestAsync(manifestTemplate, tag)); } } DescriptorDigest imageDigest = await Digests.ComputeJsonDigestAsync(manifestTemplate).ConfigureAwait(false); DescriptorDigest imageId = containerConfigurationBlobDescriptor.GetDigest(); BuildResult result = new BuildResult(imageDigest, imageId); await Task.WhenAll(pushAllTagsFutures).ConfigureAwait(false); return(result); } }
public static void MyClassInitialize(TestContext testContext) { registry = new RegistryClient(USERNAME, PASSWORD, SERVER_URL); if (registry.ResourceExists(BASE_PATH)) { MyClassCleanup(); } }
public AzureContainers(PipeAzureCfg azureCfg, SemVersion version, RegistryClient registryClient, ContainerCfg containerCfg) { AzureCfg = azureCfg; Version = version; RegistryClient = registryClient; ContainerCfg = containerCfg; Az = new(azureCfg.GetAzure); }
public AzureCleaner(AzureCleanerCfg cfg, PipeAzureCfg azureCfg, ContainerCfg containerCfg, RegistryClient registryClient, ILogger log) { Cfg = cfg; AzureCfg = azureCfg; ContainerCfg = containerCfg; RegistryClient = registryClient; Log = log; Az = new Lazy<IAzure>(azureCfg.GetAzure); }
public void NotFindInstances() { var uri = new Uri("http://host:8888/path/path1/path2?key=value"); var registryClient = new RegistryClient("prefix", new RoundRobinAddressRouter()); var results = registryClient.FindServiceInstancesAsync(uri, _instances); Assert.Equal(0, results.Count); }
/// <summary> /// Builds a deserializer for a specific schema. /// </summary> /// <param name="subject"> /// The subject of the schema that should be used to deserialize data. /// </param> /// <param name="version"> /// The version of the subject to be resolved. /// </param> /// <exception cref="AggregateException"> /// Thrown when the type is incompatible with the retrieved schema. /// </exception> public virtual async Task <IDeserializer <T> > Build <T>(string subject, int version) { var schema = await RegistryClient.GetSchemaAsync(subject, version); var id = await RegistryClient.GetSchemaIdAsync(subject, schema); return(Build <T>(id, schema)); }
/// <summary> /// Disposes the serializer, freeing up any resources. /// </summary> public void Dispose() { if (disposeRegistryClient) { RegistryClient.Dispose(); } GC.SuppressFinalize(this); }
/// <summary> /// Builds a deserializer for a specific schema. /// </summary> /// <param name="subject"> /// The subject of the schema that should be used to deserialize data. The latest version /// of the subject will be resolved. /// </param> /// <param name="tombstoneBehavior"> /// The behavior of the deserializer on tombstone records. /// </param> /// <exception cref="AggregateException"> /// Thrown when the type is incompatible with the retrieved schema. /// </exception> public virtual async Task <IDeserializer <T> > Build <T>( string subject, TombstoneBehavior tombstoneBehavior = TombstoneBehavior.None ) { var schema = await RegistryClient.GetLatestSchemaAsync(subject).ConfigureAwait(false); return(Build <T>(schema.Id, schema.SchemaString, tombstoneBehavior)); }
/// <summary> /// Builds a serializer for a specific schema. /// </summary> /// <param name="id"> /// The ID of the schema that should be used to serialize data. /// </param> /// <param name="tombstoneBehavior"> /// The behavior of the serializer on tombstone records. /// </param> /// <exception cref="AggregateException"> /// Thrown when the type is incompatible with the retrieved schema. /// </exception> public async Task <ISerializer <T> > Build <T>( int id, TombstoneBehavior tombstoneBehavior = TombstoneBehavior.None ) { var schema = await RegistryClient.GetSchemaAsync(id).ConfigureAwait(false); return(Build <T>(id, schema, tombstoneBehavior)); }
public async Task TestPushAsync() { localRegistry.PullAndPushToLocal("busybox", "busybox"); IBlob testLayerBlob = Blobs.From("crepecake"); // Known digest for 'crepecake' DescriptorDigest testLayerBlobDigest = DescriptorDigest.FromHash( "52a9e4d4ba4333ce593707f98564fee1e6d898db0d3602408c0b2a6a424d357c"); IBlob testContainerConfigurationBlob = Blobs.From("12345"); DescriptorDigest testContainerConfigurationBlobDigest = DescriptorDigest.FromHash( "5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5"); // Creates a valid image manifest. V22ManifestTemplate expectedManifestTemplate = new V22ManifestTemplate(); expectedManifestTemplate.AddLayer(9, testLayerBlobDigest); expectedManifestTemplate.SetContainerConfiguration(5, testContainerConfigurationBlobDigest); // Pushes the BLOBs. RegistryClient registryClient = RegistryClient.CreateFactory(EVENT_HANDLERS, "localhost:5000", "testimage") .SetAllowInsecureRegistries(true) .NewRegistryClient(); Assert.IsFalse( await registryClient.PushBlobAsync(testLayerBlobDigest, testLayerBlob, null, _ => { }).ConfigureAwait(false)); Assert.IsFalse( await registryClient.PushBlobAsync( testContainerConfigurationBlobDigest, testContainerConfigurationBlob, null, _ => { }).ConfigureAwait(false)); // Pushes the manifest. DescriptorDigest imageDigest = await registryClient.PushManifestAsync(expectedManifestTemplate, "latest").ConfigureAwait(false); // Pulls the manifest. V22ManifestTemplate manifestTemplate = await registryClient.PullManifestAsync <V22ManifestTemplate>("latest").ConfigureAwait(false); Assert.AreEqual(1, manifestTemplate.Layers.Count); Assert.AreEqual(testLayerBlobDigest, manifestTemplate.Layers[0].Digest); Assert.IsNotNull(manifestTemplate.GetContainerConfiguration()); Assert.AreEqual( testContainerConfigurationBlobDigest, manifestTemplate.GetContainerConfiguration().Digest); // Pulls the manifest by digest. V22ManifestTemplate manifestTemplateByDigest = await registryClient.PullManifestAsync <V22ManifestTemplate>(imageDigest.ToString()).ConfigureAwait(false); Assert.AreEqual( await Digests.ComputeJsonDigestAsync(manifestTemplate).ConfigureAwait(false), await Digests.ComputeJsonDigestAsync(manifestTemplateByDigest).ConfigureAwait(false)); }
public RegistryHandling(RegistryClient registryClient, GameConfiguration gameConfiguration) { this.RegistryClient = registryClient; this.GameConfiguration = gameConfiguration; if (this.GameConfiguration.RegistryEnabled) { InitializeStepTimer(); } }
/// <summary> /// Disposes the builder, freeing up any resources. /// </summary> protected virtual void Dispose(bool disposing) { if (disposing) { if (_disposeRegistryClient) { RegistryClient.Dispose(); } } }
/// <summary> /// 지정된 서브키의 레지스트리 명에 해당하는 값을 가져온다. 없으면 null을 반환한다. /// </summary> /// <param name="subKey">레지스트리 서브 키</param> /// <param name="name">레지스트리 명</param> /// <returns>레지스트리 값, 없으면 null을 반환한다.</returns> public string GetValue(string subKey, string name) { if(IsDebugEnabled) log.Debug("레지스트리 키[{0}]의 Name[{1}]의 값을 얻습니다.", subKey, name); using(var client = new RegistryClient(_rootKey, subKey)) { var value = client.GetValue(name); if(IsDebugEnabled) log.Debug("레지스트리에서 값을 읽었습니다!!! subKey=[{0}], name=[{1}], value=[{2}]", subKey, name, value); return (value != null) ? value.ToString() : null; } }
/// <summary> /// 이벤트 로그 크기를 조절한다. /// </summary> /// <param name="logName">이벤트 로그 이름</param> /// <param name="maxSize">Log 크기, KByte 단위</param> /// <remarks>레지스트리를 조작할 수 있는 권한이 있어야 한다.</remarks> public static void SetLogMaxSize(string logName, int maxSize) { logName.ShouldNotBeWhiteSpace("logName"); var subKey = @"SYSTEM\CurrentControlSet\Services\EventLog\" + logName; if(IsDebugEnabled) log.Debug("Set Maximum size of Log. logName=[{0}], maxSize=[{1}], subKey=[{2}]", logName, maxSize, subKey); using(var reg = new RegistryClient(Microsoft.Win32.Registry.LocalMachine)) { reg.SubKeyName = subKey; reg.SetValue("MaxSize", maxSize); } }