Richard Jankowski | 6dfca94 | 2018-08-15 15:22:26 -0400 | [diff] [blame] | 1 | # Copyright 2018-present Open Networking Foundation |
Richard Jankowski | 8af3c0e | 2018-08-14 16:07:18 -0400 | [diff] [blame] | 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 | |
| 15 | from common.kvstore.consul_client import ConsulClient |
| 16 | from common.kvstore.etcd_client import EtcdClient |
| 17 | |
| 18 | def 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 |