uncloud/uncloud/hack/db.py

53 lines
1.6 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 2020 Nico Schottelius (nico.schottelius at ungleich.ch)
#
# This file is part of uncloud.
#
# uncloud is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# uncloud is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with uncloud. If not, see <http://www.gnu.org/licenses/>.
#
#
import etcd3
class DB(object):
def __init__(self, urls):
self.urls = urls
self.prefix = "/nicohack/"
def connect(self):
self.clients = []
for endpoint in self.urls:
client = etcd3.client(host=endpoint,
ca_cert="/home/nico/vcs/ungleich-dot-cdist/files/etcd/ca.pem",
cert_cert="/home/nico/vcs/ungleich-dot-cdist/files/etcd/nico.pem",
cert_key="/home/nico/vcs/ungleich-dot-cdist/files/etcd/nico-key.pem")
clients.append(client)
def get_value(self, key):
pass
def set_value(self, key, val):
pass
if __name__ == '__main__':
endpoints = [ "https://etcd1.ungleich.ch:2379",
"https://etcd2.ungleich.ch:2379",
"https://etcd3.ungleich.ch:2379" ]
db = DB(url=endpoints)