blob: ed7f2465b133e36b20e90bd3e76b71c2bbadb08e [file] [log] [blame]
Stephane Barbarie6e1bd502018-11-05 22:44:45 -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
khenaidoofdbad6e2018-11-06 22:26:38 -050015from consul_client import ConsulClient
16from etcd_client import EtcdClient
Stephane Barbarie6e1bd502018-11-05 22:44:45 -050017
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