diff --git a/src/api-engine/api/config.py b/src/api-engine/api/config.py index 6ebb3e0ce..a289a39d6 100644 --- a/src/api-engine/api/config.py +++ b/src/api-engine/api/config.py @@ -12,3 +12,5 @@ FABRIC_CA_CFG = "/opt/node/ca.yaml.bak" FABRIC_CHAINCODE_STORE = "/opt/cello/chaincode" + +FABRIC_VERSION = "2.5.9" diff --git a/src/api-engine/api/lib/configtxgen/configtxgen.py b/src/api-engine/api/lib/configtxgen/configtxgen.py index f67ca6680..505f2e7ec 100644 --- a/src/api-engine/api/lib/configtxgen/configtxgen.py +++ b/src/api-engine/api/lib/configtxgen/configtxgen.py @@ -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 diff --git a/src/api-engine/api/lib/configtxlator/configtxlator.py b/src/api-engine/api/lib/configtxlator/configtxlator.py index dde841623..879954032 100644 --- a/src/api-engine/api/lib/configtxlator/configtxlator.py +++ b/src/api-engine/api/lib/configtxlator/configtxlator.py @@ -2,7 +2,7 @@ # 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: @@ -10,7 +10,7 @@ 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 diff --git a/src/api-engine/api/lib/peer/chaincode.py b/src/api-engine/api/lib/peer/chaincode.py index 45e48c734..917eddd32 100644 --- a/src/api-engine/api/lib/peer/chaincode.py +++ b/src/api-engine/api/lib/peer/chaincode.py @@ -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) diff --git a/src/api-engine/api/lib/peer/channel.py b/src/api-engine/api/lib/peer/channel.py index 46fa80fd1..45ffae84b 100644 --- a/src/api-engine/api/lib/peer/channel.py +++ b/src/api-engine/api/lib/peer/channel.py @@ -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) diff --git a/src/api-engine/api/lib/pki/cryptogen/cryptogen.py b/src/api-engine/api/lib/pki/cryptogen/cryptogen.py index 6709f7127..b27baddf0 100644 --- a/src/api-engine/api/lib/pki/cryptogen/cryptogen.py +++ b/src/api-engine/api/lib/pki/cryptogen/cryptogen.py @@ -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__) @@ -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 diff --git a/src/api-engine/api/routes/chaincode/views.py b/src/api-engine/api/routes/chaincode/views.py index 3a4b17b9f..52b5d7e00 100644 --- a/src/api-engine/api/routes/chaincode/views.py +++ b/src/api-engine/api/routes/chaincode/views.py @@ -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) @@ -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: @@ -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) @@ -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: @@ -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: @@ -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) @@ -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) @@ -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: diff --git a/src/api-engine/api/routes/channel/views.py b/src/api-engine/api/routes/channel/views.py index 787e1b5a2..cd68c465e 100644 --- a/src/api-engine/api/routes/channel/views.py +++ b/src/api-engine/api/routes/channel/views.py @@ -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( @@ -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") @@ -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 @@ -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 )