Subscribe
Accepted Solution

invalid properties error when creating cifs share via manageability sdk

We recently upgraded from ontap 8.2.2p2 to 8.3.2p3. Afterward, we can no longer add shares programmatically. Here's a snippet from our python script:

 

 

api = NaElement("cifs-share-create")
api.child_add_string("path",linuxdir)
api.child_add_string("share-name", username + '$')

xi = NaElement("share-properties")
api.child_add(xi)

xi.child_add_string("cifs-share-properties",shareproperties)

output = netapp.invoke_elem(api)
if (output.results_status() == "failed"):
    print("ERROR: Unable to add CIFS share (" + output.results_reason() + ")")

 

 

The error we receive is:

 

ERROR: Unable to add CIFS share (Invalid value specified for "share-properties" element within "cifs-share-create": "oplocks browsable showsnapshot changenotify".)

 

 

The share properties ( "oplocks browsable showsnapshot changenotify") seem to be valid per the documentation, and they worked in 8.2.2p2. Any thoughts?

Re: invalid properties error when creating cifs share via manageability sdk

The cifs-share-properties property is meant to be an array of strings.  What is the variable "shareproperties"?

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: invalid properties error when creating cifs share via manageability sdk

Hi,

 

When you make your NaServer connection, what API version do you specify? was it 1.31? Just wondering if there is an issue with the ZAPI call with 8.3.2. I tried it invoking the "cifs-share-create" ZAPI using multiple different ONTAPI versions and changing the syntax of the "cifs-share-properties" to use spaces, commas, quotes etc and it failed every time more than one property was used in the "cifs-share-properties" attribute. EG:

 

temp1.png

 

Not sure what the correct syntax is to pass mutliple values to the share-properties parameter using ZAPI.

 

I check the data type of the "share-properties"  attribute is definately a string and the documentation indicates it should be comma delimited. Also checked the source code for the "Add-NcCifsShare" PowerShell CmdLet, the "-ShareProperties" parameter is definately a string.

 

// DataONTAP.C.PowerShell.SDK.Cmdlets.Cifs.AddNcCifsShare
[Parameter(HelpMessage = "The list of properties for this CIFS share. Possible values: \"oplocks\", \"browsable\", \"showsnapshot\", \"changenotify\", \"homedirectory\", \"attributecache\"")]
public string[] ShareProperties
{
	get;
	set;
}

Not sure about Python but in PowerShell I can pass an array of strings to the ShareProperties parameter. EG:

 

PS C:\> $credentials = Get-Credential -Credential admin
PS C:\> Connect-NcController -Name cluster1 -HTTPS -Credential $credentials

Name                 Address           Vserver              Version
----                 -------           -------              -------
cluster1             192.168.100.2                          NetApp Release 8.3.1: Mon Aug 31 08:49:20 UTC 2015

PS C:\> Add-NcCifsShare -Name test$ -Path "/volume_001" -ShareProperties @("oplocks","browsable","showsnapshot","changenotify") -VserverContext vserver1

CifsServer                ShareName       Path                                Comment
----------                ---------       ----                                -------
VSERVER1                  test$           /volume_001

Id suspect it's a syntax issue but I haven't tried it with an 8.3.2P2 system. Anyone else have the same issue post ONTAP upgrade?

 

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: invalid properties error when creating cifs share via manageability sdk

[ Edited ]

Just add share properties in this way

 

api = NaElement("cifs-share-create")
api.child_add_string("path","/volumetest")
api.child_add_string("share-name", 'test')

xi = NaElement("share-properties")
api.child_add(xi)

xi.child_add_string("cifs-share-properties","oplocks")
xi.child_add_string("cifs-share-properties","browsable")

# print input parameters
print(api.sprintf())

output = s.invoke_elem(api)
if (output.results_status() == "failed"):
print("ERROR: Unable to add CIFS share (" + output.results_reason() + ")")

 

Re: invalid properties error when creating cifs share via manageability sdk

That's the ticket francoisbnc! Based on your comment, I just created a simple loop to add the properties I had set:

 

for property in shareproperties.split(' '):
    xi.child_add_string("cifs-share-properties",property)

where shareproperties is something like "oplocks browsable showsnapshot changenotify".

 

Thanks to all those who took time to respond.

 


francoisbnc wrote:

Juste add share properties in this way

 

api = NaElement("cifs-share-create")
api.child_add_string("path","/volumetest")
api.child_add_string("share-name", 'test')

xi = NaElement("share-properties")
api.child_add(xi)

xi.child_add_string("cifs-share-properties","oplocks")
xi.child_add_string("cifs-share-properties","browsable")

# print input parameters
print(api.sprintf())

output = s.invoke_elem(api)
if (output.results_status() == "failed"):
print("ERROR: Unable to add CIFS share (" + output.results_reason() + ")")

 

Re: invalid properties error when creating cifs share via manageability sdk

[ Edited ]

I just wanted to add that it is possible to make this work with Export-CSV and Import-CSV too.  You just have to put the ShareProperities into an array like $Properties below.  Hopefully this example will help.  I know this is not directly related to your post but I stumbled across this thread while searching on the error and thought it might help someone.

 

$SRCshares = Get-NcCifsShare -VserverContext $SourceSVM | select Vserver,Volume,ShareName,Path,@{Name=’ShareProperties’;Expression={[string]::join(“;”,($_.ShareProperties))}} | Export-Csv ($PathtoFiles + "DRPsrcshares.csv")

 

$SRCshares = Import-Csv ($PathtoFiles + "DRPsrcshares.csv")

Foreach ($SRCShare in $SRCShares) {

   $Properties = $SRCShare.ShareProperties -split ";"

   Get-NcVserver $DestinationSVM | Add-NcCifsShare -Name $SRCShare.ShareName -Path $DSTNPath -ShareProperties $Properties

}

 

Re: invalid properties error when creating cifs share via manageability sdk

Or if you want something that is easy to follow just do something like this.  Put the share properties into an array and use that array when you manipulate the CIFS share.

 

$ShareProps = @("oplocks","browsable","changenotify","homedirectory")
Get-NcVserver $HomedirSVM | Add-NcCifsShare -Name "%w" -Path "%w" -ShareProperties $ShareProps | Out-Null