Пример #1
0
        static void Delete()
        {
            String dfmSchedule = Args[4];

            try {
                // invoking the api && printing the xml ouput
                NaElement input = new NaElement("dfm-schedule-destroy");
                input.AddNewChild("schedule-name-or-id", dfmSchedule);
                input.AddNewChild("schedule-category", "dfm_schedule");
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("\nSchedule deletion "
                                  + 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);
            }
        }
Пример #2
0
        static void MemberRemove()
        {
            String poolName   = Args[4];
            String memberName = Args[5];

            try {
                // invoking the api && printing the xml ouput
                NaElement input = new NaElement("resourcepool-remove-member");
                input.AddNewChild("resourcepool-name-or-id", poolName);
                input.AddNewChild("member-name-or-id", memberName);
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("\nMember deletion "
                                  + 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);
            }
        }
Пример #3
0
        static void MemberAdd()
        {
            String memberResourceTag = null;

            // Getting the resource pool and member name
            String poolName   = Args[4];
            String memberName = Args[5];

            // parsing optional parameters
            int i = 6;

            while (i < Args.Length)
            {
                if (Args[i].Equals("-m"))
                {
                    memberResourceTag = Args[++i]; ++i;
                }
                else
                {
                    Usage();
                }
            }

            try {
                // creating the input for api execution
                // creating a resourcepool-add-member element and adding
                // child elements
                NaElement input = new NaElement("resourcepool-add-member");
                input.AddNewChild("resourcepool-name-or-id", poolName);
                input.AddNewChild("member-name-or-id", memberName);
                if (memberResourceTag != null)
                {
                    input.AddNewChild("resource-tag", memberResourceTag);
                }

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

                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);
            }
        }
Пример #4
0
        static void Delete()
        {
            String policyName = Args[4];

            try
            {
                NaElement input = new NaElement("dp-policy-edit-begin");
                input.AddNewChild("dp-policy-name-or-id", policyName);
                NaElement output = server.InvokeElem(input);

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

                // Deleting the policy name
                // creating a dp-policy-destroy element and adding edit-lock
                input = new NaElement("dp-policy-destroy");
                input.AddNewChild("edit-lock-id", lockId);
                output = server.InvokeElem(input);

                try
                {
                    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 deletion "
                                  + 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 TemplateDelete()
        {
            String templateName = Args[4];

            try
            {
                // invoking the api && printing the xml ouput
                NaElement input = new NaElement("vfiler-template-delete");
                input.AddNewChild("vfiler-template-name-or-id", templateName);
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("\nTemplate deletion "
                                  + Result(output.GetAttr("status")));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }
        static void setup(String vName, String tName)
        {
            try
            {
                // creating the input for api execution
                // creating a vfiler-create element and adding child elements
                NaElement input = new NaElement("vfiler-setup");
                input.AddNewChild("vfiler-name-or-id", vName);
                input.AddNewChild("vfiler-template-name-or-id", tName);
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("\nvFiler unit setup with template "
                                  + tName + " " + Result(output.GetAttr("status")));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }
        static void Create()
        {
            String templateName = null;

            // Getting the vfiler name, resource pool name and ip
            String vfilerName = Args[4];
            String poolName   = Args[5];
            String ip         = Args[6];

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

            try
            {
                // creating the input for api execution
                // creating a vfiler-create element and adding child elements
                NaElement input = new NaElement("vfiler-create");
                input.AddNewChild("ip-address", ip);
                input.AddNewChild("name", vfilerName);
                input.AddNewChild("resource-name-or-id", poolName);
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("\nvFiler unit creation "
                                  + Result(output.GetAttr("status")));
                Console.WriteLine("\nvFiler unit created on Storage System : "
                                  + output.GetChildContent("filer-name") + "\nRoot Volume : "
                                  + output.GetChildContent("root-volume-name"));

                if (templateName != null)
                {
                    setup(vfilerName, templateName);
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }
        static void Delete()
        {
            String policyName = Args[4];

            try {
                // invoking the api && printing the xml ouput
                NaElement input = new NaElement("provisioning-policy-destroy");
                input.AddNewChild("provisioning-policy-name-or-id", policyName);
                NaElement output = server.InvokeElem(input);

                Console.WriteLine("\nPolicy deletion "
                                  + 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 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);
            }
        }
Пример #10
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);
            }
        }
Пример #11
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);
            }
        }
Пример #12
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);
            }
        }
Пример #13
0
        static void Create()
        {
            String provPolName  = null;
            String protPolName  = null;
            String resourcePool = null;

            // Getting the dataset name
            String datasetName = Args[4];

            // parsing optional parameters
            int i = 5;

            while (i < Args.Length)
            {
                if (Args[i].Equals("-v"))
                {
                    provPolName = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-t"))
                {
                    protPolName = Args[++i]; ++i;
                }
                else if (Args[i].Equals("-r"))
                {
                    resourcePool = Args[++i]; ++i;
                }
                else
                {
                    Usage();
                }
            }

            try {
                // creating the input for api execution
                // creating a dataset-create element and adding child elements
                NaElement input = new NaElement("dataset-create");
                input.AddNewChild("dataset-name", datasetName);
                if (provPolName != null)
                {
                    input.AddNewChild("provisioning-policy-name-or-id",
                                      provPolName);
                }
                if (protPolName != null)
                {
                    input.AddNewChild("protection-policy-name-or-id",
                                      protPolName);
                }

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

                Console.WriteLine("\nDataset creation "
                                  + Result(output.GetAttr("status")));

                if (resourcePool != null)
                {
                    addResourcePool(resourcePool);
                }
            }
            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);
            }
        }