@Test
  public void testActivateOSPF() throws ResourceException, ProtocolException {

    List<IResource> routers = new ArrayList<IResource>(2);
    routers.add(startRouterResource("router1"));
    routers.add(startRouterResource("router2"));

    // Add routers to network
    INetworkBasicCapability basicCapability =
        (INetworkBasicCapability)
            networkResource.getCapabilityByInterface(INetworkBasicCapability.class);
    assertNotNull(basicCapability);

    for (IResource router : routers) {
      basicCapability.addResource(router);
    }

    // Activate OSPF
    INetOSPFCapability netOSPFCapability =
        (INetOSPFCapability) networkResource.getCapabilityByInterface(INetOSPFCapability.class);

    assertNotNull(netOSPFCapability);
    netOSPFCapability.activateOSPF();

    checkRoutersQueueContainsOSPFConfigActions(routers);
  }
  @Override
  protected Object doExecute() throws Exception {
    printInitCommand("createDeliverySource");
    try {
      IResource resource = getResourceFromFriendlyName(resourceName);
      IPowerNetManagementCapability capab =
          (IPowerNetManagementCapability)
              resource.getCapabilityByInterface(IPowerNetManagementCapability.class);

      // build source
      PowerSource source = new PowerSource();
      source.setId(sourceId);
      source.setElementId(deliveryId);
      source.setPowerMonitorLog(new PowerMonitorLog(0, 0));
      source.setPowerState(true);

      String id = capab.addPowerDeliverySource(deliveryId, sourceId, source);
      printInfo(id);
    } catch (Exception e) {
      printError("Error in createDeliverySource " + resourceName + " with id " + deliveryId);
      printError(e);
    } finally {
      printEndCommand();
    }
    printEndCommand();
    return null;
  }
  @Override
  protected Object doExecute() throws Exception {
    printInitCommand("Update VRRP virtual link address");

    try {

      IResource router = getResourceFromFriendlyName(resourceId);

      IVRRPCapability vrrpCapability =
          (IVRRPCapability) router.getCapabilityByInterface(IVRRPCapability.class);

      VRRPGroup vrrpGroup = new VRRPGroup();
      vrrpGroup.setVrrpName(vrrpGroupId);
      vrrpGroup.setVirtualLinkAddress(virtualLinkAddress);

      vrrpCapability.updateVRRPVirtualLinkAddress(vrrpGroup);

      printEndCommand();
      return null;

    } catch (Exception e) {
      printError("Error updating VRRP virtual Link address.");
      printError(e);
      printEndCommand();
      return -1;
    }
  }
  @Override
  protected Object doExecute() throws Exception {

    printInitCommand("show interfaces information");

    try {

      IResource resource = getResourceFromFriendlyName(resourceId);

      IChassisCapability chassisCapability =
          (IChassisCapability) resource.getCapabilityByInterface(IChassisCapability.class);
      InterfaceInfoList interfacesInfoList = chassisCapability.getInterfacesInfo();

      printInterfacesInfo(interfacesInfoList);

    } catch (ResourceException e) {
      printError(e);
      printEndCommand();
      return -1;
    } catch (Exception e) {
      printError("Error listing interfaces.");
      printError(e);
      printEndCommand();
      return -1;
    }
    printEndCommand();
    return null;
  }
  /**
   * Test to check netqueue method
   *
   * @throws ProtocolException
   * @throws ResourceException
   */
  @Test
  public void executeQueueTest() throws ResourceException, ProtocolException {
    Information information = new Information();
    information.setType(QUEUE_CAPABILIY_TYPE);

    QueueCapability queueCapability =
        (QueueCapability) networkResource.getCapabilityByInterface(IQueueCapability.class);
    queueCapability.execute();
  }
  @Override
  protected Object doExecute() throws Exception {

    printInitCommand("getPowerMetrics of resource: " + resourceId);

    IResource resource = getResourceFromFriendlyName(resourceId);
    MeasuredLoad metrics =
        ((IPowerMonitoringCapability)
                resource.getCapabilityByInterface(IPowerMonitoringCapability.class))
            .getCurrentPowerMetrics();
    printMetrics(metrics);

    printEndCommand();
    return null;
  }
  @Override
  protected Object doExecute() throws Exception {
    printInitCommand("DOWN interface");

    try {
      IResourceManager manager = getResourceManager();

      String[] argsRouterName = new String[2];
      try {
        argsRouterName = splitResourceName(resourceId);
      } catch (Exception e) {
        printError(e.getMessage());
        printEndCommand();
        return -1;
      }

      IResourceIdentifier resourceIdentifier = null;

      resourceIdentifier =
          manager.getIdentifierFromResourceName(argsRouterName[0], argsRouterName[1]);
      if (resourceIdentifier == null) {
        printError(
            "Could not get resource with name: " + argsRouterName[0] + ":" + argsRouterName[1]);
        printEndCommand();
        return -1;
      }

      IResource resource = manager.getResource(resourceIdentifier);

      validateResource(resource);

      IChassisCapability chassisCapability =
          (IChassisCapability) resource.getCapabilityByInterface(IChassisCapability.class);
      chassisCapability.downPhysicalInterface(prepareConfigureStatusParams(interfaceName));

    } catch (ResourceException e) {
      printError(e);
      printEndCommand();
      return -1;
    } catch (Exception e) {
      printError("Error setting down interfaces.");
      printError(e);
      printEndCommand();
      return -1;
    }
    printEndCommand();
    return null;
  }
  private void checkRoutersQueueContainsOSPFConfigActions(List<IResource> routers)
      throws ResourceException {

    for (IResource router : routers) {

      IQueueManagerCapability queueCapab =
          (IQueueManagerCapability) router.getCapabilityByInterface(IQueueManagerCapability.class);
      assertEquals(4, queueCapab.getActions().size());

      assertEquals(ActionConstants.OSPF_CONFIGURE, queueCapab.getActions().get(0).getActionID());
      assertEquals(
          ActionConstants.OSPF_CONFIGURE_AREA, queueCapab.getActions().get(1).getActionID());
      assertEquals(
          ActionConstants.OSPF_ADD_INTERFACE_IN_AREA, queueCapab.getActions().get(2).getActionID());
      assertEquals(
          ActionConstants.OSPF_ACTIVATE + "/" + ActionConstants.OSPF_DEACTIVATE,
          queueCapab.getActions().get(3).getActionID());
    }
  }
  @Override
  public ActionResponse execute(IProtocolSessionManager protocolSessionManager)
      throws ActionException {

    try {
      GenericNetworkModel model = (GenericNetworkModel) this.getModelToUpdate();

      // obtain INetworkStatisticsCapability capability of own resource
      IResource resource = (IResource) params;
      INetworkStatisticsCapability networkStatisticsCapability;
      try {
        networkStatisticsCapability =
            (INetworkStatisticsCapability)
                resource.getCapabilityByInterface(INetworkStatisticsCapability.class);
      } catch (ResourceException e) {
        throw new ActionException(
            "Failed to obtain INetworkStatisticsCapability! It is mandatory having INetworkStatisticsCapability to use IPortStatisticsCapability in generic networks!",
            e);
      }

      // obtain NetworkStatistics using capability
      NetworkStatistics networkStatistics = networkStatisticsCapability.getNetworkStatistics();

      // generate own SwitchPortStatistics from underlying network elements information
      SwitchPortStatistics ownPortStatistics =
          generateSwitchPortStatistics(
              networkStatistics.getSwitchStatistics(),
              model.getTopology().getNetworkDevicePortIdsMap());

      // create action response with an object response
      ActionResponse response = new ActionResponse();
      response.setStatus(ActionResponse.STATUS.OK);
      response.setResult(ownPortStatistics);

      return response;
    } catch (Exception e) {
      throw new ActionException(e);
    }
  }