Skip to content

Commit

Permalink
Merge branch 'hyperledger:main' into yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
link1697 authored Oct 31, 2024
2 parents b3b14ef + a32997e commit ed167b0
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 31 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
Hyperledger Cello is a blockchain provision and operation system, which helps manage blockchain networks in an efficient way.

1. [Introduction](#introduction)
2. [Main Features](#main-features)
3. [Quick Start](#quick-start)
2. [Quick Start](#quick-start)
3. [Main Features](#main-features)
4. [Documentation](#documentation-getting-started-and-develop-guideline)
5. [Why named cello?](#why-named-cello)
6. [Notice](#incubation-notice)

7. [Inclusive Language Statement](#inclusive-language-statement)

## Introduction

Using Cello, everyone can easily:
Expand Down
4 changes: 0 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ stages:
dockerfile: "build_image/docker/common/nginx/Dockerfile.in"
- imagename: "hyperledger/cello-dashboard"
dockerfile: "build_image/docker/common/dashboard/Dockerfile.in"
# - name: ansibleagent
# images:
# - imagename: "hyperledger/cello-ansible-agent"
# dockerfile: "build_image/docker/agent/ansible/Dockerfile.in"
# - name: fabricoperator
# images:
# - imagename: "hyperledger/cello-k8s-operator-agent"
Expand Down
4 changes: 0 additions & 4 deletions ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ stages:
dockerfile: "build_image/docker/common/nginx/Dockerfile.in"
- imagename: "hyperledger/cello-dashboard"
dockerfile: "build_image/docker/common/dashboard/Dockerfile.in"
- name: ansibleagent
images:
- imagename: "hyperledger/cello-ansible-agent"
dockerfile: "build_image/docker/agent/ansible/Dockerfile.in"
# - name: fabricoperator
# images:
# - imagename: "hyperledger/cello-k8s-operator-agent"
Expand Down
33 changes: 19 additions & 14 deletions src/api-engine/api/lib/peer/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ def __init__(self, version=FABRIC_VERSION, peer=FABRIC_TOOL, **kwargs):
self.osnadmin = peer + "/osnadmin"
super(Channel, self).__init__(version, **kwargs)

def create(self, channel, orderer_url, block_path, time_out="90s"):
def create(self, channel, orderer_admin_url, block_path, time_out="90s"):
try:
res = 0x100
command = ""

if os.getenv("CORE_PEER_TLS_ENABLED") == "false" or os.getenv("CORE_PEER_TLS_ENABLED") is None:
command = "{} channel join --channelID {} --config-block {} -o {}".format(self.osnadmin, channel, block_path, orderer_url)
command = "{} channel join --channelID {} --config-block {} -o {}".format(self.osnadmin, channel, block_path, orderer_admin_url)
else:
ORDERER_CA = os.getenv("ORDERER_CA")
ORDERER_ADMIN_TLS_SIGN_CERT = os.getenv("ORDERER_ADMIN_TLS_SIGN_CERT")
ORDERER_ADMIN_TLS_PRIVATE_KEY = os.getenv("ORDERER_ADMIN_TLS_PRIVATE_KEY")
command = "{} channel join --channelID {} --config-block {} -o {} --ca-file {} --client-cert {} --client-key {}".format(self.osnadmin, channel, block_path, orderer_url, ORDERER_CA, ORDERER_ADMIN_TLS_SIGN_CERT, ORDERER_ADMIN_TLS_PRIVATE_KEY)
command = "{} channel join --channelID {} --config-block {} -o {} --ca-file {} --client-cert {} --client-key {}".format(self.osnadmin, channel, block_path, orderer_admin_url, ORDERER_CA, ORDERER_ADMIN_TLS_SIGN_CERT, ORDERER_ADMIN_TLS_PRIVATE_KEY)

LOG.info(f"Running command: {command}")
LOG.info(f"{command}")
res = os.system(command)

# The return value of os.system is not the result of executing the program. It is a 16 bit number,
Expand Down Expand Up @@ -78,22 +78,27 @@ def update(self, channel, channel_tx, orderer_url):
res = res >> 8
return res

def fetch(self, option, channel):
def fetch(self, block_path, channel, orderer_general_url):
"""
Fetch a specified block, writing it to a file e.g. <channelID>.block.
params:
option: block option newest|oldest|config|(block number).
channel: channel id.
"""
try:
res = subprocess.call(args=[
self.peer,
"channel",
"fetch",
"{}".format(option),
"-c",
channel
])
res = 0x100
command = ""
if os.getenv("CORE_PEER_TLS_ENABLED") == "false" or os.getenv("CORE_PEER_TLS_ENABLED") is None:
command = "{} channel fetch config {} -o {} -c {}".format(self.peer, block_path, orderer_general_url, channel)
else:
ORDERER_CA = os.getenv("ORDERER_CA")
orderer_address = orderer_general_url.split(":")[0]
command = "{} channel fetch config {} -o {} --ordererTLSHostnameOverride {} -c {} --tls --cafile {}".format(self.peer, block_path, orderer_general_url, orderer_address, channel, ORDERER_CA)

LOG.info(f"{command}")
res = os.system(command)

res = res >> 8
except Exception as e:
err_msg = "fetch a specified block failed {}!".format(e)
raise Exception(err_msg)
Expand Down Expand Up @@ -123,7 +128,7 @@ def join(self, block_path):
try:
command = "{} channel join -b {} ".format(self.peer, block_path)

LOG.info(f"Running command: {command}")
LOG.info(f"{command}")

res = os.system(command)

Expand Down
24 changes: 18 additions & 6 deletions src/api-engine/api/routes/channel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,32 @@ def create(self, request):
ConfigTX(org.network.name).create(name, org.network.consensus, _orderers, _peers)
ConfigTxGen(org.network.name).genesis(profile=name, channelid=name, outputblock="{}.block".format(name))

block_path = "{}/{}/{}.block".format(
CELLO_HOME, org.network.name, name)
# osnadmin channel join
ordering_node = Node.objects.get(id=orderers[0])
envs = init_env_vars(ordering_node, org)
peer_channel_cli = PeerChannel(**envs)
peer_channel_cli.create(
channel=name,
orderer_url="{}.{}:{}".format(
orderer_admin_url="{}.{}:{}".format(
ordering_node.name, org.name.split(".", 1)[1], str(7053)),
block_path=block_path
block_path="{}/{}/{}.block".format(
CELLO_HOME, org.network.name, name)
)

# peer channel join
for i in range(len(peers)):
peer_node = Node.objects.get(id=peers[i])
envs = init_env_vars(peer_node, org)
join_peers(envs, block_path)
join_peers(envs, "{}/{}/{}.block".format(
CELLO_HOME, org.network.name, name))

# peer channel fetch
peer_node = Node.objects.get(id=peers[0])
envs = init_env_vars(peer_node, org)
peer_channel_cli = PeerChannel(**envs)
peer_channel_cli.fetch(block_path="{}/{}/config_block.pb".format(CELLO_HOME, org.network.name),
channel=name, orderer_general_url="{}.{}:{}".format(
ordering_node.name, org.name.split(".", 1)[1], str(7050)))

channel = Channel(
name=name,
Expand Down Expand Up @@ -395,7 +406,8 @@ def init_env_vars(node, org):

if(node.type == "orderer"):
envs = {
"ORDERER_CA": "{}/msp/tlscacerts/tlsca.{}-cert.pem".format(dir_certificate, org_domain),
"CORE_PEER_TLS_ENABLED": "true",
"ORDERER_CA": "{}/orderers/{}/msp/tlscacerts/tlsca.{}-cert.pem".format(dir_certificate, node.name + "." + org_domain, org_domain),
"ORDERER_ADMIN_TLS_SIGN_CERT": "{}/orderers/{}/tls/server.crt".format(dir_certificate, node.name + "." + org_domain),
"ORDERER_ADMIN_TLS_PRIVATE_KEY": "{}/orderers/{}/tls/server.key".format(dir_certificate, node.name + "." + org_domain)
}
Expand Down

0 comments on commit ed167b0

Please sign in to comment.