2 * ============LICENSE_START===================================================
3 * Copyright (c) 2018 Amdocs
4 * ============================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=====================================================
18 package org.onap.sdnc.apps.pomba.networkdiscovery;
20 import java.util.HashMap;
22 import java.util.StringTokenizer;
24 import org.eclipse.jetty.util.security.Password;
25 import org.onap.aai.restclient.client.RestClient;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.beans.factory.annotation.Value;
28 import org.springframework.context.annotation.Bean;
29 import org.springframework.context.annotation.Configuration;
30 import org.springframework.core.env.Environment;
33 public class OpenstackConfiguration {
35 private Environment env;
37 @Value("${openstack.identity.url:http://localhost:5000/v3}")
38 private String identityUrl;
40 @Value("${openstack.identity.user}")
41 private String identityUser;
43 @Value("${openstack.identity.password}")
44 private String identityPassword;
46 @Value("${openstack.api.microversion}")
47 private String apiMicroversion;
49 @Value("${openstack.identity.keyStorePath:config/auth/client-cert-onap.p12}")
50 private String keyStorePath;
52 @Value("${openstack.identity.keyStorePassword:OBF:1y0q1uvc1uum1uvg1pil1pjl1uuq1uvk1uuu1y10}")
53 private String keyStorePassword;
55 @Value("${openstack.connectionTimeout:5000}")
56 private int connectionTimeout;
58 @Value("${openstack.readTimeout:60000}")
59 private int readTimeout;
61 @Bean(name = "openstackClient")
62 public RestClient restClient() {
63 return new RestClient().validateServerHostname(false)
64 .validateServerCertChain(false)
65 .connectTimeoutMs(this.connectionTimeout)
66 .readTimeoutMs(this.readTimeout);
69 @Bean(name = "openstackIdentityUrl")
70 public String getIdentityURL() {
71 return this.identityUrl;
74 @Bean(name = "openstackIdentityUser")
75 public String getIdentityUser() {
76 return this.identityUser;
79 @Bean(name = "openstackIdentityPassword")
80 public String getIdentityPassword() {
81 return Password.deobfuscate(this.identityPassword);
84 @Bean(name = "openstackApiMicroversion")
85 public String getApiMicroversion() {
86 return this.apiMicroversion;
89 @Bean(name = "openstackTypeURLs")
90 public Map<String, String> getOpenstackTypeURLs() {
92 Map<String, String> result = new HashMap<>();
93 String types = this.env.getProperty("openstack.types");
98 StringTokenizer tokenizer = new StringTokenizer(types, ", ");
99 while (tokenizer.hasMoreTokens()) {
100 String type = tokenizer.nextToken();
101 String openstackUrl = this.env.getProperty("openstack.type." + type + ".url");
102 result.put(type, openstackUrl);