Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable cluster branding #279

Open
kobibarhanin opened this issue Sep 14, 2020 · 17 comments
Open

Enable cluster branding #279

kobibarhanin opened this issue Sep 14, 2020 · 17 comments

Comments

@kobibarhanin
Copy link

To add clarity to any deep dive design it would be helpful if users could add a brand / type to a cluster object:

say I have a complicated design including an AKS cluster with its own internal design - with this capability added I could then mark the cluster to be AKS and have perhaps a small AKS logo on the side to enhance the drill down clarity of the diagram.

from diagrams.azure.compute import AKS

with Cluster("Sync-service", type=AKS):
    ...    
@steschuser
Copy link

There is a pull request to allow Icons for Clusters #90

@clayms
Copy link

clayms commented Nov 4, 2020

What about this?

from diagrams.azure.compute import AKS, ContainerInstances

graph_attr = {
    "splines":"curved",
    "layout":"neato",
    }

with Diagram('\ndemo', show=False, graph_attr=graph_attr) as diag:
    with Cluster("Sync-service"):
        aks_cluster = AKS(
            label="AKS", fontsize="6", loc="t",
            fixedsize="true", width="0.5", height="0.8", 
            pin="true", pos="0,2")
        cont1 = ContainerInstances("Pod", pin="true", pos="1,1")
        blank = Node(shape="plaintext", pin="true", pos="2,1" )

diag

image

@bkmeneguello
Copy link

Please, check #407 it's a refactor of Nodes to be used as Clusters and add the node icon to the Cluster

@dan-ash
Copy link
Contributor

dan-ash commented Jan 27, 2021

please check my new PR #439 which implement the feature based on @givanovexpe @bkmeneguello & my work

@clayms clayms mentioned this issue Jan 29, 2021
@seema1711
Copy link

What about this?

from diagrams.azure.compute import AKS, ContainerInstances

graph_attr = {
    "splines":"curved",
    "layout":"neato",
    }

with Diagram('\ndemo', show=False, graph_attr=graph_attr) as diag:
    with Cluster("Sync-service"):
        aks_cluster = AKS(
            label="AKS", fontsize="6", loc="t",
            fixedsize="true", width="0.5", height="0.8", 
            pin="true", pos="0,2")
        cont1 = ContainerInstances("Pod", pin="true", pos="1,1")
        blank = Node(shape="plaintext", pin="true", pos="2,1" )

diag

image

I tried this, but I am not able to position it correctly, whatever I give in position, it's not changing. It's just this.

image

@clayms
Copy link

clayms commented Feb 19, 2021

@seema1711 please show your code.

My first guess is that you are not using neato as your layout engine.

This code works for me:

from diagrams import Diagram, Cluster
from diagrams.aws.general import OfficeBuilding, TraditionalServer
from diagrams.onprem.client import Client

graph_attr = {
    "splines":"curved",
    "layout":"neato",
    }

with Diagram('\ndemo', show=False, graph_attr=graph_attr) as diag:
    with Cluster(""):
        ofb = OfficeBuilding(
            label="", fontsize="6", loc="t",
            fixedsize="true", width="0.5", height="0.8", 
            pin="true", pos="0,2")
        cli = Client("", pin="true", pos="1,1")
        ser = TraditionalServer("", pin="true", pos="3,1" )

diag

image

@seema1711
Copy link

I have many clusters in my code, if I am using neato then it's just creates a mess with other clusters.
My code:

from diagrams import Diagram, Cluster, Edge

from diagrams.aws.network import DirectConnect, VPCRouter, TransitGateway
from diagrams.aws.general import TraditionalServer, OfficeBuilding
from diagrams.onprem.client import Client

graph_attr = {
    "splines":"spline",
    "layout":"neato"
    }
with Diagram("\nSample", graph_attr=graph_attr, show=False, direction='TB'):
    with Cluster("PMI Data Center"):
        officebuilding = OfficeBuilding(
            label="", fontsize="6", loc="t",
            fixedsize="true", width="0.5", height="0.8", 
            pin="true", pos="0,2")
        tradServer = TraditionalServer("DWH Database \nwith mixed \nmode authentication", pin="true", pos="3,1")
        pc = Client("\t\t\t\tOn Prem User \nAccess dares over HTTP", pin="true", pos="1,1")

Like this:
image

And also I tried your code, it doesn't display the border of the cluster:
image

I tried using other method also, I got this error.

@clayms
Copy link

clayms commented Feb 20, 2021

With neato, you have to specify the positions of each node for the whole Graph. (Note: neato does have automatic positioning algorithms, but you have to specify them)

Also, you can't nest the clusters. (Note: you can but, you loose some of the cluster's attributes)

Please show the code for the other clusters and nodes I see in your graph.

@seema1711
Copy link

Okay, is there any other way for cluster branding?

@bkmeneguello
Copy link

bkmeneguello commented Feb 20, 2021

I think "neato/circo/twopi" don't display subgraphs, it's a limitation. Possibly with "fdp" you could have a result similar to "neato" with subgraphs.
Source: ellson/MOTHBALLED-graphviz#1057

@clayms
Copy link

clayms commented Feb 20, 2021

the solution dan-ash and bkmeneguello are working on will be much better, but in the meantime you will have to do something like the following:

from diagrams import Diagram, Node, Edge, Cluster
from diagrams.aws.network import DirectConnect, VPCRouter, TransitGateway
from diagrams.aws.general import OfficeBuilding, TraditionalServer
from diagrams.onprem.client import Client

graph_attr = {
    "splines":"curved",
    "layout":"neato",
    }

with Diagram('\ndemo', show=False, graph_attr=graph_attr) as diag:
    
    with Cluster(""):
        Node("", shape="plaintext", pin="true", pos="-1,-1")
        Node("", shape="plaintext", pin="true", pos="10,6")
        ofb = OfficeBuilding(
            label="", fontsize="6", loc="t",
            fixedsize="true", width="0.5", height="0.8", 
            pin="true", pos="-1,6")
        
    with Cluster("client", graph_attr={"bgcolor":"azure"}):
        Node("", shape="plaintext", pin="true", pos="0,4")
        Node("", shape="plaintext", pin="true", pos="5.5,5.5")
        pc = Client("\t\t\t\tOn Prem User \nAccess dares over HTTP", pin="true", pos="1,5")
        tradServer = TraditionalServer("DWH Database \nwith mixed \nmode authentication", pin="true", pos="5,5")

    with Cluster("vpc1", graph_attr={"bgcolor":"thistle"}):
        Node("", shape="plaintext", pin="true", pos="0,0")
        Node("", shape="plaintext", pin="true", pos="3,2")
        cd1 = DirectConnect("", pin="true", pos="0.5,1")
        vpcr1 = VPCRouter("", pin="true", pos="2.5,1" )

    with Cluster("vpc2", graph_attr={"bgcolor":"seagreen3"}):
        Node("", shape="plaintext", pin="true", pos="5,1.5")
        Node("", shape="plaintext", pin="true", pos="9,2.5")
        tg = TransitGateway("", pin="true", pos="6,2")
        vpcr2 = VPCRouter("", pin="true", pos="8,2" )


diag

image

@seema1711
Copy link

Okay, I will try that. Thank you @clayms @bkmeneguello

@seema1711
Copy link

I don't know why but when I try this it's not showing any clusters. #279 (comment)
It's just this:

image

@clayms
Copy link

clayms commented Feb 21, 2021

@seema1711 if you are indeed running exactly what I posted in a fresh session, then I have no idea. My first guess is that you might be using a different versions, but that is just a guess.

Please post the exact code you are using.

My installations:

$ dot -V

dot - graphviz version 2.38.0 (20140413.2041)
$ pip freeze
...
diagrams==0.18.0
...
graphviz==0.13.2
...

@seema1711
Copy link

@seema1711 if you are indeed running exactly what I posted in a fresh session, then I have no idea. My first guess is that you might be using a different versions, but that is just a guess.

Please post the exact code you are using.

My installations:

$ dot -V

dot - graphviz version 2.38.0 (20140413.2041)
$ pip freeze
...
diagrams==0.18.0
...
graphviz==0.13.2
...

It worked actually, I found out that I was using neato instead of dot. Thanks for the help.

@ncamit
Copy link

ncamit commented Apr 23, 2022

Okay, I will try that. Thank you @clayms @bkmeneguello

I copied the same code but with any layout like neato, dot and fdp i couldn't get the same . Please help

@ncamit
Copy link

ncamit commented Apr 23, 2022

I have copied the code and cluster doesn't show

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants