Skip to content
Merged
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
17 changes: 10 additions & 7 deletions src/api-engine/api/lib/configtxgen/configtx.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ def create(self, name, consensus, orderers, peers, orderer_cfg=None, application

for orderer in orderers:
OrdererMSP = "OrdererMSP"
OrdererOrg = dict(Name="Orderer",
ID= OrdererMSP,
MSPDir='{}/{}/crypto-config/ordererOrganizations/{}/msp'.format(self.filepath, orderer["name"], orderer['name'].split(".", 1)[1]),
Policies=dict(Readers=dict(Type="Signature", Rule="OR('{}.member')".format(OrdererMSP)),
Writers=dict(Type="Signature", Rule="OR('{}.member')".format(OrdererMSP)),
Admins=dict(Type="Signature", Rule="OR('{}.admin')".format(OrdererMSP)))
)
OrdererOrg = dict(
Name="Orderer",
ID=OrdererMSP,
MSPDir='{}/{}/crypto-config/ordererOrganizations/{}/msp'.format(self.filepath, orderer["name"], orderer['name'].split(".", 1)[1]),
Policies=dict(
Readers=dict(Type="Signature", Rule="OR('{}.member')".format(OrdererMSP)),
Writers=dict(Type="Signature", Rule="OR('{}.member')".format(OrdererMSP)),
Admins=dict(Type="Signature", Rule="OR('{}.admin')".format(OrdererMSP))
)
)
for host in orderer['hosts']:
OrdererAddress.append('{}.{}:{}'.format(host['name'], orderer['name'].split(".", 1)[1], 7050))
Consenters.append(dict(
Expand Down
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 @@ -48,7 +48,7 @@ def genesis(self, profile="", channelid="", outputblock="genesis.block"):

except subprocess.CalledProcessError as e:
err_msg = "configtxgen genesis fail! "
raise Exception(err_msg+str(e))
raise Exception(err_msg + str(e))

except Exception as e:
err_msg = "configtxgen genesis fail! "
Expand All @@ -62,4 +62,4 @@ def anchorpeer(self, profile, channelid, outputblock):
outputblock: outputblock
return:
"""
pass
pass
7 changes: 4 additions & 3 deletions src/api-engine/api/lib/configtxlator/configtxlator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
LOG = logging.getLogger(__name__)


class ConfigTxLator:
"""
Class represents configtxlator CLI.
Expand All @@ -32,7 +33,7 @@ def proto_encode(self, input, type, output):
"--type={}".format(type),
"--output={}".format(output),
]

LOG.info(" ".join(command))

call(command)
Expand All @@ -57,7 +58,7 @@ def proto_decode(self, input, type, output):
"--input={}".format(input),
"--output={}".format(output),
]

LOG.info(" ".join(command))

call(command)
Expand Down Expand Up @@ -85,7 +86,7 @@ def compute_update(self, original, updated, channel_id, output):
"--channel_id={}".format(channel_id),
"--output={}".format(output),
]

LOG.info(" ".join(command))

call(command)
Expand Down
28 changes: 18 additions & 10 deletions src/api-engine/api/lib/peer/chaincode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

LOG = logging.getLogger(__name__)


class ChainCode(Command):
def __init__(self, version=FABRIC_VERSION, peer=FABRIC_TOOL, **kwargs):
self.peer = peer + "/peer"
Expand Down Expand Up @@ -70,8 +71,12 @@ def lifecycle_query_installed(self, timeout):
"--connTimeout", timeout
]
LOG.info(" ".join(command))
res = subprocess.Popen(command, shell=False,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
res = subprocess.Popen(
command,
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)

stdout, stderr = res.communicate()
return_code = res.returncode
Expand Down Expand Up @@ -164,7 +169,7 @@ def lifecycle_approve_for_my_org(self, orderer_url, channel_name, cc_name,
"--tls",
"--cafile", ORDERER_CA
]

if init_flag:
command.append("--init-required")
if policy:
Expand Down Expand Up @@ -247,7 +252,7 @@ def lifecycle_check_commit_readiness(self, channel_name, cc_name, cc_version, se
"--cafile", ORDERER_CA,
"--output", "json",
]

LOG.info(" ".join(command))

res = subprocess.Popen(command, shell=False,
Expand Down Expand Up @@ -312,13 +317,13 @@ def lifecycle_commit(self, orderer_url, channel_name, cc_name, chaincode_version
command.append(peer_list[i])
command.append("--tlsRootCertFiles")
command.append(peer_root_certs[i])

if init_flag:
command.append("--init-required")
if policy:
command.append("--signature-policy")
command.append(policy)

LOG.info(" ".join(command))
res = os.system(" ".join(command))
res = res >> 8
Expand Down Expand Up @@ -442,9 +447,12 @@ def lifecycle_calculatepackageid(self, cc_path):
:return: calculated packageid
"""
try:
res = subprocess.Popen("{} lifecycle chaincode calculatepackageid {} "
.format(self.peer, cc_path),
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
res = subprocess.Popen(
"{} lifecycle chaincode calculatepackageid {} ".format(self.peer, cc_path),
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
stdout, stderr = res.communicate()
return_code = res.returncode
if return_code == 0:
Expand All @@ -455,4 +463,4 @@ def lifecycle_calculatepackageid(self, cc_path):
return return_code, stderr
except Exception as e:
err_msg = "calculated chaincode packageid failed for {}!".format(e)
raise Exception(err_msg)
raise Exception(err_msg)
9 changes: 5 additions & 4 deletions src/api-engine/api/lib/peer/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

LOG = logging.getLogger(__name__)


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

Expand Down Expand Up @@ -47,13 +48,13 @@ def create(self, channel, orderer_admin_url, block_path, time_out="90s"):
]

LOG.info(" ".join(command))

res = subprocess.run(command, check=True)

except subprocess.CalledProcessError as e:
err_msg = "create channel failed for {}!".format(e)
raise Exception(err_msg+str(e))
raise Exception(err_msg + str(e))

except Exception as e:
err_msg = "create channel failed for {}!".format(e)
raise Exception(err_msg)
Expand Down Expand Up @@ -142,7 +143,7 @@ def fetch(self, block_path, channel, orderer_general_url, max_retries=5, retry_i
LOG.info(" ".join(command))

# Retry fetching the block up to max_retries times
for attempt in range(1, max_retries+1):
for attempt in range(1, max_retries + 1):
try:
LOG.debug("Attempt %d/%d to fetch block", attempt, max_retries)

Expand Down
5 changes: 3 additions & 2 deletions src/api-engine/api/routes/chaincode/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def validate(self, attrs):

@staticmethod
def extension_for_file(file):
extension = file.name.endswith('.tar.gz')
return extension
extension = file.name.endswith('.tar.gz')
return extension


class ChainCodeNetworkSerializer(serializers.Serializer):
id = serializers.UUIDField(help_text="Network ID")
Expand Down
Loading
Loading