Skip to content

Commit

Permalink
Support vpe (#200)
Browse files Browse the repository at this point in the history
* first implementation

* GroupPointTreeNode

* layout group point

* calc icon Location

* NewGroupedConnection()

* fip to groups

* gw router to grouping

* external icon

* icons Only

* only icons src/dst

* first implementation

* routers

* set routers

* cleanup

* sgs

* cidr

* cleanup details()

* DrawioGenerator

* DrawioGenerator

* removing allTreeNodes

* clean global vars

* fix is connected

* remove drawioResource

* DrawioGenerator struct

* new file

* oimt IBMGenerator

* gofmt

* lint

* removing Init()

* gp can only be icons[]

* subnet Conn

* handleGroupingLinesOverBorders()

* fix offset

* group square

* createGroupingSquares()

* remove double code

* lint

* comment

* first implementation

* naming endpoint

* connLabel

* add test

* create groupSquares

* GenerateDrawioTreeNode() for edges

* adding group points

* setGroupingIconsLocations()

* connectGroupies()

* right icon size

* fix groupies direction

* debugging

* code review

* block from parse args

* remove unused

* stronger overlapping

* fix setIconsMap()

* code review

* lint

* all tests

* code review

* fix icon location

* code review

* use offsets for squares

* square offset

* fix gp overlap

* fix inheritenc

* set consts

* simplify edge map

* visibility

* moving overlapping icons

* set visibility

* rewrite code

* calcGroupsOrder()

* nonGroupedIcons

* fixing rowIndex++

* adding tests

* clean test

* comments

* fix group counting

* no erows on groupPoint

* simplify calcGroupsOrder()

* rearange code

* rearange code

* rewrite code

* review

* fmt

* lint

* fix for not supporting vpe

* lint

* put vsi bigger than ni

* vpe styles

* miniIcon

* miniIcon

* initial rip

* resIPs

* resIP on drawio

* vpelayout

* vpe test

* drawio generator support

* multi nis example

* code review

* comments

* code review

* add test

* small fix

* an all test

* remove NIorRIPTreeNode

* hasMiniIcon()

* mini icons style

* remove HasVSIs

* rewrite calcGroupsVisibility

* overview

* lint

* code review

* static methods

* code review
  • Loading branch information
haim-kermany authored Oct 23, 2023
1 parent a05bbaa commit 0cb0e60
Show file tree
Hide file tree
Showing 15 changed files with 1,821 additions and 278 deletions.
2 changes: 1 addition & 1 deletion pkg/drawio/abstractTreeNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "strings"
const (
minID = 100
nextIDStep = 10
niVsiID = 1
miniIconID = 1
niFipID = 2
textID = 3
tagID = 4
Expand Down
12 changes: 5 additions & 7 deletions pkg/drawio/connectivityMap.drawio.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@
<mxGeometry width="{{$node.IconSize}}" height="{{$node.IconSize}}" x="{{$node.X}}" y="{{$node.Y}}" as="geometry"/>
</mxCell>
{{ end }}
{{ if $data.HasMiniIcon $node }}
<mxCell id="{{$data.IDsPrefix}}-{{$node.MiniIconID}}" value="" style="{{$data.MiniIconStyle $node}}" parent="{{$data.IDsPrefix}}-{{$node.ID}}" vertex="1">
<mxGeometry x="{{$data.MiniIconXOffset}}" y="{{$data.MiniIconYOffset}}" width="{{$data.MiniIconSize}}" height="{{$data.MiniIconSize}}" as="geometry"/>
</mxCell>
{{ end }}
{{ if $node.IsNI }}
{{ if $node.HasVsi }}
{{ if $data.ShowNIIcon }}
<mxCell id="{{$data.IDsPrefix}}-{{$node.VsiID}}" value="" style="{{$data.VsiStyle}}" parent="{{$data.IDsPrefix}}-{{$node.ID}}" vertex="1">
<mxGeometry x="{{$data.VSIXOffset}}" y="{{$data.VSIYOffset}}" width="{{$data.VSISize}}" height="{{$data.VSISize}}" as="geometry"/>
</mxCell>
{{ end }}
{{ end }}
{{ if $node.HasFip }}
<mxCell id="{{$data.IDsPrefix}}-{{$node.FipID}}" value="{{$node.Fip}}" style="{{$data.FIPStyle}}" parent="{{$data.IDsPrefix}}-{{$node.ID}}" vertex="1">
<mxGeometry x="{{$data.FipXOffset}}" y="{{$data.FipYOffset}}" width="{{$node.IconSize}}" height="{{$node.IconSize}}" as="geometry"/>
Expand Down
48 changes: 25 additions & 23 deletions pkg/drawio/createMapFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,29 @@ import (
var drawioTemplate string

type drawioData struct {
FipXOffset int
FipYOffset int
VSIXOffset int
VSIYOffset int
VSISize int
RootID uint
IDsPrefix string
// ShowNIIcon says if to display the NI as an NI image, or a VSI image
// the rule is that if we have a vsi icon, then we display the NI icon as an NI image
ShowNIIcon bool
Nodes []TreeNodeInterface
drawioStyles
rootID uint
Nodes []TreeNodeInterface
}

func NewDrawioData(network SquareTreeNodeInterface) *drawioData {
allNodes := getAllNodes(network)
orderedNodes := orderNodesForDrawio(allNodes)
return &drawioData{
newDrawioStyles(allNodes),
network.ID(),
orderedNodes,
}
}
func (data *drawioData) FipXOffset() int { return fipXOffset }
func (data *drawioData) FipYOffset() int { return fipYOffset }
func (data *drawioData) MiniIconXOffset() int { return miniIconXOffset }
func (data *drawioData) MiniIconYOffset() int { return miniIconYOffset }
func (data *drawioData) MiniIconSize() int { return miniIconSize }
func (data *drawioData) RootID() uint { return data.rootID }
func (data *drawioData) IDsPrefix() string { return idsPrefix }
func (data *drawioData) ElementComment(tn TreeNodeInterface) string {
return reflect.TypeOf(tn).Elem().Name() + " " + tn.Label()
}

// orderNodesForDrawio() sort the nodes for the drawio canvas
Expand Down Expand Up @@ -54,18 +66,8 @@ func orderNodesForDrawio(nodes []TreeNodeInterface) []TreeNodeInterface {

func CreateDrawioConnectivityMapFile(network SquareTreeNodeInterface, outputFile string) error {
newLayout(network).layout()
allNodes := getAllNodes(network)
data := &drawioData{
fipXOffset,
fipYOffset,
vsiXOffset,
vsiYOffset,
vsiIconSize,
network.ID(),
idsPrefix,
network.HasVSIs(),
orderNodesForDrawio(allNodes)}
return writeDrawioFile(data, outputFile)

return writeDrawioFile(NewDrawioData(network), outputFile)
}

func writeDrawioFile(data *drawioData, outputFile string) error {
Expand Down
Loading

0 comments on commit 0cb0e60

Please sign in to comment.