hyperic / hqapi Goto Github PK
View Code? Open in Web Editor NEWWeb Service API for Hyperic HQ
Home Page: http://support.hyperic.com/display/DOC/HQ+Web+Services+API
Web Service API for Hyperic HQ
Home Page: http://support.hyperic.com/display/DOC/HQ+Web+Services+API
Attempting to sync the following XML via hqapi.sh alertdefinition sync --file produces the error immediately after it.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AlertDefinitionResponse>
<Status>Success</Status>
<AlertDefinition mtime="1354626457188" ctime="1353803425597" id="298258" name="Linux Platform Availability - PROBLEM" description="https://extranet.contegix.com/display/CNT/Platform+Availability" parent="98431" priority="2" enabled="false" active="false" frequency="0" count="0" range="0" willRecover="true" notifyFiltered="false" controlFiltered="false">
<Resource id="178032" name="rmc-testing.contegix.com"/>
<Escalation id="11009" name="RMC Escalation" description="Test escalation for Rich" pauseAllowed="false" maxPauseTime="9223372036854775807" notifyAll="false" repeat="true"/>
<AlertCondition required="true" type="1" thresholdValue="1.0" thresholdComparator="!=" thresholdMetric="Availability"/>
<AlertAction id="11744316" className="org.hyperic.hq.measurement.action.MetricAlertAction"/>
</AlertDefinition>
</AlertDefinitionResponse>
Error running command: null
java.lang.ClassCastException
at java.lang.Class.cast(Class.java:2990)
at org.hyperic.hq.hqapi1.XmlUtil.deserialize(XmlUtil.java:68)
at org.hyperic.hq.hqapi1.tools.AlertDefinitionCommand.sync(AlertDefinitionCommand.java:439)
at org.hyperic.hq.hqapi1.tools.AlertDefinitionCommand.handleCommand(AlertDefinitionCommand.java:152)
at org.hyperic.hq.hqapi1.tools.Shell.dispatchCommand(Shell.java:244)
at org.hyperic.hq.hqapi1.tools.Shell.main(Shell.java:259)
Digging into the source, the issue seems to be that the sync method in AlertDefinitionCommand.java passes an object of type AlertDefinitionsResponse to XmlUtil.deserialize, which then attempts to cast it to an object of type AlertDefinitionResponse. I confirmed this by modifying the deserialize method in XmlUtil.java to have some debugging text:
public static <T> T deserialize(Class<T> res, InputStream is)
throws JAXBException
{
String pkg = res.getPackage().getName();
JAXBContext jc = getCachedContext(pkg);
Unmarshaller u = jc.createUnmarshaller();
u.setEventHandler(new DefaultValidationEventHandler());
Object unmarshalOut = u.unmarshal(is);
System.out.println(res.getName());
System.out.println(unmarshalOut.getClass().getName());
return res.cast(unmarshalOut);
}
When built and run with the same command, it produces the following output:
org.hyperic.hq.hqapi1.types.AlertDefinitionsResponse
org.hyperic.hq.hqapi1.types.AlertDefinitionResponse
Error running command: null
java.lang.ClassCastException
at java.lang.Class.cast(Class.java:2990)
at org.hyperic.hq.hqapi1.XmlUtil.deserialize(XmlUtil.java:68)
at org.hyperic.hq.hqapi1.tools.AlertDefinitionCommand.sync(AlertDefinitionCommand.java:439)
at org.hyperic.hq.hqapi1.tools.AlertDefinitionCommand.handleCommand(AlertDefinitionCommand.java:152)
at org.hyperic.hq.hqapi1.tools.Shell.dispatchCommand(Shell.java:244)
at org.hyperic.hq.hqapi1.tools.Shell.main(Shell.java:259)
This demonstrates that the res object is of type org.hyperic.hq.hqapi1.types.AlertDefinitionsResponse while the object returned by the JAXB unmarshaller is of type org.hyperic.hq.hqapi1.types.AlertDefinitionResponse.
The only workaround I have found so far is to manually change the root node of the XML to be synced to be AlertDefinitionsResponse instead of AlertDefinitionResponse, such as the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AlertDefinitionsResponse>
<Status>Success</Status>
<AlertDefinition mtime="1354626457188" ctime="1353803425597" id="298258" name="Linux Platform Availability - PROBLEM" description="https://extranet.contegix.com/display/CNT/Platform+Availability" parent="98431" priority="2" enabled="false" active="false" frequency="0" count="0" range="0" willRecover="true" notifyFiltered="false" controlFiltered="false">
<Resource id="178032" name="rmc-testing.contegix.com"/>
<Escalation id="11009" name="RMC Escalation" description="Test escalation for Rich" pauseAllowed="false" maxPauseTime="9223372036854775807" notifyAll="false" repeat="true"/>
<AlertCondition required="true" type="1" thresholdValue="1.0" thresholdComparator="!=" thresholdMetric="Availability"/>
<AlertAction id="11744316" className="org.hyperic.hq.measurement.action.MetricAlertAction"/>
</AlertDefinition>
</AlertDefinitionsResponse>
This issue has also been reported here: http://communities.vmware.com/message/2164480
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.