2 * Copyright (c) 2019 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.ovsdb.southbound;
10 import java.util.ArrayList;
11 import java.util.List;
13 import java.util.StringTokenizer;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Helper to let Blueprint XML configure {@link SouthboundProvider}.
20 * @author Michael Vorburger.ch
22 public class SouthboundProviderConfigurator {
24 private static final Logger LOG = LoggerFactory.getLogger(SouthboundProviderConfigurator.class);
26 private static final String SKIP_MONITORING_MANAGER_STATUS_PARAM = "skip-monitoring-manager-status";
27 private static final String BRIDGES_RECONCILIATION_INCLUSION_LIST_PARAM = "bridges-reconciliation-inclusion-list";
28 private static final String BRIDGES_RECONCILIATION_EXCLUSION_LIST_PARAM = "bridges-reconciliation-exclusion-list";
30 private final SouthboundProvider southboundProvider;
32 public SouthboundProviderConfigurator(SouthboundProvider southboundProvider) {
33 this.southboundProvider = southboundProvider;
36 public void setSkipMonitoringManagerStatus(boolean flag) {
37 southboundProvider.setSkipMonitoringManagerStatus(flag);
40 public void setBridgesReconciliationInclusionList(String bridgeListStr) {
41 if (bridgeListStr != null && !bridgeListStr.equals("")) {
42 SouthboundProvider.setBridgesReconciliationInclusionList(getBridgesList(bridgeListStr));
46 public void setBridgesReconciliationExclusionList(String bridgeListStr) {
47 if (bridgeListStr != null && !bridgeListStr.equals("")) {
48 SouthboundProvider.setBridgesReconciliationExclusionList(getBridgesList(bridgeListStr));
52 private static List<String> getBridgesList(final String bridgeListStr) {
53 List<String> bridgeList = new ArrayList<>();
54 StringTokenizer tokenizer = new StringTokenizer(bridgeListStr, ",");
55 while (tokenizer.hasMoreTokens()) {
56 bridgeList.add(tokenizer.nextToken());
62 public void updateConfigParameter(Map<String, Object> configParameters) {
63 if (configParameters != null && !configParameters.isEmpty()) {
64 LOG.debug("Config parameters received : {}", configParameters.entrySet());
65 for (Map.Entry<String, Object> paramEntry : configParameters.entrySet()) {
66 if (paramEntry.getKey().equalsIgnoreCase(SKIP_MONITORING_MANAGER_STATUS_PARAM)) {
68 .setSkipMonitoringManagerStatus(Boolean.parseBoolean((String) paramEntry.getValue()));
69 } else if (paramEntry.getKey().equalsIgnoreCase(BRIDGES_RECONCILIATION_INCLUSION_LIST_PARAM)) {
70 String bridgeListStr = (String)paramEntry.getValue();
71 if (bridgeListStr != null && !bridgeListStr.equals("")) {
72 SouthboundProvider.setBridgesReconciliationInclusionList(getBridgesList(bridgeListStr));
74 } else if (paramEntry.getKey().equalsIgnoreCase(BRIDGES_RECONCILIATION_EXCLUSION_LIST_PARAM)) {
75 String bridgeListStr = (String)paramEntry.getValue();
76 if (bridgeListStr != null && !bridgeListStr.equals("")) {
77 SouthboundProvider.setBridgesReconciliationExclusionList(getBridgesList(bridgeListStr));