Subscribe

API question: how to get a mounted volume export policy and how to assign a new one?

Hi Sir

 

I  want to know how to get the export policy name that a volume is using and how to assign a new export policy to it by API.  may I get the API name please?

 

BR

TC

Re: API question: how to get a mounted volume export policy and how to assign a new one?

You can get the current export policy name from "volume-get-iter" which will return something like this:

<attributes-list>

   <volume-attributes>

      <volume-export-attributes>

           <policy>mike_test10</policy>

      </volume-export-attributes>

   </volume-attributes>

</attributes-list>

 

Along with a ton of other information.

 

If you want the details of the export, you'll need to call "export-rule-get-iter" with an option "policy-name", for example:

 

NaElement request = new NaElement("export-rule-get-iter");

request.addChildElem(new NaElement("max-records", "32768"));

NaElement query = new NaElement("query");

NaElement exportRuleInfo = new NaElement("export-rule-info");

exportRuleInfo.addChildElem(new NaElement("policy-name", policyName));

query.addChildElem(exportRuleInfo);

request.addChildElem(query);

NaElement response = server.invokeElem(request);

 

 

If you'd like to assign an export rule to a volume, you can create the policy with "export-policy-create" and assign it to the volume with "volume-modify-iter" with an option set to "volume-export-attributes".  For example:

 

NaElement request = new NaElement("volume-modify-iter");

NaElement query = new NaElement("query");

NaElement attributes = new NaElement("attributes");

 

NaElement volIDAttributes = new NaElement("volume-id-attributes");

volIDAttributes.addNewChild("name", volume);

NaElement volAttributes = new NaElement("volume-attributes");

volAttributes.addChildElem(volIDAttributes);

query.addChildElem(volAttributes);

 

NaElement securityAttributes = new NaElement("volume-security-attributes");

securityAttributes.addNewChild("style",  securityStyle);

NaElement volAttributes1 = new NaElement("volume-attributes");

 

NaElement exportAttributes = new NaElement("volume-export-attributes");

exportAttributes.addNewChild("policy", exportPolicy);

volAttributes1.addChildElem(exportAttributes);

 

volAttributes1.addChildElem(securityAttributes);

attributes.addChildElem(volAttributes1);

 

request.addChildElem(query);

request.addChildElem(attributes);

NaElement response = server.invokeElem(request);

 

Re: API question: how to get a mounted volume export policy and how to assign a new one?

thanks a lot. I will try them