jiangrui
Committed by Gerrit Code Review

[ONOS-2817]: add routerService and floatingIpService api

Change-Id: I87bc6e03036b08b932a5e2a9c1b4bd50e4358538
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.vtnrsc.floatingip;
17 +
18 +import org.onosproject.event.AbstractEvent;
19 +import org.onosproject.vtnrsc.FloatingIp;
20 +
21 +/**
22 + * Describes network Floating IP event.
23 + */
24 +public class FloatingIpEvent
25 + extends AbstractEvent<FloatingIpEvent.Type, FloatingIp> {
26 + /**
27 + * Type of Floating IP events.
28 + */
29 + public enum Type {
30 + /**
31 + * Signifies that Floating IP has been created.
32 + */
33 + FLOATINGIP_PUT,
34 + /**
35 + * Signifies that Floating IP has been deleted.
36 + */
37 + FLOATINGIP_DELETE
38 + }
39 +
40 + /**
41 + * Creates an event of a given type and for the specified Floating IP.
42 + *
43 + * @param type Floating IP event type
44 + * @param floagingIp Floating IP subject
45 + */
46 + public FloatingIpEvent(Type type, FloatingIp floagingIp) {
47 + super(type, floagingIp);
48 + }
49 +
50 + /**
51 + * Creates an event of a given type and for the specified Floating IP.
52 + *
53 + * @param type Floating IP event type
54 + * @param floagingIp Floating IP subject
55 + * @param time occurrence time
56 + */
57 + public FloatingIpEvent(Type type, FloatingIp floagingIp, long time) {
58 + super(type, floagingIp, time);
59 + }
60 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.vtnrsc.floatingip;
17 +
18 +import org.onosproject.event.EventListener;
19 +
20 +/**
21 + * Entity capable of Floating IP related events.
22 + */
23 +public interface FloatingIpListener extends EventListener<FloatingIpEvent> {
24 +
25 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.vtnrsc.floatingip;
17 +
18 +import java.util.Collection;
19 +
20 +import org.onlab.packet.IpAddress;
21 +import org.onosproject.vtnrsc.FloatingIp;
22 +import org.onosproject.vtnrsc.FloatingIpId;
23 +import org.onosproject.vtnrsc.TenantId;
24 +
25 +/**
26 + * Service for interacting with the inventory of floating IP.
27 + */
28 +public interface FloatingIpService {
29 + /**
30 + * Returns exists or not of specific floatingIp identifier.
31 + *
32 + * @param floatingIpId floatingIp identifier
33 + * @return true or false
34 + */
35 + boolean exists(FloatingIpId floatingIpId);
36 +
37 + /**
38 + * Returns is used or not of specific floating IP address.
39 + *
40 + * @param floatingIpAddr floatingIp address
41 + * @param floatingIpId floatingIp identifier
42 + * @return true or false
43 + */
44 + boolean floatingIpIsUsed(IpAddress floatingIpAddr, FloatingIpId floatingIpId);
45 +
46 + /**
47 + * Returns is used or not of specific fixed IP address.
48 + *
49 + * @param fixedIpAddr fixedIp address
50 + * @param tenantId the tenant identifier of floating IP
51 + * @param floatingIpId floatingIp identifier
52 + * @return true or false
53 + */
54 + boolean fixedIpIsUsed(IpAddress fixedIpAddr, TenantId tenantId, FloatingIpId floatingIpId);
55 +
56 + /**
57 + * Returns a collection of the currently known floating IP.
58 + *
59 + * @return collection of floating IP
60 + */
61 + Collection<FloatingIp> getFloatingIps();
62 +
63 + /**
64 + * Returns the floatingIp with the specified identifier.
65 + *
66 + * @param floatingIpId floatingIp identifier
67 + * @return floatingIp or null if one with the given identifier is not known
68 + */
69 + FloatingIp getFloatingIp(FloatingIpId floatingIpId);
70 +
71 + /**
72 + * Creates new floatingIps.
73 + *
74 + * @param floatingIps the collection of floatingIp
75 + * @return true if the identifier floatingIp has been created right
76 + */
77 + boolean createFloatingIps(Collection<FloatingIp> floatingIps);
78 +
79 + /**
80 + * Updates existing floatingIps.
81 + *
82 + * @param floatingIps the collection of floatingIp
83 + * @return true if all floatingIp were updated successfully
84 + */
85 + boolean updateFloatingIps(Collection<FloatingIp> floatingIps);
86 +
87 + /**
88 + * Removes the specified floatingIp from the store.
89 + *
90 + * @param floatingIpIds the collection of floatingIp identifier
91 + * @return true if remove identifier floatingIp successfully
92 + */
93 + boolean removeFloatingIps(Collection<FloatingIpId> floatingIpIds);
94 +
95 + /**
96 + * Adds the specified listener to floating Ip manager.
97 + *
98 + * @param listener floating Ip listener
99 + */
100 + void addListener(FloatingIpListener listener);
101 +
102 + /**
103 + * Removes the specified listener to floating Ip manager.
104 + *
105 + * @param listener floating Ip listener
106 + */
107 + void removeListener(FloatingIpListener listener);
108 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Service for interacting with the inventory of FloatingIp.
19 + */
20 +package org.onosproject.vtnrsc.floatingip;
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.vtnrsc.router;
17 +
18 +import org.onosproject.event.AbstractEvent;
19 +import org.onosproject.vtnrsc.Router;
20 +
21 +/**
22 + * Describes network Router event.
23 + */
24 +public class RouterEvent extends AbstractEvent<RouterEvent.Type, Router> {
25 + /**
26 + * Type of Router events.
27 + */
28 + public enum Type {
29 + /**
30 + * Signifies that router has been created.
31 + */
32 + ROUTER_PUT,
33 + /**
34 + * Signifies that router has been deleted.
35 + */
36 + ROUTER_DELETE
37 + }
38 +
39 + /**
40 + * Creates an event of a given type and for the specified Router.
41 + *
42 + * @param type Router event type
43 + * @param router Router subject
44 + */
45 + public RouterEvent(Type type, Router router) {
46 + super(type, router);
47 + }
48 +
49 + /**
50 + * Creates an event of a given type and for the specified Router.
51 + *
52 + * @param type Router event type
53 + * @param router Router subject
54 + * @param time occurrence time
55 + */
56 + public RouterEvent(Type type, Router router, long time) {
57 + super(type, router, time);
58 + }
59 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.vtnrsc.router;
17 +
18 +import org.onosproject.event.EventListener;
19 +
20 +/**
21 + * Entity capable of Router related events.
22 + */
23 +public interface RouterListener extends EventListener<RouterEvent> {
24 +
25 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.vtnrsc.router;
17 +
18 +import java.util.Collection;
19 +
20 +import org.onosproject.vtnrsc.Router;
21 +import org.onosproject.vtnrsc.RouterId;
22 +
23 +/**
24 + * Service for interacting with the inventory of Routers.
25 + */
26 +public interface RouterService {
27 + /**
28 + * Returns exists or not of specific router identifier.
29 + *
30 + * @param routerId router identifier
31 + * @return true or false
32 + */
33 + boolean exists(RouterId routerId);
34 +
35 + /**
36 + * Returns a collection of the currently known Routers.
37 + *
38 + * @return collection of Routers
39 + */
40 + Collection<Router> getRouters();
41 +
42 + /**
43 + * Returns the Router with the specified identifier.
44 + *
45 + * @param routerId Router identifier
46 + * @return Router or null if one with the given identifier is not known
47 + */
48 + Router getRouter(RouterId routerId);
49 +
50 + /**
51 + * Creates new Routers.
52 + *
53 + * @param routers the collection of Routers
54 + * @return true if the identifier Router has been created right.
55 + * false if the identifier Router is failed to store
56 + */
57 + boolean createRouters(Collection<Router> routers);
58 +
59 + /**
60 + * Updates existing Routers.
61 + *
62 + * @param routers the collection of Routers
63 + * @return true if Routers were updated successfully.
64 + * false if Routers were updated failed
65 + */
66 + boolean updateRouters(Collection<Router> routers);
67 +
68 + /**
69 + * Removes the specified Routers from the store.
70 + *
71 + * @param routerIds the collection of Routers identifier
72 + * @return true if remove identifier Routers successfully. false if remove
73 + * identifier Routers failed
74 + */
75 + boolean removeRouters(Collection<RouterId> routerIds);
76 +
77 + /**
78 + * Adds the specified listener to Router manager.
79 + *
80 + * @param listener Router listener
81 + */
82 + void addListener(RouterListener listener);
83 +
84 + /**
85 + * Removes the specified listener to Router manager.
86 + *
87 + * @param listener Router listener
88 + */
89 + void removeListener(RouterListener listener);
90 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Service for interacting with the inventory of Router.
19 + */
20 +package org.onosproject.vtnrsc.router;
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.vtnrsc.routerinterface;
17 +
18 +import org.onosproject.event.AbstractEvent;
19 +import org.onosproject.vtnrsc.RouterInterface;
20 +
21 +/**
22 + * Describes network Router Interface event.
23 + */
24 +public class RouterInterfaceEvent
25 + extends AbstractEvent<RouterInterfaceEvent.Type, RouterInterface> {
26 +
27 + /**
28 + * Type of Router Interface events.
29 + */
30 + public enum Type {
31 + /**
32 + * Signifies that router interface has been added.
33 + */
34 + ROUTER_INTERFACE_PUT,
35 + /**
36 + * Signifies that router interface has been removed.
37 + */
38 + ROUTER_INTERFACE_DELETE
39 + }
40 +
41 + /**
42 + * Creates an event of a given type and for the specified Router Interface.
43 + *
44 + * @param type Router Interface event type
45 + * @param routerInterface Router Interface subject
46 + */
47 + public RouterInterfaceEvent(Type type, RouterInterface routerInterface) {
48 + super(type, routerInterface);
49 + }
50 +
51 + /**
52 + * Creates an event of a given type and for the specified Router Interface.
53 + *
54 + * @param type Router Interface event type.
55 + * @param routerInterface Router Interface subject
56 + * @param time occurrence time
57 + */
58 + public RouterInterfaceEvent(Type type, RouterInterface routerInterface,
59 + long time) {
60 + super(type, routerInterface, time);
61 + }
62 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.vtnrsc.routerinterface;
18 +
19 +import org.onosproject.event.EventListener;
20 +
21 +/**
22 + * Entity capable of Router Interface related events.
23 + */
24 +public interface RouterInterfaceListener
25 + extends EventListener<RouterInterfaceEvent> {
26 +
27 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.vtnrsc.routerinterface;
17 +
18 +import java.util.Collection;
19 +
20 +import org.onosproject.vtnrsc.RouterInterface;
21 +import org.onosproject.vtnrsc.SubnetId;
22 +
23 +/**
24 + * Service for interacting with the inventory of Router interface.
25 + */
26 +public interface RouterInterfaceService {
27 + /**
28 + * Returns exists or not of specific subnet identifier.
29 + *
30 + * @param subnetId subnet identifier
31 + * @return true or false
32 + */
33 + boolean exists(SubnetId subnetId);
34 +
35 + /**
36 + * Returns a collection of the currently known Router interface.
37 + *
38 + * @return collection of RouterInterface
39 + */
40 + Collection<RouterInterface> getRouterInterfaces();
41 +
42 + /**
43 + * Returns the Router interface with the specified subnet identifier.
44 + *
45 + * @param subnetId subnet identifier
46 + * @return RouterInterface or null if one with the given identifier is not
47 + * known
48 + */
49 + RouterInterface getRouterInterface(SubnetId subnetId);
50 +
51 + /**
52 + * Adds the specified RouterInterface.
53 + *
54 + * @param routerInterface the interface add to router
55 + * @return true if add router interface successfully
56 + */
57 + boolean addRouterInterface(RouterInterface routerInterface);
58 +
59 + /**
60 + * Removes the specified RouterInterface.
61 + *
62 + * @param routerInterface the interface remove from router
63 + * @return true if remove router interface successfully
64 + */
65 + boolean removeRouterInterface(RouterInterface routerInterface);
66 +
67 + /**
68 + * Adds the specified listener to Router Interface manager.
69 + *
70 + * @param listener Router Interface listener
71 + */
72 + void addListener(RouterInterfaceListener listener);
73 +
74 + /**
75 + * Removes the specified listener to RouterInterface manager.
76 + *
77 + * @param listener Router Interface listener
78 + */
79 + void removeListener(RouterInterfaceListener listener);
80 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Service for interacting with the inventory of RouterInterface.
19 + */
20 +package org.onosproject.vtnrsc.routerinterface;
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.vtnrsc.service;
17 +
18 +import java.util.Iterator;
19 +
20 +import org.onlab.packet.MacAddress;
21 +import org.onosproject.net.Device;
22 +import org.onosproject.net.DeviceId;
23 +import org.onosproject.net.HostId;
24 +import org.onosproject.vtnrsc.SegmentationId;
25 +import org.onosproject.vtnrsc.TenantId;
26 +import org.onosproject.vtnrsc.VirtualPortId;
27 +import org.onosproject.vtnrsc.event.VtnRscListener;
28 +
29 +/**
30 + * Service for interacting with the inventory of Vtn resource.
31 + */
32 +public interface VtnRscService {
33 + /**
34 + * Adds the specified listener.
35 + *
36 + * @param listener VtnRsc listener
37 + */
38 + void addListener(VtnRscListener listener);
39 +
40 + /**
41 + * Removes the specified listener.
42 + *
43 + * @param listener VtnRsc listener
44 + */
45 + void removeListener(VtnRscListener listener);
46 +
47 + /**
48 + * Returns the SegmentationId of tenant.
49 + *
50 + * @param tenantId tenant identifier
51 + * @return SegmentationId the SegmentationId of tenant
52 + */
53 + SegmentationId getL3vni(TenantId tenantId);
54 +
55 + /**
56 + * Returns Classifier Ovs list of the specific tenant.
57 + *
58 + * @param tenantId tenant identifier
59 + * @return iterable collection of Device
60 + */
61 + Iterator<Device> getClassifierOfTenant(TenantId tenantId);
62 +
63 + /**
64 + * Returns Service function forwarders Ovs list of the specific tenant.
65 + *
66 + * @param tenantId tenant identifier
67 + * @return iterable collection of Device
68 + */
69 + Iterator<Device> getSFFOfTenant(TenantId tenantId);
70 +
71 + /**
72 + * Returns gateway mac address of the specific host.
73 + *
74 + * @param hostId host identifier
75 + * @return MacAddress of host
76 + */
77 + MacAddress getGatewayMac(HostId hostId);
78 +
79 + /**
80 + * Checks if a specific port is a service function.
81 + *
82 + * @param portId port identifier
83 + * @return true or false
84 + */
85 + boolean isServiceFunction(VirtualPortId portId);
86 +
87 + /**
88 + * Returns device identifier mapping to the specific port.
89 + *
90 + * @param portId port identifier
91 + * @return device identifier
92 + */
93 + DeviceId getSFToSFFMaping(VirtualPortId portId);
94 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Service for interacting with the inventory of Vtn resource.
19 + */
20 +package org.onosproject.vtnrsc.service;