xcat

package
v0.0.0-...-57a9c67 Latest Latest
Warning

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

Go to latest
Published: May 24, 2019 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DictRes2Inv = map[string]string{
	"machinetype": "device_info.mtm",
	"arch":        "device_info.arch",
	"disksize":    "device_info.disksize",
	"memory":      "device_info.memory",
	"cputype":     "device_info.cputype",
	"cpucount":    "device_info.cpucount",
	"ip":          "network_info.primarynic.ip",
	"mac":         "network_info.primarynic.mac",
	"rack":        "position_info.rack",
	"unit":        "position_info.unit",
	"room":        "position_info.room",
	"height":      "position_info.height",
	"osimage":     "engines.netboot_engine.engine_info.osimage",
	"tags":        "obj_info.description",
}
View Source
var SelectorOpMaps = map[string][]string{
	"disksize":    []string{"=", ">", ">=", "<", "<="},
	"memory":      []string{"=", ">", ">=", "<", "<="},
	"cpucount":    []string{"=", ">", ">=", "<", "<="},
	"cputype":     []string{"=", "!=", "!~", "=~"},
	"machinetype": []string{"="},
	"name":        []string{"="},
	"rack":        []string{"="},
	"unit":        []string{"="},
	"room":        []string{"="},
	"arch":        []string{"="},
	"gpu":         []string{"="},
	"ib":          []string{"="},
}

Functions

func ApplyNodes

func ApplyNodes(baseUrl string, token interface{}, nodeattrs interface{}) (string, int, string)

func CheckHTTPResponseStatusCode

func CheckHTTPResponseStatusCode(resp *http.Response) error

func CheckTokenValidate

func CheckTokenValidate(baseUrl string, token interface{}) (string, int, string)

func Contains

func Contains(a []string, x string) bool

check whether string x is in string list a

func FormatResponse

func FormatResponse(resp interface{}, err error) (interface{}, int, string)

If there is error

check whether match known string, if yes return error code 1 and error string
or return response code and message

func Intf2Map

func Intf2Map(v interface{}) map[string]string

func ListNodeDetail

func ListNodeDetail(node string, baseUrl string, token interface{}) (string, int, string)

func ListNodePowerStatus

func ListNodePowerStatus(node string, baseUrl string, token interface{}) (string, int, string)

func ListNodeStatus

func ListNodeStatus(node string, baseUrl string, token interface{}) (string, int, string)

func Login

func Login(baseUrl string, username string, password string) (string, int, string)

func MapConvInt2Str

func MapConvInt2Str(data map[string]interface{}) map[string]string

convert

func NodeInv2Res

func NodeInv2Res(myjson string, d *schema.ResourceData, node string, status string) int

func Provider

func Provider() terraform.ResourceProvider

func ProvisionNode

func ProvisionNode(node string, baseUrl string, token interface{}, osimage string) (string, int, string)

func ReleaseNode

func ReleaseNode(node string, baseUrl string, token interface{}) (string, int, string)

func Res2DefAttr

func Res2DefAttr(resattr string) string

func SetPowerStatus

func SetPowerStatus(node string, baseUrl string, token interface{}, status string) (string, int, string)

Types

type Config

type Config struct {
	Url      string
	Username string
	Password string

	Token string
}

type HttpClient

type HttpClient struct {
	Client  *http.Client
	Headers http.Header
}

func GenerateClient

func GenerateClient(baseUrl string, timeout time.Duration) *HttpClient

return HttpClient with timeout and tls parameters

func (*HttpClient) Delete

func (s *HttpClient) Delete(url string, params *url.Values, token interface{}, body interface{}, retRaw bool) (interface{}, error)

func (*HttpClient) Do

func (s *HttpClient) Do(req *http.Request) (*http.Response, error)

func (*HttpClient) Get

func (s *HttpClient) Get(url string, params *url.Values, token interface{}, body interface{}, retRaw bool) (interface{}, error)

func (*HttpClient) Patch

func (s *HttpClient) Patch(url string, params *url.Values, token interface{}, body interface{}, retRaw bool) (interface{}, error)

func (*HttpClient) Post

func (s *HttpClient) Post(url string, params *url.Values, token interface{}, body interface{}, retRaw bool) (interface{}, error)

func (*HttpClient) Put

func (s *HttpClient) Put(url string, params *url.Values, token interface{}, body interface{}, retRaw bool) (interface{}, error)

func (*HttpClient) Request

func (s *HttpClient) Request(method string, url string, params *url.Values, headers *http.Header, token interface{}, body *[]byte, retRaw bool) (data interface{}, err error)

Jump to

Keyboard shortcuts

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