Federation plugin
[netvirt.git] / vpnservice / federation-plugin / impl / src / main / java / org / opendaylight / netvirt / federation / plugin / creators / FederationElanInterfaceModificationCreator.java
1 /*
2  * Copyright (c) 2017 Hewlett Packard Enterprise, Co. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.netvirt.federation.plugin.creators;
10
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.Collections;
14
15 import javax.inject.Inject;
16 import javax.inject.Singleton;
17
18 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
19 import org.opendaylight.netvirt.federation.plugin.FederationPluginConstants;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 @Singleton
26 public class FederationElanInterfaceModificationCreator
27         implements FederationPluginModificationCreator<ElanInterface, ElanInterfaces> {
28     private static final Logger LOG = LoggerFactory.getLogger(FederationElanInterfaceModificationCreator.class);
29
30     @Inject
31     public FederationElanInterfaceModificationCreator() {
32         FederationPluginCreatorRegistry.registerCreator(FederationPluginConstants.ELAN_INTERFACE_KEY, this);
33     }
34
35     @Override
36     public Collection<DataTreeModification<ElanInterface>> createDataTreeModifications(ElanInterfaces elanInterfaces) {
37         if (elanInterfaces == null || elanInterfaces.getElanInterface() == null) {
38             LOG.debug("No ELAN interfaces found");
39             return Collections.emptyList();
40         }
41
42         Collection<DataTreeModification<ElanInterface>> modifications = new ArrayList<>();
43         for (ElanInterface elanInterface : elanInterfaces.getElanInterface()) {
44             modifications.add(new FullSyncDataTreeModification<ElanInterface>(elanInterface));
45         }
46
47         return modifications;
48     }
49
50 }