static NaElement getPolicyContent() { NaElement policyContent = null; try { // creating a dp policy start element NaElement input = new NaElement("dp-policy-list-iter-start"); input.AddNewChild("dp-policy-name-or-id", Args[4]); // invoke the api && capturing the records && tag values NaElement output = server.InvokeElem(input); // Extracting the record && tag values && printing them String tag = output.GetChildContent("tag"); // Extracting records one at a time input = new NaElement("dp-policy-list-iter-next"); input.AddNewChild("maximum", "1"); input.AddNewChild("tag", tag); NaElement record = server.InvokeElem(input); // Navigating to the dp-policy-infos child element NaElement policyInfos = record.GetChildByName("dp-policy-infos"); // Navigating to the dp-policy-info child element NaElement policyInfo = policyInfos.GetChildByName("dp-policy-info"); // Navigating to the dp-policy-content child element policyContent = policyInfo.GetChildByName("dp-policy-content"); // 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); } // Returning the original policy content return(policyContent); }
//This function will assign an existing role to an existing // administrator. static void AdminRoleAdd() { if (Args.Length < 6) { Usage(); } String adminnameID = Args[4]; String rolenameID = Args[5]; String newAdminName = null; String newAdminID = null; try { // create the input rbac-admin-role-add API request NaElement input = new NaElement("rbac-admin-role-add"); input.AddNewChild("admin-name-or-id", adminnameID); input.AddNewChild("role-name-or-id", rolenameID); // invoke the API request NaElement output = server.InvokeElem(input); Console.WriteLine("admin role added successfully! "); NaElement newAdminNameID = output.GetChildByName("admin-name-or-id"). GetChildByName("rbac-admin-name-or-id"); newAdminName = newAdminNameID.GetChildContent("admin-name"); newAdminID = newAdminNameID.GetChildContent("admin-id"); Console.WriteLine("new admin name :" + newAdminName); Console.WriteLine("new admin id :" + newAdminID); } 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); } }
protected override void ProcessRecord() { if (_server == null || _user == null || _passwd == null) { WriteObject(Usage); return; } try { NaServer server = new NaServer(_server, 1, 0); NaElement input = new NaElement("volume-list-info"); server.SetAdminUser(User, Passwd); if (_volume != null) { input.AddNewChild("volume", _volume); } NaElement output = server.InvokeElem(input); System.Collections.IList volList = output. GetChildByName("volumes").GetChildren(); System.Collections.IEnumerator volIter = volList.GetEnumerator(); WriteObject("\n------------------------------------------------------------------------"); WriteObject("Name \t type \t state \t size-total \t size-used \t size-available"); WriteObject("------------------------------------------------------------------------"); String vol = ""; while (volIter.MoveNext()) { NaElement volInfo = (NaElement)volIter.Current; vol = volInfo.GetChildContent("name") + "\t" + volInfo.GetChildContent("type") + "\t" + volInfo.GetChildContent("state") + "\t" + volInfo.GetChildContent("size-total") + "\t" + volInfo.GetChildContent("size-used") + "\t" + volInfo.GetChildContent("size-available"); WriteObject(vol); } WriteObject("------------------------------------------------------------------------\n"); } catch (Exception e) { WriteObject(e.Message); } }
// This function will list all the administrators and their attributes. static void AdminList() { String adminNameID = ""; try { // create the rbac-admin-list-info-iter-start API request NaElement input = new NaElement("rbac-admin-list-info-iter-start"); if (Args.Length == 5) { adminNameID = Args[4]; input.AddNewChild("admin-name-or-id", adminNameID); } // invoke the api and capture the records and tag values for // rbac-admin-list-info-iter-next NaElement output = server.InvokeElem(input); String records = output.GetChildContent("records"); String tag = output.GetChildContent("tag"); // invoke the rbac-admin-list-info-iter-next api to return the // list of admins input = new NaElement("rbac-admin-list-info-iter-next"); input.AddNewChild("maximum", records); input.AddNewChild("tag", tag); output = server.InvokeElem(input); System.Collections.IList adminList = null; // capture the list of admins which is contained in admins // element if (output.GetChildByName("admins") != null) { adminList = output.GetChildByName("admins").GetChildren(); } System.Collections.IEnumerator adminIter = adminList.GetEnumerator(); Console.WriteLine( "----------------------------------------------------"); // Iterate through each admin record while (adminIter.MoveNext()) { NaElement admin = (NaElement)adminIter.Current; String id = admin.GetChildContent("admin-id"); String name = admin.GetChildContent("admin-name"); Console.WriteLine("\nadmin name : " + name); Console.WriteLine("admin id : " + id); String email = admin.GetChildContent("email-address"); if (email != null) { Console.WriteLine("email address : " + email); } } Console.WriteLine( "----------------------------------------------------"); input = new NaElement("rbac-admin-list-info-iter-end"); input.AddNewChild("tag", tag); output = 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); } }
// This function will list the roles assigned to an existing // administrator. static void RoleAdminList() { if (Args.Length < 5) { Usage(); } String adminNameID = Args[4]; String roleID = null; String roleName = null; try { //invoke the rbac-role-admin-info-list api and capture the ouput NaElement input = new NaElement("rbac-role-admin-info-list"); input.AddNewChild("admin-name-or-id", adminNameID); input.AddNewChild("follow-role-inheritance", "TRUE"); NaElement output = server.InvokeElem(input); Console.WriteLine( "----------------------------------------------------"); String adminNameID2 = output.GetChildContent("admin-name-or-id"); Console.WriteLine("\nadmin name-id :" + adminNameID); // get the list of roles which is contained in role-list element System.Collections.IList roleList = null; if (output.GetChildByName("role-list") != null) { roleList = output.GetChildByName("role-list").GetChildren(); } if (roleList == null) { return; } System.Collections.IEnumerator roleIter = roleList.GetEnumerator(); // Iterate through each role record while (roleIter.MoveNext()) { NaElement role = (NaElement)roleIter.Current; roleID = role.GetChildContent("rbac-role-id"); roleName = role.GetChildContent("rbac-role-name"); Console.WriteLine("\nrole name : " + roleName); Console.WriteLine("role id : " + roleID); } Console.WriteLine( "----------------------------------------------------"); } 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 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 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); } }
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); } }
// This function will list about an existing operation or // all operations in the system. static void OperationList() { String operation = null; String name = null; String desc = null; String type = null; String synopsis = null; if (Args.Length == 5) { operation = Args[4]; } try { // create the input API request NaElement input = new NaElement("rbac-operation-info-list"); if (operation != null) { input.AddNewChild("operation", operation); } // now invoke the api request and get the operations list NaElement output = server.InvokeElem(input); System.Collections.IList oprList = output.GetChildByName("operation-list").GetChildren(); System.Collections.IEnumerator oprIter = oprList.GetEnumerator(); // iterate through each operation Console.WriteLine( "\n----------------------------------------------------"); while (oprIter.MoveNext()) { NaElement opr = (NaElement)oprIter.Current; name = opr.GetChildContent("operation-name"); Console.WriteLine("\nName :" + name); System.Collections.IList nameDetailList = opr.GetChildByName("operation-name-details").GetChildren(); System.Collections.IEnumerator detailIter = nameDetailList.GetEnumerator(); while (detailIter.MoveNext()) { NaElement detail = (NaElement)detailIter.Current; desc = detail.GetChildContent("operation-description"); type = detail.GetChildContent("resource-type"); synopsis = detail.GetChildContent("operation-synopsis"); Console.WriteLine("Description : " + desc); Console.WriteLine("Synopsis : " + synopsis); Console.WriteLine("Resource type : " + type); } } Console.WriteLine( "----------------------------------------------------"); } 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 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); } }
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); } }
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); } }
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); } }
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 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); } }
//This function will list the operations, capabilities // and inherited roles that one or more roles have. static void RoleList() { String role = null; String roleID = null; String roleName = null; String description = null; String inhRoleID = null; String inhRoleName = null; String operationName = null; String operationDesc = null; String operationSyn = null; String resourceType = null; if (Args.Length == 5) { role = Args[4]; } try { // create the input rbac-role-info-list API request NaElement input = new NaElement("rbac-role-info-list"); if (role != null) { input.AddNewChild("role-name-or-id", role); } // invoke the API and capture the role attributes NaElement output = server.InvokeElem(input); // get the list of role attributes which is contained under // role-attributes element System.Collections.IList attrList = output.GetChildByName("role-attributes").GetChildren(); System.Collections.IEnumerator attrIter = attrList.GetEnumerator(); //iterate through each role attribute while (attrIter.MoveNext()) { NaElement attribute = (NaElement)attrIter.Current; Console.WriteLine( "----------------------------------------------------"); NaElement rolenameID = attribute.GetChildByName("role-name-and-id"). GetChildByName("rbac-role-resource"); roleID = rolenameID.GetChildContent("rbac-role-id"); roleName = rolenameID.GetChildContent("rbac-role-name"); description = attribute.GetChildContent("description"); Console.WriteLine("role name : " + roleName); Console.WriteLine("role id : " + roleID); Console.WriteLine("role description : " + description + "\n"); // iterate through the inherited roles System.Collections.IList inheritedList = attribute.GetChildByName("inherited-roles").GetChildren(); System.Collections.IEnumerator inheritedIter = inheritedList.GetEnumerator(); while (inheritedIter.MoveNext()) { NaElement inheritedRole = (NaElement)inheritedIter.Current; Console.WriteLine("inherited role details:\n"); inhRoleID = inheritedRole.GetChildContent("rbac-role-id"); inhRoleName = inheritedRole.GetChildContent("rbac-role-name"); Console.WriteLine ("inherited role name : " + inhRoleName); Console.WriteLine ("inherited role id : " + inhRoleID); } Console.WriteLine("operation details:\n"); System.Collections.IList capList = attribute.GetChildByName("capabilities").GetChildren(); System.Collections.IEnumerator capIter = capList.GetEnumerator(); // iterate through the role capabilities while (capIter.MoveNext()) { NaElement capability = (NaElement)capIter.Current; NaElement operation = capability. GetChildByName("operation"). GetChildByName("rbac-operation"); operationName = operation. GetChildContent("operation-name"); NaElement operationNameDetails = operation.GetChildByName("operation-name-details"). GetChildByName("rbac-operation-name-details"); operationDesc = operationNameDetails. GetChildContent("operation-description"); operationSyn = operationNameDetails. GetChildContent("operation-synopsis"); resourceType = operationNameDetails. GetChildContent("resource-type"); Console.WriteLine("operation name :" + operationName); Console.WriteLine("operation description :" + operationDesc); Console.WriteLine("operation synopsis :" + operationSyn); Console.WriteLine("resource type :" + resourceType + "\n"); } } Console.WriteLine( "----------------------------------------------------"); } 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); } }
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); } }
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); } }