blob: 662b34dc81d469348ff20b2b94a2c95dd2811bad [file] [log] [blame]
Matt Jeanneretf1e9c5d2019-02-08 07:41:29 -05001# Copyright 2018-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15from common.kvstore.consul_client import ConsulClient
16from common.kvstore.etcd_client import EtcdClient
17
18def create_kv_client(kv_store, host, port):
19 '''
20 Factory for creating a client interface to a KV store
21
22 :param kv_store: Specify either 'etcd' or 'consul'
23 :param host: Name or IP address of host serving the KV store
24 :param port: Port number (integer) of the KV service
25 :return: Reference to newly created client interface
26 '''
27 if kv_store == 'etcd':
28 return EtcdClient(host, port)
29 elif kv_store == 'consul':
30 return ConsulClient(host, port)
31 return None