Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for netapp storage grid adapter #96

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/Storage/Device/NetappStorageGrid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace 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
23 changes: 23 additions & 0 deletions tests/Storage/Device/NetappStorageTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Utopia\Tests\Storage\Device;

class NetappStorageAdapterTest extends S3Base
{
private $storageAdapter;

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

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

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