+
+ @Override
+ public DataBroker getDataBroker() {
+ return dataBroker;
+ }
+ @Override
+ public void createLocalCache(BigInteger dpnId, String portName, Integer vlanId, String ipAddress, String subnetMask,
+ String gatewayIp, String transportZone) {
+ if (tepCommandHelper != null) {
+ tepCommandHelper.createLocalCache(dpnId, portName, vlanId, ipAddress, subnetMask, gatewayIp, transportZone);
+ } else {
+ LOG.trace("tepCommandHelper doesnt exist");
+ }
+ }
+
+ @Override
+ public void commitTeps() {
+ try {
+ tepCommandHelper.deleteOnCommit();
+ tepCommandHelper.buildTeps();
+ } catch (Exception e) {
+ LOG.debug("unable to configure teps" + e.toString());
+ }
+ }
+
+ @Override
+ public void showTeps() {
+ tepCommandHelper.showTeps(itmManager.getTunnelMonitorEnabledFromConfigDS(),
+ itmManager.getTunnelMonitorIntervalFromConfigDS());
+ }
+
+ public void deleteVtep(BigInteger dpnId, String portName, Integer vlanId, String ipAddress, String subnetMask,
+ String gatewayIp, String transportZone) {
+ try {
+ tepCommandHelper.deleteVtep(dpnId, portName, vlanId, ipAddress, subnetMask, gatewayIp, transportZone);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void configureTunnelType(String transportZone, String tunnelType) {
+ LOG .debug("ItmProvider: configureTunnelType {} for transportZone {}", tunnelType, transportZone);
+ tepCommandHelper.configureTunnelType(transportZone,tunnelType);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opendaylight.vpnservice.itm.api.IITMProvider#addVtepConfigSchema(org.
+ * opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.config.
+ * rev151102.vtep.config.schemas.VtepConfigSchema)
+ */
+ @Override
+ public void addVtepConfigSchema(VtepConfigSchema vtepConfigSchema) {
+ VtepConfigSchema validatedSchema = ItmUtils.validateForAddVtepConfigSchema(vtepConfigSchema,
+ getAllVtepConfigSchemas());
+
+ String schemaName = validatedSchema.getSchemaName();
+ VtepConfigSchema existingSchema = getVtepConfigSchema(schemaName);
+ if (existingSchema != null) {
+ Preconditions.checkArgument(false, String.format("VtepConfigSchema [%s] already exists!", schemaName));
+ }
+ MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepConfigSchemaIdentifier(schemaName), validatedSchema);
+ LOG.debug("Vtep config schema {} added to config DS", schemaName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opendaylight.vpnservice.itm.api.IITMProvider#getVtepConfigSchema(java
+ * .lang.String)
+ */
+ @Override
+ public VtepConfigSchema getVtepConfigSchema(String schemaName) {
+ Optional<VtepConfigSchema> schema = ItmUtils.read(LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepConfigSchemaIdentifier(schemaName), this.dataBroker);
+ if (schema.isPresent()) {
+ return schema.get();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opendaylight.vpnservice.itm.api.IITMProvider#getAllVtepConfigSchemas(
+ * )
+ */
+ @Override
+ public List<VtepConfigSchema> getAllVtepConfigSchemas() {
+ Optional<VtepConfigSchemas> schemas = ItmUtils.read(LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepConfigSchemasIdentifier(), this.dataBroker);
+ if (schemas.isPresent()) {
+ return schemas.get().getVtepConfigSchema();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opendaylight.vpnservice.itm.api.IITMProvider#updateVtepSchema(java.
+ * lang.String, java.util.List, java.util.List)
+ */
+ @Override
+ public void updateVtepSchema(String schemaName, List<BigInteger> lstDpnsForAdd, List<BigInteger> lstDpnsForDelete) {
+ LOG.trace("Updating VTEP schema {} by adding DPN's {} and deleting DPN's {}.", schemaName, lstDpnsForAdd,
+ lstDpnsForDelete);
+
+ VtepConfigSchema schema = ItmUtils.validateForUpdateVtepSchema(schemaName, lstDpnsForAdd, lstDpnsForDelete,
+ this);
+ if (ItmUtils.getDpnIdList(schema.getDpnIds()) == null) {
+ VtepConfigSchemaBuilder builder = new VtepConfigSchemaBuilder(schema);
+ builder.setDpnIds(schema.getDpnIds());
+ schema = builder.build();
+ } else {
+ if (lstDpnsForAdd != null && !lstDpnsForAdd.isEmpty()) {
+ ItmUtils.getDpnIdList(schema.getDpnIds()).addAll(lstDpnsForAdd);
+ }
+ if (lstDpnsForDelete != null && !lstDpnsForDelete.isEmpty()) {
+ ItmUtils.getDpnIdList(schema.getDpnIds()).removeAll(lstDpnsForDelete);
+ }
+ }
+ MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepConfigSchemaIdentifier(schemaName), schema);
+ LOG.debug("Vtep config schema {} updated to config DS with DPN's {}", schemaName, ItmUtils.getDpnIdList(schema.getDpnIds()));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.opendaylight.vpnservice.itm.api.IITMProvider#deleteAllVtepSchemas()
+ */
+ @Override
+ public void deleteAllVtepSchemas() {
+ List<VtepConfigSchema> lstSchemas = getAllVtepConfigSchemas();
+ if (lstSchemas != null && !lstSchemas.isEmpty()) {
+ for (VtepConfigSchema schema : lstSchemas) {
+ MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepConfigSchemaIdentifier(schema.getSchemaName()));
+ }
+ }
+ LOG.debug("Deleted all Vtep schemas from config DS");
+ }
+
+ public void configureTunnelMonitorEnabled(boolean monitorEnabled) {
+ tepCommandHelper.configureTunnelMonitorEnabled(monitorEnabled);
+ }
+
+ public void configureTunnelMonitorInterval(int interval) {
+ tepCommandHelper.configureTunnelMonitorInterval(interval);
+ }