mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-25 15:05:49 +00:00
added support for tarantool in bigchain db
This commit is contained in:
parent
f366aab1f2
commit
9ff47136c8
23
planetmint/backend/tarantool/database.py
Normal file
23
planetmint/backend/tarantool/database.py
Normal file
@ -0,0 +1,23 @@
|
||||
import tarantool
|
||||
import os
|
||||
from planetmint.backend.tarantool.utils import run
|
||||
|
||||
|
||||
class TarantoolDB:
|
||||
def __init__(self , host , port , username , password):
|
||||
self.conn = tarantool.connect(host=host , port=port , user = username , password=password)
|
||||
|
||||
|
||||
def connect_to_sapce(self,spacename):
|
||||
self.conn.space(spacename)
|
||||
|
||||
|
||||
def init_tarantool():
|
||||
path = os.getcwd()
|
||||
run(["mkdir" , "tarantool"])
|
||||
run(["ln","-s",path +"/init.lua","init.lua"] , path+"/tarantool")
|
||||
run (["tarantool" , "init.lua"] ,path+ "/tarantool")
|
||||
|
||||
def drop_tarantool():
|
||||
#TODO drop tarantool
|
||||
pass
|
||||
26
planetmint/backend/tarantool/utils.py
Normal file
26
planetmint/backend/tarantool/utils.py
Normal file
@ -0,0 +1,26 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
def run(command , path=None):
|
||||
if path is not None:
|
||||
os.chdir(path)
|
||||
p=subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
|
||||
output , error = p.communicate()
|
||||
if p.returncode != 0:
|
||||
print(p.returncode + "\n" + output + "\n" +error)
|
||||
else:
|
||||
p=subprocess.run(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
|
||||
output , error = p.communicate()
|
||||
if p.returncode != 0:
|
||||
print(p.returncode + "\n" + output + "\n" +error)
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import argparse
|
||||
import copy
|
||||
import json
|
||||
import sys
|
||||
from planetmint.backend.tarantool.database import TarantoolDB, init_tarantool
|
||||
|
||||
from planetmint.core import rollback
|
||||
from planetmint.migrations.chain_migration_election import ChainMigrationElection
|
||||
@ -25,6 +26,7 @@ import planetmint
|
||||
from planetmint import (backend, ValidatorElection,
|
||||
Planetmint)
|
||||
from planetmint.backend import schema
|
||||
from planetmint.backend.tarantool import tarantool
|
||||
from planetmint.commands import utils
|
||||
from planetmint.commands.utils import (configure_planetmint,
|
||||
input_on_stderr)
|
||||
@ -241,9 +243,11 @@ def run_election_show(args, planet):
|
||||
|
||||
|
||||
def _run_init():
|
||||
bdb = planetmint.Planetmint()
|
||||
#bdb = planetmint.Planetmint()
|
||||
|
||||
schema.init_database(connection=bdb.connection)
|
||||
#schema.init_database(connection=bdb.connection)
|
||||
|
||||
init_tarantool()
|
||||
|
||||
|
||||
@configure_planetmint
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user