infra

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: 17 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRetryTimesForHTTPReq = 6

Variables

View Source
var Delete = func(url string) (resp *http.Response, err error) {
	client := &http.Client{Timeout: constvalue.HTTPDefaultTimeoutInSec * time.Second}
	req, errreq := http.NewRequest("DELETE", url, nil)
	if errreq != nil {
		klog.Errorf("##Delete2Master http.NewRequest(DELETE,url,nil) error! -%v", errreq)
		return nil, errreq
	}

	resp, errresp := client.Do(req)
	if errresp != nil {
		klog.Errorf("##Delete2Master http.DefaultClient.Do(req) error! -%v", errresp)
		return nil, errresp
	}
	klog.Infof("##temp##:HttpDelete success! errreq and errresp should nil")
	return resp, nil
}
View Source
var GetDataBase = func() dbaccessor.DbAccessor {
	return etcdDataBase
}
View Source
var HTTPClose = func(resp *http.Response) error {
	return resp.Body.Close()
}
View Source
var HTTPDelete = func(url string) (*http.Response, error) {
	var resp *http.Response
	var err error
	for i := 1; i < MaxRetryTimesForHTTPReq; i++ {
		resp, err = Delete(url)
		if err == nil {
			return resp, nil
		}
		time.Sleep(time.Second * time.Duration(i))
	}
	return resp, err
}
View Source
var HTTPGet = func(url string) (*http.Response, error) {
	var resp *http.Response
	var err error
	for i := 1; i < MaxRetryTimesForHTTPReq; i++ {
		resp, err = get(url)
		if err == nil {
			return resp, nil
		}
		time.Sleep(time.Second * time.Duration(i))
	}
	return resp, err
}
View Source
var HTTPPost = func(url string, bodyType string, postData []byte) (*http.Response, error) {
	var resp *http.Response
	var err error
	for i := 1; i < MaxRetryTimesForHTTPReq; i++ {
		resp, err = post(url, bodyType, postData)
		if err == nil {
			return resp, nil
		}
		time.Sleep(time.Second * time.Duration(i))
	}
	return resp, err
}
View Source
var HTTPReadAll = func(resp *http.Response) ([]byte, error) {

	return ioutil.ReadAll(resp.Body)
}

Functions

func CheckDB

func CheckDB() error

func GetClientset

func GetClientset() *kubernetes.Clientset

func GetClusterID

func GetClusterID() string

func GetClusterUUID

func GetClusterUUID() string

func InitKubernetesClientset

func InitKubernetesClientset(kubeCnfig string) error

func InitManagerClient

func InitManagerClient(cfg *jason.Object) error

func IsHttpMethodStatusSuccess

func IsHttpMethodStatusSuccess(statusCode int) bool

func MakeURLReqIDSuffix

func MakeURLReqIDSuffix(reqID string) string

func NewGUID

func NewGUID(podID string) string

func SetClusterID

func SetClusterID()

func SetDataBase

func SetDataBase(i dbaccessor.DbAccessor) error

Types

type CreatePortInfo

type CreatePortInfo struct {
	Name       string     `json:"name"`
	NetworkID  string     `json:"network_id"`
	MacAddress string     `json:"mac_address"`
	FixedIps   []ports.IP `json:"fixed_ips"`
	GatewayIP  string     `json:"gateway_ip"`
	Cidr       string     `json:"cidr"`
	PortID     string     `json:"id"`
}

type CreatePortsResp

type CreatePortsResp struct {
	Ports []CreatePortInfo `json:"ports"`
}

type ManagerClient

type ManagerClient struct {
	// Header *http.Header
	URLKnitterManager string
	VMID              string
}

func GetManagerClient

func GetManagerClient() *ManagerClient

func (*ManagerClient) CheckKnitterManager

func (mc *ManagerClient) CheckKnitterManager() error

func (*ManagerClient) CreateNeutronBulkPorts

func (mc *ManagerClient) CreateNeutronBulkPorts(reqID string, req *ManagerCreateBulkPortsReq, tenantID string) (b []byte, e error)

func (*ManagerClient) Delete

func (mc *ManagerClient) Delete(deleteURL string) (b []byte, statusCode int, e error)

func (*ManagerClient) DeleteNeutronPort

func (mc *ManagerClient) DeleteNeutronPort(tenantID string, portID string) (e error)

func (*ManagerClient) Get

func (mc *ManagerClient) Get(postURL string) (int, []byte, error)

func (*ManagerClient) GetCreatePortURL

func (mc *ManagerClient) GetCreatePortURL(tenantID string) string

func (*ManagerClient) GetDefaultNetWork

func (mc *ManagerClient) GetDefaultNetWork(tenantID string) (string, error)

func (ManagerClient) GetDefaultNetworkURL

func (mc ManagerClient) GetDefaultNetworkURL(tenantID string) string

func (*ManagerClient) GetDeletePortURL

func (mc *ManagerClient) GetDeletePortURL(tenantID, portID string) string

func (*ManagerClient) GetHealthURL

func (mc *ManagerClient) GetHealthURL() string

func (*ManagerClient) GetTenantURL

func (mc *ManagerClient) GetTenantURL(tenantID string) string

func (*ManagerClient) PostBytes

func (mc *ManagerClient) PostBytes(postURL string, postData []byte) (int, []byte, error)

type ManagerCreateBulkPortsReq

type ManagerCreateBulkPortsReq struct {
	Ports []ManagerCreatePortReq `json:"ports"`
}

type ManagerCreatePortReq

type ManagerCreatePortReq struct {
	TenantID    string `json:"tenant_id"`
	NetworkName string `json:"network_name"`
	PortName    string `json:"port_name"`
	VnicType    string `json:"vnic_type"` // only used by physical port create-attach, logical port create ignore it
	NodeID      string `json:"node_id"`   // node id which send request
	PodNs       string `json:"pod_ns"`
	PodName     string `json:"pod_name"`
	FixIP       string `json:"ip_addr"`
	ClusterID   string `json:"cluster_id"`
	IPGroupName string `json:"ip_group_name"`
}

Jump to

Keyboard shortcuts

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