func (c ConnProfile) updateConnectionProfilePerOrg(organizations []inputStructs.Organization, inputArgs ...string) error {
	var err error
	connectionProfilesList := []string{}
	if len(inputArgs) < 3 || len(inputArgs) > 4 {
		return errors.New("Incorrect number of arguments passed")
	}
	action, orgName, channelName := inputArgs[0], inputArgs[1], inputArgs[2]
	connProfilePath := paths.GetConnProfilePath([]string{orgName}, organizations)
	connectionProfilesList = append(connectionProfilesList, connProfilePath)
	if !strings.HasSuffix(connProfilePath, ".yaml") && !strings.HasSuffix(connProfilePath, ".yml") {
		connectionProfilesList = []string{}
		currentDir, err := paths.GetCurrentDir()
		if err != nil {
			logger.ERROR("ConnectionProfile: Failed to get the current directory, connProfilePath: ", connProfilePath)
			return err
		}
		filesList, err := ioutil.ReadDir(paths.JoinPath(currentDir, connProfilePath))
		if err != nil {
			logger.ERROR("Failed to read the connection profiles directory, connProfilePath: ", connProfilePath)
			return err
		}
		for _, file := range filesList {
			connProfileFilePath := paths.JoinPath(connProfilePath, file.Name())
			_, connProfileObject, err := c.getComponentsListFromConnProfile(connProfileFilePath, "")
			if err != nil {
				logger.ERROR("ConnectionProfile: Failed to read the connection profile, connProfilePath: ", connProfileFilePath)
			}
			if connProfileObject.Organizations[orgName].Name == orgName {
				connectionProfilesList = append(connectionProfilesList, connProfileFilePath)
			}
		}
	}
	for _, file := range connectionProfilesList {
		switch action {
		case "create":
			err = c.updateConnectionProfile(file, channelName, "orderer")
		case "join", "joinBySnapshot":
			err = c.updateConnectionProfile(file, channelName, "peer")
		case "instantiate", "upgrade":
			err = c.updateConnectionProfile(file, channelName, "chaincodes", inputArgs[len(inputArgs)-1])
		}
	}
	if err != nil {
		logger.ERROR("Failed to update connection profile after channel ", action)
		return err
	}
	return err
}
updateConnectionProfilePerOrg -- To update connection profile per an organization
package connectionprofile
import (
	"errors"
	"fmt"
	"io/ioutil"
	"strings"
	"github.com/hyperledger/fabric-test/tools/operator/logger"
	"github.com/hyperledger/fabric-test/tools/operator/networkspec"
	"github.com/hyperledger/fabric-test/tools/operator/paths"
	"github.com/hyperledger/fabric-test/tools/operator/testclient/inputStructs"
	yaml "gopkg.in/yaml.v2"
)
func (c ConnProfile) UpdateConnectionProfiles(configObjects []interface{}, organizations []inputStructs.Organization, action string) error {
	var err error
	for key := range configObjects {
		err = c.updateConnectionProfilePerChannel(configObjects[key], organizations, action)
		if err != nil {
			return err
		}
	}
	return err
}
func (c ConnProfile) updateConnectionProfilePerChannel(inputObject interface{}, organizations []inputStructs.Organization, action string) error {
	var err error
	var channelName, channelPrefix, chainCodeID string
	var numChannels int
	var orgNames []string
	if action == "instantiate" || action == "upgrade" {
		configObject, _ := inputObject.(*inputStructs.InstantiateCC)
		channelName, channelPrefix, numChannels = configObject.ChannelName, configObject.ChannelPrefix, configObject.NumChannels
		chainCodeID = fmt.Sprintf("%s:%s", configObject.ChainCodeName, configObject.ChainCodeVersion)
		orgNames = strings.Split(configObject.Organizations, ",")
	} else if action == "joinBySnapshot" {
		configObject, _ := inputObject.(*inputStructs.JoinChannelBySnapshot)
		channelName, channelPrefix, numChannels = configObject.ChannelName, configObject.ChannelPrefix, configObject.NumChannels
		orgNames = strings.Split(configObject.Organizations, ",")
	} else {
		configObject, _ := inputObject.(*inputStructs.Channel)
		channelName, channelPrefix, numChannels = configObject.ChannelName, configObject.ChannelPrefix, configObject.NumChannels
		orgNames = strings.Split(configObject.Organizations, ",")
	}
	for _, orgName := range orgNames {
		orgName = strings.TrimSpace(orgName)
		if channelPrefix != "" {
			err = c.updateConnectionProfilesIfChanPrefix(organizations, numChannels, action, orgName, channelPrefix, chainCodeID)
			if err != nil {
				return err
			}
		} else {
			err = c.updateConnectionProfilePerOrg(organizations, action, orgName, channelName, chainCodeID)
			if err != nil {
				return err
			}
		}
	}
	return err
}