Software Development Kit (SDK) and API Discussions
Software Development Kit (SDK) and API Discussions
Hi there,
I am using the SDK to develop a small helper program in Perl to provision datasets and qtrees for a customer.
Most of it is working fine, it can create datasets where needed and provision qtrees and export them as NFS when requested.
But for some reason I can't get nfs-export-root-hosts and nfs-export-rw-hosts to be applied, so the qtrees are always exported as read write for everyone.
Below is a subset of the code:
my $inputelem = NaElement->new("dataset-provision-member");
$inputelem->child_add_string("edit-lock-id", $editlock);
my $memberelem = NaElement->new("provision-member-request-info");
$memberelem->child_add_string("name", $qname );
$memberelem->child_add_string("size", $size );
my $exportelem = NaElement->new("dataset-export-info");
if ($protocol =~ /^nfs$/i ) {
$exportelem->child_add_string("dataset-export-protocol", "nfs");$exportelem->child_add_string("is-readwrite-for-all-hosts", 0);
$exportelem->child_add_string("is-readonly-for-all-hosts", 0);
my $nfsexportelem = NaElement->new("dataset-nfs-export-setting");
my $nfsexportroothosts = NaElement->new("nfs-export-root-hosts");
my $nfsexportrwhosts = NaElement->new("nfs-export-rw-hosts");
foreach (split(/,/, $nfsaccess)) {
$nfsexportroothosts->child_add_string("hostname", $_);
$nfsexportrwhosts->child_add_string("hostname", $_);
}
$nfsexportelem->child_add($nfsexportroothosts);
$nfsexportelem->child_add($nfsexportrwhosts);
$exportelem->child_add($nfsexportelem);
}
elsif ($protocol =~ /^cifs$/i ) {
# FIXME
}
$memberelem->child_add($exportelem);
$inputelem->child_add($memberelem);
print($inputelem->sprintf());
my $result = $globalservobj->invoke_elem($inputelem);
&catch_error($result);
my $commitresult = &dataset_commit($editlock);
Like I mentioned, the commit works without error. I get a qtree provisioned, just not with the export settings I specified.
As you can see above I do a sprintf() of the provision element for debug purposes. That looks like this:
<dataset-provision-member>
<edit-lock-id>1337867804</edit-lock-id>
<provision-member-request-info>
<name>q1005N</name>
<size>26214400</size>
<dataset-export-info>
<dataset-export-protocol>nfs</dataset-export-protocol>
<is-readwrite-for-all-hosts>0</is-readwrite-for-all-hosts>
<is-readonly-for-all-hosts>0</is-readonly-for-all-hosts>
<dataset-nfs-export-setting>
<nfs-export-root-hosts>
<hostname>127.0.0.1</hostname>
<hostname>192.168.1.1</hostname>
</nfs-export-root-hosts>
<nfs-export-rw-hosts>
<hostname>127.0.0.1</hostname>
<hostname>192.168.1.1</hostname>
</nfs-export-rw-hosts>
</dataset-nfs-export-setting>
</dataset-export-info>
</provision-member-request-info>
</dataset-provision-member>
Can't quite figure out what I'm doing wrong, any help greatly appreciated.
Best regards,
Peter
Solved! See The Solution
Hi Peter,
Could you please try adding a tag <nfs-export-host> as in below:
<dataset-nfs-export-setting>
<nfs-export-root-hosts>
<nfs-export-host>
<hostname>127.0.0.1</hostname>
</nfs-export-host>
<nfs-export-host>
<hostname>192.168.1.1</hostname>
</nfs-export-host>
</nfs-export-root-hosts>
<nfs-export-rw-hosts>
<nfs-export-host>
<hostname>127.0.0.1</hostname>
</nfs-export-host>
<nfs-export-host>
<hostname>192.168.1.1</hostname>
</nfs-export-host>
</nfs-export-rw-hosts>
So in your code you might have to add:
foreach (split(/,/, $nfsaccess)) {
my $nfsexporthost = new NaElement('nfs-export-host');
$nfsexporootrohosts->child_add($nfsexporthost);
$nfsexporthost->child_add_string('hostname',$_);
...
....
}
It seems to be working for me.
Regards,
-Amir
Hi Peter,
Could you please share the NMSDK & ONTAPI version that you are using?
Regards,
-Amir
Thanks for you reply Amir,
I am now using NMSDK 5.0, but I have previously used NMSDK 4.1 with the same result.
I am running this against OnCommand version 5.0 (5.0.0.7636)
The filer it provisions against is a NetApp Release 8.1 7-Mode, but I never contact it directly using the SDK, all goes through the DFM-server.
Hi Peter,
Could you please try adding a tag <nfs-export-host> as in below:
<dataset-nfs-export-setting>
<nfs-export-root-hosts>
<nfs-export-host>
<hostname>127.0.0.1</hostname>
</nfs-export-host>
<nfs-export-host>
<hostname>192.168.1.1</hostname>
</nfs-export-host>
</nfs-export-root-hosts>
<nfs-export-rw-hosts>
<nfs-export-host>
<hostname>127.0.0.1</hostname>
</nfs-export-host>
<nfs-export-host>
<hostname>192.168.1.1</hostname>
</nfs-export-host>
</nfs-export-rw-hosts>
So in your code you might have to add:
foreach (split(/,/, $nfsaccess)) {
my $nfsexporthost = new NaElement('nfs-export-host');
$nfsexporootrohosts->child_add($nfsexporthost);
$nfsexporthost->child_add_string('hostname',$_);
...
....
}
It seems to be working for me.
Regards,
-Amir
Thanks Amir, that was exactly it. I had somewhat misunderstood the concept of elements.
For the record, besides changing to add the extra nfs-export-host element, I also had to add "is-readwrite-for-all-hosts" and set it to false, as well as adding "nfs-security-flavors"-element. See below:
my $nfsexportelem = NaElement->new("dataset-nfs-export-setting");$nfsexportelem->child_add_string("is-readwrite-for-all-hosts", "false");
$nfsexportelem->child_add_string("is-readonly-for-all-hosts", "false");
my $secflavorelem = NaElement->new("nfs-security-flavors");
$secflavorelem->child_add_string("nfs-security-flavor", "sys");
$nfsexportelem->child_add($secflavorelem);
According to the NMSDK4.1 documentation, "is-readwrite-for-all-hosts" should default to "false", and "nfs-security-flavor" should default to "sys", but that has not been my experience. I have not been able to verify this in the NMSDK5.0 documentation
But adding them, together with the "nfs-export-host" element makes everything behave as expected. Thanks again!