a52a843f69a1f85b53966090bc205057388db08f
[onosfw.git] /
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.net.resource.device;
17
18 import org.onosproject.net.DeviceId;
19 import org.onosproject.net.Port;
20 import org.onosproject.net.intent.IntentId;
21
22 import java.util.Set;
23
24 public interface DeviceResourceStore {
25     /**
26      * Returns unallocated ports on the given device.
27      *
28      * @param deviceId device ID
29      * @return set of unallocated ports
30      */
31     Set<Port> getFreePorts(DeviceId deviceId);
32
33     /**
34      * Allocates the given ports to the given intent.
35      *
36      * @param ports set of ports to allocate
37      * @param intentId intent ID
38      * @return true if allocation was successful, false otherwise
39      */
40     boolean allocatePorts(Set<Port> ports, IntentId intentId);
41
42     /**
43      * Returns set of ports allocated for an intent.
44      *
45      * @param intentId the intent ID
46      * @return set of allocated ports
47      */
48     Set<Port> getAllocations(IntentId intentId);
49
50     /**
51      * Returns intent allocated to a port.
52      *
53      * @param port the port
54      * @return intent ID allocated to the port
55      */
56     IntentId getAllocations(Port port);
57
58     /**
59      * Allocates the mapping between the given intents.
60      *
61      * @param keyIntentId key intent ID
62      * @param valIntentId value intent ID
63      * @return true if mapping was successful, false otherwise
64      */
65     boolean allocateMapping(IntentId keyIntentId, IntentId valIntentId);
66
67     /**
68      * Returns the set of intents mapped to a lower intent.
69      *
70      * @param intentId intent ID
71      * @return set of intent IDs
72      */
73     Set<IntentId> getMapping(IntentId intentId);
74
75     /**
76      * Releases the mapping of the given intent.
77      *
78      * @param intentId intent ID
79      */
80     void releaseMapping(IntentId intentId);
81
82     /**
83      * Releases the ports allocated to the given intent.
84      *
85      * @param intentId intent ID
86      * @return true if release was successful, false otherwise
87      */
88     boolean releasePorts(IntentId intentId);
89 }