Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • Hotfix/1443-FixGetQuotaFunction
  • Hotfix/1942-higherQuota
  • Issue/1910-MigrationtoNET6.0
  • Issue/1951-quotaImplementation
  • Issue/2072-wormResourceType
  • Issue/2309-docs
  • Product/1100-fdsS3
  • Product/1287-dotnet5Sharepoint
  • Product/407-net5migration
  • Product/588-quotaManagement
  • Sprint/2021-01
  • Sprint/2021-03
  • Sprint/2022-01
  • Topic/1226-ecsManagerLibraryMigration
  • Topic/1279-quotaManagement
  • Topic/1292-FdsS3
  • Topic/1305-dotnet5ECSManager
  • dev
  • gitkeep
  • master
  • timeout
  • v1.1.0
  • v1.1.1
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.1.0
  • v2.2.0
  • v2.3.0
  • v2.3.1
  • v2.3.2
31 results

Target

Select target project
  • coscine/backend/libraries/ecs-manager
1 result
Select Git revision
  • Hotfix/1443-FixGetQuotaFunction
  • Hotfix/1942-higherQuota
  • Issue/1910-MigrationtoNET6.0
  • Issue/1951-quotaImplementation
  • Issue/2072-wormResourceType
  • Issue/2309-docs
  • Product/1100-fdsS3
  • Product/1287-dotnet5Sharepoint
  • Product/407-net5migration
  • Product/588-quotaManagement
  • Sprint/2021-01
  • Sprint/2021-03
  • Sprint/2022-01
  • Topic/1226-ecsManagerLibraryMigration
  • Topic/1279-quotaManagement
  • Topic/1292-FdsS3
  • Topic/1305-dotnet5ECSManager
  • dev
  • gitkeep
  • master
  • timeout
  • v1.1.0
  • v1.1.1
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.1.0
  • v2.2.0
  • v2.3.0
  • v2.3.1
  • v2.3.2
31 results
Show changes
Commits on Source (4)
......@@ -4,7 +4,7 @@
<RootNamespace>Coscine.ECSManager.Tests</RootNamespace>
<AssemblyName>Coscine.ECSManager.Tests</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<Version>2.2.0</Version></PropertyGroup>
<Version>2.3.0</Version></PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ECSManager\EcsManager.csproj" />
</ItemGroup>
......
......@@ -119,12 +119,14 @@ namespace Coscine.ECSManager.Tests
{
_rdsEcsManager.CreateBucket(_bucketName, _rdsEcsManager.EcsManagerConfiguration.BucketQuotaMax).Wait();
Assert.True(_rdsEcsManager.GetBucketQuota(_bucketName).Result == _rdsEcsManager.EcsManagerConfiguration.BucketQuotaMax);
Assert.True(_rdsEcsManager.GetBucketTotalUsedQuota(_bucketName).Result == 0);
Assert.True(_rdsEcsManager.SetBucketQuota(_bucketName, _rdsEcsManager.EcsManagerConfiguration.BucketQuotaMax - 1).Result);
Assert.True(_rdsEcsManager.GetBucketQuota(_bucketName).Result == _rdsEcsManager.EcsManagerConfiguration.BucketQuotaMax - 1);
Assert.True(_rdsEcsManager.DeleteBucket(_bucketName).Result);
_rdsS3EcsManager.CreateBucket(_bucketName, _rdsS3EcsManager.EcsManagerConfiguration.BucketQuotaMax).Wait();
Assert.True(_rdsS3EcsManager.GetBucketQuota(_bucketName).Result == _rdsS3EcsManager.EcsManagerConfiguration.BucketQuotaMax);
Assert.True(_rdsEcsManager.GetBucketTotalUsedQuota(_bucketName).Result == 0);
Assert.True(_rdsS3EcsManager.SetBucketQuota(_bucketName, _rdsS3EcsManager.EcsManagerConfiguration.BucketQuotaMax - 1).Result);
Assert.True(_rdsS3EcsManager.GetBucketQuota(_bucketName).Result == _rdsS3EcsManager.EcsManagerConfiguration.BucketQuotaMax - 1);
Assert.True(_rdsS3EcsManager.DeleteBucket(_bucketName).Result);
......
......@@ -16,11 +16,13 @@ namespace Coscine.ECSManager
public EcsManagerConfiguration EcsManagerConfiguration { get; set; }
/// <summary>
/// Creates a bucket with the provided bucket name and quota.
/// Creates a bucket with the provided bucket name and quota [GiB].
/// </summary>
/// <param name="bucketName">Name of the bucket</param>
/// <param name="quota">Quota for the bucket</param>
/// <param name="retention">Default retention period in seconds</param>
/// <param name="bucketName">Name of the bucket.</param>
/// <param name="quota">Quota for the bucket in GibiBYTE [GiB].</param>
/// <param name="retention">Default retention period in seconds [s].</param>
/// <returns>Nothing</returns>
/// <exception cref="Exception"></exception>
public async Task CreateBucket(string bucketName, long quota, long retention = 0L)
{
if (quota == 0 || quota < EcsManagerConfiguration.BucketQuotaMin || quota > EcsManagerConfiguration.BucketQuotaMax)
......@@ -46,10 +48,10 @@ namespace Coscine.ECSManager
}
/// <summary>
/// Delete a bucket with the provided bucket name.
/// Deletes a bucket by its bucket name.
/// </summary>
/// /// <param name="bucketName">Name of the bucket</param>
/// /// <returns>Operation success
/// <param name="bucketName">Name of the bucket.</param>
/// <returns>Operation success boolean.</returns>
public async Task<bool> DeleteBucket(string bucketName)
{
// create new management client USING NAMESPACE ADMINISTRATOR to obtain token
......@@ -69,11 +71,12 @@ namespace Coscine.ECSManager
}
/// <summary>
/// Sets the quota for the bucket.
/// Sets the quota for the bucket [GiB].
/// </summary>
/// /// <param name="bucketName">Name of the bucket</param>
/// /// <param name="quota">Quota for the bucket</param>
/// /// <returns>Operation success
/// <param name="bucketName">Name of the bucket.</param>
/// <param name="quota">Quota for the bucket in GibiBYTE [GiB].</param>
/// <returns>Operation success boolean.</returns>
/// <exception cref="Exception">Quota minimum compared to quota bucket maximum.</exception>
public async Task<bool> SetBucketQuota(string bucketName, long quota)
{
if (quota == 0 || quota < EcsManagerConfiguration.BucketQuotaMin || quota > EcsManagerConfiguration.BucketQuotaMax)
......@@ -99,10 +102,10 @@ namespace Coscine.ECSManager
}
/// <summary>
/// Gets the quota for the bucket.
/// Gets the reserved quota for the bucket [GiB].
/// </summary>
/// /// <param name="bucketName">Name of the bucket</param>
/// /// <returns>Quota of the bucket
/// <param name="bucketName">Name of the bucket.</param>
/// <returns>Reserved bucket quota in GibiBYTE (GiB).</returns>
public async Task<long> GetBucketQuota(string bucketName)
{
// create new management client USING NAMESPACE ADMINISTRATOR to obtain token
......@@ -120,7 +123,7 @@ namespace Coscine.ECSManager
var getBucketQuotaResult = await service.GetBucketQuota(bucketName, EcsManagerConfiguration.NamespaceName);
if (getBucketQuotaResult != null)
{
bucketQuota = getBucketQuotaResult.blockSize;
bucketQuota = getBucketQuotaResult.blockSize; // [GiB]
}
}
catch
......@@ -301,5 +304,42 @@ namespace Coscine.ECSManager
return getAclResult;
}
/// <summary>
/// Gets the total used quota for the bucket [Byte].
/// </summary>
/// <param name="bucketName">Name of the bucket.</param>
/// <returns>Total used quota by all files in the bucket in BYTE (Byte).</returns>
public async Task<long> GetBucketTotalUsedQuota(string bucketName)
{
// create new management client USING NAMESPACE ADMINISTRATOR to obtain token
using var client = new CoscineECSManagementClient(EcsManagerConfiguration.NamespaceAdminName, EcsManagerConfiguration.NamespaceAdminPassword, EcsManagerConfiguration.ManagerApiEndpoint);
// authenticate
await client.Authenticate();
// using authenticated client, obtain new instance of service client
var service = client.CreateServiceClient();
decimal bucketQuota = 0;
try
{
var getBucketBillingInfo = await service.GetBucketBillingInfo(EcsManagerConfiguration.NamespaceName, bucketName, "KB");
if (getBucketBillingInfo != null)
{
bucketQuota = getBucketBillingInfo.total_size; // [KiB]
}
}
catch
{
}
finally
{
await client.LogOut();
}
// Value update time has a delay of 30 sec to a minute.
return Convert.ToInt64(bucketQuota * 1024); // KiB to Byte
}
}
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
<RootNamespace>Coscine.ECSManager</RootNamespace>
<AssemblyName>Coscine.ECSManager</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<Version>2.2.0</Version>
<Version>2.3.0</Version>
</PropertyGroup>
<PropertyGroup>
<Authors>RWTH Aachen University</Authors>
......