blob: daf97bfaed4dd90cd38c62a85dfeb566c916f3e1 [file] [log] [blame]
Yi Tsenge72fbb52017-08-02 15:03:31 -07001/*
2 * Copyright 2017-present Open Networking Foundation
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 */
17package org.onosproject.dhcprelay.config;
18
19import com.google.common.collect.Lists;
20import org.onosproject.core.ApplicationId;
21import org.onosproject.net.config.Config;
22
23import java.util.List;
24import java.util.concurrent.atomic.AtomicBoolean;
25
26/**
27 * DHCP Relay Config class for default use case (directly connected hosts).
28 */
29public class DefaultDhcpRelayConfig extends Config<ApplicationId> {
30 public static final String KEY = "default";
31
Yi Tsenge72fbb52017-08-02 15:03:31 -070032 @Override
33 public boolean isValid() {
34 // check if all configs are valid
35 AtomicBoolean valid = new AtomicBoolean(true);
36 array.forEach(config -> valid.compareAndSet(true, DhcpServerConfig.isValid(config)));
37 return valid.get();
38 }
39
40 public List<DhcpServerConfig> dhcpServerConfigs() {
41 List<DhcpServerConfig> configs = Lists.newArrayList();
42 array.forEach(node -> configs.add(new DhcpServerConfig(node)));
43 return configs;
44 }
45}