fix ccp template and generator to include orderer and channel

Signed-off-by: Naser Mirzaei <nasermirzaei89@gmail.com>
This commit is contained in:
Naser Mirzaei 2020-08-17 20:29:46 +04:30
parent 9963449387
commit 1dbf999992
3 changed files with 67 additions and 12 deletions

View file

@ -5,35 +5,44 @@ function one_line_pem {
} }
function json_ccp { function json_ccp {
local PP=$(one_line_pem $4) local OP=$(one_line_pem $5)
local CP=$(one_line_pem $5) local PP=$(one_line_pem $6)
local CP=$(one_line_pem $7)
sed -e "s/\${ORG}/$1/" \ sed -e "s/\${ORG}/$1/" \
-e "s/\${P0PORT}/$2/" \ -e "s/\${ORDERERPORT}/$2/" \
-e "s/\${CAPORT}/$3/" \ -e "s/\${P0PORT}/$3/" \
-e "s/\${CAPORT}/$4/" \
-e "s#\${ORDERERPEM}#$OP#" \
-e "s#\${PEERPEM}#$PP#" \ -e "s#\${PEERPEM}#$PP#" \
-e "s#\${CAPEM}#$CP#" \ -e "s#\${CAPEM}#$CP#" \
organizations/ccp-template.json organizations/ccp-template.json
} }
function yaml_ccp { function yaml_ccp {
local PP=$(one_line_pem $4) local OP=$(one_line_pem $5)
local CP=$(one_line_pem $5) local PP=$(one_line_pem $6)
local CP=$(one_line_pem $7)
sed -e "s/\${ORG}/$1/" \ sed -e "s/\${ORG}/$1/" \
-e "s/\${P0PORT}/$2/" \ -e "s/\${ORDERERPORT}/$2/" \
-e "s/\${CAPORT}/$3/" \ -e "s/\${P0PORT}/$3/" \
-e "s/\${CAPORT}/$4/" \
-e "s#\${ORDERERPEM}#$OP#" \
-e "s#\${PEERPEM}#$PP#" \ -e "s#\${PEERPEM}#$PP#" \
-e "s#\${CAPEM}#$CP#" \ -e "s#\${CAPEM}#$CP#" \
organizations/ccp-template.yaml | sed -e $'s/\\\\n/\\\n /g' organizations/ccp-template.yaml | sed -e $'s/\\\\n/\\\n /g'
} }
ORDERERPORT=7050
ORDERERPEM=organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
ORG=1 ORG=1
P0PORT=7051 P0PORT=7051
CAPORT=7054 CAPORT=7054
PEERPEM=organizations/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem PEERPEM=organizations/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
CAPEM=organizations/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem CAPEM=organizations/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem
echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > organizations/peerOrganizations/org1.example.com/connection-org1.json echo "$(json_ccp $ORG $ORDERERPORT $P0PORT $CAPORT $ORDERERPEM $PEERPEM $CAPEM)" > organizations/peerOrganizations/org1.example.com/connection-org1.json
echo "$(yaml_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > organizations/peerOrganizations/org1.example.com/connection-org1.yaml echo "$(yaml_ccp $ORG $ORDERERPORT $P0PORT $CAPORT $ORDERERPEM $PEERPEM $CAPEM)" > organizations/peerOrganizations/org1.example.com/connection-org1.yaml
ORG=2 ORG=2
P0PORT=9051 P0PORT=9051
@ -41,5 +50,5 @@ CAPORT=8054
PEERPEM=organizations/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem PEERPEM=organizations/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
CAPEM=organizations/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem CAPEM=organizations/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem
echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > organizations/peerOrganizations/org2.example.com/connection-org2.json echo "$(json_ccp $ORG $ORDERERPORT $P0PORT $CAPORT $ORDERERPEM $PEERPEM $CAPEM)" > organizations/peerOrganizations/org2.example.com/connection-org2.json
echo "$(yaml_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > organizations/peerOrganizations/org2.example.com/connection-org2.yaml echo "$(yaml_ccp $ORG $ORDERERPORT $P0PORT $CAPORT $ORDERERPEM $PEERPEM $CAPEM)" > organizations/peerOrganizations/org2.example.com/connection-org2.yaml

View file

@ -22,6 +22,20 @@
] ]
} }
}, },
"channels": {
"mychannel": {
"orderers": ["orderer.example.com"],
"peers": {
"peer0.org${ORG}.example.com": {
"endorsingPeer": true,
"chaincodeQuery": true,
"ledgerQuery": true,
"eventSource": true,
"discover": true
}
}
}
},
"peers": { "peers": {
"peer0.org${ORG}.example.com": { "peer0.org${ORG}.example.com": {
"url": "grpcs://localhost:${P0PORT}", "url": "grpcs://localhost:${P0PORT}",
@ -34,6 +48,18 @@
} }
} }
}, },
"orderers": {
"orderer.example.com": {
"url": "grpcs://localhost:${ORDERERPORT}",
"tlsCACerts": {
"pem": "${ORDERERPEM}"
},
"grpcOptions": {
"ssl-target-name-override": "orderer.example.com",
"hostnameOverride": "orderer.example.com"
}
}
},
"certificateAuthorities": { "certificateAuthorities": {
"ca.org${ORG}.example.com": { "ca.org${ORG}.example.com": {
"url": "https://localhost:${CAPORT}", "url": "https://localhost:${CAPORT}",

View file

@ -14,6 +14,17 @@ organizations:
- peer0.org${ORG}.example.com - peer0.org${ORG}.example.com
certificateAuthorities: certificateAuthorities:
- ca.org${ORG}.example.com - ca.org${ORG}.example.com
channels:
mychannel:
orderers:
- orderer.example.com
peers:
peer0.org${ORG}.example.com:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
discover: true
peers: peers:
peer0.org${ORG}.example.com: peer0.org${ORG}.example.com:
url: grpcs://localhost:${P0PORT} url: grpcs://localhost:${P0PORT}
@ -23,6 +34,15 @@ peers:
grpcOptions: grpcOptions:
ssl-target-name-override: peer0.org${ORG}.example.com ssl-target-name-override: peer0.org${ORG}.example.com
hostnameOverride: peer0.org${ORG}.example.com hostnameOverride: peer0.org${ORG}.example.com
orderers:
orderer.example.com:
url: grpcs://localhost:${ORDERERPORT}
tlsCACerts:
pem: |
${ORDERERPEM}
grpcOptions:
ssl-target-name-override: orderer.example.com
hostnameOverride: orderer.example.com
certificateAuthorities: certificateAuthorities:
ca.org${ORG}.example.com: ca.org${ORG}.example.com:
url: https://localhost:${CAPORT} url: https://localhost:${CAPORT}