Skip to content

Commit

Permalink
get management_instance in IPv4 & IPv6 correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Drachionix committed Jun 26, 2023
1 parent 958e8f6 commit e57ff2d
Show file tree
Hide file tree
Showing 7 changed files with 2,185 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go/pkg/pass1/collect-routers-and-networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (c *spoc) collectRoutersAndNetworks() {
r1 := l[0]
m1 := r1.model.class
if r1.model.needManagementInstance {
mr := c.getRouter(r1.deviceName, r1.ipV6)
mr := c.getManagementInstance(r1)
if mr == nil {
c.err("Must define unmanaged router:%s\n"+
" with attribute 'management_instance'\n"+
Expand Down
4 changes: 2 additions & 2 deletions go/pkg/pass1/print-code.go
Original file line number Diff line number Diff line change
Expand Up @@ -2365,7 +2365,7 @@ func (c *spoc) getDevices() []*router {

func (c *spoc) printPanOS(fd *os.File, l []*router) {
r := l[0]
mgmt := c.getRouter(r.deviceName, r.ipV6)
mgmt := c.getManagementInstance(r)
hostnames := mgmt.deviceName
ipList := mgmt.interfaces[0].ip.String()
if backup := mgmt.backupInstance; backup != nil {
Expand Down Expand Up @@ -2393,7 +2393,7 @@ Generated by %s, version %s

func (c *spoc) printNSX(fd *os.File, l []*router) {
r := l[0]
mgmt := c.getRouter(r.deviceName, r.ipV6)
mgmt := c.getManagementInstance(r)
hostnames := mgmt.deviceName
ipList := mgmt.interfaces[0].ip.String()
if backup := mgmt.backupInstance; backup != nil {
Expand Down
8 changes: 8 additions & 0 deletions go/pkg/pass1/setup-objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -2867,6 +2867,14 @@ func (c *spoc) getRouter(name string, v6 bool) *router {
}
}

func (c *spoc) getManagementInstance(r *router) *router {
mgmt := c.getRouter(r.deviceName, c.conf.IPV6)
if mgmt == nil {
return c.getRouter(r.deviceName, !c.conf.IPV6)
}
return mgmt
}

func (c *spoc) getTypedName(a *ast.Attribute, ctx string) (string, string) {
v := c.getSingleValue(a, ctx)
typ, name, found := strings.Cut(v, ":")
Expand Down
Loading

0 comments on commit e57ff2d

Please sign in to comment.