mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
ND Tendermint api
This commit is contained in:
parent
293587701d
commit
d6404ab7c3
@ -14,7 +14,7 @@ BDB_POD_SPEC = {}
|
|||||||
|
|
||||||
class Node():
|
class Node():
|
||||||
|
|
||||||
def __init__(self, namespace='itest-setup', name=None, spec=BDB_POD_SPEC):
|
def __init__(self, namespace='default', name=None, spec=BDB_POD_SPEC):
|
||||||
kubernetes.config.load_kube_config()
|
kubernetes.config.load_kube_config()
|
||||||
config = kubernetes.client.Configuration()
|
config = kubernetes.client.Configuration()
|
||||||
config.assert_hostname = False
|
config.assert_hostname = False
|
||||||
@ -29,8 +29,7 @@ class Node():
|
|||||||
pod.kind = 'Pod'
|
pod.kind = 'Pod'
|
||||||
pod.metadata = {"name": self.name}
|
pod.metadata = {"name": self.name}
|
||||||
pod.spec = {"containers": [{"name": "tendermint",
|
pod.spec = {"containers": [{"name": "tendermint",
|
||||||
"image": "busybox",
|
"image": "bdbt:v1"},
|
||||||
"command": ["sh", "-c", "echo Hello Kubernetes! && sleep 3600"]},
|
|
||||||
{"name": "bigchaindb",
|
{"name": "bigchaindb",
|
||||||
"image": "busybox",
|
"image": "busybox",
|
||||||
"command": ["sh", "-c", "echo Hello Kubernetes! && sleep 3600"]}]}
|
"command": ["sh", "-c", "echo Hello Kubernetes! && sleep 3600"]}]}
|
||||||
@ -81,15 +80,26 @@ class Node():
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _exec_command(self, container, command):
|
def stop_tendermint(self):
|
||||||
|
self._exec_command('tendermint', 'pkill tendermint')
|
||||||
|
|
||||||
|
def start_tendermint(self):
|
||||||
|
self._exec_command('tendermint', 'tendermint node --proxy_app=dummy', tty=True)
|
||||||
|
|
||||||
|
def reset_tendermint(self):
|
||||||
|
self.stop_tendermint()
|
||||||
|
self._exec_command('tendermint', 'tendermint unsafe_reset_all')
|
||||||
|
self.start_tendermint()
|
||||||
|
|
||||||
|
def _exec_command(self, container, command, stdout=True, tty=False):
|
||||||
try:
|
try:
|
||||||
exec_command = ['/bin/sh', '-c', command]
|
exec_command = ['/bin/bash', '-c', command]
|
||||||
resp = stream(self.api_instance.connect_get_namespaced_pod_exec,
|
resp = stream(self.api_instance.connect_post_namespaced_pod_exec,
|
||||||
self.name,
|
self.name,
|
||||||
self.namespace,
|
self.namespace,
|
||||||
container=container,
|
container=container,
|
||||||
command=exec_command,
|
command=exec_command,
|
||||||
stderr=True, stdin=False, stdout=True, tty=False)
|
stderr=False, stdin=False, stdout=stdout, tty=tty)
|
||||||
return resp
|
return resp
|
||||||
except ApiException as e:
|
except ApiException as e:
|
||||||
print("Exception when executing command: %s\n" % e)
|
print("Exception when executing command: %s\n" % e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user