mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-21 17:15:10 +00:00
fix addOrg3 for test network
Also added testing addOrg3 to build pipeline Signed-off-by: D <d_kelsey@uk.ibm.com>
This commit is contained in:
parent
dcc5e5650c
commit
b2d74ddbab
4 changed files with 44 additions and 32 deletions
|
|
@ -12,8 +12,11 @@ function print() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNetwork() {
|
function createNetwork() {
|
||||||
print "Creating network"
|
print "Creating 3 Org network"
|
||||||
./network.sh up createChannel -ca -s couchdb
|
./network.sh up createChannel -ca -s couchdb
|
||||||
|
cd addOrg3
|
||||||
|
./addOrg3.sh up -ca -s couchdb
|
||||||
|
cd ..
|
||||||
print "Deploying ${CHAINCODE_NAME} chaincode"
|
print "Deploying ${CHAINCODE_NAME} chaincode"
|
||||||
./network.sh deployCC -ccn "${CHAINCODE_NAME}" -ccp "${CHAINCODE_PATH}/chaincode-${CHAINCODE_LANGUAGE}" -ccv 1 -ccs 1 -ccl "${CHAINCODE_LANGUAGE}"
|
./network.sh deployCC -ccn "${CHAINCODE_NAME}" -ccp "${CHAINCODE_PATH}/chaincode-${CHAINCODE_LANGUAGE}" -ccv 1 -ccs 1 -ccl "${CHAINCODE_LANGUAGE}"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ function generateOrg3() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
infoln "Generating certificates using Fabric CA"
|
infoln "Generating certificates using Fabric CA"
|
||||||
${CONTAINER_CLI_COMPOSE} -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1
|
${CONTAINER_CLI_COMPOSE} -f ${COMPOSE_FILE_CA_BASE} -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1
|
||||||
|
|
||||||
. fabric-ca/registerEnroll.sh
|
. fabric-ca/registerEnroll.sh
|
||||||
|
|
||||||
|
|
@ -125,13 +125,13 @@ function Org3Up () {
|
||||||
# start org3 nodes
|
# start org3 nodes
|
||||||
|
|
||||||
if [ "$CONTAINER_CLI" == "podman" ]; then
|
if [ "$CONTAINER_CLI" == "podman" ]; then
|
||||||
cp ../podman/core.ymal ../../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/
|
cp ../podman/core.yaml ../../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${DATABASE}" == "couchdb" ]; then
|
if [ "${DATABASE}" == "couchdb" ]; then
|
||||||
DOCKER_SOCK=${DOCKER_SOCK} ${CONTAINER_CLI_COMPOSE} -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH_ORG3 up -d 2>&1
|
DOCKER_SOCK=${DOCKER_SOCK} ${CONTAINER_CLI_COMPOSE} -f ${COMPOSE_FILE_BASE} -f $COMPOSE_FILE_ORG3 -f ${COMPOSE_FILE_COUCH_BASE} -f $COMPOSE_FILE_COUCH_ORG3 up -d 2>&1
|
||||||
else
|
else
|
||||||
DOCKER_SOCK=${DOCKER_SOCK} ${CONTAINER_CLI_COMPOSE} -f $COMPOSE_FILE_ORG3 up -d 2>&1
|
DOCKER_SOCK=${DOCKER_SOCK} ${CONTAINER_CLI_COMPOSE} -f ${COMPOSE_FILE_BASE} -f $COMPOSE_FILE_ORG3 up -d 2>&1
|
||||||
fi
|
fi
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
fatalln "ERROR !!!! Unable to start Org3 network"
|
fatalln "ERROR !!!! Unable to start Org3 network"
|
||||||
|
|
@ -185,11 +185,14 @@ CLI_DELAY=3
|
||||||
# channel name defaults to "mychannel"
|
# channel name defaults to "mychannel"
|
||||||
CHANNEL_NAME="mychannel"
|
CHANNEL_NAME="mychannel"
|
||||||
# use this as the docker compose couch file
|
# use this as the docker compose couch file
|
||||||
COMPOSE_FILE_COUCH_ORG3=${CONTAINER_CLI}/docker-compose-couch-org3.yaml
|
COMPOSE_FILE_COUCH_BASE=compose/compose-couch-org3.yaml
|
||||||
|
COMPOSE_FILE_COUCH_ORG3=compose/${CONTAINER_CLI}/docker-compose-couch-org3.yaml
|
||||||
# use this as the default docker-compose yaml definition
|
# use this as the default docker-compose yaml definition
|
||||||
COMPOSE_FILE_ORG3=${CONTAINER_CLI}/docker-compose-org3.yaml
|
COMPOSE_FILE_BASE=compose/compose-org3.yaml
|
||||||
|
COMPOSE_FILE_ORG3=compose/${CONTAINER_CLI}/docker-compose-org3.yaml
|
||||||
# certificate authorities compose file
|
# certificate authorities compose file
|
||||||
COMPOSE_FILE_CA_ORG3=${CONTAINER_CLI}/docker-compose-ca-org3.yaml
|
COMPOSE_FILE_CA_BASE=compose/compose-ca-org3.yaml
|
||||||
|
COMPOSE_FILE_CA_ORG3=compose/${CONTAINER_CLI}/docker-compose-ca-org3.yaml
|
||||||
# database
|
# database
|
||||||
DATABASE="leveldb"
|
DATABASE="leveldb"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,6 @@
|
||||||
|
|
||||||
version: '3.7'
|
version: '3.7'
|
||||||
|
|
||||||
volumes:
|
|
||||||
peer0.org3.example.com:
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
test:
|
test:
|
||||||
name: fabric_test
|
name: fabric_test
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
# prepending $PWD/../bin to PATH to ensure we are picking up the correct binaries
|
# prepending $PWD/../bin to PATH to ensure we are picking up the correct binaries
|
||||||
# this may be commented out to resolve installed version of tools if desired
|
# this may be commented out to resolve installed version of tools if desired
|
||||||
#
|
#
|
||||||
# However using PWD in the path has the side effect that location that
|
# However using PWD in the path has the side effect that location that
|
||||||
# this script is run from is critical. To ease this, get the directory
|
# this script is run from is critical. To ease this, get the directory
|
||||||
# this script is actually in and infer location from there. (putting first)
|
# this script is actually in and infer location from there. (putting first)
|
||||||
|
|
||||||
|
|
@ -251,13 +251,13 @@ function networkUp() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COMPOSE_FILES="-f compose/${COMPOSE_FILE_BASE} -f compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${COMPOSE_FILE_BASE}"
|
COMPOSE_FILES="-f compose/${COMPOSE_FILE_BASE} -f compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${COMPOSE_FILE_BASE}"
|
||||||
|
|
||||||
if [ "${DATABASE}" == "couchdb" ]; then
|
if [ "${DATABASE}" == "couchdb" ]; then
|
||||||
COMPOSE_FILES="${COMPOSE_FILES} -f compose/${COMPOSE_FILE_COUCH} -f compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${COMPOSE_FILE_COUCH}"
|
COMPOSE_FILES="${COMPOSE_FILES} -f compose/${COMPOSE_FILE_COUCH} -f compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${COMPOSE_FILE_COUCH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DOCKER_SOCK="${DOCKER_SOCK}" ${CONTAINER_CLI_COMPOSE} ${COMPOSE_FILES} up -d 2>&1
|
DOCKER_SOCK="${DOCKER_SOCK}" ${CONTAINER_CLI_COMPOSE} ${COMPOSE_FILES} up -d 2>&1
|
||||||
|
|
||||||
$CONTAINER_CLI ps -a
|
$CONTAINER_CLI ps -a
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
fatalln "Unable to start network"
|
fatalln "Unable to start network"
|
||||||
|
|
@ -267,20 +267,20 @@ function networkUp() {
|
||||||
# call the script to create the channel, join the peers of org1 and org2,
|
# call the script to create the channel, join the peers of org1 and org2,
|
||||||
# and then update the anchor peers for each organization
|
# and then update the anchor peers for each organization
|
||||||
function createChannel() {
|
function createChannel() {
|
||||||
# Bring up the network if it is not already up.
|
# Bring up the network if it is not already up.
|
||||||
bringUpNetwork="false"
|
bringUpNetwork="false"
|
||||||
|
|
||||||
if ! $CONTAINER_CLI info > /dev/null 2>&1 ; then
|
if ! $CONTAINER_CLI info > /dev/null 2>&1 ; then
|
||||||
fatalln "$CONTAINER_CLI network is required to be running to create a channel"
|
fatalln "$CONTAINER_CLI network is required to be running to create a channel"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if all containers are present
|
# check if all containers are present
|
||||||
CONTAINERS=($($CONTAINER_CLI ps | grep hyperledger/ | awk '{print $2}'))
|
CONTAINERS=($($CONTAINER_CLI ps | grep hyperledger/ | awk '{print $2}'))
|
||||||
len=$(echo ${#CONTAINERS[@]})
|
len=$(echo ${#CONTAINERS[@]})
|
||||||
|
|
||||||
if [[ $len -ge 4 ]] && [[ ! -d "organizations/peerOrganizations" ]]; then
|
if [[ $len -ge 4 ]] && [[ ! -d "organizations/peerOrganizations" ]]; then
|
||||||
echo "Bringing network down to sync certs with containers"
|
echo "Bringing network down to sync certs with containers"
|
||||||
networkDown
|
networkDown
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ $len -lt 4 ]] || [[ ! -d "organizations/peerOrganizations" ]] && bringUpNetwork="true" || echo "Network Running Already"
|
[[ $len -lt 4 ]] || [[ ! -d "organizations/peerOrganizations" ]] && bringUpNetwork="true" || echo "Network Running Already"
|
||||||
|
|
@ -317,18 +317,25 @@ function deployCCAAS() {
|
||||||
# Tear down running network
|
# Tear down running network
|
||||||
function networkDown() {
|
function networkDown() {
|
||||||
|
|
||||||
|
COMPOSE_BASE_FILES="-f compose/${COMPOSE_FILE_BASE} -f compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${COMPOSE_FILE_BASE}"
|
||||||
|
COMPOSE_COUCH_FILES="-f compose/${COMPOSE_FILE_COUCH} -f compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${COMPOSE_FILE_COUCH}"
|
||||||
|
COMPOSE_CA_FILES="-f compose/${COMPOSE_FILE_CA} -f compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${COMPOSE_FILE_CA}"
|
||||||
|
COMPOSE_FILES="${COMPOSE_BASE_FILES} ${COMPOSE_COUCH_FILES} ${COMPOSE_CA_FILES}"
|
||||||
|
|
||||||
# stop org3 containers also in addition to org1 and org2, in case we were running sample to add org3
|
# stop org3 containers also in addition to org1 and org2, in case we were running sample to add org3
|
||||||
for descriptor in $COMPOSE_FILE_BASE $COMPOSE_FILE_COUCH $COMPOSE_FILE_CA #$COMPOSE_FILE_COUCH_ORG3 $COMPOSE_FILE_ORG3
|
COMPOSE_ORG3_BASE_FILES="-f addOrg3/compose/${COMPOSE_FILE_ORG3_BASE} -f addOrg3/compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${COMPOSE_FILE_ORG3_BASE}"
|
||||||
do
|
COMPOSE_ORG3_COUCH_FILES="-f addOrg3/compose/${COMPOSE_FILE_ORG3_COUCH} -f addOrg3/compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${COMPOSE_FILE_ORG3_COUCH}"
|
||||||
infoln "Decomposing $descriptor"
|
COMPOSE_ORG3_CA_FILES="-f addOrg3/compose/${COMPOSE_FILE_ORG3_CA} -f addOrg3/compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${COMPOSE_FILE_ORG3_CA}"
|
||||||
if [ "${CONTAINER_CLI}" == "docker" ]; then
|
COMPOSE_ORG3_FILES="${COMPOSE_ORG3_BASE_FILES} ${COMPOSE_ORG3_COUCH_FILES} ${COMPOSE_ORG3_CA_FILES}"
|
||||||
DOCKER_SOCK=$DOCKER_SOCK ${CONTAINER_CLI_COMPOSE} -f compose/$descriptor -f compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${descriptor} down --volumes --remove-orphans
|
|
||||||
elif [ "${CONTAINER_CLI}" == "podman" ]; then
|
if [ "${CONTAINER_CLI}" == "docker" ]; then
|
||||||
${CONTAINER_CLI_COMPOSE} -f compose/$descriptor -f compose/${CONTAINER_CLI}/${CONTAINER_CLI}-${descriptor} down --volumes
|
DOCKER_SOCK=$DOCKER_SOCK ${CONTAINER_CLI_COMPOSE} ${COMPOSE_FILES} ${COMPOSE_ORG3_FILES} down --volumes --remove-orphans
|
||||||
else
|
elif [ "${CONTAINER_CLI}" == "podman" ]; then
|
||||||
fatalln "Container CLI ${CONTAINER_CLI} not supported"
|
${CONTAINER_CLI_COMPOSE} ${COMPOSE_FILES} ${COMPOSE_ORG3_FILES} down --volumes
|
||||||
fi
|
else
|
||||||
done
|
fatalln "Container CLI ${CONTAINER_CLI} not supported"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Don't remove the generated artifacts -- note, the ledgers are always removed
|
# Don't remove the generated artifacts -- note, the ledgers are always removed
|
||||||
if [ "$MODE" != "restart" ]; then
|
if [ "$MODE" != "restart" ]; then
|
||||||
|
|
@ -377,10 +384,12 @@ COMPOSE_FILE_BASE=compose-test-net.yaml
|
||||||
COMPOSE_FILE_COUCH=compose-couch.yaml
|
COMPOSE_FILE_COUCH=compose-couch.yaml
|
||||||
# certificate authorities compose file
|
# certificate authorities compose file
|
||||||
COMPOSE_FILE_CA=compose-ca.yaml
|
COMPOSE_FILE_CA=compose-ca.yaml
|
||||||
# use this as the docker compose couch file for org3
|
|
||||||
COMPOSE_FILE_COUCH_ORG3=addOrg3/${CONTAINER_CLI}/docker-compose-couch-org3.yaml
|
|
||||||
# use this as the default docker-compose yaml definition for org3
|
# use this as the default docker-compose yaml definition for org3
|
||||||
COMPOSE_FILE_ORG3=addOrg3/${CONTAINER_CLI}/docker-compose-org3.yaml
|
COMPOSE_FILE_ORG3_BASE=compose-org3.yaml
|
||||||
|
# use this as the docker compose couch file for org3
|
||||||
|
COMPOSE_FILE_ORG3_COUCH=compose-couch-org3.yaml
|
||||||
|
# certificate authorities compose file
|
||||||
|
COMPOSE_FILE_ORG3_CA=compose-ca-org3.yaml
|
||||||
#
|
#
|
||||||
# chaincode language defaults to "NA"
|
# chaincode language defaults to "NA"
|
||||||
CC_SRC_LANGUAGE="NA"
|
CC_SRC_LANGUAGE="NA"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue