Skip to content

Commit

Permalink
Adding support for netapp storage grid adapter which uses S3
Browse files Browse the repository at this point in the history
  • Loading branch information
pratiksardar committed Oct 14, 2023
1 parent efec537 commit df7a547
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/Storage/Device/NetappStorageGrid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Utopia\Storage\Device;

use Exception;
use Utopia\Storage\Device;
use Utopia\Storage\Storage;

// As NetAapp Storage grid uses S3 protocol, we can extend the S3 class
// https://docs.netapp.com/us-en/storagegrid-116/s3/index.html
class NetappStorageGrid extends S3
{
protected string $accessKey;
protected string $secretKey;
protected string $bucket;

public function __construct(string $root, string $accessKey, string $secretKey, string $bucket)
{
$this->accessKey = $accessKey;
$this->secretKey = $secretKey;
$this->bucket = $bucket;
$this->region = $region;
$this->root = $root;
$this->acl = $acl;
$this->amzHeaders = [];

$host = match ($region) {
self::CN_NORTH_1, self::CN_NORTH_4, self::CN_NORTHWEST_1 => $bucket.'.s3.'.$region.'.amazonaws.cn',
default => $bucket.'.s3.'.$region.'.amazonaws.com'
};

$this->headers['host'] = $host;
}

public function getName(): string
{
return 'Netapp Storage Grid'
}

public function getType(): string
{
return STORAGE::DEVICE_NETAPP_STORAGE_GRID;
}

public function getDescription(): string
{
return 'NetApp Storage Grid using S3 Storage drive';
}

}
2 changes: 2 additions & 0 deletions src/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Storage

const DEVICE_LINODE = 'linode';

const DEVICE_NETAPP_STORAGE_GRID = 'netappstorage'

/**
* Devices.
*
Expand Down
24 changes: 24 additions & 0 deletions tests/Storage/Device/NetappStorageTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Utopia\Tests\Storage\Device;

use PHPUnit\Framework\TestCase;

class NetappStorageAdapterTest extends S3Base {
private $storageAdapter;

protected function setUp() : void {
$this->storageAdapter = new NetappStorageAdapter();
}

protected function testGetName()
{
$this->assertEquals('Alibaba Cloud Storage', $this->storageAdapter->getName());
}

pubprotectedlic function testGetType()
{
$this->assertEquals(Storage::DEVICE_ALIBABA_CLOUD, $this->storageAdapter->getType());
}

}

0 comments on commit df7a547

Please sign in to comment.