Improve consistency of test-network output

Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
This commit is contained in:
Will Lahti 2020-12-17 16:14:32 -05:00
parent da540b9a39
commit 7acfd149fb
7 changed files with 89 additions and 163 deletions

View file

@ -15,6 +15,8 @@ export PATH=${PWD}/../../bin:${PWD}:$PATH
export FABRIC_CFG_PATH=${PWD} export FABRIC_CFG_PATH=${PWD}
export VERBOSE=false export VERBOSE=false
. ../scripts/utils.sh
# Print the usage message # Print the usage message
function printHelp () { function printHelp () {
echo "Usage: " echo "Usage: "
@ -56,33 +58,24 @@ function generateOrg3() {
if [ "$CRYPTO" == "cryptogen" ]; then if [ "$CRYPTO" == "cryptogen" ]; then
which cryptogen which cryptogen
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
echo "cryptogen tool not found. exiting" fatalln "cryptogen tool not found. exiting"
exit 1
fi fi
echo infoln "Generating certificates using cryptogen tool"
echo "##########################################################"
echo "##### Generate certificates using cryptogen tool #########"
echo "##########################################################"
echo
echo "##########################################################" infoln "Creating Org3 Identities"
echo "############ Create Org3 Identities ######################"
echo "##########################################################"
set -x set -x
cryptogen generate --config=org3-crypto.yaml --output="../organizations" cryptogen generate --config=org3-crypto.yaml --output="../organizations"
res=$? res=$?
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
if [ $res -ne 0 ]; then if [ $res -ne 0 ]; then
echo "Failed to generate certificates..." fatalln "Failed to generate certificates..."
exit 1
fi fi
fi fi
# Create crypto material using Fabric CAs # Create crypto material using Fabric CA
if [ "$CRYPTO" == "Certificate Authorities" ]; then if [ "$CRYPTO" == "Certificate Authorities" ]; then
fabric-ca-client version > /dev/null 2>&1 fabric-ca-client version > /dev/null 2>&1
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "ERROR! fabric-ca-client binary not found.." echo "ERROR! fabric-ca-client binary not found.."
@ -92,10 +85,7 @@ function generateOrg3() {
exit 1 exit 1
fi fi
echo infoln "Generating certificates using Fabric CA"
echo "##########################################################"
echo "##### Generate certificates using Fabric CA ############"
echo "##########################################################"
IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1 IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1
@ -103,16 +93,12 @@ function generateOrg3() {
sleep 10 sleep 10
echo "##########################################################" infoln "Creating Org3 Identities"
echo "############ Create Org3 Identities ######################"
echo "##########################################################"
createOrg3 createOrg3
fi fi
echo infoln "Generating CCP files for Org3"
echo "Generate CCP files for Org3"
./ccp-generate.sh ./ccp-generate.sh
} }
@ -120,22 +106,17 @@ function generateOrg3() {
function generateOrg3Definition() { function generateOrg3Definition() {
which configtxgen which configtxgen
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
echo "configtxgen tool not found. exiting" fatalln "configtxgen tool not found. exiting"
exit 1
fi fi
echo "##########################################################" infoln "Generating Org3 organization definition"
echo "####### Generating Org3 organization definition #########"
echo "##########################################################"
export FABRIC_CFG_PATH=$PWD export FABRIC_CFG_PATH=$PWD
set -x set -x
configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json
res=$? res=$?
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
if [ $res -ne 0 ]; then if [ $res -ne 0 ]; then
echo "Failed to generate Org3 config material..." fatalln "Failed to generate Org3 organization definition..."
exit 1
fi fi
echo
} }
function Org3Up () { function Org3Up () {
@ -146,8 +127,7 @@ function Org3Up () {
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1 IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1
fi fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR !!!! Unable to start Org3 network" fatalln "ERROR !!!! Unable to start Org3 network"
exit 1
fi fi
} }
@ -155,10 +135,7 @@ function Org3Up () {
function addOrg3 () { function addOrg3 () {
# If the test network is not up, abort # If the test network is not up, abort
if [ ! -d ../organizations/ordererOrganizations ]; then if [ ! -d ../organizations/ordererOrganizations ]; then
echo fatalln "ERROR: Please, run ./network.sh up createChannel first."
echo "ERROR: Please, run ./network.sh up createChannel first."
echo
exit 1
fi fi
# generate artifacts if they don't exist # generate artifacts if they don't exist
@ -167,29 +144,21 @@ function addOrg3 () {
generateOrg3Definition generateOrg3Definition
fi fi
echo "Bringing up Org3 peer" infoln "Bringing up Org3 peer"
Org3Up Org3Up
# Use the CLI container to create the configuration transaction needed to add # Use the CLI container to create the configuration transaction needed to add
# Org3 to the network # Org3 to the network
echo infoln "Generating and submitting config tx to add Org3"
echo "###############################################################"
echo "####### Generate and submit config tx to add Org3 #############"
echo "###############################################################"
docker exec cli ./scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE docker exec cli ./scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR !!!! Unable to create config tx" fatalln "ERROR !!!! Unable to create config tx"
exit 1
fi fi
echo infoln "Joining Org3 peers to network"
echo "###############################################################"
echo "############### Join Org3 peers to network ##################"
echo "###############################################################"
docker exec cli ./scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE docker exec cli ./scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR !!!! Unable to join Org3 peers to network" fatalln "ERROR !!!! Unable to join Org3 peers to network"
exit 1
fi fi
} }
@ -279,9 +248,7 @@ while [[ $# -ge 1 ]] ; do
shift shift
;; ;;
* ) * )
echo errorln "Unknown flag: $key"
echo "Unknown flag: $key"
echo
printHelp printHelp
exit 1 exit 1
;; ;;
@ -292,7 +259,7 @@ done
# Determine whether starting, stopping, restarting or generating for announce # Determine whether starting, stopping, restarting or generating for announce
if [ "$MODE" == "up" ]; then if [ "$MODE" == "up" ]; then
echo "Add Org3 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'" infoln "Adding org3 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'"
echo echo
elif [ "$MODE" == "down" ]; then elif [ "$MODE" == "down" ]; then
EXPMODE="Stopping network" EXPMODE="Stopping network"

View file

@ -1,10 +1,14 @@
#!/bin/bash
#
# Copyright IBM Corp All Rights Reserved
#
# SPDX-License-Identifier: Apache-2.0
#
. ../../scripts/utils.sh
function createOrg3 { function createOrg3 {
infoln "Enrolling the CA admin"
echo
echo "Enroll the CA admin"
echo
mkdir -p ../organizations/peerOrganizations/org3.example.com/ mkdir -p ../organizations/peerOrganizations/org3.example.com/
export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org3.example.com/ export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org3.example.com/
@ -30,23 +34,17 @@ function createOrg3 {
Certificate: cacerts/localhost-11054-ca-org3.pem Certificate: cacerts/localhost-11054-ca-org3.pem
OrganizationalUnitIdentifier: orderer' > ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml OrganizationalUnitIdentifier: orderer' > ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml
echo infoln "Registering peer0"
echo "Register peer0"
echo
set -x set -x
fabric-ca-client register --caname ca-org3 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem fabric-ca-client register --caname ca-org3 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
echo infoln "Registering user"
echo "Register user"
echo
set -x set -x
fabric-ca-client register --caname ca-org3 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem fabric-ca-client register --caname ca-org3 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
echo infoln "Registering the org admin"
echo "Register the org admin"
echo
set -x set -x
fabric-ca-client register --caname ca-org3 --id.name org3admin --id.secret org3adminpw --id.type admin --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem fabric-ca-client register --caname ca-org3 --id.name org3admin --id.secret org3adminpw --id.type admin --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -54,18 +52,14 @@ function createOrg3 {
mkdir -p ../organizations/peerOrganizations/org3.example.com/peers mkdir -p ../organizations/peerOrganizations/org3.example.com/peers
mkdir -p ../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com mkdir -p ../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com
echo infoln "Generating the peer0 msp"
echo "## Generate the peer0 msp"
echo
set -x set -x
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp --csr.hosts peer0.org3.example.com --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp --csr.hosts peer0.org3.example.com --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/config.yaml cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/config.yaml
echo infoln "Generating the peer0-tls certificates"
echo "## Generate the peer0-tls certificates"
echo
set -x set -x
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls --enrollment.profile tls --csr.hosts peer0.org3.example.com --csr.hosts localhost --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls --enrollment.profile tls --csr.hosts peer0.org3.example.com --csr.hosts localhost --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -87,9 +81,7 @@ function createOrg3 {
mkdir -p ../organizations/peerOrganizations/org3.example.com/users mkdir -p ../organizations/peerOrganizations/org3.example.com/users
mkdir -p ../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com mkdir -p ../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com
echo infoln "Generating the user msp"
echo "## Generate the user msp"
echo
set -x set -x
fabric-ca-client enroll -u https://user1:user1pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem fabric-ca-client enroll -u https://user1:user1pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -98,13 +90,10 @@ function createOrg3 {
mkdir -p ../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com mkdir -p ../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com
echo infoln "Generating the org admin msp"
echo "## Generate the org admin msp"
echo
set -x set -x
fabric-ca-client enroll -u https://org3admin:org3adminpw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem fabric-ca-client enroll -u https://org3admin:org3adminpw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/config.yaml cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/config.yaml
} }

View file

@ -141,9 +141,9 @@ function createOrgs() {
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
fatalln "cryptogen tool not found. exiting" fatalln "cryptogen tool not found. exiting"
fi fi
infoln "Generate certificates using cryptogen tool" infoln "Generating certificates using cryptogen tool"
infoln "Create Org1 Identities" infoln "Creating Org1 Identities"
set -x set -x
cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output="organizations" cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output="organizations"
@ -153,7 +153,7 @@ function createOrgs() {
fatalln "Failed to generate certificates..." fatalln "Failed to generate certificates..."
fi fi
infoln "Create Org2 Identities" infoln "Creating Org2 Identities"
set -x set -x
cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output="organizations" cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output="organizations"
@ -163,7 +163,7 @@ function createOrgs() {
fatalln "Failed to generate certificates..." fatalln "Failed to generate certificates..."
fi fi
infoln "Create Orderer Org Identities" infoln "Creating Orderer Org Identities"
set -x set -x
cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output="organizations" cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output="organizations"
@ -177,7 +177,7 @@ function createOrgs() {
# Create crypto material using Fabric CA # Create crypto material using Fabric CA
if [ "$CRYPTO" == "Certificate Authorities" ]; then if [ "$CRYPTO" == "Certificate Authorities" ]; then
infoln "Generate certificates using Fabric CA" infoln "Generating certificates using Fabric CA"
IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA up -d 2>&1 IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA up -d 2>&1
@ -192,21 +192,21 @@ function createOrgs() {
fi fi
done done
infoln "Create Org1 Identities" infoln "Creating Org1 Identities"
createOrg1 createOrg1
infoln "Create Org2 Identities" infoln "Creating Org2 Identities"
createOrg2 createOrg2
infoln "Create Orderer Org Identities" infoln "Creating Orderer Org Identities"
createOrderer createOrderer
fi fi
infoln "Generate CCP files for Org1 and Org2" infoln "Generating CCP files for Org1 and Org2"
./organizations/ccp-generate.sh ./organizations/ccp-generate.sh
} }
@ -300,9 +300,6 @@ function createChannel() {
# configtx.yaml is mounted in the cli container, which allows us to use it to # configtx.yaml is mounted in the cli container, which allows us to use it to
# create the channel artifacts # create the channel artifacts
scripts/createChannel.sh $CHANNEL_NAME $CLI_DELAY $MAX_RETRY $VERBOSE scripts/createChannel.sh $CHANNEL_NAME $CLI_DELAY $MAX_RETRY $VERBOSE
if [ $? -ne 0 ]; then
fatalln "Create channel failed"
fi
} }
@ -337,7 +334,6 @@ function networkDown() {
docker run --rm -v $(pwd):/data busybox sh -c 'cd /data && rm -rf addOrg3/fabric-ca/org3/msp addOrg3/fabric-ca/org3/tls-cert.pem addOrg3/fabric-ca/org3/ca-cert.pem addOrg3/fabric-ca/org3/IssuerPublicKey addOrg3/fabric-ca/org3/IssuerRevocationPublicKey addOrg3/fabric-ca/org3/fabric-ca-server.db' docker run --rm -v $(pwd):/data busybox sh -c 'cd /data && rm -rf addOrg3/fabric-ca/org3/msp addOrg3/fabric-ca/org3/tls-cert.pem addOrg3/fabric-ca/org3/ca-cert.pem addOrg3/fabric-ca/org3/IssuerPublicKey addOrg3/fabric-ca/org3/IssuerRevocationPublicKey addOrg3/fabric-ca/org3/fabric-ca-server.db'
# remove channel and script artifacts # remove channel and script artifacts
docker run --rm -v $(pwd):/data busybox sh -c 'cd /data && rm -rf channel-artifacts log.txt *.tar.gz' docker run --rm -v $(pwd):/data busybox sh -c 'cd /data && rm -rf channel-artifacts log.txt *.tar.gz'
fi fi
} }

View file

@ -3,8 +3,7 @@
source scripts/utils.sh source scripts/utils.sh
function createOrg1() { function createOrg1() {
infoln "Enrolling the CA admin"
infoln "Enroll the CA admin"
mkdir -p organizations/peerOrganizations/org1.example.com/ mkdir -p organizations/peerOrganizations/org1.example.com/
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org1.example.com/ export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org1.example.com/
@ -30,17 +29,17 @@ function createOrg1() {
Certificate: cacerts/localhost-7054-ca-org1.pem Certificate: cacerts/localhost-7054-ca-org1.pem
OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml
infoln "Register peer0" infoln "Registering peer0"
set -x set -x
fabric-ca-client register --caname ca-org1 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem fabric-ca-client register --caname ca-org1 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
infoln "Register user" infoln "Registering user"
set -x set -x
fabric-ca-client register --caname ca-org1 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem fabric-ca-client register --caname ca-org1 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
infoln "Register the org admin" infoln "Registering the org admin"
set -x set -x
fabric-ca-client register --caname ca-org1 --id.name org1admin --id.secret org1adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem fabric-ca-client register --caname ca-org1 --id.name org1admin --id.secret org1adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -48,14 +47,14 @@ function createOrg1() {
mkdir -p organizations/peerOrganizations/org1.example.com/peers mkdir -p organizations/peerOrganizations/org1.example.com/peers
mkdir -p organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com mkdir -p organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com
infoln "Generate the peer0 msp" infoln "Generating the peer0 msp"
set -x set -x
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp --csr.hosts peer0.org1.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp --csr.hosts peer0.org1.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/config.yaml cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/config.yaml
infoln "Generate the peer0-tls certificates" infoln "Generating the peer0-tls certificates"
set -x set -x
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls --enrollment.profile tls --csr.hosts peer0.org1.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls --enrollment.profile tls --csr.hosts peer0.org1.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -76,7 +75,7 @@ function createOrg1() {
mkdir -p organizations/peerOrganizations/org1.example.com/users mkdir -p organizations/peerOrganizations/org1.example.com/users
mkdir -p organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com mkdir -p organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com
infoln "Generate the user msp" infoln "Generating the user msp"
set -x set -x
fabric-ca-client enroll -u https://user1:user1pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem fabric-ca-client enroll -u https://user1:user1pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -85,18 +84,16 @@ function createOrg1() {
mkdir -p organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com mkdir -p organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com
infoln "Generate the org admin msp" infoln "Generating the org admin msp"
set -x set -x
fabric-ca-client enroll -u https://org1admin:org1adminpw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem fabric-ca-client enroll -u https://org1admin:org1adminpw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/config.yaml cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/config.yaml
} }
function createOrg2() { function createOrg2() {
infoln "Enrolling the CA admin"
infoln "Enroll the CA admin"
mkdir -p organizations/peerOrganizations/org2.example.com/ mkdir -p organizations/peerOrganizations/org2.example.com/
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org2.example.com/ export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org2.example.com/
@ -122,17 +119,17 @@ function createOrg2() {
Certificate: cacerts/localhost-8054-ca-org2.pem Certificate: cacerts/localhost-8054-ca-org2.pem
OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml
infoln "Register peer0" infoln "Registering peer0"
set -x set -x
fabric-ca-client register --caname ca-org2 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem fabric-ca-client register --caname ca-org2 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
infoln "Register user" infoln "Registering user"
set -x set -x
fabric-ca-client register --caname ca-org2 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem fabric-ca-client register --caname ca-org2 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
infoln "Register the org admin" infoln "Registering the org admin"
set -x set -x
fabric-ca-client register --caname ca-org2 --id.name org2admin --id.secret org2adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem fabric-ca-client register --caname ca-org2 --id.name org2admin --id.secret org2adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -140,14 +137,14 @@ function createOrg2() {
mkdir -p organizations/peerOrganizations/org2.example.com/peers mkdir -p organizations/peerOrganizations/org2.example.com/peers
mkdir -p organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com mkdir -p organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com
infoln "Generate the peer0 msp" infoln "Generating the peer0 msp"
set -x set -x
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp --csr.hosts peer0.org2.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp --csr.hosts peer0.org2.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/config.yaml cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/config.yaml
infoln "Generate the peer0-tls certificates" infoln "Generating the peer0-tls certificates"
set -x set -x
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls --enrollment.profile tls --csr.hosts peer0.org2.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls --enrollment.profile tls --csr.hosts peer0.org2.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -168,7 +165,7 @@ function createOrg2() {
mkdir -p organizations/peerOrganizations/org2.example.com/users mkdir -p organizations/peerOrganizations/org2.example.com/users
mkdir -p organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com mkdir -p organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com
infoln "Generate the user msp" infoln "Generating the user msp"
set -x set -x
fabric-ca-client enroll -u https://user1:user1pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem fabric-ca-client enroll -u https://user1:user1pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -177,18 +174,16 @@ function createOrg2() {
mkdir -p organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com mkdir -p organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com
infoln "Generate the org admin msp" infoln "Generating the org admin msp"
set -x set -x
fabric-ca-client enroll -u https://org2admin:org2adminpw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem fabric-ca-client enroll -u https://org2admin:org2adminpw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/config.yaml cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/config.yaml
} }
function createOrderer() { function createOrderer() {
infoln "Enrolling the CA admin"
infoln "Enroll the CA admin"
mkdir -p organizations/ordererOrganizations/example.com mkdir -p organizations/ordererOrganizations/example.com
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/ordererOrganizations/example.com export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/ordererOrganizations/example.com
@ -214,12 +209,12 @@ function createOrderer() {
Certificate: cacerts/localhost-9054-ca-orderer.pem Certificate: cacerts/localhost-9054-ca-orderer.pem
OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml
infoln "Register orderer" infoln "Registering orderer"
set -x set -x
fabric-ca-client register --caname ca-orderer --id.name orderer --id.secret ordererpw --id.type orderer --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem fabric-ca-client register --caname ca-orderer --id.name orderer --id.secret ordererpw --id.type orderer --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
infoln "Register the orderer admin" infoln "Registering the orderer admin"
set -x set -x
fabric-ca-client register --caname ca-orderer --id.name ordererAdmin --id.secret ordererAdminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem fabric-ca-client register --caname ca-orderer --id.name ordererAdmin --id.secret ordererAdminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -229,14 +224,14 @@ function createOrderer() {
mkdir -p organizations/ordererOrganizations/example.com/orderers/orderer.example.com mkdir -p organizations/ordererOrganizations/example.com/orderers/orderer.example.com
infoln "Generate the orderer msp" infoln "Generating the orderer msp"
set -x set -x
fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/config.yaml cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/config.yaml
infoln "Generate the orderer-tls certificates" infoln "Generating the orderer-tls certificates"
set -x set -x
fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls --enrollment.profile tls --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls --enrollment.profile tls --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
@ -254,11 +249,10 @@ function createOrderer() {
mkdir -p organizations/ordererOrganizations/example.com/users mkdir -p organizations/ordererOrganizations/example.com/users
mkdir -p organizations/ordererOrganizations/example.com/users/Admin@example.com mkdir -p organizations/ordererOrganizations/example.com/users/Admin@example.com
infoln "Generate the admin msp" infoln "Generating the admin msp"
set -x set -x
fabric-ca-client enroll -u https://ordererAdmin:ordererAdminpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem fabric-ca-client enroll -u https://ordererAdmin:ordererAdminpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp/config.yaml cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp/config.yaml
} }

View file

@ -41,7 +41,6 @@ createChannel() {
done done
cat log.txt cat log.txt
verifyResult $res "Channel creation failed" verifyResult $res "Channel creation failed"
successln "Channel '$CHANNEL_NAME' created"
} }
# joinChannel ORG # joinChannel ORG
@ -82,11 +81,12 @@ BLOCKFILE="./channel-artifacts/${CHANNEL_NAME}.block"
## Create channel ## Create channel
infoln "Creating channel ${CHANNEL_NAME}" infoln "Creating channel ${CHANNEL_NAME}"
createChannel createChannel
successln "Channel '$CHANNEL_NAME' created"
## Join all the peers to the channel ## Join all the peers to the channel
infoln "Join Org1 peers to the channel..." infoln "Joining org1 peer to the channel..."
joinChannel 1 joinChannel 1
infoln "Join Org2 peers to the channel..." infoln "Joining org2 peer to the channel..."
joinChannel 2 joinChannel 2
## Set the anchor peers for each org in the channel ## Set the anchor peers for each org in the channel
@ -95,6 +95,4 @@ setAnchorPeer 1
infoln "Setting anchor peer for org2..." infoln "Setting anchor peer for org2..."
setAnchorPeer 2 setAnchorPeer 2
successln "Channel successfully joined" successln "Channel '$CHANNEL_NAME' joined"
exit 0

View file

@ -11,9 +11,6 @@
# chaincode as version 2.0 on peer0.org3. # chaincode as version 2.0 on peer0.org3.
# #
echo
echo "========= Getting Org3 on to your test network ========= "
echo
CHANNEL_NAME="$1" CHANNEL_NAME="$1"
DELAY="$2" DELAY="$2"
TIMEOUT="$3" TIMEOUT="$3"
@ -61,16 +58,13 @@ peer channel fetch 0 $BLOCKFILE -o orderer.example.com:7050 --ordererTLSHostname
res=$? res=$?
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
cat log.txt cat log.txt
verifyResult $res "Fetching config block from orderer has Failed" verifyResult $res "Fetching config block from orderer has failed"
infoln "Joining org3 peer to the channel..."
joinChannel 3 joinChannel 3
echo "Setting anchor peer for org3..." infoln "Setting anchor peer for org3..."
setAnchorPeer 3 setAnchorPeer 3
echo "===================== peer0.org3 joined channel '$CHANNEL_NAME' ===================== "
echo successln "Channel '$CHANNEL_NAME' joined"
echo "========= Finished adding Org3 to your test network! ========= " successln "Org3 peer successfully added to network"
echo
exit 0

View file

@ -25,10 +25,9 @@ MAX_RETRY=5
# imports # imports
. scripts/envVar.sh . scripts/envVar.sh
. scripts/configUpdate.sh . scripts/configUpdate.sh
. scripts/utils.sh
echo infoln "Creating config transaction to add org3 to network"
echo "Creating config transaction to add org3 to network"
echo
# Fetch the config for the channel, writing it to config.json # Fetch the config for the channel, writing it to config.json
fetchChannelConfig 1 ${CHANNEL_NAME} config.json fetchChannelConfig 1 ${CHANNEL_NAME} config.json
@ -41,24 +40,13 @@ jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[
# Compute a config update, based on the differences between config.json and modified_config.json, write it as a transaction to org3_update_in_envelope.pb # Compute a config update, based on the differences between config.json and modified_config.json, write it as a transaction to org3_update_in_envelope.pb
createConfigUpdate ${CHANNEL_NAME} config.json modified_config.json org3_update_in_envelope.pb createConfigUpdate ${CHANNEL_NAME} config.json modified_config.json org3_update_in_envelope.pb
echo infoln "Signing config transaction"
echo "========= Config transaction to add org3 to network created ===== "
echo
echo "Signing config transaction"
echo
signConfigtxAsPeerOrg 1 org3_update_in_envelope.pb signConfigtxAsPeerOrg 1 org3_update_in_envelope.pb
echo infoln "Submitting transaction from a different peer (peer0.org2) which also signs it"
echo "========= Submitting transaction from a different peer (peer0.org2) which also signs it ========= "
echo
setGlobals 2 setGlobals 2
set -x set -x
peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${ORDERER_CA} peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${ORDERER_CA}
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
echo successln "Config transaction to add org3 to network submitted"
echo "========= Config transaction to add org3 to network submitted! =========== "
echo
exit 0