Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 17 | package org.onosproject.dhcprelay.config; |
| 18 | |
| 19 | import com.google.common.collect.Lists; |
| 20 | import org.onosproject.core.ApplicationId; |
| 21 | import org.onosproject.net.config.Config; |
| 22 | |
| 23 | import java.util.List; |
| 24 | import java.util.concurrent.atomic.AtomicBoolean; |
| 25 | |
| 26 | /** |
| 27 | * DHCP Relay Config class for default use case (directly connected hosts). |
| 28 | */ |
| 29 | public class DefaultDhcpRelayConfig extends Config<ApplicationId> { |
| 30 | public static final String KEY = "default"; |
| 31 | |
Yi Tseng | e72fbb5 | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 32 | @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 | } |