Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 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.incubator.net.domain; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | import org.onosproject.net.ConnectPoint; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 22 | import java.util.Set; |
| 23 | |
| 24 | /** |
| 25 | * Representation of an intent domain which includes the set of internal devices, |
| 26 | * the set of edge ports, and the implementation of the domain provider. |
| 27 | */ |
| 28 | @Beta |
| 29 | public class IntentDomain { |
| 30 | |
| 31 | private final IntentDomainId id; |
| 32 | private String name; |
| 33 | |
| 34 | private Set<DeviceId> internalDevices; |
| 35 | private Set<ConnectPoint> edgePorts; |
| 36 | |
| 37 | private IntentDomainProvider provider; |
| 38 | |
Brian O'Connor | ce2d8b5 | 2015-07-29 16:24:13 -0700 | [diff] [blame] | 39 | public IntentDomain(IntentDomainId id, String name, |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 40 | Set<DeviceId> internalDevices, |
| 41 | Set<ConnectPoint> edgePorts) { |
| 42 | this.id = id; |
| 43 | this.name = name; |
| 44 | this.internalDevices = internalDevices; |
| 45 | this.edgePorts = edgePorts; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Returns the id for the intent domain. |
| 50 | * |
| 51 | * @return intent domain id |
| 52 | */ |
| 53 | public IntentDomainId id() { |
| 54 | return id; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Returns the friendly name for the intent domain. |
| 59 | * |
| 60 | * @return intent domain name |
| 61 | */ |
| 62 | public String name() { |
| 63 | return name; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Returns the set of internal devices for the intent domain (devices under |
| 68 | * exclusive control of the intent domain). |
| 69 | * |
| 70 | * @return set of internal devices |
| 71 | */ |
| 72 | public Set<DeviceId> internalDevices() { |
| 73 | return internalDevices; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Returns the set of edge ports for the intent domain. |
| 78 | * |
| 79 | * @return set of edge ports |
| 80 | */ |
| 81 | public Set<ConnectPoint> edgePorts() { |
| 82 | return edgePorts; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Returns the provider for the intent domain. |
| 87 | * |
| 88 | * @return intent domain provider |
| 89 | */ |
Brian O'Connor | ce2d8b5 | 2015-07-29 16:24:13 -0700 | [diff] [blame] | 90 | public IntentDomainProvider provider() { |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 91 | return provider; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Returns the status of the intent domain. An intent domain is active if it |
| 96 | * has an intent domain provider bound, and it is inactive if one is not bound. |
| 97 | * |
| 98 | * @return true if active; false otherwise |
| 99 | */ |
| 100 | public boolean isActive() { |
| 101 | return provider != null; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Sets the provider for the intent domain if one is not already set. |
| 106 | * |
| 107 | * @param provider new intent domain provider |
| 108 | */ |
| 109 | public void setProvider(IntentDomainProvider provider) { |
| 110 | // TODO consider checkState depending on caller |
| 111 | if (this.provider == null) { |
| 112 | this.provider = provider; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /** |
Brian O'Connor | ce2d8b5 | 2015-07-29 16:24:13 -0700 | [diff] [blame] | 117 | * Unsets the provider for the intent domain. |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 118 | */ |
Brian O'Connor | ce2d8b5 | 2015-07-29 16:24:13 -0700 | [diff] [blame] | 119 | public void unsetProvider() { |
| 120 | this.provider = null; |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | //TODO add remaining setters (we will probably want to link this to the network config) |
| 124 | } |