2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.net.resource.device;
18 import org.onosproject.net.DeviceId;
19 import org.onosproject.net.Port;
20 import org.onosproject.net.intent.IntentId;
24 public interface DeviceResourceStore {
26 * Returns unallocated ports on the given device.
28 * @param deviceId device ID
29 * @return set of unallocated ports
31 Set<Port> getFreePorts(DeviceId deviceId);
34 * Allocates the given ports to the given intent.
36 * @param ports set of ports to allocate
37 * @param intentId intent ID
38 * @return true if allocation was successful, false otherwise
40 boolean allocatePorts(Set<Port> ports, IntentId intentId);
43 * Returns set of ports allocated for an intent.
45 * @param intentId the intent ID
46 * @return set of allocated ports
48 Set<Port> getAllocations(IntentId intentId);
51 * Returns intent allocated to a port.
53 * @param port the port
54 * @return intent ID allocated to the port
56 IntentId getAllocations(Port port);
59 * Allocates the mapping between the given intents.
61 * @param keyIntentId key intent ID
62 * @param valIntentId value intent ID
63 * @return true if mapping was successful, false otherwise
65 boolean allocateMapping(IntentId keyIntentId, IntentId valIntentId);
68 * Returns the set of intents mapped to a lower intent.
70 * @param intentId intent ID
71 * @return set of intent IDs
73 Set<IntentId> getMapping(IntentId intentId);
76 * Releases the mapping of the given intent.
78 * @param intentId intent ID
80 void releaseMapping(IntentId intentId);
83 * Releases the ports allocated to the given intent.
85 * @param intentId intent ID
86 * @return true if release was successful, false otherwise
88 boolean releasePorts(IntentId intentId);