Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade labels of cello tools and config files(orderer.yaml and core.yaml) to HLFv2.5.9 #632

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,7 @@ src/dashboard/lambda/mock/index.js
# Local Netlify folder
.netlify
deno.lock

# test postman
tests/postman/env.json
tests/postman/junitResult.xml
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.2.0"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use some variables, instead of fixed number?
This way is more convenient to update in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my latest commit, I've used FABRIC_VERSION in <src/api-engine/api/config.py> to control version number.

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.2.0"):
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.2.0", 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.2.0", 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
33 changes: 27 additions & 6 deletions src/api-engine/api/lib/pki/cryptogen/cryptogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
# 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__)


class CryptoGen:
"""Class represents crypto-config tool."""

def __init__(self, name, filepath=CELLO_HOME, cryptogen=FABRIC_TOOL, version="2.2.0"):
def __init__(self, name, filepath=CELLO_HOME, cryptogen=FABRIC_TOOL, version=FABRIC_VERSION):
"""init CryptoGen
param:
name: organization's name
Expand All @@ -30,8 +33,17 @@ def generate(self, output="crypto-config", config="crypto-config.yaml"):
return:
"""
try:
call([self.cryptogen, "generate", "--output={}/{}/{}".format(self.filepath, self.name, output),
"--config={}/{}/{}".format(self.filepath, self.name, config)])
command = [
self.cryptogen,
"generate",
"--output={}/{}/{}".format(self.filepath, self.name, output),
"--config={}/{}/{}".format(self.filepath, self.name, config)
]

LOG.info("Running command: " + " ".join(command))

call(command)

except Exception as e:
err_msg = "cryptogen generate fail for {}!".format(e)
raise Exception(err_msg)
Expand All @@ -44,8 +56,17 @@ def extend(self, input="crypto-config", config="crypto-config.yaml"):
return:
"""
try:
call([self.cryptogen, "extend", "--input={}/{}/{}".format(self.filepath, self.name, input),
"--config={}/{}/{}".format(self.filepath, self.name, config)])
command = [
self.cryptogen,
"extend",
"--input={}/{}/{}".format(self.filepath, self.name, input),
"--config={}/{}/{}".format(self.filepath, self.name, config)
]

LOG.info("Running command: " + " ".join(command))

call(command)

except Exception as e:
err_msg = "cryptogen extend fail for {}!".format(e)
raise Exception(err_msg)
18 changes: 9 additions & 9 deletions src/api-engine/api/routes/chaincode/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def package(self, request):
# )
# peer_node = qs.first()
# envs = init_env_vars(peer_node, org)
# peer_channel_cli = PeerChainCode("v2.2.0", **envs)
# peer_channel_cli = PeerChainCode("v2.5.9", **envs)
# return_code, content = peer_channel_cli.lifecycle_calculatepackageid(temp_cc_path)
# if (return_code != 0):
# return Response(
Expand Down 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.2.0", **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.2.0", **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.2.0", **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.2.0", **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.2.0", **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.2.0", **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.2.0", **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.2.0", **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.2.0", **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.2.0", **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.2.0", **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.2.0", **envs)
peer_channel_cli = PeerChannel(**envs)
peer_channel_cli.join(
block_file=block_path
)
Loading
Loading