accessor

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Del4CloudT = func(db dbaccessor.DbAccessor, url, portid string) error {

	key4cloudt := url + "/" + portid

	if db == nil {
		klog.Errorf("db is null!!")
		return errors.New("db is null")
	}
	err := db.DeleteDir(key4cloudt)
	if err != nil {
		klog.Errorf("Del4CloudT key -%v,error!-%v", key4cloudt, err)
		return err
	}
	return nil
}
View Source
var Get4CloudT = func(db dbaccessor.DbAccessor, url, portid string) (*CloudTInfo, error) {

	key4cloudt := []string{url + "/" + portid + "/self",
		url + "/" + portid + "/veths",
		url + "/" + portid + "/ovsbrs",
		url + "/" + portid + "/driver"}
	var value4cloudt [4]string

	if db == nil {
		klog.Errorf("db is null!!")
		return nil, errors.New("db is null")
	}
	for index := range key4cloudt {
		str, err := db.ReadLeaf(key4cloudt[index])
		if err != nil {
			klog.Errorf("Get4CloudT key -%v,error!-%v", key4cloudt[index], err)
			return nil, err
		}
		value4cloudt[index] = str
	}
	var cloudt CloudTInfo
	cloudt.PortInfo = value4cloudt[0]
	cloudt.VethInfo = value4cloudt[1]
	cloudt.OvsbrInfo = value4cloudt[2]
	cloudt.MechDriverType = value4cloudt[3]

	return &cloudt, nil
}
View Source
var Set4CloudT = func(db dbaccessor.DbAccessor, url, portid string, t CloudTInfo) error {

	key4cloudt := []string{url + "/" + portid + "/self",
		url + "/" + portid + "/veths",
		url + "/" + portid + "/ovsbrs",
		url + "/" + portid + "/driver"}

	var value4cloudt [4]string
	value4cloudt[0] = t.PortInfo
	value4cloudt[1] = t.VethInfo
	value4cloudt[2] = t.OvsbrInfo
	value4cloudt[3] = t.MechDriverType

	if db == nil {
		klog.Errorf("db is null!!")
		return errors.New("db is null")
	}

	for index := range key4cloudt {
		err := db.SaveLeaf(key4cloudt[index], value4cloudt[index])
		if err != nil {
			klog.Errorf("Set4CloudT key -%v,error!-%v", key4cloudt[index], err)
			return err
		}
	}
	return nil
}

Functions

This section is empty.

Types

type Accessor

type Accessor interface {
	Init()
	Set(key string, value string) error
	Get(url string) (*jason.Object, error)
	DeleteDir(url string) error
	DeleteLeaf(url string) error
}

type CloudTInfo

type CloudTInfo struct {
	PortInfo       string
	VethInfo       string
	OvsbrInfo      string
	MechDriverType string
}

type Etcd

type Etcd struct {
	URL       string
	ServerAPI client.KeysAPI
}

func (*Etcd) CreateAPI

func (e *Etcd) CreateAPI(cfg client.Config) (client.KeysAPI, error)

func (*Etcd) DeleteDir

func (e *Etcd) DeleteDir(url string) error

func (*Etcd) DeleteLeaf

func (e *Etcd) DeleteLeaf(url string) error

func (*Etcd) Get

func (e *Etcd) Get(key string) (*jason.Object, error)

func (*Etcd) GetDir

func (e *Etcd) GetDir(key string) (*client.Response, error)

func (*Etcd) GetEtcdServerURLFromConfigure

func (e *Etcd) GetEtcdServerURLFromConfigure(serverconf []byte) (string, error)

func (*Etcd) GetPodID

func (e *Etcd) GetPodID(podinfo *jason.Object) (string, error)

func (*Etcd) GetPodNS

func (e *Etcd) GetPodNS(podinfo *jason.Object) (string, error)

func (*Etcd) GetPodName

func (e *Etcd) GetPodName(podinfo *jason.Object) (string, error)

func (*Etcd) Init

func (e *Etcd) Init(cniargs string, serverinfo []byte) error

func (*Etcd) Set

func (e *Etcd) Set(key string, value string) error

Jump to

Keyboard shortcuts

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