public static void ListVservers()
        {
            NaElement xi, xo;
            String    rootVol, rootVolAggr, secStyle, state;
            String    tag = "";

            while (tag != null)
            {
                xi = new NaElement("vserver-get-iter");
                if (args.Length > 3)
                {
                    if (args.Length < 5 || !args[3].Equals("-v"))
                    {
                        PrintUsageAndExit();
                    }
                    server.Vserver = args[4];
                }
                if (!tag.Equals(""))
                {
                    xi.AddNewChild("tag", tag);
                }
                xo = server.InvokeElem(xi);
                if (xo.GetChildIntValue("num-records", 0) == 0)
                {
                    Console.WriteLine("No vserver(s) information available\n");
                    return;
                }
                tag = xo.GetChildContent("next-tag");
                List <NaElement> vserverList = xo.GetChildByName("attributes-list").GetChildren();
                Console.WriteLine("----------------------------------------------------");
                foreach (NaElement vserverInfo in vserverList)
                {
                    Console.WriteLine("Name                    : " + vserverInfo.GetChildContent("vserver-name"));
                    Console.WriteLine("Type                    : " + vserverInfo.GetChildContent("vserver-type"));
                    rootVolAggr = vserverInfo.GetChildContent("root-volume-aggregate");
                    rootVol     = vserverInfo.GetChildContent("root-volume");
                    secStyle    = vserverInfo.GetChildContent("root-volume-security-style");
                    state       = vserverInfo.GetChildContent("state");
                    Console.WriteLine("Root volume aggregate   : " + (rootVolAggr != null ? rootVolAggr : ""));
                    Console.WriteLine("Root volume             : " + (rootVol != null ? rootVol : ""));
                    Console.WriteLine("Root volume sec style   : " + (secStyle != null ? secStyle : ""));
                    Console.WriteLine("UUID                    : " + vserverInfo.GetChildContent("uuid"));
                    Console.WriteLine("State                   : " + (state != null ? state : ""));
                    NaElement allowedProtocols = null;
                    Console.Write("Allowed protocols       : ");
                    if ((allowedProtocols = vserverInfo.GetChildByName("allowed-protocols")) != null)
                    {
                        List <NaElement> allowedProtocolsList = allowedProtocols.GetChildren();
                        foreach (NaElement protocol in allowedProtocolsList)
                        {
                            Console.Write(protocol.GetContent() + " ");
                        }
                    }
                    Console.Write("\nName server switch      : ");
                    NaElement nameServerSwitch = null;
                    if ((nameServerSwitch = vserverInfo.GetChildByName("name-server-switch")) != null)
                    {
                        List <NaElement> nsSwitchList = nameServerSwitch.GetChildren();
                        foreach (NaElement nsSwitch in  nsSwitchList)
                        {
                            Console.Write(nsSwitch.GetContent() + " ");
                        }
                    }
                    Console.WriteLine("\n----------------------------------------------------");
                }
            }
        }
        static void TemplateList()
        {
            String templateName = null;

            try
            {
                // creating a template lsit start element
                NaElement input =
                    new NaElement("vfiler-template-list-info-iter-start");
                if (Args.Length > 4)
                {
                    templateName = Args[4];
                    input.
                    AddNewChild("vfiler-template-name-or-id", templateName);
                }

                // invoke the api && capturing the records && tag values
                NaElement output = server.InvokeElem(input);

                // Extracting the record && tag values && printing them
                String records = output.GetChildContent("records");

                if (records.Equals("0"))
                {
                    Console.WriteLine("\nNo templates to display");
                }

                String tag = output.GetChildContent("tag");


                // Extracting records one at a time
                input = new NaElement("vfiler-template-list-info-iter-next");
                input.AddNewChild("maximum", records);
                input.AddNewChild("tag", tag);
                NaElement record = server.InvokeElem(input);

                // Navigating to the vfiler templates child element
                NaElement stat = record.GetChildByName("vfiler-templates");

                // Navigating to the vfiler-info child element
                System.Collections.IList infoList = null;

                if (stat != null)
                {
                    infoList = stat.GetChildren();
                }
                if (infoList == null)
                {
                    return;
                }


                System.Collections.IEnumerator infoIter =
                    infoList.GetEnumerator();

                // Iterating through each record
                while (infoIter.MoveNext())
                {
                    String    value;
                    NaElement info = (NaElement)infoIter.Current;

                    Console.WriteLine(
                        "--------------------------------------------------------");
                    // extracting the template name and printing it
                    value = info.GetChildContent("vfiler-template-name");
                    Console.WriteLine("Template Name : " + value);

                    value = info.GetChildContent("vfiler-template-id");
                    Console.WriteLine("Template Id : " + value);

                    value = info.GetChildContent("vfiler-template-description");
                    Console.Write("Template Description : ");
                    if (value != null)
                    {
                        Console.Write(value);
                    }

                    Console.WriteLine("\n----------------------------------"
                                      + "--------------");

                    // printing detials if only one template is selected
                    if (templateName != null)
                    {
                        value = info.GetChildContent("cifs-auth-type");
                        Console.WriteLine("\nCIFS Authhentication     : "
                                          + value);

                        value = info.GetChildContent("cifs-domain");
                        Console.Write("CIFS Domain              : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        value = info.GetChildContent("cifs-security-style");
                        Console.WriteLine("\nCIFS Security Style      : "
                                          + value);

                        value = info.GetChildContent("dns-domain");
                        Console.Write("DNS Domain               : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        value = info.GetChildContent("nis-domain");
                        Console.Write("\nNIS Domain               : ");
                        if (value != null)
                        {
                            Console.WriteLine(value);
                        }
                    }
                }

                // invoking the iter-end zapi
                input = new NaElement("vfiler-template-list-info-iter-end");
                input.AddNewChild("tag", tag);
                server.InvokeElem(input);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }
Пример #3
0
        static void MemberList()
        {
            String memberName = null;
            String poolName   = Args[4];

            try {
                // creating a resourcepool member start element
                NaElement input =
                    new NaElement("resourcepool-member-list-info-iter-start");
                input.AddNewChild("resourcepool-name-or-id", poolName);
                if (Args.Length > 5)
                {
                    memberName = Args[5];
                    input.
                    AddNewChild("resourcepool-member-name-or-id", memberName);
                }

                // invoke the api && capturing the records && tag values
                NaElement output = server.InvokeElem(input);


                // Extracting the record && tag values && printing them
                String records = output.GetChildContent("records");

                if (records.Equals("0"))
                {
                    Console.WriteLine("\nNo members to display");
                }


                String tag = output.GetChildContent("tag");

                // Extracting records one at a time
                input =
                    new NaElement("resourcepool-member-list-info-iter-next");
                input.AddNewChild("maximum", records);
                input.AddNewChild("tag", tag);
                NaElement record = server.InvokeElem(input);

                // Navigating to the resourcepool-members child element
                NaElement stat = record.GetChildByName("resourcepool-members");

                // Navigating to the schedule-info child element
                System.Collections.IList infoList = null;

                if (stat != null)
                {
                    infoList = stat.GetChildren();
                }
                if (infoList == null)
                {
                    return;
                }


                System.Collections.IEnumerator infoIter =
                    infoList.GetEnumerator();

                // Iterating through each record
                while (infoIter.MoveNext())
                {
                    String    value;
                    NaElement info = (NaElement)infoIter.Current;

                    // extracting the member name and printing it
                    String name = info.GetChildContent("member-name");
                    String id   = info.GetChildContent("member-id");
                    if (memberName == null || (memberName != null &&
                                               (name.Equals(memberName) || id.Equals(memberName))))
                    {
                        Console.WriteLine(
                            "----------------------------------------------------");
                        Console.WriteLine("Member Name : " + name);
                        Console.WriteLine("Member Id : " + id);
                        Console.WriteLine(
                            "----------------------------------------------------");
                    }
                    else
                    {
                        throw new NaException("Member " + memberName + " name not found");
                    }

                    // printing detials if only one member is selected for listing
                    if (memberName != null && (name.Equals(memberName) ||
                                               id.Equals(memberName)))
                    {
                        value = info.GetChildContent("member-type");
                        Console.WriteLine("\nMember Type            : " + value);

                        value = info.GetChildContent("member-status");
                        Console.WriteLine("Member Status          : " + value);

                        value = info.GetChildContent("member-perf-status");
                        Console.WriteLine("Member Perf Status     : " + value);

                        value = info.GetChildContent("resource-tag");
                        Console.Write("Resource Tag           : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        value = info.GetChildContent("member-count");
                        Console.Write("\nMember Member Count    : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        value = info.GetChildContent("member-used-space");
                        Console.WriteLine("\nMember Used Space      : "
                                          + value + " bytes");

                        value = info.GetChildContent("member-committed-space");
                        Console.WriteLine("Member Committed Space : "
                                          + value + " bytes");

                        value = info.GetChildContent("member-size");
                        Console.WriteLine("Member Size            : "
                                          + value + " bytes");
                    }
                }

                // invoking the iter-end zapi
                input = new NaElement("resourcepool-member-list-info-iter-end");
                input.AddNewChild("tag", tag);
                server.InvokeElem(input);
            }
            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);
            }
        }
Пример #4
0
        static void List()
        {
            String dfmSchedule = null;

            try {
                // creating a dfm schedule start element
                NaElement input =
                    new NaElement("dfm-schedule-list-info-iter-start");
                input.AddNewChild("schedule-category", "dfm_schedule");
                if (Args.Length > 4)
                {
                    dfmSchedule = Args[4];
                    input.AddNewChild("schedule-name-or-id", dfmSchedule);
                }

                // invoke the api && capturing the records && tag values
                NaElement output = server.InvokeElem(input);


                // Extracting the record && tag values && printing them
                String records = output.GetChildContent("records");

                if (records.Equals("0"))
                {
                    Console.WriteLine("\nNo schedules to display");
                }


                String tag = output.GetChildContent("tag");



                // Extracting records one at a time
                input = new NaElement("dfm-schedule-list-info-iter-next");
                input.AddNewChild("maximum", records);
                input.AddNewChild("tag", tag);
                NaElement record = server.InvokeElem(input);

                // Navigating to the schedule-content-list child element
                NaElement stat = record.GetChildByName("schedule-content-list");

                // Navigating to the schedule-info child element
                System.Collections.IList infoList = null;

                if (stat != null)
                {
                    infoList = stat.GetChildren();
                }
                if (infoList == null)
                {
                    return;
                }


                System.Collections.IEnumerator infoIter =
                    infoList.GetEnumerator();

                // Iterating through each record
                while (infoIter.MoveNext())
                {
                    String    value;
                    NaElement info = (NaElement)infoIter.Current;
                    // extracting the schedule details && printing it
                    Console.WriteLine(
                        "----------------------------------------------------");
                    Console.WriteLine("Schedule Name : "
                                      + info.GetChildContent("schedule-name"));

                    Console.WriteLine("Schedule Id          : " +
                                      info.GetChildContent("schedule-id"));

                    Console.WriteLine("Schedule Description : " +
                                      info.GetChildContent("schedule-description"));

                    Console.WriteLine(
                        "----------------------------------------------------");

                    // printing details if only one schedule is selected
                    if (dfmSchedule != null)
                    {
                        Console.WriteLine("\nSchedule Type        : " +
                                          info.GetChildContent("schedule-type"));

                        Console.WriteLine("Schedule Category    : " +
                                          info.GetChildContent("schedule-category"));


                        String type = info.GetChildContent("schedule-type");

                        NaElement typeList =
                            info.GetChildByName(type + "-list");
                        if (typeList != null)
                        {
                            NaElement typeInfo =
                                typeList.GetChildByName(type + "-info");

                            if (type.Equals("daily"))
                            {
                                Console.WriteLine("Item Id              : " +
                                                  typeInfo.GetChildContent("item-id"));

                                value = typeInfo.GetChildContent("start-hour");
                                Console.Write("Start Hour           : ");
                                if (value != null)
                                {
                                    Console.Write(value);
                                }

                                value =
                                    typeInfo.GetChildContent("start-minute");
                                Console.Write("\nStart Minute         : ");
                                if (value != null)
                                {
                                    Console.WriteLine(value);
                                }
                            }
                            else if (type.Equals("weekly"))
                            {
                                Console.WriteLine("Item Id              : " +
                                                  typeInfo.GetChildContent("item-id"));

                                value = typeInfo.GetChildContent("start-hour");
                                Console.Write("Start Hour           : ");
                                if (value != null)
                                {
                                    Console.Write(value);
                                }

                                value =
                                    typeInfo.GetChildContent("start-minute");
                                Console.Write("\nStart Minute         : ");
                                if (value != null)
                                {
                                    Console.Write(value);
                                }

                                value = typeInfo.GetChildContent("day-of-week");
                                Console.Write("\nDay Of Week          : ");
                                if (value != null)
                                {
                                    Console.WriteLine(value);
                                }
                            }
                            else if (type.Equals("monthly"))
                            {
                                Console.WriteLine("Item Id              : " +
                                                  typeInfo.GetChildContent("item-id"));

                                value = typeInfo.GetChildContent("start-hour");
                                Console.Write("Start Hour           : ");
                                if (value != null)
                                {
                                    Console.Write(value);
                                }

                                value =
                                    typeInfo.GetChildContent("start-minute");
                                Console.Write("\nStart Minute         : ");
                                if (value != null)
                                {
                                    Console.Write(value);
                                }

                                value = typeInfo.GetChildContent("day-of-week");
                                Console.Write("\nDay Of Week          : ");
                                if (value != null)
                                {
                                    Console.Write(value);
                                }

                                value =
                                    typeInfo.GetChildContent("week-of-month");
                                Console.Write("\nWeek Of Month        : ");
                                if (value != null)
                                {
                                    Console.Write(value);
                                }

                                value =
                                    typeInfo.GetChildContent("day-of-month");
                                Console.Write("\nDay Of Month         : ");
                                if (value != null)
                                {
                                    Console.WriteLine(value);
                                }
                            }
                        }
                    }
                }

                // invoking the iter-end zapi
                input = new NaElement("dfm-schedule-list-info-iter-end");
                input.AddNewChild("tag", tag);
                server.InvokeElem(input);
            }
            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;
            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);
            }
        }
Пример #6
0
        static void List()
        {
            String poolName = null;

            try {
                // creating a resource pool start element
                NaElement input =
                    new NaElement("resourcepool-list-info-iter-start");
                if (Args.Length > 4)
                {
                    poolName = Args[4];
                    input.AddNewChild("object-name-or-id", poolName);
                }

                // invoke the api && capturing the records && tag values
                NaElement output = server.InvokeElem(input);


                // Extracting the record && tag values && printing them
                String records = output.GetChildContent("records");

                if (records.Equals("0"))
                {
                    Console.WriteLine("\nNo resourcepools to display");
                }


                String tag = output.GetChildContent("tag");


                // Extracting records one at a time
                input = new NaElement("resourcepool-list-info-iter-next");
                input.AddNewChild("maximum", records);
                input.AddNewChild("tag", tag);
                NaElement record = server.InvokeElem(input);

                // Navigating to the resourcepools child element
                NaElement stat = record.GetChildByName("resourcepools");

                // Navigating to the schedule-info child element
                System.Collections.IList infoList = null;

                if (stat != null)
                {
                    infoList = stat.GetChildren();
                }
                if (infoList == null)
                {
                    return;
                }


                System.Collections.IEnumerator infoIter =
                    infoList.GetEnumerator();

                // Iterating through each record
                while (infoIter.MoveNext())
                {
                    String    value;
                    NaElement info = (NaElement)infoIter.Current;

                    Console.WriteLine(
                        "--------------------------------------------------------");
                    // extracting the resource-pool name and printing it
                    value = info.GetChildContent("resourcepool-name");
                    Console.WriteLine("Resourcepool Name : " + value);

                    value = info.GetChildContent("resourcepool-id");
                    Console.WriteLine("Resourcepool Id : " + value);

                    value = info.GetChildContent("resourcepool-description");
                    Console.WriteLine("Resourcepool Description : " + value);

                    Console.WriteLine(
                        "--------------------------------------------------------");

                    // printing detials if only one resource-pool is selected for listing
                    if (poolName != null)
                    {
                        value = info.GetChildContent("\nresourcepool-status");
                        Console.WriteLine("Resourcepool Status                "
                                          + "      : " + value);

                        value =
                            info.GetChildContent("resourcepool-perf-status");
                        Console.WriteLine("Resourcepool Perf Status           "
                                          + "      : " + value);

                        value = info.GetChildContent("resource-tag");
                        Console.Write("Resource Tag                           "
                                      + "  : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        value =
                            info.GetChildContent("resourcepool-member-count");
                        Console.WriteLine("\nResourcepool Member Count         "
                                          + "       : " + value);

                        value =
                            info.GetChildContent("resourcepool-full-threshold");
                        Console.Write("Resourcepool Full Threshold            "
                                      + "  : ");
                        if (value != null)
                        {
                            Console.Write(value + "%");
                        }

                        value = info.
                                GetChildContent("resourcepool-nearly-full-threshold");
                        Console.Write("\nResourcepool Nearly Full Threshold    "
                                      + "   : ");
                        if (value != null)
                        {
                            Console.Write(value + "%");
                        }

                        value = info.GetChildContent("aggregate-nearly-"
                                                     + "overcommitted-threshold");
                        Console.WriteLine("\nAggregate Nearly Overcommitted"
                                          + " Threshold : " + value + "%");

                        value = info.
                                GetChildContent("aggregate-overcommitted-threshold");
                        Console.WriteLine("Aggregate Overcommitted Threshold   "
                                          + "     : " + value + "%");
                    }
                }

                // invoking the iter-end zapi
                input = new NaElement("resourcepool-list-info-iter-end");
                input.AddNewChild("tag", tag);
                server.InvokeElem(input);
            }
            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);
            }
        }
Пример #7
0
        static void List()
        {
            String policyName = null;

            try
            {
                // creating a dp policy start element
                NaElement input = new NaElement("dp-policy-list-iter-start");
                if (Args.Length > 4)
                {
                    policyName = Args[4];
                    input.AddNewChild("dp-policy-name-or-id", policyName);
                }

                // invoke the api && capturing the records && tag values
                NaElement output = server.InvokeElem(input);


                // Extracting the record && tag values && printing them
                String records = output.GetChildContent("records");

                if (records.Equals("0"))
                {
                    Console.WriteLine("\nNo policies to display");
                }

                String tag = output.GetChildContent("tag");



                // Extracting records one at a time
                input = new NaElement("dp-policy-list-iter-next");
                input.AddNewChild("maximum", records);
                input.AddNewChild("tag", tag);
                NaElement record = server.InvokeElem(input);

                // Navigating to the dp-policy-infos child element
                NaElement stat = record.GetChildByName("dp-policy-infos");

                // Navigating to the dp-policy-info child element
                System.Collections.IList infoList = null;

                if (stat != null)
                {
                    infoList = stat.GetChildren();
                }
                if (infoList == null)
                {
                    return;
                }


                System.Collections.IEnumerator infoIter =
                    infoList.GetEnumerator();

                // Iterating through each record
                while (infoIter.MoveNext())
                {
                    String    value;
                    NaElement info = (NaElement)infoIter.Current;


                    // extracting the policy name and printing it
                    // Navigating to the dp-policy-content child element
                    NaElement policyContent =
                        info.GetChildByName("dp-policy-content");

                    // Removing non modifiable policies
                    if (policyContent.GetChildContent("name").IndexOf("NM") < 0)
                    {
                        Console.WriteLine(
                            "----------------------------------------------------");
                        value = policyContent.GetChildContent("name");
                        Console.WriteLine("Policy Name : " + value);


                        value = info.GetChildContent("id");
                        Console.WriteLine("Id : " + value);

                        value = policyContent.GetChildContent("description");
                        Console.WriteLine("Description : " + value);

                        Console.WriteLine(
                            "----------------------------------------------------");


                        // printing detials if only one policy is selected for listing
                        if (policyName != null)
                        {
                            // printing connection info
                            NaElement dpc = policyContent.
                                            GetChildByName("dp-policy-connections");
                            NaElement dpci =
                                dpc.GetChildByName("dp-policy-connection-info");

                            value = dpci.GetChildContent("backup-schedule-name");
                            Console.Write("\nBackup Schedule Name : ");
                            if (value != null)
                            {
                                Console.Write(value);
                            }

                            value = dpci.GetChildContent("backup-schedule-id");
                            Console.Write("\nBackup Schedule Id   : ");
                            if (value != null)
                            {
                                Console.WriteLine(value);
                            }

                            value = dpci.GetChildContent("id");
                            Console.WriteLine("Connection Id        : " + value);

                            value = dpci.GetChildContent("type");
                            Console.WriteLine("Connection Type      : " + value);

                            value =
                                dpci.GetChildContent("lag-warning-threshold");
                            Console.WriteLine("Lag Warning Threshold: " + value);

                            value = dpci.GetChildContent("lag-error-threshold");
                            Console.WriteLine("Lag Error Threshold  : " + value);

                            value = dpci.GetChildContent("from-node-name");
                            Console.WriteLine("From Node Name       : " + value);

                            value = dpci.GetChildContent("from-node-id");
                            Console.WriteLine("From Node Id         : " + value);

                            value = dpci.GetChildContent("to-node-name");
                            Console.WriteLine("To Node Name         : " + value);

                            value = dpci.GetChildContent("to-node-id");
                            Console.WriteLine("To Node Id           : " + value);
                        }
                    }
                }

                // invoking the iter-end zapi
                input = new NaElement("dp-policy-list-iter-end");
                input.AddNewChild("tag", tag);
                server.InvokeElem(input);
            }
            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);
            }
        }
Пример #8
0
        static void TrackJob(String jobId)
        {
            String    jobStatus = "running";
            NaElement xi;
            NaElement xo;

            try {
                Console.WriteLine("Job ID\t\t: " + jobId);
                Console.Write("Job Status\t: " + jobStatus);
                //Continuously poll to see if the job completed
                while (jobStatus.Equals("queued") || jobStatus.Equals("running") ||
                       jobStatus.Equals("aborting"))
                {
                    xi = new NaElement("dp-job-list-iter-start");
                    xi.AddNewChild("job-id", jobId);
                    xo = server.InvokeElem(xi);

                    xi = new NaElement("dp-job-list-iter-next");
                    xi.AddNewChild("maximum", xo.GetChildContent("records"));
                    xi.AddNewChild("tag", xo.GetChildContent("tag"));
                    xo = server.InvokeElem(xi);

                    NaElement dpJobs    = xo.GetChildByName("jobs");
                    NaElement dpJobInfo = dpJobs.GetChildByName("dp-job-info");
                    jobStatus = dpJobInfo.GetChildContent("job-state");
                    Thread.Sleep(3000); Console.Write(".");
                    if (jobStatus.Equals("completed") ||
                        jobStatus.Equals("aborted"))
                    {
                        Console.WriteLine("\nOverall Status\t: "
                                          + dpJobInfo.GetChildContent("job-overall-status"));
                    }
                }

                //Display the job result - success/failure and provisioned
                // member details
                xi = new NaElement("dp-job-progress-event-list-iter-start");
                xi.AddNewChild("job-id", jobId);
                xo = server.InvokeElem(xi);

                xi = new NaElement("dp-job-progress-event-list-iter-next");
                xi.AddNewChild("tag", xo.GetChildContent("tag"));
                xi.AddNewChild("maximum", xo.GetChildContent("records"));
                xo = server.InvokeElem(xi);


                NaElement progEvnts = xo.GetChildByName("progress-events");
                System.Collections.IList progEvntsInfo =
                    progEvnts.GetChildren();
                Console.Write("\nProvision Details:\n");
                Console.WriteLine("==========================================="
                                  + "===============");
                System.Collections.IEnumerator progIter =
                    progEvntsInfo.GetEnumerator();

                while (progIter.MoveNext())
                {
                    NaElement evnt = (NaElement)progIter.Current;
                    if (evnt.GetChildContent("event-type") != null)
                    {
                        Console.Write(evnt.GetChildContent("event-type"));
                    }
                    Console.WriteLine("\t: "
                                      + evnt.GetChildContent("event-message") + "\n");
                }
            } catch (Exception e) {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }
Пример #9
0
        static void MemberList()
        {
            String memberName  = null;
            String datasetName = Args[4];

            try {
                // creating a dataset member list start element
                NaElement input =
                    new NaElement("dataset-member-list-info-iter-start");
                input.AddNewChild("dataset-name-or-id", datasetName);
                if (Args.Length > 5)
                {
                    memberName = Args[5];
                    input.AddNewChild("member-name-or-id", memberName);
                }
                input.AddNewChild("include-indirect", "true");

                // Invoke the api && capturing the records && tag values
                NaElement output = server.InvokeElem(input);

                // Extracting the record && tag values && printing them
                String records = output.GetChildContent("records");

                if (records.Equals("0"))
                {
                    Console.WriteLine("\nNo members to display");
                }

                String tag = output.GetChildContent("tag");


                // Extracting records one at a time
                input = new NaElement("dataset-member-list-info-iter-next");
                input.AddNewChild("maximum", records);
                input.AddNewChild("tag", tag);
                NaElement record = server.InvokeElem(input);

                // Navigating to the dataset-members child element
                NaElement stat = record.GetChildByName("dataset-members");

                // Navigating to the dataset-info child element
                System.Collections.IList infoList = null;

                if (stat != null)
                {
                    infoList = stat.GetChildren();
                }
                if (infoList == null)
                {
                    return;
                }


                System.Collections.IEnumerator infoIter =
                    infoList.GetEnumerator();

                // Iterating through each record
                while (infoIter.MoveNext())
                {
                    String    value;
                    NaElement info = (NaElement)infoIter.Current;

                    String name = info.GetChildContent("member-name");
                    String id   = info.GetChildContent("member-id");

                    if (!name.EndsWith("-"))
                    {
                        // extracting the member name and printing it
                        Console.WriteLine(
                            "----------------------------------------------------");

                        Console.WriteLine("Member Name : " + name);
                        Console.WriteLine("Member Id : " + id);
                        Console.WriteLine(
                            "----------------------------------------------------");

                        // printing details if only one member is selected
                        if (memberName != null)
                        {
                            value = info.GetChildContent("member-type");
                            Console.WriteLine("\nMember Type            : "
                                              + value);

                            value = info.GetChildContent("member-status");
                            Console.WriteLine("Member Status          : "
                                              + value);

                            value = info.GetChildContent("member-perf-status");
                            Console.WriteLine("Member Perf Status     : "
                                              + value);

                            value = info.GetChildContent("storageset-id");
                            Console.WriteLine("Storageset Id          : "
                                              + value);

                            value = info.GetChildContent("storageset-name");
                            Console.WriteLine("Storageset Name        : "
                                              + value);
                            value = info.GetChildContent("dp-node-name");
                            Console.WriteLine("Node Name              : " +
                                              value);
                        }
                    }
                }

                // invoking the iter-end zapi
                input = new NaElement("dataset-member-list-info-iter-end");
                input.AddNewChild("tag", tag);
                server.InvokeElem(input);
            }
            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);
            }
        }
Пример #10
0
        static void List()
        {
            String datasetName = null;

            try {
                // creating a dataset list start element
                NaElement input = new NaElement("dataset-list-info-iter-start");
                if (Args.Length > 4)
                {
                    datasetName = Args[4];
                    input.AddNewChild("object-name-or-id", datasetName);
                }

                // Invoke the api && capturing the records && tag values
                NaElement output = server.InvokeElem(input);

                // Extracting the record && tag values && printing them
                String records = output.GetChildContent("records");

                if (records.Equals("0"))
                {
                    Console.WriteLine("\nNo datasets to display");
                }

                String tag = output.GetChildContent("tag");



                // Extracting records one at a time
                input = new NaElement("dataset-list-info-iter-next");
                input.AddNewChild("maximum", records);
                input.AddNewChild("tag", tag);
                NaElement record = server.InvokeElem(input);

                // Navigating to the datasets child element
                NaElement stat = record.GetChildByName("datasets");

                // Navigating to the dataset-info child element
                System.Collections.IList infoList = null;

                if (stat != null)
                {
                    infoList = stat.GetChildren();
                }
                if (infoList == null)
                {
                    return;
                }


                System.Collections.IEnumerator infoIter =
                    infoList.GetEnumerator();

                // Iterating through each record
                while (infoIter.MoveNext())
                {
                    String    value;
                    NaElement info = (NaElement)infoIter.Current;

                    // extracting the dataset name and printing it
                    Console.WriteLine(
                        "--------------------------------------------------------");
                    value = info.GetChildContent("dataset-name");
                    Console.WriteLine("Dataset Name : " + value);

                    value = info.GetChildContent("dataset-id");
                    Console.WriteLine("Dataset Id : " + value);

                    value = info.GetChildContent("dataset-description");
                    Console.WriteLine("Dataset Description : " + value);

                    Console.WriteLine(
                        "--------------------------------------------------------");

                    // printing detials if only one dataset is selected
                    if (datasetName != null)
                    {
                        value = info.GetChildContent("\ndataset-contact");
                        Console.WriteLine("Dataset Contact          : " + value);

                        value = info.GetChildContent("provisioning-policy-id");
                        Console.Write("Provisioning Policy Id   : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        value =
                            info.GetChildContent("provisioning-policy-name");
                        Console.Write("\nProvisioning Policy Name : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        value = info.GetChildContent("protection-policy-id");
                        Console.Write("\nProtection Policy Id     : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        value = info.GetChildContent("protection-policy-name");
                        Console.Write("\nProtection Policy Name   : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        value = info.GetChildContent("resourcepool-name");
                        Console.Write("\nResource Pool Name       : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        NaElement status =
                            info.GetChildByName("dataset-status");

                        value = status.GetChildContent("resource-status");
                        Console.WriteLine("\nResource Status          : "
                                          + value);

                        value = status.GetChildContent("conformance-status");
                        Console.WriteLine("Conformance Status       : " + value);

                        value = status.GetChildContent("performance-status");
                        Console.WriteLine("Performance Status       : " + value);

                        value = status.GetChildContent("protection-status");
                        Console.Write("Protection Status        : ");
                        if (value != null)
                        {
                            Console.Write(value);
                        }

                        value = status.GetChildContent("space-status");
                        Console.WriteLine("\nSpace Status             : "
                                          + value);
                    }
                }

                // invoking the iter-end zapi
                input = new NaElement("dataset-list-info-iter-end");
                input.AddNewChild("tag", tag);
                server.InvokeElem(input);
            }
            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 List()
        {
            String policyName = null;

            try {
                // creating a start element
                NaElement input =
                    new NaElement("provisioning-policy-list-iter-start");
                input.AddNewChild("provisioning-policy-type", "nas");
                if (Args.Length > 4)
                {
                    policyName = Args[4];
                    input.AddNewChild("provisioning-policy-name-or-id",
                                      policyName);
                }

                // invoke the api && capturing the records && tag values
                NaElement output = server.InvokeElem(input);



                // Extracting the record && tag values && printing them
                String records = output.GetChildContent("records");

                if (records.Equals("0"))
                {
                    Console.WriteLine("\nNo policies to display");
                }

                String tag = output.GetChildContent("tag");


                // Extracting records one at a time
                input = new NaElement("provisioning-policy-list-iter-next");
                input.AddNewChild("maximum", records);
                input.AddNewChild("tag", tag);
                NaElement record = server.InvokeElem(input);

                // Navigating to the provisioning-policys child element
                NaElement stat =
                    record.GetChildByName("provisioning-policies");

                System.Collections.IList infoList = null;

                if (stat != null)
                {
                    infoList = stat.GetChildren();
                }
                if (infoList == null)
                {
                    return;
                }


                System.Collections.IEnumerator infoIter =
                    infoList.GetEnumerator();

                // Iterating through each record
                while (infoIter.MoveNext())
                {
                    String    value;
                    NaElement info = (NaElement)infoIter.Current;

                    NaElement nasContainerSettings =
                        info.GetChildByName("nas-container-settings");
                    // Checking if the container is nas before printing
                    if (nasContainerSettings != null)
                    {
                        Console.WriteLine(
                            "------------------------------------------------");
                        // extracting the policy name and printing it
                        value =
                            info.GetChildContent("provisioning-policy-name");
                        Console.WriteLine("Policy Name : " + value);

                        value =
                            info.GetChildContent("provisioning-policy-id");
                        Console.WriteLine("Policy Id : " + value);

                        value = info.
                                GetChildContent("provisioning-policy-description");
                        Console.WriteLine("Policy Description : " + value);
                        Console.WriteLine(
                            "------------------------------------------------");

                        // printing detials if only one policy is selected for listing
                        if (policyName != null)
                        {
                            value =
                                info.GetChildContent("provisioning-policy-type");
                            Console.WriteLine("Policy Type        : "
                                              + value);


                            value = info.GetChildContent("dedupe-enabled");
                            Console.WriteLine("Dedupe Enabled     : "
                                              + value);


                            NaElement storageRelilability =
                                info.GetChildByName("storage-reliability");

                            value = storageRelilability.
                                    GetChildContent("disk-failure");
                            Console.WriteLine("Disk Failure       : "
                                              + value);


                            value = storageRelilability.
                                    GetChildContent("sub-system-failure");
                            Console.WriteLine("Subsystem Failure  : "
                                              + value);


                            value = storageRelilability.
                                    GetChildContent("controller-failure");
                            Console.WriteLine("Controller Failure : "
                                              + value);


                            value = nasContainerSettings.
                                    GetChildContent("default-user-quota");
                            Console.Write("Default User Quota : ");
                            if (value != null)
                            {
                                Console.Write(value + " kb");
                            }

                            value = nasContainerSettings.
                                    GetChildContent("default-group-quota");
                            Console.Write("\nDefault Group Quota: ");
                            if (value != null)
                            {
                                Console.Write(value + " kb");
                            }

                            value = nasContainerSettings.
                                    GetChildContent("snapshot-reserve");
                            Console.Write("\nSnapshot Reserve   : ");
                            if (value != null)
                            {
                                Console.Write(value);
                            }

                            value = nasContainerSettings.
                                    GetChildContent("space-on-demand");
                            Console.Write("\nSpace On Demand    : ");
                            if (value != null)
                            {
                                Console.Write(value);
                            }

                            value = nasContainerSettings.
                                    GetChildContent("thin-provision");
                            Console.Write("\nThin Provision     : ");
                            if (value != null)
                            {
                                Console.WriteLine(value);
                            }
                        }
                    }
                    if (nasContainerSettings == null && policyName != null)
                    {
                        Console.WriteLine("\nsan type of provisioning "
                                          + "policy is not supported for listing");
                    }
                }

                // invoking the iter-end zapi
                input = new NaElement("provisioning-policy-list-iter-end");
                input.AddNewChild("tag", tag);
                server.InvokeElem(input);
            }
            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);
            }
        }