From 75e293183b8f2ccd608d49c5cdcf628b49ee133f Mon Sep 17 00:00:00 2001 From: Keith Smith Date: Fri, 22 Jun 2018 09:25:05 -0400 Subject: [PATCH] [FAB-10811] fabric-ca sample is broken on v1.2 The Profile section of configtx.yaml must now be at the end of the file, so the building of this file dynamically must be updated. I also updated the version of the fabric CA in bootstrap.sh to 1.2.0. Change-Id: Ifabccebc901f74569cfa1fe1d824fbcd26c4ffd1 Signed-off-by: Keith Smith Signed-off-by: Christopher Ferris --- fabric-ca/README.md | 52 +++++++++++----------- fabric-ca/bootstrap.sh | 10 +---- fabric-ca/scripts/setup-fabric.sh | 72 +++++++++++++++---------------- scripts/bootstrap.sh | 4 +- 4 files changed, 66 insertions(+), 72 deletions(-) diff --git a/fabric-ca/README.md b/fabric-ca/README.md index 9c11e16f61..d704faa9ad 100755 --- a/fabric-ca/README.md +++ b/fabric-ca/README.md @@ -5,50 +5,50 @@ The Hyperledger Fabric CA sample demonstrates the following: * How to use the Hyperledger Fabric CA client and server to generate all crypto material rather than using cryptogen. The cryptogen tool is not intended for a production environment because it generates all private keys in one location - which must then be copied to the appropriate host or container. This sample demonstrates - how to generate crypto material for orderers, peers, administrators, and end - users so that private keys never leave the host or container in which they are generated. + which must then be copied to the appropriate host or container. This sample + demonstrates how to generate crypto material for orderers, peers, + administrators, and end users so that private keys never leave the host or + container in which they are generated. -* How to use Attribute-Based Access Control (ABAC). See fabric-samples/chaincode/abac/abac.go and - note the use of the *github.com/hyperledger/fabric/core/chaincode/lib/cid* package to extract - attributes from the invoker's identity. Only identities with the *abac.init* attribute value of - *true* can successfully call the *Init* function to instantiate the chaincode. +* How to use Attribute-Based Access Control (ABAC). See + fabric-samples/chaincode/abac/abac.go and note the use of the *github.com/hyperledger/fabric/core/chaincode/lib/cid* package to extract + attributes from the invoker's identity. Only identities with the *abac.init* + attribute value of *true* can successfully call the *Init* function to + instantiate the chaincode. ## Running this sample 1. The following images are required to run this sample: *hyperledger/fabric-ca-orderer*, *hyperledger/fabric-ca-peer*, and *hyperledger/fabric-ca-tools* - #### 1.1.0 - Run the *bootstrap.sh* script provided with this sample to download the required images for - fabric-ca sample. + #### install the images + Run the *bootstrap.sh* script provided with this sample to download the + required images for fabric-ca sample. For the v1.2.0-rc1 release, you + will need to specify the version as follows: - #### 1.0.X - These images are new in the v1.1.0 release of the *github.com/hyperledger/fabric-ca*. - In order to run this sample prior to the v1.1.0 release, you must build these - images manually as follows: - a) pull the master branch of the *github.com/hyperledger/fabric* and - *github.com/hyperledger/fabric-ca* repositories; - b) make sure these repositories are on your GOPATH; - c) run the *build-images.sh* script provided with this sample. + ``` + bootstrap.sh 1.2.0-rc1 + ``` -2. To run this sample, simply run the *start.sh* script. You may do this multiple times in a row as needed -since the *start.sh* script cleans up before starting each time. +2. To run this sample, simply run the *start.sh* script. You may do this +multiple times in a row as needed since the *start.sh* script cleans up before +starting each time. 3. To stop the containers which are started by the *start.sh* script, you may run the *stop.sh* script. ## Understanding this sample -There are some variables at the top of *fabric-samples/fabric-ca/scripts/env.sh* script which -define the names and topology of this sample. You may modify these as described in the comments -of the script in order to customize this sample. By default, there are three organizations. -The orderer organization is *org0*, and two peer organizations are *org1* and *org2*. +There are some variables at the top of *fabric-samples/fabric-ca/scripts/env.sh* +script which define the names and topology of this sample. You may modify these +as described in the comments of the script in order to customize this sample. +By default, there are three organizations. The orderer organization is *org0*, +and two peer organizations are *org1* and *org2*. The *start.sh* script first builds the *docker-compose.yml* file (by invoking the *makeDocker.sh* script) and then starts the docker containers. The *data* directory is a volume mount for all containers. -This volume mount is not be needed in a real scenario, but it is used by this sample -for the following reasons: +This volume mount is not be needed in a real scenario, but it is used by this +sample for the following reasons: a) so that all containers can write their logs to a common directory (i.e. *the *data/logs* directory) to make debugging easier; b) to synchronize the sequence in which containers start as described below diff --git a/fabric-ca/bootstrap.sh b/fabric-ca/bootstrap.sh index f536c16a16..ad096e2403 100755 --- a/fabric-ca/bootstrap.sh +++ b/fabric-ca/bootstrap.sh @@ -6,13 +6,9 @@ # # current version of fabric-ca released -export CA_VERSION=${1:-1.1.0} -export ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}') -#Set MARCH variable i.e ppc64le,s390x,x86_64,i386 -MARCH=`uname -m` +export CA_TAG=${1:-1.2.0} dockerCaPull() { - local CA_TAG=$1 echo "==> FABRIC CA IMAGE" echo for image in "" "-tools" "-orderer" "-peer"; do @@ -21,10 +17,8 @@ dockerCaPull() { done } -: ${CA_TAG:="$MARCH-$CA_VERSION"} - echo "===> Pulling fabric ca Image" dockerCaPull ${CA_TAG} echo "===> List out hyperledger docker images" -docker images | grep hyperledger* +docker images | grep hyperledger/fabric-ca diff --git a/fabric-ca/scripts/setup-fabric.sh b/fabric-ca/scripts/setup-fabric.sh index 90beeb806e..48c3c57a34 100755 --- a/fabric-ca/scripts/setup-fabric.sh +++ b/fabric-ca/scripts/setup-fabric.sh @@ -124,7 +124,42 @@ function printPeerOrg { function makeConfigTxYaml { { - echo "################################################################################ + echo " +################################################################################ +# +# Section: Organizations +# +# - This section defines the different organizational identities which will +# be referenced later in the configuration. +# +################################################################################ +Organizations:" + + for ORG in $ORDERER_ORGS; do + printOrdererOrg $ORG + done + + for ORG in $PEER_ORGS; do + printPeerOrg $ORG 1 + done + + echo " +################################################################################ +# +# SECTION: Application +# +# This section defines the values to encode into a config transaction or +# genesis block for application related parameters +# +################################################################################ +Application: &ApplicationDefaults + + # Organizations is the list of orgs which are defined as participants on + # the application side of the network + Organizations: +" + echo " +################################################################################ # # Profile # @@ -208,41 +243,6 @@ Profiles: echo " - *${ORG_CONTAINER_NAME}" done - echo " -################################################################################ -# -# Section: Organizations -# -# - This section defines the different organizational identities which will -# be referenced later in the configuration. -# -################################################################################ -Organizations:" - - for ORG in $ORDERER_ORGS; do - printOrdererOrg $ORG - done - - for ORG in $PEER_ORGS; do - printPeerOrg $ORG 1 - done - - echo " -################################################################################ -# -# SECTION: Application -# -# This section defines the values to encode into a config transaction or -# genesis block for application related parameters -# -################################################################################ -Application: &ApplicationDefaults - - # Organizations is the list of orgs which are defined as participants on - # the application side of the network - Organizations: -" - } > /etc/hyperledger/fabric/configtx.yaml # Copy it to the data directory to make debugging easier cp /etc/hyperledger/fabric/configtx.yaml /$DATA diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 37beaf4d93..b02d90047c 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -6,11 +6,11 @@ # # if version not passed in, default to latest released version -export VERSION=1.1.0 +export VERSION=1.2.0 # if ca version not passed in, default to latest released version export CA_VERSION=$VERSION # current version of thirdparty images (couchdb, kafka and zookeeper) released -export THIRDPARTY_IMAGE_VERSION=0.4.7 +export THIRDPARTY_IMAGE_VERSION=0.4.8 export ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')") export MARCH=$(uname -m)