Skip to content

Commit

Permalink
fix: update netapp storage backend
Browse files Browse the repository at this point in the history
  • Loading branch information
fregataa committed Mar 31, 2024
1 parent a0be351 commit 670a0e7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
2 changes: 2 additions & 0 deletions configs/storage-proxy/sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ path = "/vfroot/netapp"
netapp_ontap_endpoint = "https://netapp.example.com"
netapp_ontap_user = "admin-username"
netapp_ontap_password = "admin-passwd"
netapp_user_id = 1100 # Owner user id. Must be created on Netapp mgmt server.
netapp_group_id = 1100 # Owner group id. Must be created on Netapp mgmt server.
netapp_svm = "svm-name"
netapp_volume_name = "netapp-volume-name"
netapp_xcp_cmd = ["/home/user/xcp/linux/xcp"]
Expand Down
16 changes: 12 additions & 4 deletions src/ai/backend/storage/netapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,15 @@ async def create_quota_scope(
result = await self.netapp_client.create_qtree(self.svm_id, self.volume_id, qspath.name)
self.netapp_client.check_job_result(result, [])
if options is not None:
await self.update_quota_scope(quota_scope_id, options)
result = await self.netapp_client.set_quota_rule(
self.svm_id,
self.volume_id,
qspath.name,
options,
)
self.netapp_client.check_job_result(result, [])
result = await self.netapp_client.enable_quota(self.volume_id)
self.netapp_client.check_job_result(result, ["5308507"]) # pass if "already on"

async def describe_quota_scope(
self,
Expand All @@ -97,15 +105,13 @@ async def update_quota_scope(
config: QuotaConfig,
) -> None:
qspath = self.mangle_qspath(quota_scope_id)
result = await self.netapp_client.set_quota_rule(
result = await self.netapp_client.update_quota_rule(
self.svm_id,
self.volume_id,
qspath.name,
config,
)
self.netapp_client.check_job_result(result, [])
result = await self.netapp_client.enable_quota(self.volume_id)
self.netapp_client.check_job_result(result, ["5308507"]) # pass if "already on"

# FIXME: How do we implement unset_quota() for NetApp?
async def unset_quota(self, quota_scope_id: QuotaScopeID) -> None:
Expand Down Expand Up @@ -419,6 +425,8 @@ async def init(self) -> None:
self.ontap_endpoint,
self.config["netapp_ontap_user"],
self.config["netapp_ontap_password"],
self.config["netapp_user_id"],
self.config["netapp_group_id"],
)
self.netapp_nfs_host = self.config["netapp_nfs_host"]
self.netapp_xcp_cmd = self.config["netapp_xcp_cmd"]
Expand Down
33 changes: 33 additions & 0 deletions src/ai/backend/storage/netapp/netappclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,23 @@ class NetAppClient:
endpoint: str
user: str
password: str
user_id: int
group_id: int
_session: aiohttp.ClientSession

def __init__(
self,
endpoint: str,
user: str,
password: str,
user_id: int,
group_id: int,
) -> None:
self.endpoint = endpoint
self.user = user
self.password = password
self.user_id = user_id
self.group_id = group_id
_connector = aiohttp.TCPConnector(ssl=False)
_auth = aiohttp.BasicAuth(self.user, self.password)
self._session = aiohttp.ClientSession(
Expand Down Expand Up @@ -414,6 +420,8 @@ async def create_qtree(
"svm.uuid": str(svm_id),
"volume.uuid": str(volume_id),
"name": qtree_name,
"user.id": self.user_id,
"group.id": self.group_id,
},
) as resp:
data = await resp.json()
Expand Down Expand Up @@ -472,6 +480,31 @@ async def _find_quota_rule(
)
return records[0]

async def update_quota_rule(
self,
svm_id: StorageID,
volume_id: VolumeID,
qtree_name: str,
config: QuotaConfig,
) -> AsyncJobResult:
record = await self._find_quota_rule(svm_id, volume_id, qtree_name)
async with self.send_request(
"patch",
f"/api/storage/quota/rules/{record['uuid']}",
data={
"space": {
"hard_limit": config.limit_bytes,
"soft_limit": config.limit_bytes,
},
# 'files': { # not supported yet from Backend.AI
# 'hard_limit': 0,
# 'soft_limit': 0,
# },
},
) as resp:
data = await resp.json()
return await self.wait_job(data["job"]["uuid"])

async def get_quota_rule(
self,
svm_id: StorageID,
Expand Down

0 comments on commit 670a0e7

Please sign in to comment.