Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -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 | */ |
| 16 | package org.onosproject.incubator.net.domain; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
Brian O'Connor | ce2d8b5 | 2015-07-29 16:24:13 -0700 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableSet; |
Ray Milkey | a412236 | 2015-08-18 15:19:08 -0700 | [diff] [blame] | 20 | import org.onosproject.net.config.Config; |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 21 | import org.onosproject.net.ConnectPoint; |
| 22 | import org.onosproject.net.DeviceId; |
| 23 | |
| 24 | import java.util.Set; |
| 25 | |
| 26 | /** |
| 27 | * Configuration for an intent domain including a name, set of internal devices, |
| 28 | * set of edge ports, and the application bound to control the domain. |
| 29 | */ |
| 30 | @Beta |
Brian O'Connor | ce2d8b5 | 2015-07-29 16:24:13 -0700 | [diff] [blame] | 31 | public class IntentDomainConfig extends Config<IntentDomainId> { |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 32 | |
Brian O'Connor | ce2d8b5 | 2015-07-29 16:24:13 -0700 | [diff] [blame] | 33 | private static final String DOMAIN_NAME = "name"; |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 34 | private static final String APPLICATION_NAME = "applicationName"; |
Brian O'Connor | ce2d8b5 | 2015-07-29 16:24:13 -0700 | [diff] [blame] | 35 | private static final String INTERNAL_DEVICES = "internalDevices"; |
| 36 | private static final String EDGE_PORTS = "edgePorts"; |
| 37 | |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Returns the friendly name for the domain. |
| 41 | * |
| 42 | * @return domain name |
| 43 | */ |
| 44 | public String domainName() { |
| 45 | return get(DOMAIN_NAME, subject.toString()); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Sets the friendly name for the domain. |
| 50 | * |
| 51 | * @param domainName new name for the domain; null to clear |
| 52 | * @return self |
| 53 | */ |
| 54 | public IntentDomainConfig domainName(String domainName) { |
| 55 | return (IntentDomainConfig) setOrClear(DOMAIN_NAME, domainName); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Returns the friendly name for the domain. |
| 60 | * |
| 61 | * @return domain name |
| 62 | */ |
| 63 | public String applicationName() { |
Brian O'Connor | ce2d8b5 | 2015-07-29 16:24:13 -0700 | [diff] [blame] | 64 | return get(APPLICATION_NAME, "FIXME"); //TODO maybe not null? |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Sets the friendly name for the domain. |
| 69 | * |
| 70 | * @param applicationName new name for the domain; null to clear |
| 71 | * @return self |
| 72 | */ |
| 73 | public IntentDomainConfig applicationName(String applicationName) { |
| 74 | return (IntentDomainConfig) setOrClear(APPLICATION_NAME, applicationName); |
| 75 | } |
| 76 | |
Brian O'Connor | ce2d8b5 | 2015-07-29 16:24:13 -0700 | [diff] [blame] | 77 | /** |
| 78 | * Returns the set of internal devices. |
| 79 | * |
| 80 | * @return set of internal devices |
| 81 | */ |
| 82 | public Set<DeviceId> internalDevices() { |
| 83 | return ImmutableSet.copyOf(getList(INTERNAL_DEVICES, DeviceId::deviceId)); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Sets the set of internal devices. |
| 88 | * |
| 89 | * @param devices set of devices; null to clear |
| 90 | * @return self |
| 91 | */ |
| 92 | public IntentDomainConfig internalDevices(Set<DeviceId> devices) { |
| 93 | return (IntentDomainConfig) setOrClear(INTERNAL_DEVICES, devices); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Returns the set of edge ports. |
| 98 | * |
| 99 | * @return set of edge ports |
| 100 | */ |
| 101 | public Set<ConnectPoint> edgePorts() { |
| 102 | return ImmutableSet.copyOf(getList(EDGE_PORTS, ConnectPoint::deviceConnectPoint)); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Sets the set of edge ports. |
| 107 | * |
| 108 | * @param connectPoints set of edge ports; null to clear |
| 109 | * @return self |
| 110 | */ |
| 111 | public IntentDomainConfig edgePorts(Set<ConnectPoint> connectPoints) { |
| 112 | return (IntentDomainConfig) setOrClear(EDGE_PORTS, connectPoints); |
| 113 | } |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 114 | |
| 115 | } |