/**
   * Get the GRETunnelService
   *
   * @return GRETunnelService
   * @throws IOException
   */
  public static GRETunnelService getGRETunnelService(
      String tunnelName, String ipv4Address, String subnetMask, String ipSource, String ipDestiny) {
    GRETunnelService greService = new GRETunnelService();
    greService.setElementName("");
    greService.setName(tunnelName);

    GRETunnelConfiguration greConfig = new GRETunnelConfiguration();
    greConfig.setSourceAddress(ipSource);
    greConfig.setDestinationAddress(ipDestiny);

    GRETunnelEndpoint gE = new GRETunnelEndpoint();
    gE.setIPv4Address(ipv4Address);
    gE.setSubnetMask(subnetMask);

    greService.setGRETunnelConfiguration(greConfig);
    greService.addProtocolEndpoint(gE);

    return greService;
  }
  @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);
  }
  /**
   * Get the GRETunnelService
   *
   * @return GRETunnelService
   * @throws IOException
   */
  private GRETunnelService getGRETunnelService() {

    GRETunnelService greService = new GRETunnelService();
    greService.setElementName("");
    greService.setName("gr-0/1/1.2");

    GRETunnelConfiguration greConfig = new GRETunnelConfiguration();
    greConfig.setSourceAddress("147.56.89.62");
    greConfig.setDestinationAddress("193.45.23.1");

    GRETunnelEndpoint gE = new GRETunnelEndpoint();
    gE.setIPv6Address("51:4F3::3A:B1");
    gE.setPrefixLength(Short.valueOf("64"));
    gE.setProtocolIFType(ProtocolIFType.IPV6);

    greService.setGRETunnelConfiguration(greConfig);
    greService.addProtocolEndpoint(gE);

    return greService;
  }
  @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());
  }
Exemple #5
0
 /**
  * Get the GRETunnelService
  *
  * @return GRETunnelService
  * @throws IOException
  */
 private static GRETunnelService getGRETunnelService() {
   GRETunnelService greTunnelService = new GRETunnelService();
   greTunnelService.setName("gr-0/1/3.2");
   return greTunnelService;
 }