fabric-tools

command
v0.2.0-develop.76 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2019 License: BSD-3-Clause Imports: 1 Imported by: 0

README

fabric-tools

This package is designed to support configuration and deployment of dovetail applications in public cloud services, including AWS, Azure, and IBM Cloud. Since IBM Blockchain Platform (IBP) is currently the only public cloud environment that supports Hyperledger Fabric v1.4, we describe the deployment process for marble-app and marble-client for IBP only.

Build and install fabric-tools

cd $GOPATH/src/github.com/TIBCOSoftware/dovetail-contrib/hyperledger-fabric/fabric-tools
go install
fabric-tools help

Create Hyperledger Fabric network in IBM Cloud

The IBP Tutorial describes how to create a Hyperledger Fabric network in IBM Cloud, which involves the following steps:

  1. Create IBM Cloud Kubernetes cluster, IBP Tutorial (Step 4);
  2. Build Fabric network using IBM Blockchain Platform console, IBP Tutorial (Step 5), which includes:
  • Create and start Certificate Authority (CA) servers for orderer and peer organizations;
  • Create identities for organization administrators and peer/orderer nodes;
  • Create MSP definitions for orderer and peer organizations;
  • Create and start orderer and peer nodes;
  • Define network consortium by adding organizations in an orderer;
  • Create a channel, and join peers to the channel.

Package and install/instantiate chaincode

Chaincode must be packaged as cds file to be installed in IBP. We can package the marble-app chaincode using a local cli docker container, i.e.,

cd $GOPATH/src/github.com/TIBCOSoftware/dovetail-contrib/hyperledger-fabric/marble-app
make package

Note that this command requires that you start the local cli docker container, or simply start all containers of the first-network sample network:

cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network
./byfn.sh up -s couchdb

If you do not want to start a local fabric sample network, you can use the fabric-tools to generate the cds file from chaincode source code, e.g., /tmp/marble_app/marble_cc/src, as follows.

mkdir -p $GOPATH/src/github.com/chaincode
cp -R /tmp/marble_app/marble_cc/src $GOPATH/src/github.com/chaincode/marble_cc
fabric-tools package -n marble_cc -v 1.0 -p $GOPATH/src/github.com/chaincode/marble_cc
rm -R $GOPATH/src/github.com/chaincode

You can then install and instantiate the resulting package, marble_cc.cds using the IBP console as shown in the IBP Tutorial (Step 6).

Prepare IBP network for client app

Download the connection profile of the instantiated marble_cc.cds as shown in the IBP Tutorial (Step 7). Save the profile in the scripts folder, e.g., scripts/ibpConnection.json.

In IBP Console, register a user with type of client in Org1 CA as shown in the IBP Tutorial (Step 5). This user, e.g., user1, will be used by the marble-client to invoke the chaincode.

Execute the following script to create the network config and user crypto data for the client app:

cd $GOPATH/src/github.com/TIBCOSoftware/dovetail-contrib/hyperledger-fabric/fabric-tools/scripts
./setup-ibp.sh ibpConnection.json user1 user1pw

This script uses the connection profile and user and password specified in the above steps, so change them to match the names in your configuration.

Verify that a network-config-file, config-ibp.yaml is created, which will be used by the client app to connect to the IBP network. A folder crypto-ibp should be created and it contains required crypto data, especially the private key and signing certificate of the client user, user1, which is in the folder, e.g., crypto-ibp/organizations/org1msp/users/user1/msp, and the signing certificate should be named as, e.g., signcerts/user1@org1msp-cert.pem.

Note that the setup script depends on the fabric-ca-client, which must be installed in advance, i.e.,

go get -u github.com/hyperledger/fabric-ca/cmd/...

Edit and build marble-client app

Use TIBCO Flogo® Enterprise v2.6 to edit the marble_client_app.json:

  • Start Flogo Enterprise
cd $FLOGO_HOME/2.6/bin
./run-studio.sh
  • Launch Flogo Console in Chrome at http://localhost:8090
  • Open Extensions tab, and upload fabclient extension, fabclientExtension.zip;
  • Open Apps tab, create app named marble_client_app and import app with the file marble_client_app.json;
  • Open the marble_client_app and click the App Properties link, update the value of CLIENT_USER to match the name of the user created in the previous step;
  • Open Connections tab, edit and save the connector local-first-network to use configuration files ./scripts/config-ibp.yaml, which is generated in the previous step, and empty_entity_matchers.yaml;
  • Open Apps tab, export the marble_client_app and download the updated app to marble-client/marble_client_app.json.

Build and start the marble-client-app:

cd $GOPATH/src/github.com/TIBCOSoftware/dovetail-contrib/hyperledger-fabric/marble-client
make create
make build
export CRYPTO_PATH=$GOPATH/src/github.com/TIBCOSoftware/dovetail-contrib/hyperledger-fabric/fabric-tools/scripts/crypto-ibp
make run

Note that the CRYPTO_PATH must be set to the crypto folder generated by the previous step. To run the client app in a docker container, you can copy or mount this crypto folder in the docker container, and configure CRYPTO_PATH accordingly.

Test marble-client app

The REST APIs, described in marble-client, can be used to test the marble-client with the chaincode marble-app instantiated in IBM Cloud.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL