blob: 148860a583321c03623b856e2d02104ec486ac3e [file] [log] [blame]
Brian O'Connorf69e3e32018-05-10 02:25:09 -07001/*
2 * Copyright 2018-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 */
16package org.onosproject.openflow.config;
17
18import com.google.common.annotations.Beta;
19import org.onosproject.net.DeviceId;
20import org.onosproject.net.config.Config;
21
22import java.util.Optional;
23
24/**
25 * Configuration for OpenFlow devices.
26 */
27@Beta
28public class OpenFlowDeviceConfig extends Config<DeviceId> {
29
30 /**
31 * netcfg ConfigKey.
32 */
33 public static final String CONFIG_KEY = "openflow";
34
35 public static final String CLIENT_KEY_ALIAS = "keyAlias";
36
37 @Override
38 public boolean isValid() {
39 return hasOnlyFields(CLIENT_KEY_ALIAS);
40 }
41
42 /**
43 * Gets the certFile for the switch.
44 *
45 * @return cert file
46 */
47 public Optional<String> keyAlias() {
48 String keyAlias = get(CLIENT_KEY_ALIAS, "");
49 return (keyAlias.isEmpty() ? Optional.empty() : Optional.ofNullable(keyAlias));
50 }
51
52 /**
53 * Sets the key alias for the Device.
54 *
55 * @param keyAlias key alias as string
56 * @return instance for chaining
57 */
58 public OpenFlowDeviceConfig setKeyAlias(String keyAlias) {
59 return (OpenFlowDeviceConfig) setOrClear(CLIENT_KEY_ALIAS, keyAlias);
60 }
61}