Skip to content

Commit

Permalink
add FABRIC_VERSION into config.py
Browse files Browse the repository at this point in the history
Signed-off-by: YoungHypo <[email protected]>
  • Loading branch information
YoungHypo committed Sep 19, 2024
1 parent 5e339fa commit b2ea3f2
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/api-engine/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
FABRIC_CA_CFG = "/opt/node/ca.yaml.bak"

FABRIC_CHAINCODE_STORE = "/opt/cello/chaincode"

FABRIC_VERSION = "2.5.9"
4 changes: 2 additions & 2 deletions src/api-engine/api/lib/configtxgen/configtxgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# SPDX-License-Identifier: Apache-2.0
#
from subprocess import call
from api.config import CELLO_HOME, FABRIC_TOOL
from api.config import CELLO_HOME, FABRIC_TOOL, FABRIC_VERSION


class ConfigTxGen:
"""Class represents cryptotxgen."""

def __init__(self, network, filepath=CELLO_HOME, configtxgen=FABRIC_TOOL, version="2.5.9"):
def __init__(self, network, filepath=CELLO_HOME, configtxgen=FABRIC_TOOL, version=FABRIC_VERSION):
"""init CryptoGen
param:
network: network's name
Expand Down
4 changes: 2 additions & 2 deletions src/api-engine/api/lib/configtxlator/configtxlator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# SPDX-License-Identifier: Apache-2.0
#
from subprocess import call, run
from api.config import FABRIC_TOOL
from api.config import FABRIC_TOOL, FABRIC_VERSION


class ConfigTxLator:
"""
Class represents configtxlator CLI.
"""

def __init__(self, configtxlator=FABRIC_TOOL, version="2.5.9"):
def __init__(self, configtxlator=FABRIC_TOOL, version=FABRIC_VERSION):
self.configtxlator = configtxlator + "/configtxlator"
self.version = version

Expand Down
4 changes: 2 additions & 2 deletions src/api-engine/api/lib/peer/chaincode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import json
import subprocess
from api.lib.peer.command import Command
from api.config import FABRIC_TOOL, FABRIC_CFG
from api.config import FABRIC_TOOL, FABRIC_CFG, FABRIC_VERSION


class ChainCode(Command):
def __init__(self, version="2.5.9", peer=FABRIC_TOOL, **kwargs):
def __init__(self, version=FABRIC_VERSION, peer=FABRIC_TOOL, **kwargs):
self.peer = peer + "/peer"
super(ChainCode, self).__init__(version, **kwargs)

Expand Down
4 changes: 2 additions & 2 deletions src/api-engine/api/lib/peer/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import json
import subprocess
from api.lib.peer.command import Command
from api.config import FABRIC_TOOL
from api.config import FABRIC_TOOL, FABRIC_VERSION


class Channel(Command):
"""Call CMD to perform channel create, join and other related operations"""

def __init__(self, version="2.5.9", peer=FABRIC_TOOL, **kwargs):
def __init__(self, version=FABRIC_VERSION, peer=FABRIC_TOOL, **kwargs):
self.peer = peer + "/peer"
super(Channel, self).__init__(version, **kwargs)

Expand Down
4 changes: 2 additions & 2 deletions src/api-engine/api/lib/pki/cryptogen/cryptogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
#
from subprocess import call
from api.config import CELLO_HOME, FABRIC_TOOL
from api.config import CELLO_HOME, FABRIC_TOOL, FABRIC_VERSION

import logging
LOG = logging.getLogger(__name__)
Expand All @@ -11,7 +11,7 @@
class CryptoGen:
"""Class represents crypto-config tool."""

def __init__(self, name, filepath=CELLO_HOME, cryptogen=FABRIC_TOOL, version="2.5.9"):
def __init__(self, name, filepath=CELLO_HOME, cryptogen=FABRIC_TOOL, version=FABRIC_VERSION):
"""init CryptoGen
param:
name: organization's name
Expand Down
16 changes: 8 additions & 8 deletions src/api-engine/api/routes/chaincode/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def install(self, request):
peer_node = qs.first()
envs = init_env_vars(peer_node, org)

peer_channel_cli = PeerChainCode("v2.5.9", **envs)
peer_channel_cli = PeerChainCode(**envs)
res = peer_channel_cli.lifecycle_install(cc_targz)
if res != 0:
return Response(err("install chaincode failed."), status=status.HTTP_400_BAD_REQUEST)
Expand Down Expand Up @@ -270,7 +270,7 @@ def query_installed(self, request):
envs = init_env_vars(peer_node, org)

timeout = "5s"
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
peer_channel_cli = PeerChainCode(**envs)
res, installed_chaincodes = peer_channel_cli.lifecycle_query_installed(
timeout)
if res != 0:
Expand Down Expand Up @@ -300,7 +300,7 @@ def get_installed_package(self, request):
envs = init_env_vars(peer_node, org)

timeout = "5s"
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
peer_channel_cli = PeerChainCode(**envs)
res = peer_channel_cli.lifecycle_get_installed_package(timeout)
if res != 0:
return Response(err("get installed package failed."), status=status.HTTP_400_BAD_REQUEST)
Expand Down Expand Up @@ -352,7 +352,7 @@ def approve_for_my_org(self, request):
peer_node = qs.first()
envs = init_env_vars(peer_node, org)

peer_channel_cli = PeerChainCode("v2.5.9", **envs)
peer_channel_cli = PeerChainCode(**envs)
code, content = peer_channel_cli.lifecycle_approve_for_my_org(orderer_url, orderer_tls_root_cert, channel_name,
chaincode_name, chaincode_version, policy, sequence)
if code != 0:
Expand Down Expand Up @@ -384,7 +384,7 @@ def query_approved(self, request):
channel_name = request.data.get("channel_name")
cc_name = request.data.get("chaincode_name")

peer_channel_cli = PeerChainCode("v2.5.9", **envs)
peer_channel_cli = PeerChainCode(**envs)
code, content = peer_channel_cli.lifecycle_query_approved(
channel_name, cc_name)
if code != 0:
Expand Down Expand Up @@ -438,7 +438,7 @@ def check_commit_readiness(self, request):
peer_node = qs.first()
envs = init_env_vars(peer_node, org)

peer_channel_cli = PeerChainCode("v2.5.9", **envs)
peer_channel_cli = PeerChainCode(**envs)
code, content = peer_channel_cli.lifecycle_check_commit_readiness(orderer_url, orderer_tls_root_cert,
channel_name, chaincode_name,
chaincode_version, policy, sequence)
Expand Down Expand Up @@ -507,7 +507,7 @@ def commit(self, request):
peer_address_list.append(peer_address)
peer_root_certs.append(peer_tls_cert)

peer_channel_cli = PeerChainCode("v2.5.9", **envs)
peer_channel_cli = PeerChainCode(**envs)
code = peer_channel_cli.lifecycle_commit(orderer_url, orderer_tls_root_cert, channel_name,
chaincode_name, chaincode_version, policy,
peer_address_list, peer_root_certs, sequence)
Expand Down Expand Up @@ -539,7 +539,7 @@ def query_committed(self, request):
raise ResourceNotFound
peer_node = qs.first()
envs = init_env_vars(peer_node, org)
peer_channel_cli = PeerChainCode("v2.5.9", **envs)
peer_channel_cli = PeerChainCode(**envs)
code, chaincodes_commited = peer_channel_cli.lifecycle_query_committed(
channel_name, chaincode_name)
if code != 0:
Expand Down
8 changes: 4 additions & 4 deletions src/api-engine/api/routes/channel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def create(self, request):
ordering_node = Node.objects.get(id=orderers[0])
peer_node = Node.objects.get(id=peers[0])
envs = init_env_vars(peer_node, org)
peer_channel_cli = PeerChannel("v2.5.9", **envs)
peer_channel_cli = PeerChannel(**envs)
peer_channel_cli.create(
channel=name,
orderer_url="{}.{}:{}".format(
Expand Down Expand Up @@ -312,7 +312,7 @@ def update(self, request, pk=None):
env = {
"FABRIC_CFG_PATH": "{}/{}/peers/{}/".format(dir_node, org.name, node.name + "." + org.name),
}
cli = PeerChannel("v2.5.9", **env)
cli = PeerChannel(**env)
cli.signconfigtx(
channel.get_channel_artifacts_path(CFG_DELTA_ENV_PB))
LOG.info("Peers to send the update transaction success")
Expand Down Expand Up @@ -343,7 +343,7 @@ def get_channel_org_config(self, request, pk=None):
env = {
"FABRIC_CFG_PATH": "{}/{}/peers/{}/".format(dir_node, org.name, node.name + "." + org.name),
}
peer_channel_cli = PeerChannel("v2.5.9", **env)
peer_channel_cli = PeerChannel(**env)
peer_channel_cli.fetch(option="config", channel=channel.name)

# Decode latest config block into json
Expand Down Expand Up @@ -407,7 +407,7 @@ def join_peers(envs, block_path):
:param block_path: Path to file containing genesis block
"""
# Join the peers to the channel.
peer_channel_cli = PeerChannel("v2.5.9", **envs)
peer_channel_cli = PeerChannel(**envs)
peer_channel_cli.join(
block_file=block_path
)

0 comments on commit b2ea3f2

Please sign in to comment.