func ConnProfileInformationForOrg(connProfilePath, orgName string) (ConnProfileOptions, error) {
	var config ConnProfileOptions
	if !(strings.HasSuffix(connProfilePath, "yaml") || strings.HasSuffix(connProfilePath, "yml")) {
		files, err := ioutil.ReadDir(connProfilePath)
		if err != nil {
			return config, err
		}
		for _, file := range files {
			if strings.Contains(file.Name(), orgName) {
				connProfilePath = paths.JoinPath(connProfilePath, file.Name())
				break
			}
		}
	}
	yamlFile, err := ioutil.ReadFile(connProfilePath)
	if err != nil {
		logger.ERROR("Failed to read connectionprofile to get MSPID ")
		return config, err
	}
	err = yaml.Unmarshal(yamlFile, &config)
	if err != nil {
		logger.ERROR("Failed to create ConnProfileOptions object")
		return config, err
	}
	return config, nil
}
ConnProfileInformationForOrg -- To get the MSP ID for an organization
package operations
import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/url"
	"strconv"
	"strings"
	"time"
	"github.com/davecgh/go-spew/spew"
	"github.com/hyperledger/fabric-test/tools/operator/connectionprofile"
	"github.com/hyperledger/fabric-test/tools/operator/logger"
	"github.com/hyperledger/fabric-test/tools/operator/networkclient"
	"github.com/hyperledger/fabric-test/tools/operator/paths"
	"github.com/hyperledger/fabric-test/tools/operator/testclient/inputStructs"
	yaml "gopkg.in/yaml.v2"
)
type InstantiateCCUIObject struct {
	SDK             string                   `json:"sdk,omitempty"`
	TransType       string                   `json:"transType,omitempty"`
	TLS             string                   `json:"TLS,omitempty"`
	ChainCodeID     string                   `json:"chaincodeID,omitempty"`
	ChainCodeVer    string                   `json:"chaincodeVer,omitempty"`
	ConnProfilePath string                   `json:"ConnProfilePath,omitempty"`
	ChannelOpt      ChannelOptions           `json:"channelOpt,omitempty"`
	DeployOpt       InstantiateDeployOptions `json:"deploy,omitempty"`
	TimeOutOpt      TimeOutOptions           `json:"timeoutOpt,omitempty"`
	Sequence        string                   `json:"sequence,omitempty"`
	TargetPeers     []string                 `json:"targetPeers,omitempty"`
}
type InstantiateDeployOptions struct {
	Function              string             `json:"fcn,omitempty"`
	Arguments             []string           `json:"args,omitempty"`
	Endorsement           *EndorsementPolicy `json:"endorsement,omitempty"`
	CollectionsConfigPath string             `json:"collectionsConfigPath,omitempty"`
}
type TimeOutOptions struct {
	PreConfig string `json:"preConfig,omitempty"`
	Request   string `json:"request,omitempty"`
}
type EndorsementPolicy struct {
	Identities      []Identity          `json:"identities,omitempty"`
	Policy          map[string][]Policy `json:"policy,omitempty"`
	SignaturePolicy string              `json:"signaturePolicy,omitempty"`
}
type Policy struct {
	SignedBy int `json:"signed-by"`
}
type Identity struct {
	Role struct {
		Name  string `json:"name,omitempty"`
		MSPID string `json:"mspId,omitempty"`
	} `json:"role,omitempty"`
}
type ConnProfileOptions struct {
	Organizations map[string]struct {
		MSPID string   `yaml:"mspid,omitempty"`
		Peers []string `yaml:"peers,omitempty"`
	} `yaml:"organizations,omitempty"`
	Peers map[string]struct {
		URL        string `yaml:"url,omitempty"`
		MetricsURL string `yaml:"metricsURL,omitempty"`
	} `yaml:"peers,omitempty"`
	Orderers map[string]struct {
		URL        string `yaml:"url,omitempty"`
		MetricsURL string `yaml:"metricsURL,omitempty"`
	}
	Channels map[string]struct {
		Orderers []string `yaml:"orderers,omitempty"`
		Peers    []string `yaml:"peers,omitempty"`
	}
}
type InstalledCC struct {
	CC []struct {
		PackageID string `json:"package_id,omitempty"`
		Label     string `json:"label,omitempty"`
	} `json:"installed_chaincodes,omitempty"`
}
func (i InstantiateCCUIObject) InstantiateCC(config inputStructs.Config, tls, action string) error {
	var instantiateCCObjects []InstantiateCCUIObject
	configObjects := config.InstantiateCC
	var ccConfigObjects []interface{}
	if action == "upgrade" {
		configObjects = config.UpgradeCC
	}
	fmt.Printf("\033[1m\nAction:%s\nInput:\033[0m\n%s\n", action, spew.Sdump(configObjects))
	for index := 0; index < len(configObjects); index++ {
		ccObjects, err := i.generateInstantiateCCObjects(configObjects[index], config.Organizations, tls, action)
		if err != nil {
			return err
		}
		ccConfigObjects = append(ccConfigObjects, &configObjects[index])
		instantiateCCObjects = append(instantiateCCObjects, ccObjects...)
	}
	err := i.instantiateCC(instantiateCCObjects)
	if err != nil {
		return err
	}
	var connProfileObject connectionprofile.ConnProfile
	err = connProfileObject.UpdateConnectionProfiles(ccConfigObjects, config.Organizations, action)
	if err != nil {
		return err
	}
	return nil
}
func (i InstantiateCCUIObject) generateInstantiateCCObjects(ccObject inputStructs.InstantiateCC, organizations []inputStructs.Organization, tls, action string) ([]InstantiateCCUIObject, error) {
	var instantiateCCObjects []InstantiateCCUIObject
	var err error
	if ccObject.ChannelPrefix != "" && ccObject.NumChannels > 0 {
		instantiateCCObjects, err = i.createInstantiateCCObjectIfChanPrefix(ccObject, organizations, tls, action)
		if err != nil {
			return instantiateCCObjects, err
		}
		return instantiateCCObjects, nil
	}
	orgNames := strings.Split(ccObject.Organizations, ",")
	instantiateCCObjects, err = i.createInstantiateCCObjects(orgNames, ccObject.ChannelName, tls, action, organizations, ccObject)
	if err != nil {
		return instantiateCCObjects, err
	}
	return instantiateCCObjects, nil
}
func (i InstantiateCCUIObject) createInstantiateCCObjects(orgNames []string, channelName, tls, action string, organizations []inputStructs.Organization, ccObject inputStructs.InstantiateCC) ([]InstantiateCCUIObject, error) {
	var instantiateCCObjects []InstantiateCCUIObject
	targetPeers := strings.Split(ccObject.TargetPeers, ",")
	i = InstantiateCCUIObject{
		SDK:             ccObject.SDK,
		TransType:       action,
		TLS:             tls,
		ConnProfilePath: paths.GetConnProfilePath(orgNames, organizations),
		ChainCodeID:     ccObject.ChainCodeName,
		ChainCodeVer:    ccObject.ChainCodeVersion,
		TargetPeers:     targetPeers,
		Sequence:        ccObject.Sequence,
		ChannelOpt: ChannelOptions{
			Name:    channelName,
			OrgName: orgNames,
		},
		DeployOpt: InstantiateDeployOptions{
			Function:  ccObject.CCFcn,
			Arguments: strings.Split(ccObject.CCFcnArgs, ","),
		},
		TimeOutOpt: TimeOutOptions{
			PreConfig: ccObject.TimeOutOpt.PreConfig,
			Request:   ccObject.TimeOutOpt.Request,
		},
	}
	if ccObject.TimeOutOpt.PreConfig == "" {
		i.TimeOutOpt = TimeOutOptions{PreConfig: "600000", Request: "600000"}
	}
	if ccObject.EndorsementPolicy != "" {
		if ccObject.SDK != "cli" || strings.Contains(ccObject.EndorsementPolicy, "of") {
			endorsementPolicy, err := i.getEndorsementPolicy(organizations, ccObject.EndorsementPolicy)
			if err != nil {
				logger.ERROR("Failed to get the endorsement policy")
				return instantiateCCObjects, err
			}
			i.DeployOpt.Endorsement = endorsementPolicy
		} else {
			endorsementPolicy := &EndorsementPolicy{SignaturePolicy: ccObject.EndorsementPolicy}
			i.DeployOpt.Endorsement = endorsementPolicy
		}
	}
	if ccObject.CollectionPath != "" {
		i.DeployOpt.CollectionsConfigPath = ccObject.CollectionPath
	}
	instantiateCCObjects = append(instantiateCCObjects, i)
	return instantiateCCObjects, nil
}
func (i InstantiateCCUIObject) createInstantiateCCObjectIfChanPrefix(ccObject inputStructs.InstantiateCC, organizations []inputStructs.Organization, tls, action string) ([]InstantiateCCUIObject, error) {
	var instantiateCCObjects []InstantiateCCUIObject
	var channelName string
	for j := 0; j < ccObject.NumChannels; j++ {
		channelName = fmt.Sprintf("%s%s", ccObject.ChannelPrefix, strconv.Itoa(j))
		orgNames := strings.Split(ccObject.Organizations, ",")
		ccObjects, err := i.createInstantiateCCObjects(orgNames, channelName, tls, action, organizations, ccObject)
		if err != nil {
			return instantiateCCObjects, err
		}
		instantiateCCObjects = append(instantiateCCObjects, ccObjects...)
	}
	return instantiateCCObjects, nil
}
func (i InstantiateCCUIObject) getEndorsementPolicy(organizations []inputStructs.Organization, policy string) (*EndorsementPolicy, error) {
	var endorsementPolicy *EndorsementPolicy
	var identities []Identity
	var policies []Policy
	var identity Identity
	args := strings.Split(policy, "(")
	orgs := args[len(args)-1]
	orgs = orgs[:len(orgs)-1]
	orgNames := strings.Split(orgs, ",")
	for _, orgName := range orgNames {
		orgName = strings.TrimSpace(orgName)
		connProfilePath := paths.GetConnProfilePath([]string{orgName}, organizations)
		connProfConfig, err := ConnProfileInformationForOrg(connProfilePath, orgName)
		if err != nil {
			return endorsementPolicy, err
		}
		mspID := connProfConfig.Organizations[orgName].MSPID
		identity.Role.Name = "member"
		identity.Role.MSPID = mspID
		identities = append(identities, identity)
	}
	numPolicies, err := strconv.Atoi(args[0][0:1])
	if err != nil {
		logger.ERROR("Failed to convert string to integer")
		return endorsementPolicy, err
	}
	key := fmt.Sprintf("%d-of", numPolicies)
	for i := 0; i < len(orgNames); i++ {
		policy := Policy{SignedBy: i}
		policies = append(policies, policy)
	}
	policyMap := make(map[string][]Policy)
	policyMap[key] = policies
	endorsementPolicy = &EndorsementPolicy{Identities: identities, Policy: policyMap}
	return endorsementPolicy, nil
}