func GetResource(nsId string, resourceType string, resourceId string) (interface{}, error) {

	err := common.CheckString(nsId)
	if err != nil {
		common.CBLog.Error(err)
		return nil, err
	}

	err = common.CheckString(resourceId)
	if err != nil {
		common.CBLog.Error(err)
		return nil, err
	}
	check, err := CheckResource(nsId, resourceType, resourceId)

	if !check {
		errString := "The " + resourceType + " " + resourceId + " does not exist."
		//mapA := map[string]string{"message": errString}
		//mapB, _ := json.Marshal(mapA)
		err := fmt.Errorf(errString)
		return nil, err
	}

	if err != nil {
		common.CBLog.Error(err)
		return nil, err
	}
	fmt.Println("[Get resource] " + resourceType + ", " + resourceId)

	key := common.GenResourceKey(nsId, resourceType, resourceId)
	//fmt.Println(key)

	keyValue, err := common.CBStore.Get(key)
	if err != nil {
		common.CBLog.Error(err)
		return nil, err
	}
	if keyValue != nil {
		switch resourceType {
		case common.StrImage:
			res := TbImageInfo{}
			err = json.Unmarshal([]byte(keyValue.Value), &res)
			if err != nil {
				common.CBLog.Error(err)
				return nil, err
			}
			return res, nil
		case common.StrSecurityGroup:
			res := TbSecurityGroupInfo{}
			err = json.Unmarshal([]byte(keyValue.Value), &res)
			if err != nil {
				common.CBLog.Error(err)
				return nil, err
			}
			return res, nil
		case common.StrSpec:
			res := TbSpecInfo{}
			err = json.Unmarshal([]byte(keyValue.Value), &res)
			if err != nil {
				common.CBLog.Error(err)
				return nil, err
			}
			return res, nil
		case common.StrSSHKey:
			res := TbSshKeyInfo{}
			err = json.Unmarshal([]byte(keyValue.Value), &res)
			if err != nil {
				common.CBLog.Error(err)
				return nil, err
			}
			return res, nil
		case common.StrVNet:
			res := TbVNetInfo{}
			err = json.Unmarshal([]byte(keyValue.Value), &res)
			if err != nil {
				common.CBLog.Error(err)
				return nil, err
			}
			return res, nil
		}

		//return true, nil
	}
	errString := "Cannot get " + resourceType + " " + resourceId + "."
	err = fmt.Errorf(errString)
	return nil, err
}
// GetResource returns the requested TB MCIR object
GetResource returns the requested TB MCIR object
// GetResource returns the requested TB MCIR object
func GetResource(nsId string, resourceType string, resourceId string) (interface{}, error) {
	err := common.CheckString(nsId)
	if err != nil {
		common.CBLog.Error(err)
		return nil, err
	}
	err = common.CheckString(resourceId)
	if err != nil {
		common.CBLog.Error(err)
		return nil, err
	}
	check, err := CheckResource(nsId, resourceType, resourceId)
	if !check {
		errString := "The " + resourceType + " " + resourceId + " does not exist."
		err := fmt.Errorf(errString)
		return nil, err
	}
	if err != nil {
		common.CBLog.Error(err)
		return nil, err
	}
	fmt.Println("[Get resource] " + resourceType + ", " + resourceId)
	key := common.GenResourceKey(nsId, resourceType, resourceId)
	keyValue, err := common.CBStore.Get(key)
	if err != nil {
		common.CBLog.Error(err)
		return nil, err
	}
	if keyValue != nil {
		switch resourceType {
		case common.StrImage:
			res := TbImageInfo{}
			err = json.Unmarshal([]byte(keyValue.Value), &res)
			if err != nil {
				common.CBLog.Error(err)
				return nil, err
			}
			return res, nil
		case common.StrSecurityGroup:
			res := TbSecurityGroupInfo{}
			err = json.Unmarshal([]byte(keyValue.Value), &res)
			if err != nil {
				common.CBLog.Error(err)
				return nil, err
			}
			return res, nil
		case common.StrSpec:
			res := TbSpecInfo{}
			err = json.Unmarshal([]byte(keyValue.Value), &res)
			if err != nil {
				common.CBLog.Error(err)
				return nil, err
			}
			return res, nil
		case common.StrSSHKey:
			res := TbSshKeyInfo{}
			err = json.Unmarshal([]byte(keyValue.Value), &res)
			if err != nil {
				common.CBLog.Error(err)
				return nil, err
			}
			return res, nil
		case common.StrVNet:
			res := TbVNetInfo{}
			err = json.Unmarshal([]byte(keyValue.Value), &res)
			if err != nil {
				common.CBLog.Error(err)
				return nil, err
			}
			return res, nil
		}
	}
	errString := "Cannot get " + resourceType + " " + resourceId + "."
	err = fmt.Errorf(errString)
	return nil, err
}
func GetResource ( nsId string , resourceType string , resourceId string ) ( interface { } , error ) { err := common . CheckString ( nsId ) if err != nil { common . CBLog . Error ( err ) return nil , err } err = common . CheckString ( resourceId ) if err != nil { common . CBLog . Error ( err ) return nil , err } check , err := CheckResource ( nsId , resourceType , resourceId ) if ! check { errString := " " + resourceType + " " + resourceId + " " err := fmt . Errorf ( errString ) return nil , err } if err != nil { common . CBLog . Error ( err ) return nil , err } fmt . Println ( " " + resourceType + " " + resourceId ) key := common . GenResourceKey ( nsId , resourceType , resourceId ) keyValue , err := common . CBStore . Get ( key ) if err != nil { common . CBLog . Error ( err ) return nil , err } if keyValue != nil { switch resourceType { case common . StrImage : res := TbImageInfo { } err = json . Unmarshal ( [ ] byte ( keyValue . Value ) , & res ) if err != nil { common . CBLog . Error ( err ) return nil , err } return res , nil case common . StrSecurityGroup : res := TbSecurityGroupInfo { } err = json . Unmarshal ( [ ] byte ( keyValue . Value ) , & res ) if err != nil { common . CBLog . Error ( err ) return nil , err } return res , nil case common . StrSpec : res := TbSpecInfo { } err = json . Unmarshal ( [ ] byte ( keyValue . Value ) , & res ) if err != nil { common . CBLog . Error ( err ) return nil , err } return res , nil case common . StrSSHKey : res := TbSshKeyInfo { } err = json . Unmarshal ( [ ] byte ( keyValue . Value ) , & res ) if err != nil { common . CBLog . Error ( err ) return nil , err } return res , nil case common . StrVNet : res := TbVNetInfo { } err = json . Unmarshal ( [ ] byte ( keyValue . Value ) , & res ) if err != nil { common . CBLog . Error ( err ) return nil , err } return res , nil } } errString := " " + resourceType + " " + resourceId + " " err = fmt . Errorf ( errString ) return nil , err }
GetResource returns the requested TB MCIR object
GetResource returns the requested TB MCIR object
//mapA := map[string]string{"message": errString} //mapB, _ := json.Marshal(mapA) //fmt.Println(key) //return true, nil