Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 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 | */ |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 16 | package org.onosproject.net.resource.device; |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 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 { |
Marc De Leenheer | 88194c3 | 2015-05-29 22:10:59 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Returns unallocated ports on the given device. |
| 27 | * |
| 28 | * @param deviceId device ID |
| 29 | * @return set of unallocated ports |
| 30 | */ |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 31 | Set<Port> getFreePorts(DeviceId deviceId); |
| 32 | |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 33 | /** |
| 34 | * Allocates the given ports to the given intent. |
Marc De Leenheer | 88194c3 | 2015-05-29 22:10:59 -0700 | [diff] [blame] | 35 | * |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 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); |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 41 | |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 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 | /** |
Marc De Leenheer | 9f7d189 | 2015-05-30 13:22:24 -0700 | [diff] [blame] | 76 | * Releases the mapping of the given intent. |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 77 | * |
Marc De Leenheer | 9f7d189 | 2015-05-30 13:22:24 -0700 | [diff] [blame] | 78 | * @param intentId intent ID |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 79 | */ |
Marc De Leenheer | 9f7d189 | 2015-05-30 13:22:24 -0700 | [diff] [blame] | 80 | void releaseMapping(IntentId intentId); |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 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); |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 89 | } |