Пример #1
0
        static void MemberAdd()
        {
            NaElement input;
            NaElement output;

            // Getting the dataset name and member name
            String datasetName = Args[4];
            String memberName  = Args[5];

            try {
                // Setting the edit lock for adding member
                input = new NaElement("dataset-edit-begin");
                input.AddNewChild("dataset-name-or-id", Args[4]);
                output = server.InvokeElem(input);

                // extracting the edit lock id
                String lockId = output.GetChildContent("edit-lock-id");

                try {
                    // creating the input for api execution
                    // creating a dataset-add-member element and adding child
                    // elements
                    input = new NaElement("dataset-add-member");
                    input.AddNewChild("edit-lock-id", lockId);
                    NaElement mem   = new NaElement("dataset-member-parameters");
                    NaElement param = new NaElement("dataset-member-parameter");
                    param.AddNewChild("object-name-or-id", memberName);
                    mem.AddChildElement(param);
                    input.AddChildElement(mem);
                    // invoking the api && printing the xml ouput
                    output = server.InvokeElem(input);

                    input = new NaElement("dataset-edit-commit");
                    input.AddNewChild("edit-lock-id", lockId);
                    output = server.InvokeElem(input);
                }
                catch (Exception e) {
                    Console.Error.WriteLine(e.Message);
                    input = new NaElement("dataset-edit-rollback");
                    input.AddNewChild("edit-lock-id", lockId);
                    server.InvokeElem(input);
                    Environment.Exit(1);
                }

                Console.WriteLine("\nMember addition "
                                  + Result(output.GetAttr("status")));
            }
            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);
            }
        }
        //This funcion will add a new operation to the RBAC system.
        static void OperationAdd()
        {
            if (Args.Length < 8)
            {
                Usage();
            }
            String name     = Args[4];
            String desc     = Args[5];
            String synopsis = Args[6];
            String type     = Args[7];

            try
            {
                // construct the input rbac-operation-add API request
                NaElement input         = new NaElement("rbac-operation-add");
                NaElement operation     = new NaElement("operation");
                NaElement rbacOperation = new NaElement("rbac-operation");
                rbacOperation.AddNewChild("operation-name", name);
                NaElement operationNameDetails =
                    new NaElement("operation-name-details");
                NaElement rbacOperationNameDetails =
                    new NaElement("rbac-operation-name-details");
                rbacOperationNameDetails.
                AddNewChild("operation-description", desc);
                rbacOperationNameDetails.
                AddNewChild("operation-synopsis", synopsis);
                rbacOperationNameDetails.AddNewChild("resource-type", type);
                input.AddChildElement(operation);
                operation.AddChildElement(rbacOperation);
                rbacOperation.AddChildElement(operationNameDetails);
                operationNameDetails.AddChildElement(rbacOperationNameDetails);

                // invoke the API request
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("Operation added successfully!");
            }
            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 TemplateCreate()
        {
            String cifsAuth     = null;
            String cifsDomain   = null;
            String cifsSecurity = null;

            // Getting the template name
            String templateName = Args[4];

            // parsing optional parameters
            int i = 5;

            while (i < Args.Length)
            {
                if (Args[i].Equals("-a"))
                {
                    cifsAuth = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-d"))
                {
                    cifsDomain = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-s"))
                {
                    cifsSecurity = Args[++i]; ++i;
                }
                else
                {
                    Usage();
                }
            }

            try
            {
                // creating the input for api execution
                // creating a vfiler-template-create element and adding
                // child elements
                NaElement input    = new NaElement("vfiler-template-create");
                NaElement temp     = new NaElement("vfiler-template");
                NaElement template = new NaElement("vfiler-template-info");
                template.AddNewChild("vfiler-template-name", templateName);
                if (cifsAuth != null)
                {
                    template.AddNewChild("cifs-auth-type", cifsAuth);
                }
                if (cifsDomain != null)
                {
                    template.AddNewChild("cifs-domain", cifsDomain);
                }
                if (cifsSecurity != null)
                {
                    template.AddNewChild("cifs-security-style", cifsSecurity);
                }
                temp.AddChildElement(template);
                input.AddChildElement(temp);

                // invoking the api && printing the xml ouput
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("\nvFiler template creation "
                                  + Result(output.GetAttr("status")));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }
        //This function will add a capability to a role.
        static void RoleCapabilityAdd()
        {
            if (Args.Length < 8)
            {
                Usage();
            }

            String rolenameID   = Args[4];
            String operation    = Args[5];
            String resourceType = Args[6];
            String resourceName = Args[7];

            // check for the proper resource type
            if (!resourceType.Equals("dataset") &&
                !resourceType.Equals("filer"))
            {
                Console.Error.WriteLine("Invalid resource type");
                System.Environment.Exit(2);
            }

            try
            {
                // create the input rbac-role-capability-add API request
                NaElement input = new NaElement("rbac-role-capability-add");
                input.AddNewChild("operation", operation);
                input.AddNewChild("role-name-or-id", rolenameID);

                NaElement resource   = new NaElement("resource");
                NaElement resourceID = new NaElement("resource-identifier");
                input.AddChildElement(resource);
                resource.AddChildElement(resourceID);
                // check for the resource type and frame the request
                if (resourceType.Equals("dataset"))
                {
                    NaElement dataset         = new NaElement("dataset");
                    NaElement datasetResource =
                        new NaElement("dataset-resource");
                    datasetResource.AddNewChild("dataset-name", resourceName);
                    dataset.AddChildElement(datasetResource);
                    resourceID.AddChildElement(dataset);
                }
                else if (resourceType.Equals("filer"))
                {
                    NaElement filer         = new NaElement("filer");
                    NaElement filerResource = new NaElement("filer-resource");
                    filerResource.AddNewChild("filer-name", resourceName);
                    filer.AddChildElement(filerResource);
                    resourceID.AddChildElement(filer);
                }

                // invoke the API
                NaElement output = server.InvokeElem(input);
                Console.WriteLine("capability added successfully! ");
            }
            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);
            }
        }
Пример #5
0
        static void Create()
        {
            String startHour   = null;
            String startMinute = null;
            String dayOfWeek   = null;
            String dayOfMonth  = null;
            String weekOfMonth = null;
            // Getting the schedule name and type
            String dfmSchedule  = Args[4];
            String scheduleType = Args[5];

            // Checking if the type selected is valid
            if ((!scheduleType.Equals("daily")) &&
                (!scheduleType.Equals("weekly")) &&
                (!scheduleType.Equals("monthly")))
            {
                Usage();
            }

            // parsing optional parameters
            int i = 6;

            while (i < Args.Length)
            {
                if (Args[i].Equals("-h"))
                {
                    startHour = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-m"))
                {
                    startMinute = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-d"))
                {
                    dayOfWeek = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-D"))
                {
                    dayOfMonth = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-w"))
                {
                    weekOfMonth = Args[++i]; ++i;
                }
                else
                {
                    Usage();
                }
            }

            try {
                // creating the input for api execution
                // creating a dfm-schedule-create element and adding child elem
                NaElement input    = new NaElement("dfm-schedule-create");
                NaElement schedule = new NaElement("schedule-content-info");
                schedule.AddNewChild("schedule-name", dfmSchedule);
                schedule.AddNewChild("schedule-type", scheduleType);
                schedule.AddNewChild("schedule-category", "dfm_schedule");

                // creating a daily-list element
                if (scheduleType.Equals("daily") && (startHour != null ||
                                                     startMinute != null))
                {
                    NaElement daily     = new NaElement("daily-list");
                    NaElement dailyInfo = new NaElement("daily-info");
                    if (startHour != null)
                    {
                        dailyInfo.AddNewChild("start-hour", startHour);
                    }
                    if (startMinute != null)
                    {
                        dailyInfo.AddNewChild("start-minute", startMinute);
                    }
                    daily.AddChildElement(dailyInfo);
                    // appending daily list to schedule
                    schedule.AddChildElement(daily);
                }


                // creating a weekly-list element
                if (scheduleType.Equals("weekly") &&
                    (startHour != null || startMinute != null ||
                     dayOfWeek != null))
                {
                    NaElement weekly     = new NaElement("weekly-list");
                    NaElement weeklyInfo = new NaElement("weekly-info");
                    if (startHour != null)
                    {
                        weeklyInfo.AddNewChild("start-hour", startHour);
                    }
                    if (startMinute != null)
                    {
                        weeklyInfo.AddNewChild("start-minute", startMinute);
                    }
                    if (dayOfWeek != null)
                    {
                        weeklyInfo.AddNewChild("day-of-week", dayOfWeek);
                    }
                    weekly.AddChildElement(weeklyInfo);
                    // appending weekly list to schedule
                    schedule.AddChildElement(weekly);
                }

                // creating 2 monthly-list element
                if (scheduleType.Equals("monthly") && (startHour != null ||
                                                       startMinute != null || dayOfWeek != null ||
                                                       dayOfMonth != null || weekOfMonth != null))
                {
                    NaElement monthly     = new NaElement("monthly-list");
                    NaElement monthlyInfo = new NaElement("monthly-info");
                    if (startHour != null)
                    {
                        monthlyInfo.AddNewChild("start-hour", startHour);
                    }
                    if (startMinute != null)
                    {
                        monthlyInfo.AddNewChild("start-minute", startMinute);
                    }
                    if (dayOfMonth != null)
                    {
                        monthlyInfo.AddNewChild("day-of-month", dayOfMonth);
                    }
                    if (dayOfWeek != null)
                    {
                        monthlyInfo.AddNewChild("day-of-week", dayOfWeek);
                    }
                    if (weekOfMonth != null)
                    {
                        monthlyInfo.AddNewChild("week-of-month", weekOfMonth);
                    }
                    monthly.AddChildElement(monthlyInfo);
                    // appending monthly list to schedule
                    schedule.AddChildElement(monthly);
                }

                // appending schedule to main input
                input.AddChildElement(schedule);

                // invoking the api && printing the xml ouput
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("\nSchedule creation "
                                  + Result(output.GetAttr("status")));
            }
            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);
            }
        }
Пример #6
0
        static void Create()
        {
            String fullThresh       = null;
            String nearlyFullThresh = null;
            String resourceTag      = null;

            // Getting the pool name
            String poolName = Args[4];

            // parsing optional parameters
            int i = 5;

            while (i < Args.Length)
            {
                if (Args[i].Equals("-t"))
                {
                    resourceTag = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-f"))
                {
                    fullThresh = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-n"))
                {
                    nearlyFullThresh = Args[++i]; ++i;
                }
                else
                {
                    Usage();
                }
            }

            try
            {
                // creating the input for api execution
                // creating a resourcepool-create element and adding child
                // elements
                NaElement input = new NaElement("resourcepool-create");
                NaElement rpool = new NaElement("resourcepool");
                NaElement pool  = new NaElement("resourcepool-info");
                pool.AddNewChild("resourcepool-name", poolName);
                if (resourceTag != null)
                {
                    pool.AddNewChild("resource-tag", resourceTag);
                }
                if (fullThresh != null)
                {
                    pool.AddNewChild("resourcepool-full-threshold", fullThresh);
                }
                if (nearlyFullThresh != null)
                {
                    pool.AddNewChild("resourcepool-nearly-full-threshold",
                                     nearlyFullThresh);
                }

                rpool.AddChildElement(pool);
                input.AddChildElement(rpool);

                // invoking the api && printing the xml ouput
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("\nPool creation "
                                  + Result(output.GetAttr("status")));
            }
            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 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);
            }
        }
Пример #8
0
        static void Create()
        {
            String policyTemplate = Args[4];
            String policyName     = Args[5];

            try
            {
                // Copy section
                // Making a copy of policy in the format copy of <policy name>
                NaElement input = new NaElement("dp-policy-copy");
                input.AddNewChild("template-dp-policy-name-or-id",
                                  policyTemplate);
                input.AddNewChild("dp-policy-name", "copy of "
                                  + policyTemplate);
                server.InvokeElem(input);

                // Modify section
                // creating edit section
                input = new NaElement("dp-policy-edit-begin");
                input.AddNewChild("dp-policy-name-or-id", "copy of "
                                  + policyTemplate);
                NaElement output = server.InvokeElem(input);

                String lockId = output.GetChildContent("edit-lock-id");

                // modifying the policy name
                // creating a dp-policy-modify element and adding child elements
                input = new NaElement("dp-policy-modify");
                input.AddNewChild("edit-lock-id", lockId);

                // getting the policy content deailts of the original policy
                NaElement origPolicyContent = getPolicyContent();

                // Creating a new dp-policy-content elem and adding name, desc
                NaElement policyContent = new NaElement("dp-policy-content");
                policyContent.AddNewChild("name", policyName);
                policyContent.AddNewChild("description", "Added by sample code");

                // appending the original connections and nodes children
                policyContent.AddChildElement(origPolicyContent.
                                              GetChildByName("dp-policy-connections"));
                policyContent.AddChildElement(origPolicyContent.
                                              GetChildByName("dp-policy-nodes"));

                // Attaching the new policy content child to modify element
                input.AddChildElement(policyContent);

                try
                {
                    // invoking the api && printing the xml ouput
                    output = server.InvokeElem(input);

                    input = new NaElement("dp-policy-edit-commit");
                    input.AddNewChild("edit-lock-id", lockId);
                    output = server.InvokeElem(input);
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(e.Message);
                    input = new NaElement("dp-policy-edit-rollback");
                    input.AddNewChild("edit-lock-id", lockId);
                    server.InvokeElem(input);
                    Environment.Exit(1);
                }

                Console.WriteLine("\nPolicy creation "
                                  + Result(output.GetAttr("status")));
            }
            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);
            }
        }
Пример #9
0
        static void MemberProvision()
        {
            String datasetName = Args[4];
            String memberName  = Args[5];
            String size        = Args[6];
            String maxSize     = null;

            if (Args.Length > 7)
            {
                maxSize = Args[7];
            }

            NaElement input;
            NaElement output;
            NaElement finalOutput;
            String    jobId;

            try {
                // Setting the edit lock for provisioning member
                input = new NaElement("dataset-edit-begin");
                input.AddNewChild("dataset-name-or-id", Args[4]);
                output = server.InvokeElem(input);

                // extracting the edit lock id
                String lockId = output.GetChildContent("edit-lock-id");

                try {
                    // invoking the api && printing the xml ouput
                    input = new NaElement("dataset-provision-member");
                    input.AddNewChild("edit-lock-id", lockId);
                    NaElement provMember =
                        new NaElement("provision-member-request-info");
                    provMember.AddNewChild("name", memberName);
                    provMember.AddNewChild("size", size);
                    if (maxSize != null)
                    {
                        // for san
                        provMember.
                        AddNewChild("maximum-snapshot-space", maxSize);
                        // for nas with nfs
                        provMember.AddNewChild("maximum-data-size", maxSize);
                    }
                    input.AddChildElement(provMember);

                    // invoking the api && printing the xml ouput
                    output = server.InvokeElem(input);

                    input = new NaElement("dataset-edit-commit");
                    input.AddNewChild("edit-lock-id", lockId);
                    finalOutput = server.InvokeElem(input);
                    jobId       = (finalOutput.GetChildByName("job-ids")).
                                  GetChildByName("job-info").GetChildContent("job-id");
                    // tracking the job
                    TrackJob(jobId);
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(e.Message);
                    input = new NaElement("dataset-edit-rollback");
                    input.AddNewChild("edit-lock-id", lockId);
                    server.InvokeElem(input);
                    Environment.Exit(1);
                }
            }
            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 Create()
        {
            String groupQuota        = null;
            String userQuota         = null;
            bool   dedupeEnable      = false;
            bool   controllerFailure = false;
            bool   subsystemFailure  = false;
            bool   snapshotReserve   = false;
            bool   spaceOnDemand     = false;
            bool   thinProvision     = false;

            // Getting the policy name
            String policyName = Args[4];

            // parsing optional parameters
            int i = 5;

            while (i < Args.Length)
            {
                if (Args[i].Equals("-g"))
                {
                    groupQuota = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-u"))
                {
                    userQuota = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-d"))
                {
                    dedupeEnable = true; ++i;
                }
                else if (Args[i].Equals("-c"))
                {
                    controllerFailure = true; ++i;
                }
                else if (Args[i].Equals("-s"))
                {
                    subsystemFailure = true; ++i;
                }
                else if (Args[i].Equals("-r"))
                {
                    snapshotReserve = true; ++i;
                }
                else if (Args[i].Equals("-S"))
                {
                    spaceOnDemand = true; ++i;
                }
                else if (Args[i].Equals("-t"))
                {
                    thinProvision = true; ++i;
                }
                else
                {
                    Usage();
                }
            }

            try {
                // creating the input for api execution
                // creating a create element and adding child elements
                NaElement input =
                    new NaElement("provisioning-policy-create");
                NaElement policy =
                    new NaElement("provisioning-policy-info");
                policy.AddNewChild("provisioning-policy-name", policyName);
                policy.AddNewChild("provisioning-policy-type", "nas");
                if (dedupeEnable)
                {
                    policy.AddNewChild("dedupe-enabled", "$dedupe_enable");
                }

                // creating the storage reliability child and adding
                // parameters if input
                if (controllerFailure || subsystemFailure)
                {
                    NaElement storageRelilability =
                        new NaElement("storage-reliability");
                    if (controllerFailure)
                    {
                        storageRelilability.
                        AddNewChild("controller-failure", "true");
                    }
                    if (subsystemFailure)
                    {
                        storageRelilability.
                        AddNewChild("sub-system-failure", "true");
                    }

                    // appending storage-reliability child to parent and
                    // then to policy info
                    policy.AddChildElement(storageRelilability);
                }

                // creating the nas container settings child and
                // adding parameters if input
                if (groupQuota != null || userQuota != null ||
                    snapshotReserve || spaceOnDemand || thinProvision)
                {
                    NaElement nasContainerSettings =
                        new NaElement("nas-container-settings");
                    if (groupQuota != null)
                    {
                        nasContainerSettings.
                        AddNewChild("default-group-quota", groupQuota);
                    }
                    if (userQuota != null)
                    {
                        nasContainerSettings.
                        AddNewChild("default-user-quota", userQuota);
                    }
                    if (snapshotReserve)
                    {
                        nasContainerSettings.
                        AddNewChild("snapshot-reserve", "false");
                    }
                    if (spaceOnDemand)
                    {
                        nasContainerSettings.
                        AddNewChild("space-on-demand", "true");
                    }
                    if (thinProvision)
                    {
                        nasContainerSettings.
                        AddNewChild("thin-provision", "true");
                    }

                    // adding nas-containter-settings child to policy info
                    policy.AddChildElement(nasContainerSettings);
                }

                // Adding policy to parent element
                input.AddChildElement(policy);


                // invoking the api && printing the xml ouput
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("\nPolicy creation "
                                  + Result(output.GetAttr("status")));
            }
            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);
            }
        }