forked from PaloAltoNetworks/pango
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect.go
36 lines (31 loc) · 941 Bytes
/
connect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package pango
/*
Connect opens a connection to the PAN-OS client, then uses the "model" info
to return a pointer to either a Firewall or Panorama struct.
The Initialize function is invoked as part of this discovery, so there is no
need to Initialize() the Client connection prior to invoking this.
*/
func Connect(c Client) (interface{}, error) {
var err error
logg := c.Logging
c.Logging = LogQuiet
if err = c.Initialize(); err != nil {
return nil, err
}
model := c.SystemInfo["model"]
if model == "Panorama" || model[:2] == "M-" {
pano := &Panorama{Client: c}
pano.Logging = logg
if err = pano.Initialize(); err != nil {
return nil, err
}
return pano, nil
} else {
fw := &Firewall{Client: c}
fw.Logging = logg
if err = fw.Initialize(); err != nil {
return nil, err
}
return fw, nil
}
}