Search in sources :

Example 11 with Outage

use of org.opennms.netmgt.config.poller.outages.Outage in project opennms by OpenNMS.

the class ScheduledOutagesRestServiceIT method testSetOutage.

@Test
public void testSetOutage() throws Exception {
    String url = "/sched-outages";
    String outage = "<?xml version=\"1.0\"?>" + "<outage name='test-outage' type='specific'>" + "<time day='friday' begins='13:20:00' ends='15:30:00' />" + "<time begins='17-Feb-2012 19:20:00' ends='18-Feb-2012 22:30:00' />" + "<node id='11' />" + "</outage>";
    sendPost(url, outage, 201, null);
    Outage out = getXmlObject(m_jaxbContext, "/sched-outages/test-outage", 200, Outage.class);
    Assert.assertNotNull(out);
    Assert.assertEquals("13:20:00", out.getTimes().get(0).getBegins());
    // Update the outage slightly
    outage = "<?xml version=\"1.0\"?>" + "<outage name='test-outage' type='specific'>" + "<time day='friday' begins='14:20:00' ends='15:30:00' />" + "<time begins='17-Feb-2012 19:20:00' ends='18-Feb-2012 22:30:00' />" + "<node id='11' />" + "</outage>";
    sendPost(url, outage, 204, null);
    out = getXmlObject(m_jaxbContext, "/sched-outages/test-outage", 200, Outage.class);
    Assert.assertNotNull(out);
    Assert.assertEquals("14:20:00", out.getTimes().get(0).getBegins());
}
Also used : Outage(org.opennms.netmgt.config.poller.outages.Outage) Test(org.junit.Test)

Example 12 with Outage

use of org.opennms.netmgt.config.poller.outages.Outage in project opennms by OpenNMS.

the class ScheduledOutagesRestService method isInterfaceInOutage.

@GET
@Path("{outageName}/interfaceInOutage/{ipAddr}")
@Produces(MediaType.TEXT_PLAIN)
public String isInterfaceInOutage(@PathParam("outageName") String outageName, @PathParam("ipAddr") String ipAddr) {
    validateAddress(ipAddr);
    Outage outage = getOutage(outageName);
    Boolean inOutage = m_pollOutagesConfigFactory.isInterfaceInOutage(ipAddr, outage) && m_pollOutagesConfigFactory.isCurTimeInOutage(outage);
    return inOutage.toString();
}
Also used : Outage(org.opennms.netmgt.config.poller.outages.Outage) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Outage (org.opennms.netmgt.config.poller.outages.Outage)12 Test (org.junit.Test)4 Time (org.opennms.netmgt.config.poller.outages.Time)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 GregorianCalendar (java.util.GregorianCalendar)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Interface (org.opennms.netmgt.config.poller.outages.Interface)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 ThreshdConfigManager (org.opennms.netmgt.config.ThreshdConfigManager)1 Node (org.opennms.netmgt.config.poller.outages.Node)1