Exemple #1
0
def get_chaincode_deploy_spec(projectDir, ccType, path, name, args):
    subprocess.call(["peer", "chaincode", "package",
                     "-n", name,
                     "-c", '{"Args":{0}}'.format(args),
                     "-p", path,
                     "configs/{0}/test.file".format(projectDir)], shell=True)
    ccDeploymentSpec = chaincode_pb2.ChaincodeDeploymentSpec()
    with open("test.file", 'rb') as f:
        ccDeploymentSpec.ParseFromString(f.read())
    return ccDeploymentSpec
def createDeploymentSpec(context, ccSpec):
    contextHelper = ContextHelper.GetHelper(context=context)
    cacheDeploymentSpec = contextHelper.isConfigEnabled("cache-deployment-spec")
    fileName = "deploymentspec-{0}-{1}-{2}-{3}".format(chaincode_pb2.ChaincodeSpec.Type.Name(ccSpec.type), ccSpec.chaincode_id.path, ccSpec.chaincode_id.name, ccSpec.chaincode_id.version)
    outputPath, fileExists = contextHelper.getTmpPathForName(name=fileName,
                                                             copyFromCache=cacheDeploymentSpec)
    if not fileExists:
        _createDeploymentSpecAsFile(ccSpec=ccSpec, outputPath=outputPath)
        if cacheDeploymentSpec:
            contextHelper.copyToCache(fileName)
    ccDeploymentSpec = chaincode_pb2.ChaincodeDeploymentSpec()
    with open(outputPath, 'rb') as f:
        ccDeploymentSpec.ParseFromString(f.read())
    return ccDeploymentSpec
Exemple #3
0
def createDeploymentSpec(context, ccSpec):
    contextHelper = bootstrap_util.ContextHelper.GetHelper(context=context)
    cacheDeploymentSpec = contextHelper.isConfigEnabled("cache-deployment-spec")
    fileName = "deploymentspec_{0}".format(ccSpec.chaincodeID.name)
    outputPath, fileExists = contextHelper.getTmpPathForName(name=fileName,
                                                             copyFromCache=cacheDeploymentSpec)
    if not fileExists:
        _createDeploymentSpecAsFile(ccSpec=ccSpec, outputPath=outputPath)
        if cacheDeploymentSpec:
            contextHelper.copyToCache(fileName)
    ccDeploymentSpec = chaincode_pb2.ChaincodeDeploymentSpec()
    with open(outputPath, 'rb') as f:
        ccDeploymentSpec.ParseFromString(f.read())
    return ccDeploymentSpec