blob: ed81703d13ace19fc440c94b005a6634e04c45b0 [file] [log] [blame]
Brian O'Connorb7baf712015-07-28 23:27:03 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Brian O'Connorb7baf712015-07-28 23:27:03 -07003 *
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;
19import org.onosproject.net.ConnectPoint;
20import org.onosproject.net.DeviceId;
21
Brian O'Connorb7baf712015-07-28 23:27:03 -070022import 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
29public 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'Connorce2d8b52015-07-29 16:24:13 -070039 public IntentDomain(IntentDomainId id, String name,
Brian O'Connorb7baf712015-07-28 23:27:03 -070040 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'Connorce2d8b52015-07-29 16:24:13 -070090 public IntentDomainProvider provider() {
Brian O'Connorb7baf712015-07-28 23:27:03 -070091 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'Connorce2d8b52015-07-29 16:24:13 -0700117 * Unsets the provider for the intent domain.
Brian O'Connorb7baf712015-07-28 23:27:03 -0700118 */
Brian O'Connorce2d8b52015-07-29 16:24:13 -0700119 public void unsetProvider() {
120 this.provider = null;
Brian O'Connorb7baf712015-07-28 23:27:03 -0700121 }
122
123 //TODO add remaining setters (we will probably want to link this to the network config)
124}