package asahttp import ( "errors" "fmt" "github.rackspace.com/gorax/clients/coreAPI" ) const asaPort = 8443 const asaContextPort = 443 type ASAHttp struct { user string password string baseUrl string } func NewASA(d *coreAPI.DeviceInfo, user, pass string, forcePublic bool) (*ASAHttp, error) { if d == nil { return nil, errors.New("CoreAPI DeviceInfo cannot be nil.") } ip := d.PrimaryIP if d.DracIP != "" && !forcePublic { ip = d.DracIP } if ip == "" { return nil, fmt.Errorf("Unable to find an IP address for %v", d.ID) } return newASA(ip, user, pass, d.Context) } // newASA function will return a ASAHttp type initialized with the required // values needed to make subsequent ASA Post/Get commands. func newASA(ip, user, password string, context bool) (*ASAHttp, error) { port := asaPort if context { port = asaContextPort } asa := &ASAHttp{ user: user, password: password, baseUrl: fmt.Sprintf("https://%s:%d/exec/", ip, port), } //if err := asa.TestConnection(ip, port); err != nil { // return nil, fmt.Errorf("Upsteam connection to %v failed. Cannot connect to HTTPS port 8443 or 443", ip) //} return asa, nil }