Honeynode test tool
[transportpce.git] / tests / honeynode / restconf / src / main / java / io / fd / honeycomb / northbound / restconf / RestconfConfiguration.java
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
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 io.fd.honeycomb.northbound.restconf;
18
19 import java.util.Optional;
20 import net.jmob.guice.conf.core.BindConfig;
21 import net.jmob.guice.conf.core.InjectConfig;
22 import net.jmob.guice.conf.core.Syntax;
23
24 //TODO - HONEYCOMB-377 - do not include module to active modules if disabled
25 @BindConfig(value = "restconf", syntax = Syntax.JSON)
26 public class RestconfConfiguration {
27
28     @InjectConfig("restconf-http-enabled")
29     public String restconfHttp;
30     @InjectConfig("restconf-binding-address")
31     public Optional<String> restconfBindingAddress;
32     @InjectConfig("restconf-port")
33     public Optional<Integer> restconfPort;
34     @InjectConfig("restconf-https-enabled")
35     public String restconfHttps;
36     @InjectConfig("restconf-https-binding-address")
37     public Optional<String> restconfHttpsBindingAddress;
38     @InjectConfig("restconf-https-port")
39     public Optional<Integer> restconfHttpsPort;
40     /**
41      * Restconf keystore file name. It will be loaded from the classpath so must be present in one of the folders
42      * packaged with the distribution e.g. cert/
43      */
44     @InjectConfig("restconf-keystore")
45     public Optional<String> restconfKeystore = Optional.of("/honeycomb-keystore");
46     @InjectConfig("restconf-keystore-password")
47     public Optional<String> keystorePassword;
48     @InjectConfig("restconf-keystore-manager-password")
49     public Optional<String> keystoreManagerPassword;
50     /**
51      * Restconf truststore file name. It will be loaded from the classpath so must be present in one of the folders
52      * packaged with the distribution e.g. cert/
53      */
54     @InjectConfig("restconf-truststore")
55     public Optional<String> restconfTruststore;
56     @InjectConfig("restconf-truststore-password")
57     public Optional<String> truststorePassword;
58     @InjectConfig("restconf-websocket-address")
59     public Optional<String> restconfWebsocketAddress;
60     @InjectConfig("restconf-websocket-port")
61     public Optional<Integer> restconfWebsocketPort;
62     @InjectConfig("restconf-root-path")
63     public Optional<String> restconfRootPath = Optional.of("/restconf");
64     @InjectConfig("restconf-pool-max-size")
65     public Optional<Integer> restPoolMaxSize = Optional.of(10);
66     @InjectConfig("restconf-pool-min-size")
67     public Optional<Integer> restPoolMinSize = Optional.of(1);
68     @InjectConfig("restconf-acceptors-size")
69     public Optional<Integer> acceptorsSize = Optional.of(1);
70     @InjectConfig("restconf-selectors-size")
71     public Optional<Integer> selectorsSize = Optional.of(1);
72     @InjectConfig("restconf-https-acceptors-size")
73     public Optional<Integer> httpsAcceptorsSize = Optional.of(1);
74     @InjectConfig("restconf-https-selectors-size")
75     public Optional<Integer> httpsSelectorsSize = Optional.of(1);
76
77     public boolean isRestconfHttpEnabled() {
78         return Boolean.valueOf(restconfHttp);
79     }
80
81     public boolean isRestconfHttpsEnabled() {
82         return Boolean.valueOf(restconfHttps);
83     }
84
85     public boolean isRestconfEnabled() {
86         return isRestconfHttpEnabled() || isRestconfHttpsEnabled();
87     }
88
89     @Override
90     public String toString() {
91         return "RestconfConfiguration{" +
92             "restconfHttp='" + restconfHttp + '\'' +
93             ", restconfBindingAddress=" + restconfBindingAddress +
94             ", restconfPort=" + restconfPort +
95             ", restconfHttps='" + restconfHttps + '\'' +
96             ", restconfHttpsBindingAddress=" + restconfHttpsBindingAddress +
97             ", restconfHttpsPort=" + restconfHttpsPort +
98             ", restconfKeystore=" + restconfKeystore +
99             ", keystorePassword=" + keystorePassword +
100             ", keystoreManagerPassword=" + keystoreManagerPassword +
101             ", restconfTruststore=" + restconfTruststore +
102             ", truststorePassword=" + truststorePassword +
103             ", restconfWebsocketAddress=" + restconfWebsocketAddress +
104             ", restconfWebsocketPort=" + restconfWebsocketPort +
105             ", restconfRootPath=" + restconfRootPath +
106             ", restPoolMaxSize=" + restPoolMaxSize +
107             ", restPoolMinSize=" + restPoolMinSize +
108             ", acceptorsSize=" + acceptorsSize +
109             ", selectorsSize=" + selectorsSize +
110             ", httpsAcceptorsSize=" + httpsAcceptorsSize +
111             ", httpsSelectorsSize=" + httpsSelectorsSize +
112             '}';
113     }
114 }