def create_channel(self, context, orderers, channelId=TEST_CHANNEL_ID): configDir = "/var/hyperledger/configs/{0}".format(context.composition.projectName) setup = self.get_env_vars(context, "peer0.org1.example.com") timeout = str(120 + common_util.convertToSeconds(context.composition.environ.get('CONFIGTX_ORDERER_BATCHTIMEOUT', '0s'))) command = ["peer", "channel", "create", "--file", "/var/hyperledger/configs/{0}/{1}.tx".format(context.composition.projectName, channelId), "--channelID", channelId, "--timeout", timeout, "--orderer", '{0}:7050'.format(orderers[0])] if context.tls: command = command + ["--tls", common_util.convertBoolean(context.tls), "--cafile", '{0}/ordererOrganizations/example.com/orderers/orderer0.example.com/msp/tlscacerts/tlsca.example.com-cert.pem'.format(configDir)] command.append('"') output = context.composition.docker_exec(setup+command, ['cli']) print("[{0}]: {1}".format(" ".join(setup+command), output)) assert "Error:" not in output, "Unable to successfully create channel {}".format(channelId) # # For now, copy the channel block to the config directory # output = context.composition.docker_exec(["cp", # "{0}.block".format(channelId), # configDir], # ['cli']) # print("[{0}]: {1}".format(" ".join(command), output)) return output
def create_channel(self, context, orderer, channelId=TEST_CHANNEL_ID): configDir = "/var/hyperledger/configs/{0}".format(context.composition.projectName) setup = self.get_env_vars(context, "peer0.org1.example.com") timeout = str(120 + common_util.convertToSeconds(context.composition.environ.get('CONFIGTX_ORDERER_BATCHTIMEOUT', '0s'))) command = ["peer", "channel", "create", "--file", "/var/hyperledger/configs/{0}/{1}.tx".format(context.composition.projectName, channelId), "--channelID", channelId, "--timeout", timeout, "--orderer", '{0}:7050'.format(orderer)] if context.tls: command = command + ["--tls", common_util.convertBoolean(context.tls), "--cafile", '{0}/ordererOrganizations/example.com/orderers/{1}/msp/tlscacerts/tlsca.example.com-cert.pem'.format(configDir, orderer)] command.append('"') output = context.composition.docker_exec(setup+command, ['cli']) print("[{0}]: {1}".format(" ".join(setup+command), output)) if "SERVICE_UNAVAILABLE" in output['cli']: time.sleep(5) print("Received: {0}, Trying again...".format(output['cli'])) output = context.composition.docker_exec(setup+command, ['cli']) assert "Error:" not in output, "Unable to successfully create channel {}".format(channelId) return output
def create_channel(self, context, orderer, channelId=TEST_CHANNEL_ID, user="******"): configDir = "/var/hyperledger/configs/{0}".format(context.composition.projectName) setup = self.get_env_vars(context, "peer0.org1.example.com", user=user) # Ideally this would NOT be a 5 minute timeout, but more like a 2 minute timeout. timeout = 300 + common_util.convertToSeconds(context.composition.environ.get('CONFIGTX_ORDERER_BATCHTIMEOUT', '0s')) command = ["peer", "channel", "create", "--file", "/var/hyperledger/configs/{0}/{1}.tx".format(context.composition.projectName, channelId), "--channelID", channelId, "--timeout", "{}s".format(timeout), "--orderer", '{0}:7050'.format(orderer)] if context.tls: command = command + ["--tls", common_util.convertBoolean(context.tls), "--cafile", '{0}/ordererOrganizations/example.com/orderers/{1}/msp/tlscacerts/tlsca.example.com-cert.pem'.format(configDir, orderer)] if hasattr(context, "mutual_tls") and context.mutual_tls: org = "org1.example.com" command = command + ["--clientauth", "--certfile", '{0}/peerOrganizations/{1}/users/{2}@{1}/tls/client.crt'.format(configDir, org, user), "--keyfile", '{0}/peerOrganizations/{1}/users/{2}@{1}/tls/client.key'.format(configDir, org, user)] command.append('"') output = context.composition.docker_exec(setup+command, ['cli']) print("[{0}]: {1}".format(" ".join(setup+command), output)) if "SERVICE_UNAVAILABLE" in output['cli']: time.sleep(5) print("Received: {0}, Trying again...".format(output['cli'])) output = context.composition.docker_exec(setup+command, ['cli']) assert "Error:" not in output, "Unable to successfully create channel {}".format(channelId) return output