blob: 6cc6fb823b36e31ad22b3b576cbc1cd2b6324678 [file] [log] [blame]
Brian O'Connorb7baf712015-07-28 23:27:03 -07001/*
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 */
16package org.onosproject.incubator.net.domain;
17
18import com.google.common.annotations.Beta;
Brian O'Connorce2d8b52015-07-29 16:24:13 -070019import com.google.common.collect.ImmutableSet;
Brian O'Connorb7baf712015-07-28 23:27:03 -070020import org.onosproject.incubator.net.config.Config;
21import org.onosproject.net.ConnectPoint;
22import org.onosproject.net.DeviceId;
23
24import 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'Connorce2d8b52015-07-29 16:24:13 -070031public class IntentDomainConfig extends Config<IntentDomainId> {
Brian O'Connorb7baf712015-07-28 23:27:03 -070032
Brian O'Connorce2d8b52015-07-29 16:24:13 -070033 private static final String DOMAIN_NAME = "name";
Brian O'Connorb7baf712015-07-28 23:27:03 -070034 private static final String APPLICATION_NAME = "applicationName";
Brian O'Connorce2d8b52015-07-29 16:24:13 -070035 private static final String INTERNAL_DEVICES = "internalDevices";
36 private static final String EDGE_PORTS = "edgePorts";
37
Brian O'Connorb7baf712015-07-28 23:27:03 -070038
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'Connorce2d8b52015-07-29 16:24:13 -070064 return get(APPLICATION_NAME, "FIXME"); //TODO maybe not null?
Brian O'Connorb7baf712015-07-28 23:27:03 -070065 }
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'Connorce2d8b52015-07-29 16:24:13 -070077 /**
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'Connorb7baf712015-07-28 23:27:03 -0700114
115}