1 Rookie
•
16 Posts
0
77
NFS client modification via Rest
Trying to work on an automated process to add to the clients list of a NFS export via a Rest or a web call.
The only thing I have found so far is the following PUT but it replaces the existing entries in the client list.
Example:
Put https:/<server>/platform/16/protocols/nfs/exports/<id>
{"clients":[
"server2",
"server3",
],
}
The problem is that If server1 is already in the clients list, calling the above adds server2 and server3, but removes server1.
I could pull the current servers and then add them to the body of the put call along with the new servers, but not 100% that the server 1 would not loose access with it basically being remove and re-added.
Anyone figure a work around for this? basically want the equivalent of the following isi command:
isi nfs exports modify --id=<id> --add-client <server>.
tchstnut
1 Rookie
1 Rookie
•
16 Posts
0
March 14th, 2024 16:50
@Alptech Expert Thanks, that is pretty much what I am doing via Powershell subset of script:
$newclient="new_server"
$exportpath="/ifs/blah/blah"
$zone="nfs"
# create base for cluster Uri
$baseNFSurl = 'https://'+$Clustersname+/platform/16/protocols/nfs/exports/'
$Getexportinfourl=$baseNFSurl+"?path="+$exportpath+"&zone="+$zone
$nfsexportdata=Invoke-RestMethod -Uri $Getexportinfourl -Method Get -Headers $headers
$exportid=$nfsexportdata.exports.id
$clientlist=New-Object System.Collections.ArrayList
foreach($client in $nfsexportdata.exports.clients){
$clientlist.add($client)
}
$clientlist.add($newclient)
$Body=@{}
$Body.add("clients",$clientlist)
#replace clients
$modnfsurl=$baseNFSurl+$exportid+"/?zone="+$zone
Invoke-RestMethod -uri $modnfsurl -Method "PUT" -Headers $headers -body ($Body|convertto-json)