示例#1
0
  public static VRRPGroup newParamsVRRPGroupWithOneEndpoint(
      String virtualIPAddress,
      String interfaceName,
      String interfaceIPAddress,
      String interfaceSubnetMask) {
    // VRRPGroup
    VRRPGroup vrrpGroup = new VRRPGroup();
    vrrpGroup.setVrrpName(201);
    vrrpGroup.setVirtualIPAddress(virtualIPAddress);

    // VRRPProtocolEndpoint
    VRRPProtocolEndpoint vrrProtocolEndpoint1 = new VRRPProtocolEndpoint();
    vrrProtocolEndpoint1.setPriority(100);
    vrrProtocolEndpoint1.setService(vrrpGroup);

    // IPProtocolEndpoint
    IPProtocolEndpoint ipProtocolEndpoint1 = new IPProtocolEndpoint();
    ipProtocolEndpoint1.setIPv4Address(interfaceIPAddress);
    ipProtocolEndpoint1.setSubnetMask(interfaceSubnetMask);
    vrrProtocolEndpoint1.bindServiceAccessPoint(ipProtocolEndpoint1);

    // EthernetPort
    EthernetPort eth1 = new EthernetPort();
    eth1.setLinkTechnology(NetworkPort.LinkTechnology.ETHERNET);
    eth1.setName(interfaceName);
    ipProtocolEndpoint1.addLogiaclPort(eth1);

    return vrrpGroup;
  }
示例#2
0
 public static Object newParamsInterfaceGRE() {
   EthernetPort eth = new EthernetPort();
   eth.setName("gr-0/3/2");
   eth.setPortNumber(2);
   IPProtocolEndpoint ip = new IPProtocolEndpoint();
   ip.setIPv4Address("192.168.32.1");
   ip.setSubnetMask("255.255.255.0");
   eth.addProtocolEndpoint(ip);
   return eth;
 }
示例#3
0
 /*
  * test of an interface ethernet without vlan encapsulation
  */
 public static Object newParamsInterfaceEthernet() {
   EthernetPort eth = new EthernetPort();
   eth.setLinkTechnology(NetworkPort.LinkTechnology.ETHERNET);
   eth.setName("fe-0/3/2");
   IPProtocolEndpoint ip = new IPProtocolEndpoint();
   ip.setIPv4Address("192.168.32.1");
   ip.setSubnetMask("255.255.255.0");
   eth.addProtocolEndpoint(ip);
   return eth;
 }
示例#4
0
  /*
   * test of an interface ethernet without vlan encapsulation
   */
  public static Object newParamsInterfaceLT() {
    LogicalTunnelPort ltp = new LogicalTunnelPort();
    ltp.setLinkTechnology(NetworkPort.LinkTechnology.ETHERNET);
    ltp.setName("lt-0/3/2");
    ltp.setPeer_unit(101);
    IPProtocolEndpoint ip = new IPProtocolEndpoint();
    ip.setIPv4Address("192.168.32.1");
    ip.setSubnetMask("255.255.255.0");
    ltp.addProtocolEndpoint(ip);

    return ltp;
  }
示例#5
0
 public static Object newParamsInterfaceEtherVLAN() {
   EthernetPort eth = new EthernetPort();
   eth.setLinkTechnology(NetworkPort.LinkTechnology.OTHER);
   eth.setName("fe-0/3/2");
   eth.setPortNumber(2);
   IPProtocolEndpoint ip = new IPProtocolEndpoint();
   ip.setIPv4Address("192.168.32.1");
   ip.setSubnetMask("255.255.255.0");
   eth.addProtocolEndpoint(ip);
   VLANEndpoint vlan = new VLANEndpoint();
   vlan.setVlanID(2);
   eth.addProtocolEndpoint(vlan);
   return eth;
 }
示例#6
0
  /*
   * (non-Javadoc)
   *
   * @see org.opennaas.extensions.router.capability.ip.IIPCapability#setIPv4(org.opennaas.extensions.router.model.LogicalPort)
   */
  @Override
  public void setIPv4(LogicalDevice iface, IPProtocolEndpoint ipProtocolEndpoint)
      throws CapabilityException {
    NetworkPort param = new NetworkPort();
    param.setName(iface.getName());
    if (iface instanceof NetworkPort) {
      param.setPortNumber(((NetworkPort) iface).getPortNumber());
      param.setLinkTechnology(((NetworkPort) iface).getLinkTechnology());
    }
    IPProtocolEndpoint ip = new IPProtocolEndpoint();
    ip.setIPv4Address(ipProtocolEndpoint.getIPv4Address());
    ip.setSubnetMask(ipProtocolEndpoint.getSubnetMask());
    param.addProtocolEndpoint(ipProtocolEndpoint);

    IAction action = createActionAndCheckParams(IPActionSet.SET_IPv4, param);
    queueAction(action);
  }
示例#7
0
  @Test
  public void UpDownActionTest() throws CapabilityException {
    Response resp;
    QueueResponse queueResponse;

    resp = (Response) chassisCapability.sendMessage(ActionConstants.GETCONFIG, null);
    Assert.assertEquals(Status.QUEUED, resp.getStatus());
    Assert.assertTrue(resp.getErrors().size() == 0);

    queueResponse = (QueueResponse) queueCapability.sendMessage(QueueConstants.EXECUTE, null);
    Assert.assertTrue(queueResponse.isOk());

    String str = "";
    ComputerSystem model = (ComputerSystem) mockResource.getModel();
    Assert.assertNotNull(model);
    for (LogicalDevice device : model.getLogicalDevices()) {
      if (device instanceof EthernetPort) {
        EthernetPort port = (EthernetPort) device;
        Assert.assertNotNull("OperationalStatus must be set", port.getOperationalStatus());

        str += "- EthernetPort: " + '\n';
        str += port.getName() + '.' + port.getPortNumber() + '\n';
        str += port.getOperationalStatus();
        str += '\n';
        for (ProtocolEndpoint protocolEndpoint : port.getProtocolEndpoint()) {
          if (protocolEndpoint instanceof IPProtocolEndpoint) {
            IPProtocolEndpoint ipProtocol = (IPProtocolEndpoint) protocolEndpoint;
            str += "ipv4: " + ipProtocol.getIPv4Address() + '\n';
            str += "ipv6: " + ipProtocol.getIPv6Address() + '\n';
          }
        }

      } else {
        str += "not searched device";
      }
    }

    log.info(str);

    String interfaceName = "fe-0/1/3";

    /* check model */
    LogicalDevice logicalDevice = null;
    try {
      logicalDevice = getLogicalDevice(interfaceName, (ComputerSystem) mockResource.getModel());
    } catch (Exception ex) {
      Assert.fail("LogicalDevice not found");
    }

    if (logicalDevice.getOperationalStatus() != OperationalStatus.OK) {
      Assert.fail("The test can't be executed because the needed interface is down");
    }

    /* send to change status */
    resp =
        (Response)
            chassisCapability.sendMessage(
                ActionConstants.CONFIGURESTATUS,
                newParamsConfigureStatus(interfaceName, OperationalStatus.STOPPED));
    Assert.assertEquals(Status.QUEUED, resp.getStatus());
    Assert.assertTrue(resp.getErrors().size() == 0);

    Assert.assertTrue(
        ((List<IAction>) queueCapability.sendMessage(QueueConstants.GETQUEUE, null)).size() == 1);
    queueResponse = (QueueResponse) queueCapability.sendMessage(QueueConstants.EXECUTE, null);
    Assert.assertTrue(queueResponse.isOk());
    Assert.assertTrue(
        ((List<IAction>) queueCapability.sendMessage(QueueConstants.GETQUEUE, null)).size() == 0);

    if (!isMock) {
      checkOperationalStatus(
          (ComputerSystem) mockResource.getModel(), interfaceName, OperationalStatus.STOPPED);
    }

    /* send to change status */
    resp =
        (Response)
            chassisCapability.sendMessage(
                ActionConstants.CONFIGURESTATUS,
                newParamsConfigureStatus(interfaceName, OperationalStatus.OK));
    Assert.assertEquals(Status.QUEUED, resp.getStatus());
    Assert.assertTrue(resp.getErrors().size() == 0);

    Assert.assertTrue(
        ((List<IAction>) queueCapability.sendMessage(QueueConstants.GETQUEUE, null)).size() == 1);
    queueResponse = (QueueResponse) queueCapability.sendMessage(QueueConstants.EXECUTE, null);
    Assert.assertTrue(queueResponse.isOk());
    Assert.assertTrue(
        ((List<IAction>) queueCapability.sendMessage(QueueConstants.GETQUEUE, null)).size() == 0);

    if (!isMock) {
      checkOperationalStatus(
          (ComputerSystem) mockResource.getModel(), interfaceName, OperationalStatus.OK);
    }
  }
示例#8
0
 /** @return */
 public static IPProtocolEndpoint getIPProtocolEndPoint() {
   IPProtocolEndpoint ipProtocolEndpoint = new IPProtocolEndpoint();
   ipProtocolEndpoint.setIPv4Address("192.168.0.1");
   ipProtocolEndpoint.setSubnetMask("255.255.255.0");
   return ipProtocolEndpoint;
 }