コード例 #1
0
 @Override
 public final void setChannel(Channel channel) {
   this.channel = channel;
   final SocketAddress address = channel.getRemoteAddress();
   if (address instanceof InetSocketAddress) {
     final InetSocketAddress inetAddress = (InetSocketAddress) address;
     final IpAddress ipAddress = IpAddress.valueOf(inetAddress.getAddress());
     if (ipAddress.isIp4()) {
       channelId = ipAddress.toString() + ':' + inetAddress.getPort();
     } else {
       channelId = '[' + ipAddress.toString() + "]:" + inetAddress.getPort();
     }
   }
 }
コード例 #2
0
ファイル: BgpId.java プロジェクト: ccascone/onos
 /**
  * Produces device URI from the given DPID long.
  *
  * @param ipAddress device ip address
  * @return device URI
  */
 public static URI uri(IpAddress ipAddress) {
   try {
     return new URI(SCHEME, ipAddress.toString(), null);
   } catch (URISyntaxException e) {
     return null;
   }
 }
コード例 #3
0
 @Override
 public NetconfDevice getNetconfDevice(IpAddress ip, int port) {
   for (DeviceId info : netconfDeviceMap.keySet()) {
     if (info.uri().getSchemeSpecificPart().equals(ip.toString() + ":" + port)) {
       return netconfDeviceMap.get(info);
     }
   }
   return null;
 }
コード例 #4
0
  public static SessionMappingKey Of(IpAddress publicIp, byte protocol, int publicTpPort) {
    String keyString =
        new StringBuilder()
            .append(publicIp.toString())
            .append("-")
            .append(protocol)
            .append("-")
            .append(publicTpPort)
            .toString();

    return new SessionMappingKey(keyString, publicIp, protocol, publicTpPort);
  }
コード例 #5
0
ファイル: BgpId.java プロジェクト: ccascone/onos
 /**
  * Convert the BGPId value to a ':' separated hexadecimal string.
  *
  * @return the BGPId value as a ':' separated hexadecimal string.
  */
 @Override
 public String toString() {
   return ipAddress.toString();
 }
コード例 #6
0
ファイル: DefaultOvsdbClient.java プロジェクト: rvhub/onos
 /**
  * Gets tunnel name.
  *
  * @param tunnelType
  * @param dstIp the remote ip address
  * @return tunnel name
  */
 private String getTunnelName(String tunnelType, IpAddress dstIp) {
   return tunnelType + "-" + dstIp.toString();
 }
コード例 #7
0
ファイル: DefaultOvsdbClient.java プロジェクト: rvhub/onos
  @Override
  public void createTunnel(IpAddress srcIp, IpAddress dstIp) {
    String bridgeUuid = getBridgeUuid(OvsdbConstant.INTEGRATION_BRIDGE);
    if (bridgeUuid == null) {
      log.warn(
          "Could not find bridge {} and Could not create tunnel. ",
          OvsdbConstant.INTEGRATION_BRIDGE);
      return;
    }

    DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
    String portName = getTunnelName(OvsdbConstant.TYPEVXLAN, dstIp);
    String portUuid = getPortUuid(portName, bridgeUuid);

    Port port = (Port) TableGenerator.createTable(dbSchema, OvsdbTable.PORT);
    if (port != null) {
      port.setName(portName);
    }

    if (portUuid == null) {
      portUuid =
          insertConfig(
              OvsdbConstant.PORT,
              "_uuid",
              OvsdbConstant.BRIDGE,
              "ports",
              bridgeUuid,
              port.getRow());
    } else {
      updateConfig(OvsdbConstant.PORT, "_uuid", portUuid, port.getRow());
    }

    // When a tunnel is created, A row is inserted into port table and
    // interface table of the ovsdb node.
    // and the following step is to get the interface uuid from local store
    // in controller node.
    // but it need spend some time synchronising data between node and
    // controller.
    // so loop to judge if interfaceUUid is null is necessary.
    String interfaceUuid = null;
    for (int i = 0; i < 10; i++) {
      interfaceUuid = getInterfaceUuid(portUuid, portName);
      if (interfaceUuid == null) {
        try {
          Thread.sleep(500);
        } catch (InterruptedException e) {
          log.warn("Interrupted while waiting to get interfaceUuid");
          Thread.currentThread().interrupt();
        }
      } else {
        break;
      }
    }

    if (interfaceUuid != null) {

      Interface tunInterface =
          (Interface) TableGenerator.createTable(dbSchema, OvsdbTable.INTERFACE);

      if (tunInterface != null) {

        tunInterface.setType(OvsdbConstant.TYPEVXLAN);
        Map<String, String> options = Maps.newHashMap();
        options.put("key", "flow");
        options.put("local_ip", srcIp.toString());
        options.put("remote_ip", dstIp.toString());
        tunInterface.setOptions(options);
        updateConfig(OvsdbConstant.INTERFACE, "_uuid", interfaceUuid, tunInterface.getRow());
        log.info("Tunnel added success", tunInterface);
      }
    }

    return;
  }