From 60e72502e997017317fad143f656cfbf000e013f Mon Sep 17 00:00:00 2001 From: Baohua Yang Date: Mon, 25 Dec 2017 10:28:59 +0800 Subject: [PATCH] Generate artifacts for new org --- .../latest/scripts/gen_config.sh | 28 +++++++++++++++-- .../latest/scripts/variables.sh | 3 ++ .../latest/solo/org3/configtx.yaml | 31 +++++++++++++++++++ .../latest/solo/org3/crypto-config.yaml | 18 +++++++++++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 hyperledger_fabric/latest/solo/org3/configtx.yaml create mode 100644 hyperledger_fabric/latest/solo/org3/crypto-config.yaml diff --git a/hyperledger_fabric/latest/scripts/gen_config.sh b/hyperledger_fabric/latest/scripts/gen_config.sh index a5b4d8d6..e5be7cd5 100644 --- a/hyperledger_fabric/latest/scripts/gen_config.sh +++ b/hyperledger_fabric/latest/scripts/gen_config.sh @@ -66,10 +66,34 @@ echo_b "Create the new app channel tx using configtx.yaml" gen_con_exec bash -c "configtxgen -inspectChannelCreateTx /tmp/${CHANNEL_ARTIFACTS}/${APP_CHANNEL_TX} > /tmp/${CHANNEL_ARTIFACTS}/${APP_CHANNEL_TX}.json" echo_b "Create the anchor peer configuration tx using configtx.yaml" -[ -f ${CHANNEL_ARTIFACTS}/${UPDATE_ANCHOR_ORG1_TX} ] || gen_con_exec configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate /tmp/${CHANNEL_ARTIFACTS}/${UPDATE_ANCHOR_ORG1_TX} -channelID ${APP_CHANNEL} -asOrg Org1MSP -[ -f ${CHANNEL_ARTIFACTS}/${UPDATE_ANCHOR_ORG2_TX} ] || gen_con_exec configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate /tmp/${CHANNEL_ARTIFACTS}/${UPDATE_ANCHOR_ORG2_TX} -channelID ${APP_CHANNEL} -asOrg Org2MSP +[ -f ${CHANNEL_ARTIFACTS}/${UPDATE_ANCHOR_ORG1_TX} ] || gen_con_exec configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate /tmp/${CHANNEL_ARTIFACTS}/${UPDATE_ANCHOR_ORG1_TX} -channelID ${APP_CHANNEL} -asOrg ${ORG1MSP} +[ -f ${CHANNEL_ARTIFACTS}/${UPDATE_ANCHOR_ORG2_TX} ] || gen_con_exec configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate /tmp/${CHANNEL_ARTIFACTS}/${UPDATE_ANCHOR_ORG2_TX} -channelID ${APP_CHANNEL} -asOrg ${ORG2MSP} + +echo_b "Output the json for each org" +[ -f ${CHANNEL_ARTIFACTS}/${ORG1MSP}.json ] || gen_con_exec bash -c "configtxgen -printOrg ${ORG1MSP} >/tmp/${CHANNEL_ARTIFACTS}/${ORG1MSP}.json" +[ -f ${CHANNEL_ARTIFACTS}/${ORG2MSP}.json ] || gen_con_exec bash -c "configtxgen -printOrg ${ORG2MSP} >/tmp/${CHANNEL_ARTIFACTS}/${ORG2MSP}.json" echo_b "Remove the container $GEN_CONTAINER" && docker rm -f $GEN_CONTAINER +echo_b "Generate additional artifacts for new added org" + +docker run \ + -d -it \ + --name $GEN_CONTAINER \ + -e "CONFIGTX_LOGGING_LEVEL=DEBUG" \ + -e "CONFIGTX_LOGGING_FORMAT=%{color}[%{id:03x} %{time:01-02 15:04:05.00 MST}] [%{longpkg}] %{callpath} -> %{level:.4s}%{color:reset} %{message}" \ + -v $PWD/org3/configtx.yaml:${FABRIC_CFG_PATH}/configtx.yaml \ + -v $PWD/org3/crypto-config.yaml:${FABRIC_CFG_PATH}/crypto-config.yaml \ + -v $PWD/${CRYPTO_CONFIG}:${FABRIC_CFG_PATH}/${CRYPTO_CONFIG} \ + -v $PWD/${CHANNEL_ARTIFACTS}:/tmp/${CHANNEL_ARTIFACTS} \ + ${GEN_IMG} bash -c 'while true; do sleep 20171001; done' + +if [ "${GEN_CRYPTO}" = "true" ]; then + echo_b "Generating crypto-config" + gen_con_exec cryptogen generate --config=$FABRIC_CFG_PATH/crypto-config.yaml --output ${FABRIC_CFG_PATH}/${CRYPTO_CONFIG} +fi + +[ -f ${CHANNEL_ARTIFACTS}/${ORG3MSP}.json ] || gen_con_exec bash -c "configtxgen -printOrg ${ORG3MSP} >/tmp/${CHANNEL_ARTIFACTS}/${ORG3MSP}.json" + echo_g "Generated artifacts for ${MODE}" diff --git a/hyperledger_fabric/latest/scripts/variables.sh b/hyperledger_fabric/latest/scripts/variables.sh index 2c7b88b5..d9ab54ce 100644 --- a/hyperledger_fabric/latest/scripts/variables.sh +++ b/hyperledger_fabric/latest/scripts/variables.sh @@ -28,6 +28,9 @@ ORG2_PEER1_TLS_ROOTCERT=/etc/hyperledger/fabric/crypto-config/peerOrganizations/ ORDERER_ADMIN_MSP=/etc/hyperledger/fabric/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp ORG1_ADMIN_MSP=/etc/hyperledger/fabric/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp ORG2_ADMIN_MSP=/etc/hyperledger/fabric/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp +ORG1MSP=Org1MSP +ORG2MSP=Org2MSP +ORG3MSP=Org3MSP # Node URLS ORDERER_URL="orderer.example.com:7050" diff --git a/hyperledger_fabric/latest/solo/org3/configtx.yaml b/hyperledger_fabric/latest/solo/org3/configtx.yaml new file mode 100644 index 00000000..e1205455 --- /dev/null +++ b/hyperledger_fabric/latest/solo/org3/configtx.yaml @@ -0,0 +1,31 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +--- +################################################################################ +# +# Section: Organizations +# +# - This section defines the different organizational identities which will +# be referenced later in the configuration. +# +################################################################################ +Organizations: + - &Org3 + # DefaultOrg defines the organization which is used in the sampleconfig + # of the fabric.git development environment + Name: Org3MSP + + # ID to load the MSP definition as + ID: Org3MSP + + MSPDir: crypto-config/peerOrganizations/org3.example.com/msp + + AnchorPeers: + # AnchorPeers defines the location of peers which can be used + # for cross org gossip communication. Note, this value is only + # encoded in the genesis block in the Application section context + - Host: peer0.org3.example.com + Port: 7051 diff --git a/hyperledger_fabric/latest/solo/org3/crypto-config.yaml b/hyperledger_fabric/latest/solo/org3/crypto-config.yaml new file mode 100644 index 00000000..24b5dd88 --- /dev/null +++ b/hyperledger_fabric/latest/solo/org3/crypto-config.yaml @@ -0,0 +1,18 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +# --------------------------------------------------------------------------- +# "PeerOrgs" - Definition of organizations managing peer nodes +# --------------------------------------------------------------------------- +PeerOrgs: + # --------------------------------------------------------------------------- + # Org3 + # --------------------------------------------------------------------------- + - Name: Org3 + Domain: org3.example.com + Template: + Count: 2 + Users: + Count: 1