private ActionResponse executeAction(IAction action) throws CapabilityException { ActionResponse response; try { IProtocolManager protocolManager = Activator.getProtocolManagerService(); IProtocolSessionManager protocolSessionManager = protocolManager.getProtocolSessionManager(this.resourceId); response = action.execute(protocolSessionManager); } catch (ProtocolException pe) { log.error("Error with protocol session - " + pe.getMessage()); throw new CapabilityException(pe); } catch (ActivatorException ae) { String errorMsg = "Error getting protocol manager - " + ae.getMessage(); log.error(errorMsg); throw new CapabilityException(errorMsg, ae); } catch (ActionException ae) { log.error("Error executing " + action.getActionID() + " action - " + ae.getMessage()); throw (ae); } if (!response.getStatus().equals(ActionResponse.STATUS.OK)) { String errMsg = "Error executing " + action.getActionID() + " action - " + response.getInformation(); log.error(errMsg); throw new ActionException(errMsg); } return response; }
/** * TODO, it is necessary to implement the dummy state to configure vlans * * @throws ActionException */ @Test public void testExecuteforETH() throws ActionException { LogicalPort feIface = createEthernetPort("fe-0/3/2", 4); feIface = addVlanToIface(feIface, 3); setVlanAction.setParams(feIface); ActionResponse response = setVlanAction.execute(protocolSessionManager); Assert.assertEquals(ActionConstants.SET_VLANID, response.getActionID()); List<Response> responses = response.getResponses(); for (Response resp : responses) { Assert.assertEquals(Response.Status.OK, resp.getStatus()); } // An interface with vlan-tagging and subinterfaces with vlans LogicalPort phyFeIface = createPhysicalInterface("fe-0/1/3"); // FIXME This test fails due to mock router not filering config // setEncapsulationAction.setParams(phyFeIface); // response = setEncapsulationAction.execute(protocolSessionManager); // Assert.assertEquals(ActionConstants.SET_TAGGEDETHERNET_ENCAPSULATION, // response.getActionID()); // responses = response.getResponses(); // for (Response resp : responses) { // Assert.assertEquals(Response.Status.OK, resp.getStatus()); // } try { removeEncapsulationAction.setParams(phyFeIface); response = removeEncapsulationAction.execute(protocolSessionManager); // Assert.assertEquals(ActionConstants.REMOVE_TAGGEDETHERNET_ENCAPSULATION, // response.getActionID()); // responses = response.getResponses(); // for (Response resp : responses) { // Assert.assertEquals(Response.Status.OK, resp.getStatus()); // } } catch (ActionException e) { Assert.assertTrue( e.getLocalizedMessage() .contains( "Interface has subinterfaces with vlanId. Please remove them before changing encapsulation.")); } }