Software Development Kit (SDK) and API Discussions

PSTK: Remove-NcNetDns missing




I notice that there is Get-NcNetDns and Set-NcNetDns (to get the list of DNS servers, and to change the DNS servers), but there is no corresponding Remove-NcNetDns to remove the DNS config from an SVM or the Cluster.


Would it be possible to add that commandlet to the next version of PSTK? Currently we're relying on Invoke-NcSSH for that, and that has some other quirks that make it undesirable





Re: PSTK: Remove-NcNetDns missing


You can actually use the "Set-NcNetDns" command to remove DNS servers from the configuration by just using empty double quotes for the NameServers parameter. (code snippet from the output of the "Get-Help Set-NcNetDns -Examples command"): 


    --------------  Example 3 --------------

    C:\PS>Set-NcNetDns -NameServers ""

    Remove the name server list from the DNS configuration of the current vserver.


Re: PSTK: Remove-NcNetDns missing


Did you actually try that command? Because it was the first thing I tried, and it doesn't work:


PS C:\> set-ncnetdns -vserver ClusterF -NameServers ""
set-ncnetdns : Invalid value specified with "-name-servers". Specify a valid IP address.
At line:1 char:1
+ set-ncnetdns -vserver ClusterF -NameServers ""
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ( [Set-NcNetDns], EAPIERROR
    + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Net.SetNcNetDns


Re: PSTK: Remove-NcNetDns missing


Dang, that's what I get for assuming that a cmdlet will work according to its documentation! 🙂 


It looks like there's a discrepancy between what the cmdlet itself accepts for the NameServers parameter and what the "name-servers" parameter in ZAPI accepts.  From the de-compiled Set-NcNetDns cmdlet:


[Parameter(HelpMessage = "Addresses of name servers such as ''.", Position = 1, ValueFromPipelineByPropertyName = true)]
    [Alias(new string[] {"Servers"})]
    public string[] NameServers { get; set; }

 And the ZAPI:

<?xml version="1.0" encoding="UTF-8"?>
<netapp  xmlns="" version="1.160">


PS C:\users\donny.lang\desktop> $Request = @"
>>   <net-dns-modify>
>>     <name-servers>
>>       <ip-address>""</ip-address>
>>     </name-servers>
>>   </net-dns-modify>
>> "
PS C:\users\donny.lang\desktop> Invoke-NcSystemApi -Request $Request -VserverContext lab-svm-01
Invoke-NcSystemApi : Invalid value specified for "name-servers" element within "net-dns-modify": """".
At line:1 char:1
+ Invoke-NcSystemApi -Request $Request -VserverContext lab-svm-01
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ( [Invoke-NcSystemApi], EINVALIDINPUTERROR
    + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.System.InvokeNcSystemApi

 I wonder if it worked in an older version of the API and was removed/changed for some reason. 

Re: PSTK: Remove-NcNetDns missing


The"" will not in Ontap 9. It use to work in Data Ontap 8.

::*> dns modify -vserver vs1 -domains domain.local -name-servers "" 
Error: command failed: Invalid value specified with "-name-servers". Specify a
       valid IP address.


Earn Rewards for Your Review!
GPI Review Banner
All Community Forums