ucsclient

package
v0.0.0-...-12b9222 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const BODY_TYPE_XML = "text/xml"

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient(insecureSkipVerify bool) *http.Client

Types

type Config

type Config struct {
	IpAddress             string
	Username              string
	Password              string
	TslInsecureSkipVerify bool
	LogLevel              int
	LogFilename           string
	AppName               string
}

func (*Config) Client

func (c *Config) Client() *UCSClient

Configures and returns a fully initialised UCSClient.

type HTTPClient

type HTTPClient interface {
	Post(string, string, io.Reader) (*http.Response, error)
}

type ServiceProfile

type ServiceProfile struct {
	Name         string
	Template     string
	TargetOrg    string
	Hierarchical bool
	VNICs        []VNIC
}

func (*ServiceProfile) DN

func (sp *ServiceProfile) DN() string

func (*ServiceProfile) Marshal

func (sp *ServiceProfile) Marshal(cookie string) ([]byte, error)

The XML request sent to the UCS server to create a Service Profile *must* include a cookie which does not belong to the ServiceProfile model per se, hence the `cookie` argument required.

func (*ServiceProfile) ToJSON

func (sp *ServiceProfile) ToJSON() (string, error)

type UCSClient

type UCSClient struct {
	Logger *utils.Logger
	// contains filtered or unexported fields
}

func NewUCSClient

func NewUCSClient(c *Config) *UCSClient

func (*UCSClient) ConfigResolveDN

func (c *UCSClient) ConfigResolveDN(dn string) (*ServiceProfile, error)

func (*UCSClient) CreateServiceProfile

func (c *UCSClient) CreateServiceProfile(sp *ServiceProfile) (bool, error)

Performs a POST request to the UCS server to create a service profile. Returns bool to indicate wether or not the resource could be created, along with an error if anything went wrong.

func (*UCSClient) Destroy

func (c *UCSClient) Destroy(name, targetOrg string, hierarchical bool) error

func (*UCSClient) IsLoggedIn

func (c *UCSClient) IsLoggedIn() bool

Determines if the UCSClient is logged into the server by checking the presence of cookie.

func (*UCSClient) Login

func (c *UCSClient) Login() error

Logs into the UCS server by posting the username and password in the config. Returns an error if anything goes wrong.

func (*UCSClient) Logout

func (c *UCSClient) Logout()

Logs out of the UCS server.

func (*UCSClient) Post

func (c *UCSClient) Post(payload []byte) ([]byte, error)

Performs a POST request to the UCS Server. Returns a string with the response's body. In case that an error happens it will return an empty string along with an error.

type VNIC

type VNIC struct {
	Name string
	Mac  string
	CIDR string
	Ip   net.IP
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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