Software Development Kit (SDK) and API Discussions

Highlighted

PSTK: Remove-NcNetDns missing

Hi,

 

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

 

Thanks

-Michael

3 REPLIES 3
Highlighted

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.

  

Highlighted

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: (10.91.81.206:NcController) [Set-NcNetDns], EAPIERROR
    + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Net.SetNcNetDns

 

Highlighted

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 '123.123.123.123'.", Position = 1, ValueFromPipelineByPropertyName = true)]
    [AllowNull]
    [AllowEmptyCollection]
    [Alias(new string[] {"Servers"})]
    public string[] NameServers { get; set; }

 And the ZAPI:

<?xml version="1.0" encoding="UTF-8"?>
<netapp  xmlns="http://www.netapp.com/filer/admin" version="1.160">
  <net-dns-modify>
    <attempts></attempts>
    <dns-state></dns-state>
    <domains></domains>
    <is-tld-query-enabled></is-tld-query-enabled>
    <name-servers>
      <ip-address></ip-address>
    </name-servers>
    <require-packet-query-match></require-packet-query-match>
    <require-source-address-match></require-source-address-match>
    <skip-config-validation></skip-config-validation>
    <timeout></timeout>
  </net-dns-modify>
</netapp>

 

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: (10.250.63.175:NcController) [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. 

Check out the KB!
Knowledge Base
All Community Forums