adapter

package
v0.0.0-...-9649b88 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClearDirFromDb = func(url string) error {
	agtCtx := cni.GetGlobalContext()
	return agtCtx.DB.DeleteDir(url)
}
View Source
var ClearLeafFromDb = func(url string) error {
	agtCtx := cni.GetGlobalContext()
	return agtCtx.DB.DeleteLeaf(url)
}
View Source
var ClearLeafFromRemoteDB = func(url string) error {
	agtCtx := cni.GetGlobalContext()
	return agtCtx.RemoteDB.DeleteLeaf(url)
}
View Source
var CreateSouthVnicInterface = func(tenantID, portName, networkName, vnicType, containerID string) (*mgragt.CreatePortInfo, error) {
	defer func() {
		if err := recover(); err != nil {
			klog.Infof("bridge:adapter_func: CreateSouthVnicInterface panic recover!")
		}
	}()
	agtCtx := cni.GetGlobalContext()
	var req = agtmgr.AttachPortReq{
		TenantID:    tenantID,
		NetworkName: networkName,
		PortName:    portName,
		NodeID:      agtCtx.VMID,
		VnicType:    vnicType,
		FixIP:       "",
		ClusterID:   agtCtx.ClusterID,
	}
	reqJSON, err := json.Marshal(&req)
	postURL := agtCtx.Mc.GetVnicInterfaceCreateURL(tenantID) + manager.MakeURLReqIDSuffix(manager.NewGUID(containerID))
	klog.Infof("CreateSouthVnicInterface:reqJSON:[%v], postUrl:[%v]", string(reqJSON), postURL)
	postStatusCode, portByte, err := agtCtx.Mc.PostBytes(postURL, reqJSON)
	if err != nil {
		klog.Errorf("masterClient.PostBytes error : %v, %v", err, string(portByte))
		return nil, fmt.Errorf("%v:CreateSouthVnicInterface-ERROR", err)
	}
	if postStatusCode != 200 {
		klog.Errorf("masterClient.PostBytes error : the status code is: -%v, portByte:[%v]", postStatusCode, string(portByte))
		return nil, fmt.Errorf("CreateSouthVnicInterface-ERROR, StatusCode:%v, ErrMsg:%v", postStatusCode, errobj.GetErrMsg(portByte))
	}
	var portObj mgragt.CreatePortResp
	err = json.Unmarshal(portByte, &portObj)
	if err != nil {
		klog.Errorf("CreateSouthVnicInterface: Unmarshal[%s] FAIL, error: %v", portByte, err)
		return nil, err
	}
	klog.Infof("CreateSouthVnicInterface: execute SUCC portObj[%+v]", portObj)

	return &(portObj.Port), nil
}
View Source
var DataPersisterIsExist = func(dp *infra.DataPersister) bool {
	return dp.IsExist()
}
View Source
var DataPersisterLoadFromMemFile = func(dp *infra.DataPersister, i interface{}) error {
	return dp.LoadFromMemFile(i)
}
View Source
var DataPersisterSaveToMemFile = func(dp *infra.DataPersister, i interface{}) error {
	return dp.SaveToMemFile(i)
}
View Source
var DestroyPort = func(agtObj *cni.AgentContext, port iaasaccessor.Interface) error {
	return agtObj.Mc.DeleteNeutronPort(port.Id, port.TenantID)
}

br0

View Source
var DestroySouthVnicInterface = func(tenantId, portID, containerID string) error {
	defer func() {
		if err := recover(); err != nil {
			klog.Infof("bridge:adapter_func: DestroySouthVnicInterface panic recover!")
		}
	}()
	agtCtx := cni.GetGlobalContext()
	delURL := agtCtx.Mc.GetVnicInterfaceDeleteURL(tenantId, agtCtx.VMID, portID) + manager.MakeURLReqIDSuffix(manager.NewGUID(containerID))
	_, statusCode, err := agtCtx.Mc.Delete(delURL)
	if err != nil {
		klog.Errorf("masterClient.Delete error : %v", err)
		return fmt.Errorf("%v:DestroySouthVnicInterface-ERROR", err)
	}
	if statusCode < 200 || statusCode >= 300 {
		klog.Errorf("masterClient.Delete error : the status code is: -%v", statusCode)
		return fmt.Errorf("DestroySouthVnicInterface-ERROR, StatusCode:%v", statusCode)
	}
	return nil
}
View Source
var GetPodsByNodeID = func(nodeId string) ([]*jason.Object, error) {
	agtCtx := cni.GetGlobalContext()
	return agtCtx.K8s.GetPodsOfNode(nodeId)
}

k8s

View Source
var JSONMarshal = func(v interface{}) ([]byte, error) {
	return json.Marshal(v)
}
View Source
var JasonObjectGetString = func(object *jason.Object, keys ...string) (string, error) {
	return object.GetString(keys...)
}
View Source
var ReadDirFromDb = func(url string) ([]*client.Node, error) {
	agtCtx := cni.GetGlobalContext()
	return agtCtx.DB.ReadDir(url)
}
View Source
var ReadLeafFromDb = func(url string) (string, error) {
	agtCtx := cni.GetGlobalContext()
	return agtCtx.DB.ReadLeaf(url)
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL