Lisp processing additional fixes
[groupbasedpolicy.git] / renderers / vpp / src / main / java / org / opendaylight / groupbasedpolicy / renderer / vpp / lisp / info / container / states / VrfState.java
1 /*
2  * Copyright (c) 2017 Cisco Systems. 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 package org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.info.container.states;
9
10 import org.apache.commons.lang3.mutable.MutableLong;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
12
13 public class VrfState {
14     private SubnetHolder subnetHolder;
15     private String protocolName;
16     private MutableLong nextRouteId;
17
18     public VrfState(String routingProtocolName) {
19         this.subnetHolder = new SubnetHolder();
20         this.protocolName = routingProtocolName;
21         this.nextRouteId = new MutableLong(1L);
22     }
23
24     public SubnetHolder getSubnetHolder() {
25         return subnetHolder;
26     }
27
28     public String getProtocolName() {
29         return protocolName;
30     }
31
32     public long getNextRouteId() {
33         return nextRouteId.getValue();
34     }
35
36     public void addNewPortIpInVrf(String portSubnetUuid, Ipv4Address portIp) {
37         subnetHolder.getSubnetState(portSubnetUuid).addNewIp(portIp);
38         nextRouteId.increment();
39     }
40
41     public void removePortIpFromVrf(String portSubnetUuid, Ipv4Address portIp) {
42         if (subnetHolder.subnetStateContains(portSubnetUuid)) {
43             subnetHolder.getSubnetState(portSubnetUuid).removeIp(portIp);
44         }
45     }
46
47     public int subnetCount() {
48         return subnetHolder.subnetHolderCount();
49     }
50
51     @Override public String toString() {
52         return "VrfState{" + "subnetHolder=" + subnetHolder + ", protocolName='" + protocolName + '\''
53             + ", nextRouteId=" + nextRouteId + '}';
54     }
55 }