@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);
  }
Пример #2
0
  @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;
  }
  @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;
    }
  }
  @Test
  public void testGRECreateTunnelAction() throws CapabilityException, ProtocolException {
    log.info("TEST GRE TUNNEL ACTION");
    IGRETunnelCapability greCapability =
        (IGRETunnelCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE));

    greCapability.createGRETunnel(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, IPv4_ADDRESS, IP_SOURCE, IP_DESTINY));

    IQueueManagerCapability queueCapability =
        (IQueueManagerCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(
                    TestsConstants.QUEUE_CAPABILIY_TYPE));

    List<IAction> queue = (List<IAction>) queueCapability.getActions();
    Assert.assertEquals(queue.size(), 1);

    QueueResponse queueResponse = (QueueResponse) queueCapability.execute();
    Assert.assertEquals(queueResponse.getResponses().size(), 1);

    Assert.assertEquals(queueResponse.getPrepareResponse().getStatus(), ActionResponse.STATUS.OK);
    Assert.assertEquals(queueResponse.getConfirmResponse().getStatus(), ActionResponse.STATUS.OK);
    Assert.assertEquals(queueResponse.getRefreshResponse().getStatus(), ActionResponse.STATUS.OK);
    Assert.assertEquals(
        queueResponse.getRestoreResponse().getStatus(), ActionResponse.STATUS.PENDING);

    Assert.assertTrue(queueResponse.isOk());

    queue = (List<IAction>) queueCapability.getActions();
    Assert.assertEquals(queue.size(), 0);
  }
  /**
   * Stop and remove the router resource
   *
   * @throws ResourceException
   * @throws ProtocolException
   */
  protected void stopResource() throws ResourceException, ProtocolException {
    // Stop resource
    resourceManager.stopResource(routerResource.getResourceIdentifier());

    // Remove resource
    resourceManager.removeResource(routerResource.getResourceIdentifier());
  }
  /**
   * This test require the dirty model, since the checkParams method would check there's a
   * GreTunnelService in the model.
   *
   * @throws CapabilityException
   * @throws ProtocolException
   */
  @Test
  @Ignore
  public void testDeleteUnexistingTunnelAction() throws CapabilityException, ProtocolException {
    log.info("TEST GRE TUNNEL ACTION");
    IGRETunnelCapability greCapability =
        (IGRETunnelCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE));

    greCapability.deleteGRETunnel(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, null, null, null, null));

    IQueueManagerCapability queueCapability =
        (IQueueManagerCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(
                    TestsConstants.QUEUE_CAPABILIY_TYPE));

    List<IAction> queue = (List<IAction>) queueCapability.getActions();
    Assert.assertEquals(queue.size(), 1);

    QueueResponse queueResponse = (QueueResponse) queueCapability.execute();
    Assert.assertEquals(queueResponse.getResponses().size(), 1);

    Assert.assertFalse(queueResponse.isOk());

    queue = (List<IAction>) queueCapability.getActions();
    Assert.assertEquals(queue.size(), 0);
  }
  public void startResource() throws ResourceException, ProtocolException {
    /* initialize model */
    List<CapabilityDescriptor> lCapabilityDescriptors = new ArrayList<CapabilityDescriptor>();

    CapabilityDescriptor greCapabilityDescriptor =
        ResourceHelper.newCapabilityDescriptor(
            TestsConstants.ACTION_NAME,
            TestsConstants.CAPABILIY_VERSION,
            TestsConstants.GRE_CAPABILITY_TYPE,
            TestsConstants.CAPABILITY_URI);
    lCapabilityDescriptors.add(greCapabilityDescriptor);

    // Add Queue Capability Descriptor
    CapabilityDescriptor queueCapabilityDescriptor = ResourceHelper.newQueueCapabilityDescriptor();
    lCapabilityDescriptors.add(queueCapabilityDescriptor);

    // Router Resource Descriptor
    ResourceDescriptor resourceDescriptor =
        ResourceHelper.newResourceDescriptor(
            lCapabilityDescriptors,
            TestsConstants.RESOURCE_TYPE,
            TestsConstants.RESOURCE_URI,
            RESOURCE_INFO_NAME);

    routerResource = resourceManager.createResource(resourceDescriptor);

    // If not exists the protocol session manager, it's created and add the session context
    InitializerTestHelper.addSessionContext(
        protocolManager,
        routerResource.getResourceIdentifier().getId(),
        TestsConstants.RESOURCE_URI);

    // Start resource
    resourceManager.startResource(routerResource.getResourceIdentifier());
  }
  private IResource startRouterResource(String routerName)
      throws ResourceException, ProtocolException {

    List<CapabilityDescriptor> lCapabilityDescriptors = new ArrayList<CapabilityDescriptor>();
    CapabilityDescriptor ospfCapabilityDescriptor =
        ResourceHelper.newCapabilityDescriptor("junos", "10.10", "ospf", CAPABILITY_URI);
    lCapabilityDescriptors.add(ospfCapabilityDescriptor);

    // Add Queue Capability Descriptor
    CapabilityDescriptor queueCapabilityDescriptor = ResourceHelper.newQueueCapabilityDescriptor();
    lCapabilityDescriptors.add(queueCapabilityDescriptor);

    // Router Resource Descriptor
    ResourceDescriptor resourceDescriptor =
        ResourceHelper.newResourceDescriptor(
            lCapabilityDescriptors, "router", RESOURCE_URI, routerName);

    IResource routerResource = resourceManager.createResource(resourceDescriptor);

    // If not exists the protocol session manager, it's created and add the session context
    addSessionContext(routerResource.getResourceIdentifier().getId());

    // Start resource
    resourceManager.startResource(routerResource.getResourceIdentifier());

    return routerResource;
  }
  @Test
  public void repoIsPublishedInResourceManagerTest() throws ResourceException, ProtocolException {

    ResourceDescriptor resourceDescriptor = ResourceHelper.newResourceDescriptorProteus("roadm");

    IResource resource = resourceManger.createResource(resourceDescriptor);
    createProtocolForResource(resource.getResourceIdentifier().getId());
    resourceManger.startResource(resource.getResourceIdentifier());
    resourceManger.stopResource(resource.getResourceIdentifier());
    resourceManger.removeResource(resource.getResourceIdentifier());
  }
 @Override
 public ICapability create(IResource resource) throws CapabilityException {
   ICapability capability =
       this.create(
           resource
               .getResourceDescriptor()
               .getCapabilityDescriptor(PowerSupplyCapability.CAPABILITY_TYPE),
           resource.getResourceDescriptor().getId());
   capability.setResource(resource);
   return capability;
 }
  @Test
  public void showGRETunnelConfigurationTest() throws CapabilityException, ProtocolException {
    log.info("Test showGRETunnelConfiguration method");

    IGRETunnelCapability greCapability =
        (IGRETunnelCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE));

    ComputerSystem routerModel = (ComputerSystem) routerResource.getModel();
    routerModel.addHostedService(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, IPv4_ADDRESS, IP_SOURCE, IP_DESTINY));
    routerModel.addHostedService(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, IPv6_ADDRESS, IP_SOURCE, IP_DESTINY));

    List<GRETunnelService> greServices = greCapability.showGRETunnelConfiguration();
    Assert.assertEquals(greServices.size(), 2);

    GRETunnelService greService = greServices.get(0);
    Assert.assertEquals(TUNNEL_NAME, greService.getName());

    Assert.assertNotNull(greService.getGRETunnelConfiguration());
    GRETunnelConfiguration greConfig = greService.getGRETunnelConfiguration();
    Assert.assertEquals(IP_SOURCE, greConfig.getSourceAddress());
    Assert.assertEquals(IP_DESTINY, greConfig.getDestinationAddress());

    Assert.assertEquals(greService.getProtocolEndpoint().size(), 1);
    ProtocolEndpoint pE = greService.getProtocolEndpoint().get(0);
    Assert.assertTrue(pE instanceof GRETunnelEndpoint);
    GRETunnelEndpoint gE = (GRETunnelEndpoint) pE;
    Assert.assertEquals(IPUtilsHelper.getAddressFromIP(IPv4_ADDRESS), gE.getIPv4Address());
    Assert.assertEquals(
        IPUtilsHelper.getPrefixFromIp(IPv4_ADDRESS),
        IPUtilsHelper.parseLongToShortIpv4NetMask(gE.getSubnetMask()));
    Assert.assertEquals(ProtocolIFType.IPV4, gE.getProtocolIFType());

    greService = greServices.get(1);
    Assert.assertEquals(TUNNEL_NAME, greService.getName());

    Assert.assertNotNull(greService.getGRETunnelConfiguration());
    greConfig = greService.getGRETunnelConfiguration();
    Assert.assertEquals(IP_SOURCE, greConfig.getSourceAddress());
    Assert.assertEquals(IP_DESTINY, greConfig.getDestinationAddress());

    Assert.assertEquals(greService.getProtocolEndpoint().size(), 1);
    pE = greService.getProtocolEndpoint().get(0);
    Assert.assertTrue(pE instanceof GRETunnelEndpoint);
    gE = (GRETunnelEndpoint) pE;
    Assert.assertEquals(IPUtilsHelper.getAddressFromIP(IPv6_ADDRESS), gE.getIPv6Address());
    Assert.assertEquals(
        IPUtilsHelper.getPrefixFromIp(IPv6_ADDRESS), String.valueOf(gE.getPrefixLength()));
    Assert.assertEquals(ProtocolIFType.IPV6, gE.getProtocolIFType());
  }
  @Test
  public void RemoveAndCreateResource() throws Exception {

    ResourceDescriptor resourceDescriptor = ResourceHelper.newResourceDescriptorProteus("roadm");

    IResource resource = repository.createResource(resourceDescriptor);
    Assert.assertFalse(repository.listResources().isEmpty());

    createProtocolForResource(resource.getResourceIdentifier().getId());

    repository.removeResource(resource.getResourceIdentifier().getId());
    Assert.assertTrue(repository.listResources().isEmpty());
  }
 @Test
 public void testSetInterfaceDescription() throws ProtocolException, ResourceException {
   IIPCapability ipCapability =
       (IIPCapability)
           routerResource.getCapability(
               InitializerTestHelper.getCapabilityInformation(TestsConstants.IP_CAPABILITY_TYPE));
   ipCapability.setInterfaceDescription(ParamCreationHelper.getLogicalPort());
   IQueueManagerCapability queueCapability =
       (IQueueManagerCapability)
           routerResource.getCapability(
               InitializerTestHelper.getCapabilityInformation(
                   TestsConstants.QUEUE_CAPABILIY_TYPE));
   QueueResponse queueResponse = (QueueResponse) queueCapability.execute();
   Assert.assertTrue(queueResponse.isOk());
 }
  @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;
  }
 @Test
 /** Test to check if capability is available from OSGi. */
 public void isCapabilityAccessibleFromResource() throws ResourceException, ProtocolException {
   startResource();
   Assert.assertFalse(routerResource.getCapabilities().isEmpty());
   Assert.assertNotNull(
       routerResource.getCapability(
           InitializerTestHelper.getCapabilityInformation(TestsConstants.QUEUE_CAPABILIY_TYPE)));
   Assert.assertNotNull(
       routerResource.getCapability(
           InitializerTestHelper.getCapabilityInformation(
               TestsConstants.STATIC_ROUTE_CAPABILITY_TYPE)));
   stopResource();
   Assert.assertTrue(resourceManager.listResources().isEmpty());
 }
Пример #17
0
  @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;
  }
Пример #18
0
  /**
   * Start network resource with queue and ospf capability
   *
   * @throws ResourceException
   * @throws ProtocolException
   */
  @Before
  public void startResource() throws ResourceException, ProtocolException {

    List<CapabilityDescriptor> capDescriptors = new ArrayList<CapabilityDescriptor>();

    capDescriptors.add(
        ResourceHelper.newCapabilityDescriptor(
            ACTION_NAME, CAPABILIY_VERSION, BASIC_CAPABILIY_TYPE, CAPABILITY_URI));

    capDescriptors.add(
        ResourceHelper.newCapabilityDescriptor(
            ACTION_NAME, CAPABILIY_VERSION, OSPF_CAPABILIY_TYPE, CAPABILITY_URI));

    capDescriptors.add(
        ResourceHelper.newCapabilityDescriptor(
            ACTION_NAME, CAPABILIY_VERSION, QUEUE_CAPABILIY_TYPE, CAPABILITY_URI));

    // Network Resource Descriptor
    ResourceDescriptor resourceDescriptor =
        ResourceHelper.newResourceDescriptor(
            capDescriptors, RESOURCE_TYPE, RESOURCE_URI, RESOURCE_INFO_NAME);

    // Create resource
    networkResource = resourceManager.createResource(resourceDescriptor);

    // Start resource
    resourceManager.startResource(networkResource.getResourceIdentifier());
  }
 public void createResource(MantychoreRepository repository, ResourceDescriptor descriptor) {
   /* Profile info is not cloned */
   // descriptor.setProfileId(profileName);
   IResource resource = null;
   try {
     log.info("Creating Resource ...... ");
     resource = repository.createResource(descriptor);
   } catch (ResourceException e) {
     log.error(e.getMessage());
   }
   log.info(
       "Resource of type "
           + resource.getResourceDescriptor().getInformation().getType()
           + " created with name: "
           + resource.getResourceDescriptor().getInformation().getName());
 }
  private boolean isALogicalRouter(IResource resource) {
    ResourceDescriptor resourceDescriptor = resource.getResourceDescriptor();
    /* Check that the logical router exists */
    if (resourceDescriptor == null || resourceDescriptor.getProperties() == null) return false;

    return (resourceDescriptor.getProperties().get(ResourceDescriptor.VIRTUAL) != null
        && resourceDescriptor.getProperties().get(ResourceDescriptor.VIRTUAL).equals("true"));
  }
Пример #21
0
  /**
   * 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();
  }
Пример #22
0
 @Override
 public ICapability create(IResource resource) throws CapabilityException {
   ICapability capability =
       this.create(
           resource.getResourceDescriptor().getCapabilityDescriptor(QueueManager.QUEUE),
           resource.getResourceDescriptor().getId());
   capability.setResource(resource);
   return capability;
 }
  /**
   * FIXME this method should be part of refresh action. Remove it when moved!!!
   *
   * @param resource
   * @throws ResourceException
   */
  private void initVirtualResources(IResource resource) throws ResourceException {

    if (resource.getModel() != null) {

      List<String> nameLogicalRouters = resource.getModel().getChildren();

      if (!nameLogicalRouters.isEmpty()) {

        log.debug("Loading child logical routers");

        /* resource type for all child logical devices is the same as the parent (physical) one */
        String typeResource = resource.getResourceIdentifier().getType();
        IResourceManager resourceManager;
        try {
          resourceManager = Activator.getResourceManagerService();
        } catch (Exception e1) {
          throw new ResourceException("Could not get Resource Manager Service.");
        }

        /* initialize each resource */
        int createdResources = 0;
        for (String nameResource : nameLogicalRouters) {
          try {
            resourceManager.getIdentifierFromResourceName(typeResource, nameResource);
            log.info("A resource with this name already exists, omitting creation");
          } catch (ResourceNotFoundException e) {
            // TODO If the resource exists what it is our decision?
            log.error(e.getMessage());
            log.info("This resource is new, it have to be created");
            ResourceDescriptor newResourceDescriptor =
                newResourceDescriptor(resource.getResourceDescriptor(), nameResource);

            /* create new resources */
            resourceManager.createResource(newResourceDescriptor);
            createdResources++;
          }
        }
        log.debug("Loaded " + createdResources + " new logical routers");

        // FIXME If a resource is created, we have to delete the don't used resources
      }
    }
  }
Пример #24
0
  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());
    }
  }
  @Test
  public void testGREDeleteTunnelAction() throws CapabilityException, ProtocolException {
    log.info("TEST GRE TUNNEL ACTION");
    IGRETunnelCapability greCapability =
        (IGRETunnelCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE));

    // add gre tunnel service to the router model.
    GRETunnelService greTunnelService = new GRETunnelService();
    greTunnelService.setName(TUNNEL_NAME);

    ComputerSystem model = (ComputerSystem) routerResource.getModel();
    model.addHostedService(greTunnelService);
    routerResource.setModel(model);

    greCapability.deleteGRETunnel(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, null, null, null, null));

    IQueueManagerCapability queueCapability =
        (IQueueManagerCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(
                    TestsConstants.QUEUE_CAPABILIY_TYPE));

    List<IAction> queue = (List<IAction>) queueCapability.getActions();
    Assert.assertEquals(queue.size(), 1);

    QueueResponse queueResponse = (QueueResponse) queueCapability.execute();
    Assert.assertEquals(queueResponse.getResponses().size(), 1);

    Assert.assertEquals(queueResponse.getPrepareResponse().getStatus(), ActionResponse.STATUS.OK);
    Assert.assertEquals(queueResponse.getConfirmResponse().getStatus(), ActionResponse.STATUS.OK);
    Assert.assertEquals(queueResponse.getRefreshResponse().getStatus(), ActionResponse.STATUS.OK);
    Assert.assertEquals(
        queueResponse.getRestoreResponse().getStatus(), ActionResponse.STATUS.PENDING);

    Assert.assertTrue(queueResponse.isOk());

    queue = (List<IAction>) queueCapability.getActions();
    Assert.assertEquals(queue.size(), 0);
  }
  @Test
  public void createGRETunnelv6Test() throws CapabilityException, ProtocolException {
    log.info("Test createGRETunnel method");
    IGRETunnelCapability greCapability =
        (IGRETunnelCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(TestsConstants.GRE_CAPABILITY_TYPE));

    greCapability.createGRETunnel(
        ParamCreationHelper.getGRETunnelService(TUNNEL_NAME, IPv6_ADDRESS, IP_SOURCE, IP_DESTINY));

    IQueueManagerCapability queueCapability =
        (IQueueManagerCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(
                    TestsConstants.QUEUE_CAPABILIY_TYPE));

    QueueResponse queueResponse = (QueueResponse) queueCapability.execute();
    Assert.assertTrue(queueResponse.isOk());
  }
  /** Test to check create static route method */
  @Test
  public void createStaticRouteTest() throws ProtocolException, ResourceException {
    startResource();

    StaticRouteCapability staticRouteCapability =
        (StaticRouteCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(
                    TestsConstants.STATIC_ROUTE_CAPABILITY_TYPE));
    staticRouteCapability.createStaticRoute("0.0.0.0", "0.0.0.0", "192.168.1.1");

    IQueueManagerCapability queueCapability =
        (IQueueManagerCapability)
            routerResource.getCapability(
                InitializerTestHelper.getCapabilityInformation(
                    TestsConstants.QUEUE_CAPABILIY_TYPE));
    QueueResponse queueResponse = (QueueResponse) queueCapability.execute();
    Assert.assertTrue(queueResponse.isOk());

    stopResource();
  }
  @After
  public void clearRepo() {

    log.info("Clearing resource repo");

    IResource[] toRemove = new IResource[repository.listResources().size()];
    toRemove = repository.listResources().toArray(toRemove);

    for (IResource resource : toRemove) {
      if (resource.getState().equals(State.ACTIVE)) {
        try {
          repository.stopResource(resource.getResourceIdentifier().getId());
        } catch (ResourceException e) {
          log.error(
              "Failed to remove resource "
                  + resource.getResourceIdentifier().getId()
                  + " from repository.");
        }
      }
      try {
        repository.removeResource(resource.getResourceIdentifier().getId());
      } catch (ResourceException e) {
        log.error(
            "Failed to remove resource "
                + resource.getResourceIdentifier().getId()
                + " from repository.");
      }
    }

    log.info("Resource repo cleared!");
  }
Пример #29
0
  @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);
    }
  }
  /** tests ConnectionsCapability.getActionSet().getStartupRefreshAction() != null */
  @Test
  public void getStartUpRefreshActionTest() throws Exception {

    ((Resource) mockResource)
        .setResourceDescriptor(ResourceHelper.newResourceDescriptorProteus("roadm"));

    // Test elements not null
    log.info("Checking connections factory");
    Assert.assertNotNull(connectionFactory);
    log.info("Checking capability descriptor");
    Assert.assertNotNull(
        mockResource.getResourceDescriptor().getCapabilityDescriptor("connections"));
    log.info("Creating connection capability");
    connectionsCapability = (AbstractCapability) connectionFactory.create(mockResource);
    Assert.assertNotNull(connectionsCapability);
    connectionsCapability.initialize();

    Assert.assertFalse(connectionsCapability.getActionSet().getRefreshActionName().isEmpty());
    startupActionNames = connectionsCapability.getActionSet().getRefreshActionName();
  }