-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for netapp storage grid adapter which uses S3
- Loading branch information
1 parent
efec537
commit df7a547
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} |