Active IQ Unified Manager Discussions
Active IQ Unified Manager Discussions
Having problems using perf-threshold-template-attach-objects to add an object (volume) to an existing threshold template. I'd like to know if I am doing this wrong (and hosw to fix it), or if there is a problem with the API.
I'm using the perl API and the code looks like this:
my $obj_info = NetAppApi::NaElement->new("object-info");
$obj_info->child_add_string("object-id", $volume->get_id()):
$obj_info->child_add_string("object-type", 'volume');
my $new_objs = NetAppApi::NaElement->new("new-objects");
$new_objs->child_add($obj_info);
my $cmd = NetAppApi::NaElement->new("perf-threshold-template-attach-objects");
$cmd->child_add_sting("template-name-or-id", $self->get_id());
$cmd->child_add($new_objs);
my $output = $serv->invoke($cmd);
The error I get back is 'Extra content at en of the document', so I suspect I'm constructing the cmd incorrectly. Any pointers?
The equivalent CLI does work:
./dfm perf template attach 2 12974
Attached object to the template
where 2 it the threshold template id and 12974 is a volume object id.
Solved! See The Solution
There was one layer of NeElement nesting too deep in both code versions. In your example script $xi2 is not needed. $xi1 are array elements of $x1. I now have a version that works.
Thanks for the help.
The XML request sent by the CLI to the dfm server will be logged into audit.log file (in /opt/NTAPdfm/log directory by default). The XML request you have created can be dumped using sprintf member function. Using these two dumps, you should be able to figure out the issue with the perl script.
Regards
Harish
The audit log shows the CLI version as:
Aug 09 15:01:14 [Unknown:NOTIC]: algarch:API:in:[127.0.0.1]::<perf-threshold-template-attach-bjects> <new-objects> <object-info> <object-is>12974</object-id> </object-info> </new-objects> <template-name-or-id>2</template-name-or-id> </perf-threshold-template-attach-objects>
Aug 09 15:01:14 [Unknown:NOTIC]: algarch:API:in:[127.0.0.1]:: 12974 2 Aug 09 15:01:14 [perf:NOTIC]: algarch:CMD:in:[127.0.0.1]:perf template attach 2 12974:Attached object to the template.
Which looks like the same XML I am attempting to send via the API.
But the API call only inserts an error in the audit.log, no indication of what was received is written there:
Aug 09 15:13:14 [Unknown:NOTIC]: dfmapi:API:err:[172.24.1.136]::Extra content at the end of the document
Could you please dump the XML request you created from the perl script using NaElement->sprintf() function?
$cmd->sprintf() returns somthing that looks like:
'<perl-threshold-template-attach-objects>
<template-name-or-id>2</template-name-or-id>
<new-objects>
<object-info>
<object-id>12974</object-id>
<object-type>volume</object-type>
</object-info>
</new-objects>
</perf-threshold-template-attach-objects>';
Which matches my reading of the API documentation. Any ideas?
From cli:
<perf-threshold-template-attach-objects>
<new-objects>
<object-info>
<object-id>12974</object-id>
</object-info>
</new-objects>
<template-name-or-id>2</template-name-or-id>
</perf-threshold-template-attach-objects>
From perl script:
<perl-threshold-template-attach-objects>
<template-name-or-id>2</template-name-or-id>
<new-objects>
<object-info>
<object-id>12974</object-id>
<object-type>volume</object-type>
</object-info>
</new-objects>
</perf-threshold-template-attach-objects>
The difference I see is the extra "object-type" tag in the perl script and the incorrectly spelt first line (perl instead of perf). I changed perl to perf and I am able to attach object to the template. Is the serv (the server object) configured properly? Are you able to execute any other zapi requests using
this serv object?
The perl instead of perf is just a typo in this web form. It's "perf" in the XML.
object-type is optional according to the docs. If I remove it the error does not change.
$VAR1 = ' <perf-threshold-template-attach-objects>
<template-name-or-id>2</template-name-or-id>
<new-objects>
<object-info>
<object-id>12974</object-id>
</object-info>
</new-objects>
</perf-threshold-template-attach-objects>
The $serv obect is an NaServer object. It works for many other calls.
Did you try using apitest ? Could you try executing your XML through spitest and see, if you get the same error.
is apitest applicable to dfm api calls? It works for me against filers, but not against DFM.
Are you able to use the perf-threshold-template-attach-objects method? Can you validate that it works as documented for the perl API? I'm a bit stuck otherwise and this is blocking dev.
Thanks,
Chris
Has anyone been able to validate that the documentation and function of this method are correct? The same syntax for perf-threshold-template-detach-objects works ok, so I am still stuck on why perf-threshold-template-attach-objects does not.
Just getting back to the dev of this system and I'm blocked on this issue.
Chris
Hi Chris,
apitest tool also works for DFM API. I tested "perf-threshold-template-attach-objects" ZAPI using apitest and it is working fine.
[root@lnx186-58 ~]# dfm perf template list
Id Name Status Description
------- ---------------- --------- ----------------------------------------
2 tmp1 Enabled
[root@lnx186-58 ~]# vi file.txt
[root@lnx186-58 ~]# /u/agireesh/apitest -t dfm -h XX.XX.XX.XX -p ******* -f file.txt
Testing: perf-threshold-template-attach-objects(template-name-or-id=2, new-objects=
) Success
{
}
[root@lnx186-58 ~]# cat file.txt
<perf-threshold-template-attach-objects>
<template-name-or-id>2</template-name-or-id>
<new-objects>
<object-info>
<object-id>198</object-id>
</object-info>
</new-objects>
</perf-threshold-template-attach-objects>
[root@lnx186-58 ~]#
There might be other reason due to that your API is failing. Could you check below things
1. Did you add threshold to template before attaching the objects to template..? If there is no threshold added for template then you cannot add the template to object.
2. You are trying to attach the threshold template to incompatible objects. could you please send the output of "dfm perf threshold list -x" command.
Regards,
Gireesh
Hi Chris,
Could you test that script?
my $api = new NaElement('perf-threshold-template-attach-objects');
# Name or id of a performance template
$api->child_add_string('template-name-or-id','2');
# The list of objects to be attached to the template. At least one object should be specified.
my $xi = new NaElement('new-objects');
$api->child_add($xi);
my $xi1 = new NaElement('object-info');
$xi->child_add($xi1);
# The object that is associated with the view
my $xi2 = new NaElement('object-id');
$xi1->child_add($xi2);
# Identification number (ID) for a DFM object.
$xi2->child_add_string('obj-id','12974');
# Type of the DFM object. "resource_group" "data_set" "resource_pool" "filer" "vfiler" "volume" "qtree" "lun" "aggregate" "interface"
$xi1->child_add_string('object-type','volume');
print 'Calling:\n';
print $api->sprintf();
my $r = $s->invoke_elem($api);
if ($r->results_status() eq 'failed') {
print 'Error:\n';
print $r->sprintf();
exit 1;
}
print 'Received:\n';
print $r->sprintf();
Regards,
I think
# The object that is associated with the view
my $xi2 = new NaElement('object-id');
$xi1->child_add($xi2);
# Identification number (ID) for a DFM object.
$xi2->child_add_string('obj-id','12974');
has to replaced by
# The object that is associated with the view
# Identification number (ID) for a DFM object.
$xi1->child_add_string('object-id','12974');
So this moved me past the initial error - Thanks. My initial mistake was $cmd->invoke($cmd) where $cmd was an NaElement, should have been invoke_elem ! I won't do that again.
Now I get a good return code, but the outcome is not as expected with your code or mine. When I try to add a volume to the template the object that is actualy added is "Global", obj-id 1.
volume is a valid object type for the template, and the equivalent dfm cli command does the right thing (adds the volume).
./dfm perf template attach 3 13002
Template Id: 3
Template Name: test_template
Template Status: Enabled
Template Description: test_template
Threshold Information:
Threshold Id: 7
Threshold Event Name: test_threshold
Thershold Interval: 300 seconds
Counter Information:
Counter Name: nfs_write_ops:volume
Counter Tyoe: upper
Counter Unit: per_sec
Counter Value: 1000
Applied objects:
lnn30oznp1:/lnn30f1v2 (13002)
However, using the sample code the output is the same other than:
Applied objects:
Global
The sprintf output shows the command to be:
Calling:
<perf-threshold-template-attach-objects>
<template-name-or-id>3</template-name-or-id>
<new-objects>
<object-info>
<object-id>
<obj-id>13002</obj-id.
</object-id>
<object-type?volume</object-type>
</object-info>
</new-objects>
</perf-threshold-tempalte-attach-objects>
Received:\n<results status="passed"></results>
and running it again tries to add Global again:
Error:\n<result reason="1 (1) is already attatched." status="failed" errno"13115"></results>
Any ideas?
There was one layer of NeElement nesting too deep in both code versions. In your example script $xi2 is not needed. $xi1 are array elements of $x1. I now have a version that works.
Thanks for the help.