Subscribe

Is this (powershell) possible in c# with the ManageOntap API?

foreach ($controller in $controllers){
	$FAS=connect-nacontroller $controller -credential $cred -HTTPS
	$vols = get-navol | where {($_.Name -like "*_VOL_D01") -and ($_.Dedupe -eq "True")}
	foreach ($vol in $vols){
		$options=get-navoloption -Name $vol.Name |where {$_.Name -eq "nosnapdir"}
		"$($vol) $($options.Value)"
	}
}

 I have the above working in Powershell to check if the snapshot directory is hidden or visable, is this possible do do with the api sdk? ie looking for equivilents for get-navoloption in c#?

 

Thanks

Re: Is this (powershell) possible in c# with the ManageOntap API?

think i have found the longest way possible to do it?

 

            try
            {

                s = new NaServer(Server, 1, 3);
                s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                s.SetAdminUser(user, pwd);

                xi = new NaElement("volume-list-info");

                xo = s.InvokeElem(xi);

                ArrayList vols = new ArrayList();

                System.Collections.IList volList = xo.GetChildByName("volumes").GetChildren();
                System.Collections.IEnumerator volIter = volList.GetEnumerator();
                while (volIter.MoveNext())
                {
                    NaElement volInfo = (NaElement)volIter.Current;
                    vols.Add(volInfo.GetChildContent("name"));
                }

                foreach (string i in vols)
                {
                    xi = new NaElement("volume-options-list-info");

                    xi.AddNewChild("volume", i);

                    xo = s.InvokeElem(xi);

                    System.Collections.IList optionList = xo.GetChildByName("options").GetChildren();
                    System.Collections.IEnumerator optionIter = optionList.GetEnumerator();
                    while (optionIter.MoveNext())
                    {
                        NaElement volInfo = (NaElement)optionIter.Current;

                        if (volInfo.GetChildContent("name") == "nosnapdir")
                        {
                            Console.WriteLine("---------------------------------");
                            Console.Write("Volume\t\t: ");
                            Console.WriteLine(i);
                            Console.Write("Name\t\t: ");
                            Console.WriteLine(volInfo.GetChildContent("name"));
                            Console.Write("Value\t\t: ");
                            Console.WriteLine(volInfo.GetChildContent("value"));
                            Console.WriteLine("---------------------------------");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
            }

 Thanks

Re: Is this (powershell) possible in c# with the ManageOntap API?

How would you set the volume option ( nosnapdir ) via the SDK?