blob: 959c01b134fa8660d19f2d43532e3744a87cac93 [file] [log] [blame]
Yi Tseng483ac6f2017-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
32
33
34 @Override
35 public boolean isValid() {
36 // check if all configs are valid
37 AtomicBoolean valid = new AtomicBoolean(true);
38 array.forEach(config -> valid.compareAndSet(true, DhcpServerConfig.isValid(config)));
39 return valid.get();
40 }
41
42 public List<DhcpServerConfig> dhcpServerConfigs() {
43 List<DhcpServerConfig> configs = Lists.newArrayList();
44 array.forEach(node -> configs.add(new DhcpServerConfig(node)));
45 return configs;
46 }
47}