func NewClient()

in pkg/cloud/client.go [49:63]


func NewClient(cc_path string) (Client, error) {
	c := &client{}
	apiUrl, apiKey, secretKey, err := readAPIConfig(cc_path)
	if err != nil {
		return nil, errors.Wrapf(err, "Error encountered while reading config at path: %s", cc_path)
	}

	// TODO: attempt a less clunky client liveliness check (not just listing zones).
	c.cs = cloudstack.NewAsyncClient(apiUrl, apiKey, secretKey, false)
	_, err = c.cs.Zone.ListZones(c.cs.Zone.NewListZonesParams())
	if err != nil && strings.Contains(err.Error(), "i/o timeout") {
		return c, errors.Wrap(err, "Timeout while checking CloudStack API Client connectivity.")
	}
	return c, errors.Wrap(err, "Error encountered while checking CloudStack API Client connectivity.")
}