+ }
+
+ @Override
+ public InterfaceInfo getInterfaceInfoFromOperationalDataStore(String interfaceName) {
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = InterfaceManagerCommonUtils
+ .getInterfaceStateFromOperDS(interfaceName, dataBroker);
+ if (ifState == null) {
+ LOG.error("Interface {} is not present", interfaceName);
+ return null;
+ }
+ Integer lportTag = ifState.getIfIndex();
+ InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
+ NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
+ if (ncId != null) {
+ interfaceInfo.setPortName(IfmUtil.getPortName(dataBroker, ncId));
+ interfaceInfo.setDpId(new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId)));
+ interfaceInfo.setPortNo(Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId)));
+ }
+ interfaceInfo.setAdminState((ifState.getAdminStatus() == AdminStatus.Up) ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
+ interfaceInfo.setInterfaceName(interfaceName);
+ interfaceInfo.setInterfaceTag(lportTag);
+ interfaceInfo.setOpState((ifState.getOperStatus() == OperStatus.Up) ? InterfaceInfo.InterfaceOpState.UP : InterfaceInfo.InterfaceOpState.DOWN);
+ return interfaceInfo;
+ }
+
+ public void createVLANInterface(String interfaceName, String portName, BigInteger dpId, Integer vlanId,
+ String description, IfL2vlan.L2vlanMode l2vlanMode) {
+ LOG.info("Create VLAN interface : {}",interfaceName);
+ InstanceIdentifier<Interface> interfaceInstanceIdentifier = InterfaceManagerCommonUtils.
+ getInterfaceIdentifier(new InterfaceKey(interfaceName));
+ IfL2vlanBuilder l2vlanBuilder = new IfL2vlanBuilder().setL2vlanMode(l2vlanMode);
+ if(vlanId > 0){
+ l2vlanBuilder.setVlanId(new VlanId(vlanId));
+ }
+ ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(portName).build();
+ Interface inf = new InterfaceBuilder().setEnabled(true).setName(interfaceName).setType(L2vlan.class).
+ addAugmentation(IfL2vlan.class, l2vlanBuilder.build()).addAugmentation(ParentRefs.class, parentRefs).
+ setDescription(description).build();
+ WriteTransaction t = dataBroker.newWriteOnlyTransaction();
+ t.put(LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier, inf, true);
+ }
+
+ public void bindService(String interfaceName, BoundServices serviceInfo){
+ LOG.info("Binding Service : {}",interfaceName);
+ WriteTransaction t = dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<BoundServices> boundServicesInstanceIdentifier = InstanceIdentifier.builder(ServiceBindings.class).child(ServicesInfo.class, new ServicesInfoKey(interfaceName))
+ .child(BoundServices.class, new BoundServicesKey(serviceInfo.getServicePriority())).build();
+ // List<BoundServices> services = (List<BoundServices>)serviceInfo.getBoundServices();
+ t.put(LogicalDatastoreType.CONFIGURATION, boundServicesInstanceIdentifier, serviceInfo, true);
+ t.submit();
+ }
+
+ public void unbindService(String interfaceName, BoundServices serviceInfo){
+ LOG.info("Unbinding Service : {}",interfaceName);
+ WriteTransaction t = dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<BoundServices> boundServicesInstanceIdentifier = InstanceIdentifier.builder(ServiceBindings.class).child(ServicesInfo.class, new ServicesInfoKey(interfaceName))
+ .child(BoundServices.class, new BoundServicesKey(serviceInfo.getServicePriority())).build();
+ t.delete(LogicalDatastoreType.CONFIGURATION, boundServicesInstanceIdentifier);
+ t.submit();
+ }