diff --git a/.gitignore b/.gitignore index 7b1269c1..59f09cb0 100644 --- a/.gitignore +++ b/.gitignore @@ -18,5 +18,8 @@ website/build # node modules node_modules +# testing +main.py + # trash .DS_Store \ No newline at end of file diff --git a/config.py b/config.py index 67562868..2f569131 100644 --- a/config.py +++ b/config.py @@ -72,6 +72,7 @@ ALIASES = { "ci": { "Circleci": "CircleCI", "Travisci": "TravisCI", + "Teamcity": "TC", }, "container": { "Rkt": "RKT", diff --git a/diagrams/__init__.py b/diagrams/__init__.py index 9626ea6d..8d35ca4e 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -1,6 +1,6 @@ import contextvars import os -from hashlib import md5 +import uuid from pathlib import Path from random import getrandbits from typing import List, Union, Dict @@ -159,13 +159,13 @@ class Diagram: return True return False - def node(self, hashid: str, label: str, **attrs) -> None: + def node(self, nodeid: str, label: str, **attrs) -> None: """Create a new node.""" - self.dot.node(hashid, label=label, **attrs) + self.dot.node(nodeid, label=label, **attrs) def connect(self, node: "Node", node2: "Node", edge: "Edge") -> None: """Connect the two Nodes.""" - self.dot.edge(node.hashid, node2.hashid, **edge.attrs) + self.dot.edge(node.nodeid, node2.nodeid, **edge.attrs) def subgraph(self, dot: Digraph) -> None: """Create a subgraph for clustering""" @@ -243,9 +243,9 @@ class Cluster: return True return False - def node(self, hashid: str, label: str, **attrs) -> None: + def node(self, nodeid: str, label: str, **attrs) -> None: """Create a new node in the cluster.""" - self.dot.node(hashid, label=label, **attrs) + self.dot.node(nodeid, label=label, **attrs) def subgraph(self, dot: Digraph) -> None: self.dot.subgraph(dot) @@ -267,8 +267,8 @@ class Node: :param label: Node label. """ - # Generates a hash for identifying a node. - self._hash = self._rand_hash() + # Generates an ID for identifying a node. + self._id = self._rand_id() self.label = label # fmt: off @@ -291,9 +291,9 @@ class Node: # If a node is in the cluster context, add it to cluster. if self._cluster: - self._cluster.node(self._hash, self.label, **self.attrs) + self._cluster.node(self._id, self.label, **self.attrs) else: - self._diagram.node(self._hash, self.label, **self.attrs) + self._diagram.node(self._id, self.label, **self.attrs) def __repr__(self): _name = self.__class__.__name__ @@ -366,8 +366,8 @@ class Node: return self @property - def hashid(self): - return self._hash + def nodeid(self): + return self._id # TODO: option for adding flow description to the connection edge def connect(self, node: "Node", edge: "Edge"): @@ -386,8 +386,8 @@ class Node: return node @staticmethod - def _rand_hash(): - return md5(getrandbits(64).to_bytes(64, "big")).hexdigest() + def _rand_id(): + return uuid.uuid4().hex def _load_icon(self): basedir = Path(os.path.abspath(os.path.dirname(__file__))) @@ -436,10 +436,13 @@ class Edge: for k, v in self._default_edge_attrs.items(): self._attrs[k] = v - # Graphviz complaining about using label for edges, so replace it with xlabel. - self._attrs["xlabel"] = label - self._attrs["color"] = color - self._attrs["style"] = style + if label: + # Graphviz complaining about using label for edges, so replace it with xlabel. + self._attrs["xlabel"] = label + if color: + self._attrs["color"] = color + if style: + self._attrs["style"] = style self._attrs.update(attrs) def __sub__(self, other: Union["Node", "Edge", List["Node"]]): diff --git a/diagrams/aws/network.py b/diagrams/aws/network.py index b3963d45..705e1962 100644 --- a/diagrams/aws/network.py +++ b/diagrams/aws/network.py @@ -36,6 +36,10 @@ class ElasticLoadBalancing(_Network): _icon = "elastic-load-balancing.png" +class Endpoint(_Network): + _icon = "endpoint.png" + + class GlobalAccelerator(_Network): _icon = "global-accelerator.png" @@ -68,6 +72,10 @@ class TransitGateway(_Network): _icon = "transit-gateway.png" +class VPCRouter(_Network): + _icon = "vpc-router.png" + + class VPC(_Network): _icon = "vpc.png" diff --git a/diagrams/onprem/ci.py b/diagrams/onprem/ci.py index 490fcd83..f6302b05 100644 --- a/diagrams/onprem/ci.py +++ b/diagrams/onprem/ci.py @@ -16,6 +16,10 @@ class Jenkins(_Ci): _icon = "jenkins.png" +class Teamcity(_Ci): + _icon = "teamcity.png" + + class Travisci(_Ci): _icon = "travisci.png" @@ -24,3 +28,4 @@ class Travisci(_Ci): CircleCI = Circleci TravisCI = Travisci +TC = Teamcity diff --git a/diagrams/onprem/iac.py b/diagrams/onprem/iac.py index 1fda1a1b..a2ae55d1 100644 --- a/diagrams/onprem/iac.py +++ b/diagrams/onprem/iac.py @@ -8,6 +8,14 @@ class _Iac(_OnPrem): _icon_dir = "resources/onprem/iac" +class Ansible(_Iac): + _icon = "ansible.png" + + +class Awx(_Iac): + _icon = "awx.png" + + class Terraform(_Iac): _icon = "terraform.png" diff --git a/diagrams/onprem/network.py b/diagrams/onprem/network.py index 05203fb6..82a61499 100644 --- a/diagrams/onprem/network.py +++ b/diagrams/onprem/network.py @@ -56,6 +56,10 @@ class Pfsense(_Network): _icon = "pfsense.png" +class Pomerium(_Network): + _icon = "pomerium.png" + + class Tomcat(_Network): _icon = "tomcat.png" diff --git a/docs/nodes/aws.md b/docs/nodes/aws.md index 09f68841..a032d90c 100644 --- a/docs/nodes/aws.md +++ b/docs/nodes/aws.md @@ -62,6 +62,7 @@ Node classes list of aws provider. - **diagrams.aws.network.Cloudfront**, **CF** (alias) - **diagrams.aws.network.DirectConnect** - **diagrams.aws.network.ElasticLoadBalancing**, **ELB** (alias) +- **diagrams.aws.network.Endpoint** - **diagrams.aws.network.GlobalAccelerator**, **GAX** (alias) - **diagrams.aws.network.InternetGateway** - **diagrams.aws.network.NATGateway** @@ -70,6 +71,7 @@ Node classes list of aws provider. - **diagrams.aws.network.Route53** - **diagrams.aws.network.SiteToSiteVpn** - **diagrams.aws.network.TransitGateway** +- **diagrams.aws.network.VPCRouter** - **diagrams.aws.network.VPC** ## aws.management diff --git a/docs/nodes/onprem.md b/docs/nodes/onprem.md index aac9b292..81db45d4 100644 --- a/docs/nodes/onprem.md +++ b/docs/nodes/onprem.md @@ -14,6 +14,7 @@ Node classes list of onprem provider. - **diagrams.onprem.ci.Circleci**, **CircleCI** (alias) - **diagrams.onprem.ci.Jenkins** +- **diagrams.onprem.ci.Teamcity**, **TC** (alias) - **diagrams.onprem.ci.Travisci**, **TravisCI** (alias) ## onprem.queue @@ -77,6 +78,7 @@ Node classes list of onprem provider. - **diagrams.onprem.network.Linkerd** - **diagrams.onprem.network.Nginx** - **diagrams.onprem.network.Pfsense**, **PFSense** (alias) +- **diagrams.onprem.network.Pomerium** - **diagrams.onprem.network.Tomcat** - **diagrams.onprem.network.Traefik** - **diagrams.onprem.network.Vyos**, **VyOS** (alias) @@ -90,6 +92,8 @@ Node classes list of onprem provider. ## onprem.iac +- **diagrams.onprem.iac.Ansible** +- **diagrams.onprem.iac.Awx** - **diagrams.onprem.iac.Terraform** ## onprem.analytics diff --git a/resources/aws/network/endpoint.png b/resources/aws/network/endpoint.png new file mode 100644 index 00000000..2357ce49 Binary files /dev/null and b/resources/aws/network/endpoint.png differ diff --git a/resources/aws/network/vpc-router.png b/resources/aws/network/vpc-router.png new file mode 100644 index 00000000..b0ae6d14 Binary files /dev/null and b/resources/aws/network/vpc-router.png differ diff --git a/resources/onprem/ci/teamcity.png b/resources/onprem/ci/teamcity.png new file mode 100644 index 00000000..54e922d1 Binary files /dev/null and b/resources/onprem/ci/teamcity.png differ diff --git a/resources/onprem/iac/ansible.png b/resources/onprem/iac/ansible.png new file mode 100644 index 00000000..39d77aa6 Binary files /dev/null and b/resources/onprem/iac/ansible.png differ diff --git a/resources/onprem/iac/awx.png b/resources/onprem/iac/awx.png new file mode 100644 index 00000000..975da780 Binary files /dev/null and b/resources/onprem/iac/awx.png differ diff --git a/resources/onprem/network/pomerium.png b/resources/onprem/network/pomerium.png new file mode 100644 index 00000000..1bf2da51 Binary files /dev/null and b/resources/onprem/network/pomerium.png differ