Esempio n. 1
0
        public static void Main(String[] vargs)
        {
            args = vargs;
            int index = 0;

            if (args.Length < 3)
            {
                PrintUsageAndExit();
            }
            try
            {
                server = new NaServer(args[index++], 1, 15);
                server.SetAdminUser(args[index++], args[index++]);
                ListVolumes();
            }
            catch (NaException e)
            {
                //Print the error message
                Console.Error.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            NaElement xi;
            NaElement xo;
            NaServer  s;
            String    decPasswd;

            if (args.Length < 4)
            {
                Console.Error.WriteLine("Usage: encrypt_string <filer> <user> <password> <test-password>");
                Environment.Exit(1);
            }

            String server = args[0], user = args[1], pwd = args[2], testPwd = args[3];

            try
            {
                Console.WriteLine("|--------------------------------------------------|");
                Console.WriteLine("| Program to demo use of encrypted child elements  |");
                Console.WriteLine("|--------------------------------------------------|\n");

                //Initialize connection to server, and
                //request version 1.3 of the API set
                //
                s       = new NaServer(server, 1, 1);
                s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                s.SetAdminUser(user, pwd);

                //Create input element
                xi = new NaElement("test-password-set");
                xi.AddNewEncryptedChild("password", testPwd);

                //try to get the decrypted password
                decPasswd = xi.GetChildEncryptContent("password");
                Console.WriteLine("Expected decrypted password from server:" + decPasswd);

                //Invokes ONTAPI API
                xo = s.InvokeElem(xi);

                //Display output in XML format
                Console.WriteLine("\nOUTPUT XML:");
                String output = xo.ToString();
                Console.WriteLine(output);
            }
            catch (NaAuthException e)
            {
                System.Console.Error.WriteLine("Authorization Failed: " + e.Message);
            }
            catch (NaApiFailedException e)
            {
                System.Console.Error.WriteLine("API FAILED: " + e.Message);
            }
            catch (Exception e)
            {
                System.Console.Error.WriteLine(e.Message);
            }
        }
Esempio n. 3
0
        static void GetSchedule(String[] args)
        {
            NaServer s;
            string   filer = args[1];
            string   user  = args[2];
            string   pwd   = args[3];
            string   vol   = args[4];

            NaElement xi, xo;

            //
            // get the schedule
            //
            try
            {
                s               = new NaServer(filer, 1, 0);
                s.Style         = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                s.TransportType = NaServer.TRANSPORT_TYPE.HTTP;
                s.SetAdminUser(user, pwd);

                xi = new NaElement("snapshot-get-schedule");
                if (args.Length == 5)
                {
                    xi.AddNewChild("volume", vol);
                }
                else
                {
                    Console.Error.WriteLine("Invalid number of arguments");
                    Usage(args);
                    System.Environment.Exit(-1);
                }

                xo = s.InvokeElem(xi);
                //
                // print it out
                //
                Console.WriteLine("Snapshot schedule for volume " + vol + " on filer " + filer + ":");
                Console.WriteLine("-----------------------------------------------------------------");
                Console.WriteLine("Snapshots are taken on minutes [" +
                                  xo.GetChildIntValue("which-minutes", 0) + "] of each hour (" +
                                  xo.GetChildContent("minutes") + " kept)");
                Console.WriteLine("Snapshots are taken on hours [" +
                                  xo.GetChildContent("which-hours") + "] of each day (" +
                                  xo.GetChildContent("hours") + " kept)\n");
                Console.WriteLine(xo.GetChildContent("days") + " nightly snapshots are kept\n");
                Console.WriteLine(xo.GetChildContent("weeks") + " weekly snapshots are kept\n");
                Console.WriteLine("\n");
            }
            catch (NaException e)
            {
                Console.WriteLine("ERROR: " + e.Message);
            }
        }
Esempio n. 4
0
        static void RenameSnapshot(String[] args)
        {
            try
            {
                NaServer  s;
                string    filer = args[1];
                string    user = args[2];
                string    pwd = args[3];
                string    vol = args[4];
                string    ssnameOld = args[5];
                string    ssnameNew = args[6];
                NaElement xi, xo;

                s               = new NaServer(filer, 1, 0);
                s.Style         = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                s.TransportType = NaServer.TRANSPORT_TYPE.HTTP;
                s.SetAdminUser(user, pwd);

                xi = new NaElement("snapshot-rename");
                if (args.Length == 7)
                {
                    xi.AddNewChild("volume", vol);
                    xi.AddNewChild("current-name", ssnameOld);
                    xi.AddNewChild("new-name", ssnameNew);
                }
                else
                {
                    Console.Error.WriteLine("Invalid number of arguments");
                    Usage(args);
                    System.Environment.Exit(-1);
                }

                xo = s.InvokeElem(xi);
                //
                // print it out
                //
                Console.WriteLine("Snapshot " + ssnameOld + " renamed to " +
                                  ssnameNew + " for volume " + vol + " on filer " + filer);
            }
            catch (IndexOutOfRangeException e)
            {
                Console.Error.WriteLine("ERROR:" + e.Message);
                Usage(args);
                System.Environment.Exit(-1);
            }
            catch (NaException e)
            {
                Console.Error.WriteLine("ERROR: " + e.Message);
            }
        }
Esempio n. 5
0
        static void ListInfo(String[] args)
        {
            NaServer s;
            string   filer = args[1];
            string   user  = args[2];
            string   pwd   = args[3];
            string   vol   = args[4];

            NaElement xi, xo;

            //
            // get the schedule
            //
            try
            {
                s               = new NaServer(filer, 1, 0);
                s.Style         = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                s.TransportType = NaServer.TRANSPORT_TYPE.HTTP;
                s.SetAdminUser(user, pwd);

                xi = new NaElement("snapshot-list-info");
                xi.AddNewChild("volume", vol);
                xo = s.InvokeElem(xi);

                System.Collections.IList       snapshots = xo.GetChildByName("snapshots").GetChildren();
                System.Collections.IEnumerator snapiter  = snapshots.GetEnumerator();
                while (snapiter.MoveNext())
                {
                    NaElement snapshot = (NaElement)snapiter.Current;
                    Console.WriteLine("SNAPSHOT:");
                    int      accesstime = snapshot.GetChildIntValue("access-time", 0);
                    DateTime datetime   = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(accesstime);
                    Console.WriteLine("   NAME \t\t= " + snapshot.GetChildContent("name"));
                    Console.WriteLine("   ACCESS TIME (GMT) \t= " + datetime);
                    Console.WriteLine("   BUSY \t\t= " + snapshot.GetChildContent("busy"));
                    Console.WriteLine("   TOTAL (of 1024B) \t= " + snapshot.GetChildContent("total"));
                    Console.WriteLine("   CUMULATIVE TOTAL (of 1024B) = " + snapshot.GetChildContent("cumulative-total"));
                    Console.WriteLine("   DEPENDENCY \t\t= " + snapshot.GetChildContent("dependency"));
                }
            }
            catch (NaAuthException e)
            {
                Console.Error.WriteLine("Authentication Error : " + e.Message);
            }
            catch (NaApiFailedException e)
            {
                Console.Error.WriteLine("API Failed : " + e.Message);
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            NaServer  s;
            NaElement xi, xo;

            if (args.Length < 3)
            {
                Console.Error.WriteLine("Usage: hello_ontapi  filer user passwd");
                Environment.Exit(1);
            }
            String Server = args[0];
            String User   = args[1];
            String Pwd    = args[2];

            try
            {
                Console.WriteLine("|---------------------------------------------------------------|");
                Console.WriteLine("| Program to Demo a simple API call to query Data ONTAP Version |");
                Console.WriteLine("|---------------------------------------------------------------|\n");
                //Initialize connection to server, and
                //request version 1.3 of the API set
                //
                s       = new NaServer(Server, 1, 0);
                s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                s.SetAdminUser(User, Pwd);

                //Invokes ONTAPI API to get the Data ONTAP
                //version number of a filer
                xi = new NaElement("system-get-version");
                xo = s.InvokeElem(xi);
                //Parse output
                String output = xo.GetChildContent("version");
                //Print output
                Console.Out.WriteLine("Hello! " +
                                      "Data ONTAP version of " + Server + " is \"" + output + "\"");
            }
            catch (NaException e)
            {
                //Print the error message
                Console.Error.WriteLine(e.Message);
            }
            catch (System.Exception e)
            {
                Console.Error.WriteLine(e.Message);
            }
        }
        protected override void ProcessRecord()
        {
            if (_server == null || _user == null || _passwd == null)
            {
                WriteObject(Usage);
                return;
            }

            try
            {
                NaServer  server = new NaServer(_server, 1, 0);
                NaElement input  = new NaElement("volume-list-info");
                server.SetAdminUser(User, Passwd);
                if (_volume != null)
                {
                    input.AddNewChild("volume", _volume);
                }
                NaElement output = server.InvokeElem(input);

                System.Collections.IList volList = output.
                                                   GetChildByName("volumes").GetChildren();
                System.Collections.IEnumerator volIter = volList.GetEnumerator();
                WriteObject("\n------------------------------------------------------------------------");
                WriteObject("Name \t type \t state \t size-total \t size-used \t size-available");
                WriteObject("------------------------------------------------------------------------");
                String vol = "";
                while (volIter.MoveNext())
                {
                    NaElement volInfo = (NaElement)volIter.Current;
                    vol = volInfo.GetChildContent("name") + "\t" +
                          volInfo.GetChildContent("type") + "\t" +
                          volInfo.GetChildContent("state") + "\t" +
                          volInfo.GetChildContent("size-total") + "\t" +
                          volInfo.GetChildContent("size-used") + "\t" +
                          volInfo.GetChildContent("size-available");
                    WriteObject(vol);
                }
                WriteObject("------------------------------------------------------------------------\n");
            }
            catch (Exception e)
            {
                WriteObject(e.Message);
            }
        }
        protected override void ProcessRecord()
        {
            if (_server == null || _user == null || _passwd == null)
            {
                WriteObject(Usage);
                return;
            }

            try
            {
                NaServer server = new NaServer(_server, 1, 0);
                server.SetAdminUser(User, Passwd);
                NaElement output  = server.Invoke("system-get-version");
                String    version = output.GetChildContent("version");
                WriteObject("Hello world!  DOT version of " + _server + " is: " + version);
            }
            catch (Exception e)
            {
                WriteObject(e.Message);
            }
        }
        static void Main(String[] args)
        {
            Args = args;
            int arglen = Args.Length;

            // Checking for valid number of parameters
            if (arglen < 4)
            {
                Usage();
            }

            String dfmserver = Args[0];
            String dfmuser   = Args[1];
            String dfmpw     = Args[2];
            String dfmop     = Args[3];

            // checking for valid number of parameters for the respective
            // operations
            if ((dfmop.Equals("delete") && arglen != 5) ||
                (dfmop.Equals("create") && arglen < 7) ||
                (dfmop.Equals("template-list") && arglen < 4) ||
                (dfmop.Equals("template-delete") && arglen != 5) ||
                (dfmop.Equals("template-create") && arglen < 5))
            {
                Usage();
            }

            // checking if the operation selected is valid
            if ((!dfmop.Equals("list")) && (!dfmop.Equals("create")) &&
                (!dfmop.Equals("delete")) && (!dfmop.Equals("template-list")) &&
                (!dfmop.Equals("template-create")) &&
                (!dfmop.Equals("template-delete")))
            {
                Usage();
            }

            try
            {
                //Initialize connection to server, and
                //request version 1.0 of the API set
                //
                // Creating a server object and setting appropriate attributes
                server            = new NaServer(dfmserver, 1, 0);
                server.Style      = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                server.ServerType = NaServer.SERVER_TYPE.DFM;
                server.SetAdminUser(dfmuser, dfmpw);

                // Calling the functions based on the operation selected
                if (dfmop.Equals("create"))
                {
                    Create();
                }
                else if (dfmop.Equals("delete"))
                {
                    Delete();
                }
                else if (dfmop.Equals("template-list"))
                {
                    TemplateList();
                }
                else if (dfmop.Equals("template-create"))
                {
                    TemplateCreate();
                }
                else if (dfmop.Equals("template-delete"))
                {
                    TemplateDelete();
                }
                else
                {
                    Usage();
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }
        static void Main(String[] args)
        {
            // check for the valid no. of arguments
            if (args.Length < 4)
            {
                Usage();
            }

            String operation = null;

            server = null;

            try
            {
                // create the server context for DFM Server
                server            = new NaServer(args[0], 1, 0);
                server.Style      = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                server.ServerType = NaServer.SERVER_TYPE.DFM;
                server.SetAdminUser(args[1], args[2]);

                Args      = args;
                operation = args[3];

                // Check for the given input operation and call
                //appropriate function.
                if (operation.Equals("operation-list"))
                {
                    OperationList();
                }
                else if (operation.Equals("operation-add"))
                {
                    OperationAdd();
                }
                else if (operation.Equals("operation-delete"))
                {
                    OperationDelete();
                }
                else if (operation.Equals("role-add"))
                {
                    RoleAdd();
                }
                else if (operation.Equals("role-delete"))
                {
                    RoleDelete();
                }
                else if (operation.Equals("role-list"))
                {
                    RoleList();
                }
                else if (operation.Equals("role-capability-add"))
                {
                    RoleCapabilityAdd();
                }
                else if (operation.Equals("role-capability-delete"))
                {
                    RoleCapabilityDelete();
                }
                else if (operation.Equals("admin-role-add"))
                {
                    AdminRoleAdd();
                }
                else if (operation.Equals("admin-role-delete"))
                {
                    AdminRoleDelete();
                }
                else if (operation.Equals("admin-role-list"))
                {
                    RoleAdminList();
                }
                else if (operation.Equals("admin-list"))
                {
                    AdminList();
                }
                else
                {
                    Usage();
                }
            }
            catch (NaException e)
            {
                //Print the error message
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }
        static void Main(string[] args)
        {
            NaElement xi;
            NaElement xo;
            NaServer  s;

            if (args.Length < 3)
            {
                Console.WriteLine("Usage : vollist <filername> <username> <passwd> [<volume>]");
                System.Environment.Exit(1);
            }

            String Server = args[0], user = args[1], pwd = args[2];

            try {
                Console.WriteLine("|--------------------------------------------------------|");
                Console.WriteLine("| Program to Demo use of Volume APIs to list Volume info |");
                Console.WriteLine("|--------------------------------------------------------|");

                //Initialize connection to server, and
                //request version 1.3 of the API set
                //
                s       = new NaServer(Server, 1, 3);
                s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                s.SetAdminUser(user, pwd);

                //Create Vol list Info ONTAPI API
                xi = new NaElement("volume-list-info");
                if (args.Length == 4)
                {
                    String volume_name = args[3];
                    xi.AddNewChild("volume", volume_name);
                }

                //Invoke Vol list Info ONTAPI API
                xo = s.InvokeElem(xi);
                //
                //Get the list of children from element(Here 'xo') and iterate
                //through each of the child element to fetch their values
                //
                System.Collections.IList       volList = xo.GetChildByName("volumes").GetChildren();
                System.Collections.IEnumerator volIter = volList.GetEnumerator();
                while (volIter.MoveNext())
                {
                    NaElement volInfo = (NaElement)volIter.Current;
                    Console.WriteLine("---------------------------------");
                    Console.Write("Volume Name\t\t: ");
                    Console.WriteLine(volInfo.GetChildContent("name"));
                    Console.Write("Volume State\t\t: ");
                    Console.WriteLine(volInfo.GetChildContent("state"));
                    Console.Write("Disk Count\t\t: ");
                    Console.WriteLine(volInfo.GetChildIntValue("disk-count", -1));
                    Console.Write("Total Files\t\t: ");
                    Console.WriteLine(volInfo.GetChildIntValue("files-total", -1));
                    Console.Write("No of files used\t: ");
                    Console.WriteLine(volInfo.GetChildIntValue("files-used", -1));
                    Console.WriteLine("---------------------------------");
                }
            }
            catch (Exception e) {
                Console.Error.WriteLine(e.Message);
            }
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            NaElement xi;
            NaElement xo;
            NaServer  s;
            String    op;

            if (args.Length < 3)
            {
                Console.Out.Write("Usage : optmgmt <filername> " + "<username> <passwd> [operation(get/set)] " + "[<optionName>] [<value>]");
                Environment.Exit(1);
            }
            try
            {
                Console.WriteLine("|------------------------------------------------|");
                Console.WriteLine("| Program to Demo use of OPTIONS MANAGEMENT APIs |");
                Console.WriteLine("|------------------------------------------------|");
                //Initialize connection to server, and
                //request version 1.3 of the API set
                //
                s       = new NaServer(args[0], 1, 1);
                s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                s.SetAdminUser(args[1], args[2]);

                //Invoke option list Info ONTAPI API
                if (args.Length > 3)
                {
                    op = args[3];

                    //
                    // Get value of a specific option
                    //
                    if (0 == String.Compare(op, "get"))
                    {
                        xi = new NaElement("options-get");
                        if (args.Length == 5)
                        {
                            xi.AddNewChild("name", args[4]);
                        }
                        else
                        {
                            Console.Error.WriteLine("Improper number of arguments. Correct and re-run.");
                            Environment.Exit(1);
                        }

                        xo = s.InvokeElem(xi);
                        Console.Out.WriteLine("----------------------------");
                        Console.Out.Write("Option Value:");
                        Console.Out.WriteLine(xo.GetChildContent("value"));
                        Console.Out.Write("Cluster Constraint:");
                        Console.Out.WriteLine(xo.GetChildContent("cluster-constraint"));
                        Console.Out.WriteLine("----------------------------");
                    }
                    //
                    // Set value of a specific option
                    else if (0 == String.Compare(op, "set"))
                    {
                        xi = new NaElement("options-set");
                        if (args.Length == 6)
                        {
                            xi.AddNewChild("name", args[4]);
                            xi.AddNewChild("value", args[5]);
                        }
                        else
                        {
                            Console.Error.WriteLine("Improper number of arguments. Correct and re-run.");
                            Environment.Exit(1);
                        }
                        xo = s.InvokeElem(xi);
                        Console.Out.WriteLine("----------------------------");
                        if (xo.GetChildContent("message") != null)
                        {
                            Console.Out.Write("Message: ");
                            Console.Out.WriteLine(xo.GetChildContent("message"));
                        }
                        Console.Out.Write("Cluster Constraint: ");
                        Console.Out.WriteLine(xo.GetChildContent("cluster-constraint"));
                        Console.Out.WriteLine("----------------------------");
                    }
                    else
                    {
                        Console.Out.WriteLine("Invalid Operation");
                        Environment.Exit(1);
                    }
                    Environment.Exit(0);
                }
                //
                // List out all the options
                //
                else
                {
                    xi = new NaElement("options-list-info");

                    xo = s.InvokeElem(xi);
                    //
                    // Get the list of children from element(Here
                    // 'xo') and iterate through each of the child
                    // element to fetch their values
                    //
                    System.Collections.IList       optionList = xo.GetChildByName("options").GetChildren();
                    System.Collections.IEnumerator optionIter = optionList.GetEnumerator();
                    while (optionIter.MoveNext())
                    {
                        NaElement optionInfo = (NaElement)optionIter.Current;
                        Console.Out.WriteLine("----------------------------");
                        Console.Out.Write("Option Name:");
                        Console.Out.WriteLine(optionInfo.GetChildContent("name"));
                        Console.Out.Write("Option Value:");
                        Console.Out.WriteLine(optionInfo.GetChildContent("value"));
                        Console.Out.Write("Cluster Constraint:");
                        Console.Out.WriteLine(optionInfo.GetChildContent("cluster-constraint"));
                    }
                }
            }
            catch (NaConnectionException e)
            {
                Console.Error.WriteLine("NaConnException: " + e.Message);
                Environment.Exit(1);
            }
            catch (NaException e)
            {
                Console.Error.WriteLine("NAEXCEPTION: " + e.Message);
                Environment.Exit(1);
            }
            catch (System.Exception e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }
        static void Main(string[] args)
        {
            NaElement xi;
            NaElement xo;
            NaServer  s;
            String    operation;

            if (args.Length < 4)
            {
                PrintUsage();
            }
            try
            {
                Console.WriteLine("|-----------------------------------------|");
                Console.WriteLine("| Program to Demo use of Performance APIs |");
                Console.WriteLine("|-----------------------------------------|");

                /*
                 * Initialize connection to server, and
                 * request version 1.3 of the API set
                 */
                s = new NaServer(args[0], 1, 3);

                /* Set connection style(HTTP)*/
                s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                s.SetAdminUser(args[1], args[2]);
                operation = args[3];

                /* To invoke perf-object-list-info API
                 *  Usage: perf_operation <filer> <user> <password> object-list
                 *
                 */
                if (operation.Equals("object-list"))
                {
                    xi = new NaElement("perf-object-list-info");
                    xo = s.InvokeElem(xi);
                    System.Collections.IList       objList = xo.GetChildByName("objects").GetChildren();
                    System.Collections.IEnumerator objIter = objList.GetEnumerator();

                    while (objIter.MoveNext())
                    {
                        NaElement objInfo = (NaElement)objIter.Current;
                        Console.Out.Write("Object Name = " + objInfo.GetChildContent("name") + "\t");
                        Console.Out.Write("privilege level = " + objInfo.GetChildContent("privilege-level") + "\n");
                    }
                    Console.Out.WriteLine("\n");
                }

                /* To invoke perf-object-instance-list-info API
                 *  Usage: perf_operation <filer> <user> <password> instance-list <objectname>
                 *
                 */
                else if (operation.Equals("instance-list"))
                {
                    if (args.Length < 5)
                    {
                        Console.Out.WriteLine("Usage:");
                        Console.Out.WriteLine("perf_operation <filer> <user> <password> <instance-list> <objectname>");
                        Environment.Exit(1);
                    }

                    xi = new NaElement("perf-object-instance-list-info");
                    xi.AddNewChild("objectname", args[4]);
                    xo = s.InvokeElem(xi);

                    System.Collections.IList       instList = xo.GetChildByName("instances").GetChildren();
                    System.Collections.IEnumerator instIter = instList.GetEnumerator();

                    while (instIter.MoveNext())
                    {
                        NaElement instInfo = (NaElement)instIter.Current;
                        Console.Out.WriteLine("Instance Name = " + instInfo.GetChildContent("name"));
                    }
                }

                /* To invoke perf-object-counter-list-info API
                 *  Usage: perf_operation <filer> <user> <password> counter-list <objectname>
                 *
                 */
                else if (operation.Equals("counter-list"))
                {
                    if (args.Length < 5)
                    {
                        Console.Out.WriteLine("Usage:");
                        Console.Out.WriteLine("perf_operation <filer> <user> <password> <counter-list> <objectname>");
                        Environment.Exit(1);
                    }

                    xi = new NaElement("perf-object-counter-list-info");
                    xi.AddNewChild("objectname", args[4]);
                    xo = s.InvokeElem(xi);

                    System.Collections.IList       counterList = xo.GetChildByName("counters").GetChildren();
                    System.Collections.IEnumerator counterIter = counterList.GetEnumerator();

                    while (counterIter.MoveNext())
                    {
                        NaElement counterInfo = (NaElement)counterIter.Current;
                        Console.Out.Write("Counter Name = " + counterInfo.GetChildContent("name") + "\t\t\t\t");

                        if (counterInfo.GetChildContent("base-counter") != null)
                        {
                            Console.Out.Write("Base Counter = " + counterInfo.GetChildContent("base-counter") + "\t");
                        }
                        else
                        {
                            Console.Out.Write("Base Counter = none\t\t\t");
                        }

                        Console.Out.Write("Privilege Level = " + counterInfo.GetChildContent("privilege-level") + "\t\t");

                        if (counterInfo.GetChildContent("unit") != null)
                        {
                            Console.Out.Write("Unit = " + counterInfo.GetChildContent("unit") + "\t");
                        }
                        else
                        {
                            Console.Out.Write("Unit = none\t");
                        }

                        Console.Out.Write("\n");
                    }
                }

                /* To invoke perf-object-get-instances-iter-* API
                 *  Usage: perf_operation <filer> <user> <password>
                 *                           <get-counter-values> <objectname> <counter1> <counter2> <counter3>......
                 */
                else if (operation.Equals("get-counter-values"))
                {
                    int    totalRecords = 0;
                    int    maxRecords   = 10;
                    int    numRecords   = 0;
                    String iterTag      = null;

                    if (args.Length < 5)
                    {
                        Console.Out.WriteLine("Usage:");
                        Console.Out.WriteLine("perf_operation <filer> <user> <password> " +
                                              "<get-counter-values> <objectname> [<counter1> <counter2> ...]");
                        Environment.Exit(1);
                    }

                    xi = new NaElement("perf-object-get-instances-iter-start");

                    xi.AddNewChild("objectname", args[4]);

                    NaElement counters = new NaElement("counters");

                    /*Now store rest of the counter names as child
                     * element of counters
                     *
                     * Here it has been hard coded as 5 because
                     * first counter is specified at 6th position from
                     * cmd prompt
                     */
                    int numCounter = 5;

                    while (numCounter < (args.Length))
                    {
                        counters.AddNewChild("counter", args[numCounter]);
                        numCounter++;
                    }

                    /* If no counters are specified then all the counters are fetched */
                    if (numCounter > 5)
                    {
                        xi.AddChildElement(counters);
                    }

                    xo           = s.InvokeElem(xi);
                    totalRecords = xo.GetChildIntValue("records", -1);
                    iterTag      = xo.GetChildContent("tag");

                    do
                    {
                        xi = new NaElement("perf-object-get-instances-iter-next");
                        xi.AddNewChild("tag", iterTag);
                        xi.AddNewChild("maximum", System.Convert.ToString(maxRecords));
                        xo         = s.InvokeElem(xi);
                        numRecords = xo.GetChildIntValue("records", 0);

                        if (numRecords != 0)
                        {
                            System.Collections.IList       instList = xo.GetChildByName("instances").GetChildren();
                            System.Collections.IEnumerator instIter = instList.GetEnumerator();

                            while (instIter.MoveNext())
                            {
                                NaElement instData = (NaElement)instIter.Current;
                                Console.Out.WriteLine("Instance = " + instData.GetChildContent("name"));
                                System.Collections.IList       counterList = instData.GetChildByName("counters").GetChildren();
                                System.Collections.IEnumerator counterIter = counterList.GetEnumerator();
                                while (counterIter.MoveNext())
                                {
                                    NaElement counterData = (NaElement)counterIter.Current;
                                    Console.Out.Write("counter name = " + counterData.GetChildContent("name"));
                                    Console.Out.Write("\t counter value = " + counterData.GetChildContent("value") + "\n");
                                }
                                Console.Out.WriteLine("\n");
                            }
                        }
                    }while (numRecords != 0);

                    xi = new NaElement("perf-object-get-instances-iter-end");
                    xi.AddNewChild("tag", iterTag);
                    xo = s.InvokeElem(xi);
                }
                else
                {
                    PrintUsage();
                }
            }
            catch (NaAuthException e)
            {
                Console.Error.WriteLine(e.Message + "Bad login/password");
            }
            catch (NaApiFailedException e)
            {
                Console.Error.WriteLine("API failed (" + e.Message + ")");
            }
            catch (NaProtocolException e)
            {
                Console.Error.WriteLine(e.Message);
            }
            catch (System.Exception e)
            {
                Console.Error.WriteLine(e.Message);
            }
        }
        static void Main(string[] args)
        {
            NaElement xi;
            NaElement xo;
            NaServer  s;
            int       index;
            String    options;
            int       dos1 = 0;

            if (args.Length < 5)
            {
                usage();
            }

            index = args[0].IndexOf('-');
            if (index == 0 && args[0][index] == '-')
            {
                options = args[0].Substring(index + 1);
                if (options.Equals("s") && args.Length > 5)
                {
                    dos1 = 1;
                }
                else
                {
                    usage();
                }
            }

            Console.WriteLine("|------------------------------------|");
            Console.WriteLine("| Program to Demo VFILER Tunnel APIs |");
            Console.WriteLine("|------------------------------------|");

            try {
                if (dos1 == 1)
                {
                    //Initialize connection to server, and
                    //request version 1.7 of the API set for vfiler-tunneling
                    //
                    s       = new NaServer(args[2], 1, 7);
                    s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                    s.SetAdminUser(args[3], args[4]);
                    s.TransportType = NaServer.TRANSPORT_TYPE.HTTPS;
                    s.Port          = 443;
                    s.ServerType    = NaServer.SERVER_TYPE.FILER;
                    s.SetVfilerTunneling(args[1]);

                    //Invoke any  ONTAPI API with arguments
                    //in (key,value) pair
                    //args[0]=option,args[1]=vfiler-name,args[2]=vfiler,
                    //args[3]=user,args[4] = passwd, args[5]=Ontapi API,
                    //args[6] onwards arguments in (key,value)
                    //pair
                    //
                    xi = new NaElement(args[5]);

                    try {
                        if (args.Length > 6)
                        {
                            for (int index1 = 6; index1 <
                                 args.Length; index1++)
                            {
                                xi.AddNewChild(
                                    args[index1],
                                    args[index1 + 1]);
                                index1++;
                            }
                        }
                    }
                    catch (IndexOutOfRangeException e) {
                        Console.Out.WriteLine("Mismatch in arguments passed "
                                              + "(in (key,value) Pair) to Ontapi API");
                        throw new NaApiFailedException(e.Message);
                    }
                }
                else
                {
                    //Initialize connection to server, and
                    //request version 1.7 of the API set for vfiler-tunneling
                    //
                    s       = new NaServer(args[1], 1, 7);
                    s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                    s.SetAdminUser(args[2], args[3]);
                    s.SetVfilerTunneling(args[0]);

                    //Invoke any  ONTAPI API with arguments
                    //in (key,value) pair
                    //args[0]=filer,args[1]=user,args[2]=passwd
                    //args[3]=Ontapi API,args[4] onward arguments
                    // in (key,value) pair
                    //
                    xi = new NaElement(args[4]);
                    try {
                        if (args.Length > 5)
                        {
                            for (int index2 = 5; index2 <
                                 args.Length; index2++)
                            {
                                xi.AddNewChild(
                                    args[index2],
                                    args[index2 + 1]);
                                index2++;
                            }
                        }
                    }
                    catch (IndexOutOfRangeException e) {
                        Console.Error.WriteLine("Mismatch in arguments passed "
                                                + "(in (key,value) Pair) to Ontapi API");
                        throw new NaApiFailedException(e.Message);
                    }
                }
                xo = s.InvokeElem(xi);
                Console.WriteLine(xo.ToPrettyString(""));
            }
            catch (NaApiFailedException e) {
                Console.Error.WriteLine("API Failed Exception : " + e.Message);
                System.Environment.Exit(1);
            }
            catch (Exception e) {
                Console.Error.WriteLine("Exception: " + e.Message);
                System.Environment.Exit(1);
            }
        }
        static void Main(string[] args)
        {
            NaElement xi;
            NaElement xo;
            NaServer  s;
            String    operation;

            if (args.Length < 4)
            {
                PrintUsage();
            }
            try
            {
                Console.WriteLine("|-----------------------------------------|");
                Console.WriteLine("| Program to demo use of NFS related APIs |");
                Console.WriteLine("|-----------------------------------------|\n");

                /*
                 * Initialize connection to server, and
                 * request version 1.3 of the API set
                 */
                s = new NaServer(args[0], 1, 3);

                /* Set connection style(HTTP)*/
                s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;
                s.SetAdminUser(args[1], args[2]);
                operation = args[3];

                /* To invoke nfs-enable API
                 *  Usage: nfs <filer> <user> <password> enable
                 *
                 */
                if (operation.Equals("enable"))
                {
                    xi = new NaElement("nfs-enable");
                    xo = s.InvokeElem(xi);
                    Console.Out.WriteLine("enabled successfully!");
                }

                /* To invoke nfs-enable API
                 *  Usage: nfs <filer> <user> <password> disable
                 *
                 */
                else if (operation.Equals("disable"))
                {
                    xi = new NaElement("nfs-disable");
                    xo = s.InvokeElem(xi);
                    Console.Out.WriteLine("disabled successfully!");
                }

                /* To invoke nfs-status API
                 *  Usage: nfs <filer> <user> <password> status
                 *
                 */
                else if (operation.Equals("status"))
                {
                    xi = new NaElement("nfs-status");
                    xo = s.InvokeElem(xi);
                    String enabled = xo.GetChildContent("is-enabled");
                    if (String.Compare(enabled, "true") == 0)
                    {
                        Console.Out.WriteLine("NFS Server is enabled");
                    }
                    else
                    {
                        Console.Out.WriteLine("NFS Server is disabled");
                    }
                }

                /* To invoke nfs-exportfs-list-rules API
                 *  Usage: nfs <filer> <user> <password> list
                 *
                 */
                else if (operation.Equals("list"))
                {
                    xi = new NaElement("nfs-exportfs-list-rules");
                    xo = s.InvokeElem(xi);

                    System.Collections.IList retList = xo.GetChildByName("rules").GetChildren();
                    System.Console.WriteLine(xo.ToPrettyString(""));
                    Environment.Exit(0);
                    System.Collections.IEnumerator retIter = retList.GetEnumerator();

                    while (retIter.MoveNext())
                    {
                        NaElement retInfo  = (NaElement)retIter.Current;
                        String    pathName = retInfo.GetChildContent("pathname");
                        String    rwList   = "rw=";
                        String    roList   = "ro=";
                        String    rootList = "root=";


                        if (retInfo.GetChildByName("read-only") != null)
                        {
                            NaElement ruleElem = retInfo.GetChildByName("read-only");
                            System.Collections.IList       hosts    = ruleElem.GetChildren();
                            System.Collections.IEnumerator hostIter = hosts.GetEnumerator();
                            while (hostIter.MoveNext())
                            {
                                NaElement hostInfo = (NaElement)hostIter.Current;
                                if (hostInfo.GetChildContent("all-hosts") != null)
                                {
                                    String allHost = hostInfo.GetChildContent("all-hosts");
                                    if (String.Compare(allHost, "true") == 0)
                                    {
                                        roList = roList + "all-hosts";
                                        break;
                                    }
                                }
                                else if (hostInfo.GetChildContent("name") != null)
                                {
                                    roList = roList + hostInfo.GetChildContent("name") + ":";
                                }
                            }
                        }
                        if (retInfo.GetChildByName("read-write") != null)
                        {
                            NaElement ruleElem = retInfo.GetChildByName("read-write");
                            System.Collections.IList       hosts    = ruleElem.GetChildren();
                            System.Collections.IEnumerator hostIter = hosts.GetEnumerator();
                            while (hostIter.MoveNext())
                            {
                                NaElement hostInfo = (NaElement)hostIter.Current;
                                if (hostInfo.GetChildContent("all-hosts") != null)
                                {
                                    String allHost = hostInfo.GetChildContent("all-hosts");
                                    if (String.Compare(allHost, "true") == 0)
                                    {
                                        rwList = rwList + "all-hosts";
                                        break;
                                    }
                                }
                                else if (hostInfo.GetChildContent("name") != null)
                                {
                                    rwList = rwList + hostInfo.GetChildContent("name") + ":";
                                }
                            }
                        }
                        if (retInfo.GetChildByName("root") != null)
                        {
                            NaElement ruleElem = retInfo.GetChildByName("root");
                            System.Collections.IList       hosts    = ruleElem.GetChildren();
                            System.Collections.IEnumerator hostIter = hosts.GetEnumerator();
                            while (hostIter.MoveNext())
                            {
                                NaElement hostInfo = (NaElement)hostIter.Current;
                                if (hostInfo.GetChildContent("all-hosts") != null)
                                {
                                    String allHost = hostInfo.GetChildContent("all-hosts");
                                    if (String.Compare(allHost, "true") == 0)
                                    {
                                        rootList = rootList + "all-hosts";
                                        break;
                                    }
                                }
                                else if (hostInfo.GetChildContent("name") != null)
                                {
                                    rootList = rootList + hostInfo.GetChildContent("name") + ":";
                                }
                            }
                        }

                        if (String.Compare(roList, "ro=") != 0)
                        {
                            pathName = pathName + ", \t" + roList;
                        }
                        if (String.Compare(rwList, "rw=") != 0)
                        {
                            pathName = pathName + ", \t" + rwList;
                        }
                        if (String.Compare(rootList, "root=") != 0)
                        {
                            pathName = pathName + ", \t" + rootList;
                        }

                        Console.Out.WriteLine(pathName);
                    }
                }
                else
                {
                    PrintUsage();
                }
            }
            catch (NaAuthException e)
            {
                Console.Error.WriteLine("Bad login/password" + e.Message);
            }
            catch (NaApiFailedException e)
            {
                Console.Error.WriteLine("API failed (" + e.Message + ")");
            }
            catch (NaProtocolException e)
            {
                Console.Error.WriteLine(e.StackTrace);
            }
            catch (System.Exception e)
            {
                Console.Error.WriteLine(e.Message);
            }
        }