addOrg4.sh

This commit is contained in:
Kurt Seifried 2021-03-10 09:43:04 -07:00
parent 862b7a86cd
commit 8320010b8c
No known key found for this signature in database
GPG key ID: F15CADC4A00F8174
2 changed files with 55 additions and 49 deletions

View file

@ -20,11 +20,11 @@ export VERBOSE=false
# Print the usage message
function printHelp () {
echo "Usage: "
echo " addOrg3.sh up|down|generate [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>]"
echo " addOrg3.sh -h|--help (print this message)"
echo " addOrg4.sh up|down|generate [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>]"
echo " addOrg4.sh -h|--help (print this message)"
echo " <mode> - one of 'up', 'down', or 'generate'"
echo " - 'up' - add org3 to the sample network. You need to bring up the test network and create a channel first."
echo " - 'down' - bring down the test network and org3 nodes"
echo " - 'up' - add org4 to the sample network. You need to bring up the test network and create a channel first."
echo " - 'down' - bring down the test network and org4 nodes"
echo " - 'generate' - generate required certificates and org definition"
echo " -c <channel name> - test network channel name (defaults to \"mychannel\")"
echo " -ca <use CA> - Use a CA to generate the crypto material"
@ -36,14 +36,14 @@ function printHelp () {
echo "Typically, one would first generate the required certificates and "
echo "genesis block, then bring up the network. e.g.:"
echo
echo " addOrg3.sh generate"
echo " addOrg3.sh up"
echo " addOrg3.sh up -c mychannel -s couchdb"
echo " addOrg3.sh down"
echo " addOrg4.sh generate"
echo " addOrg4.sh up"
echo " addOrg4.sh up -c mychannel -s couchdb"
echo " addOrg4.sh down"
echo
echo "Taking all defaults:"
echo " addOrg3.sh up"
echo " addOrg3.sh down"
echo " addOrg4.sh up"
echo " addOrg4.sh down"
}
# We use the cryptogen tool to generate the cryptographic material
@ -51,7 +51,7 @@ function printHelp () {
# be put in the organizations folder with org1 and org2
# Create Organziation crypto material using cryptogen or CAs
function generateOrg3() {
function generateOrg4() {
# Create crypto material using cryptogen
if [ "$CRYPTO" == "cryptogen" ]; then
which cryptogen
@ -60,10 +60,10 @@ function generateOrg3() {
fi
infoln "Generating certificates using cryptogen tool"
infoln "Creating Org3 Identities"
infoln "Creating Org4 Identities"
set -x
cryptogen generate --config=org3-crypto.yaml --output="../organizations"
cryptogen generate --config=org4-crypto.yaml --output="../organizations"
res=$?
{ set +x; } 2>/dev/null
if [ $res -ne 0 ]; then
@ -84,78 +84,78 @@ function generateOrg3() {
fi
infoln "Generating certificates using Fabric CA"
docker-compose -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1
docker-compose -f $COMPOSE_FILE_CA_ORG4 up -d 2>&1
. fabric-ca/registerEnroll.sh
sleep 10
infoln "Creating Org3 Identities"
createOrg3
infoln "Creating Org4 Identities"
createOrg4
fi
infoln "Generating CCP files for Org3"
infoln "Generating CCP files for Org4"
./ccp-generate.sh
}
# Generate channel configuration transaction
function generateOrg3Definition() {
function generateOrg4Definition() {
which configtxgen
if [ "$?" -ne 0 ]; then
fatalln "configtxgen tool not found. exiting"
fi
infoln "Generating Org3 organization definition"
infoln "Generating Org4 organization definition"
export FABRIC_CFG_PATH=$PWD
set -x
configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json
configtxgen -printOrg Org4MSP > ../organizations/peerOrganizations/org4.example.com/org4.json
res=$?
{ set +x; } 2>/dev/null
if [ $res -ne 0 ]; then
fatalln "Failed to generate Org3 organization definition..."
fatalln "Failed to generate Org4 organization definition..."
fi
}
function Org3Up () {
# start org3 nodes
function Org4Up () {
# start org4 nodes
if [ "${DATABASE}" == "couchdb" ]; then
docker-compose -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH_ORG3 up -d 2>&1
docker-compose -f $COMPOSE_FILE_ORG4 -f $COMPOSE_FILE_COUCH_ORG4 up -d 2>&1
else
docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1
docker-compose -f $COMPOSE_FILE_ORG4 up -d 2>&1
fi
if [ $? -ne 0 ]; then
fatalln "ERROR !!!! Unable to start Org3 network"
fatalln "ERROR !!!! Unable to start Org4 network"
fi
}
# Generate the needed certificates, the genesis block and start the network.
function addOrg3 () {
function addOrg4 () {
# If the test network is not up, abort
if [ ! -d ../organizations/ordererOrganizations ]; then
fatalln "ERROR: Please, run ./network.sh up createChannel first."
fi
# generate artifacts if they don't exist
if [ ! -d "../organizations/peerOrganizations/org3.example.com" ]; then
generateOrg3
generateOrg3Definition
if [ ! -d "../organizations/peerOrganizations/org4.example.com" ]; then
generateOrg4
generateOrg4Definition
fi
infoln "Bringing up Org3 peer"
Org3Up
infoln "Bringing up Org4 peer"
Org4Up
# Use the CLI container to create the configuration transaction needed to add
# Org3 to the network
infoln "Generating and submitting config tx to add Org3"
docker exec cli ./scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
# Org4 to the network
infoln "Generating and submitting config tx to add Org4"
docker exec cli ./scripts/org4-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
if [ $? -ne 0 ]; then
fatalln "ERROR !!!! Unable to create config tx"
fi
infoln "Joining Org3 peers to network"
docker exec cli ./scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
infoln "Joining Org4 peers to network"
docker exec cli ./scripts/org4-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
if [ $? -ne 0 ]; then
fatalln "ERROR !!!! Unable to join Org3 peers to network"
fatalln "ERROR !!!! Unable to join Org4 peers to network"
fi
}
@ -175,11 +175,11 @@ CLI_DELAY=3
# channel name defaults to "mychannel"
CHANNEL_NAME="mychannel"
# use this as the docker compose couch file
COMPOSE_FILE_COUCH_ORG3=docker/docker-compose-couch-org3.yaml
COMPOSE_FILE_COUCH_ORG4=docker/docker-compose-couch-org4.yaml
# use this as the default docker-compose yaml definition
COMPOSE_FILE_ORG3=docker/docker-compose-org3.yaml
COMPOSE_FILE_ORG4=docker/docker-compose-org4.yaml
# certificate authorities compose file
COMPOSE_FILE_CA_ORG3=docker/docker-compose-ca-org3.yaml
COMPOSE_FILE_CA_ORG4=docker/docker-compose-ca-org4.yaml
# database
DATABASE="leveldb"
@ -238,12 +238,12 @@ done
# Determine whether starting, stopping, restarting or generating for announce
if [ "$MODE" == "up" ]; then
infoln "Adding org3 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'"
infoln "Adding org4 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'"
echo
elif [ "$MODE" == "down" ]; then
EXPMODE="Stopping network"
elif [ "$MODE" == "generate" ]; then
EXPMODE="Generating certs and organization definition for Org3"
EXPMODE="Generating certs and organization definition for Org4"
else
printHelp
exit 1
@ -251,12 +251,12 @@ fi
#Create the network using docker compose
if [ "${MODE}" == "up" ]; then
addOrg3
addOrg4
elif [ "${MODE}" == "down" ]; then ## Clear the network
networkDown
elif [ "${MODE}" == "generate" ]; then ## Generate Artifacts
generateOrg3
generateOrg3Definition
generateOrg4
generateOrg4Definition
else
printHelp
exit 1

View file

@ -5,13 +5,19 @@
# SPDX-License-Identifier: Apache-2.0
#
function createOrg3 {
#
# 4 5 6
#
function createOrg4 {
infoln "Enrolling the CA admin"
mkdir -p ../organizations/peerOrganizations/org3.example.com/
mkdir -p ../organizations/peerOrganizations/org4.example.com/
export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org3.example.com/
export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org4.example.com/
set -x
#
# 4 5 6
#
fabric-ca-client enroll -u https://admin:adminpw@localhost:11054 --caname ca-org3 --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem"
{ set +x; } 2>/dev/null