Initial commit
This commit is contained in:
commit
c18e4b6f9d
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
__pycache__
|
||||||
|
*.png
|
||||||
17
audio.py
Executable file
17
audio.py
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
from diagrams.custom import Custom
|
||||||
|
|
||||||
|
def Amplifier(label='Amplifier'):
|
||||||
|
return Custom(label, './icons/amplifier.png')
|
||||||
|
|
||||||
|
def AudioStreamer(label='Audio streamer'):
|
||||||
|
return Custom(label, './icons/music.png')
|
||||||
|
|
||||||
|
def TubeAmp(label='Tube Amplifier'):
|
||||||
|
return Custom(label, './icons/tube_amp.png')
|
||||||
|
|
||||||
|
def TurnTable(label='TurnTable'):
|
||||||
|
return Custom(label, './icons/turntable.png')
|
||||||
11
consoles.py
Executable file
11
consoles.py
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
from diagrams.custom import Custom
|
||||||
|
|
||||||
|
def NintendoSwitch(label='Nintendo Switch'):
|
||||||
|
return Custom(label, './icons/nintendo_switch.png')
|
||||||
|
|
||||||
|
def PlayStation4(label='PlayStation 4'):
|
||||||
|
return Custom(label, './icons/playstation4.png')
|
||||||
26
devices.py
Executable file
26
devices.py
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
from diagrams.custom import Custom
|
||||||
|
|
||||||
|
def AndroidPhone(label='Android Phone'):
|
||||||
|
return Custom(label, './icons/android_phone.png')
|
||||||
|
|
||||||
|
def IPhone(label='IPhone'):
|
||||||
|
return Custom(label, './icons/iphone.png')
|
||||||
|
|
||||||
|
def Laptop(label='Laptop'):
|
||||||
|
return Custom(label, './icons/laptop.png')
|
||||||
|
|
||||||
|
def NUC(label='Intel NUC'):
|
||||||
|
return Custom(label, './icons/intel_nuc.png')
|
||||||
|
|
||||||
|
def Rpi4(label='RaspBerryPi4'):
|
||||||
|
return Custom(label, './icons/raspberry_pi.png')
|
||||||
|
|
||||||
|
def Printer(label='Printer'):
|
||||||
|
return Custom(label, './icons/printer.png')
|
||||||
|
|
||||||
|
def WashingMachine(label='Washing Machine'):
|
||||||
|
return Custom(label, './icons/washing_machine.png')
|
||||||
30
edges.py
Executable file
30
edges.py
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
from diagrams import Edge, Node
|
||||||
|
|
||||||
|
# Dict defining our custom edges styles.
|
||||||
|
EDGES = {
|
||||||
|
'adsl': { 'color': 'purple4', 'style': 'dotted' },
|
||||||
|
'audio': { 'color': 'khaki4', 'style': 'solid' },
|
||||||
|
'bluetooth': { 'color': 'royalblue1', 'style': 'dashed' },
|
||||||
|
'cable': { 'color': 'rebeccapurple', 'style': 'dotted' },
|
||||||
|
'electric': { 'color': 'turquoise', 'style': 'tapered' },
|
||||||
|
'ethernet': { 'color': 'navy', 'style': 'solid' },
|
||||||
|
'hdmi': { 'color': 'palegreen4', 'style': 'solid' },
|
||||||
|
'wifi': { 'color': 'firebrick', 'style': 'dashed' },
|
||||||
|
'zigbee': { 'color': 'orange', 'style': 'dashed' }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Common method to instanciate a styled edge
|
||||||
|
def MyEdge(edge):
|
||||||
|
return Edge(color=EDGES[edge]['color'], style=EDGES[edge]['style'])
|
||||||
|
|
||||||
|
# Generate a legend for the colors and styles
|
||||||
|
def Legend():
|
||||||
|
_html = '<<TABLE>'
|
||||||
|
for edge in EDGES.keys():
|
||||||
|
_html += f"""<TR><TD BGCOLOR="{EDGES[edge]['color']}">{edge} ({EDGES[edge]['style']})</TD></TR>"""
|
||||||
|
_html += '</TABLE>>'
|
||||||
|
return Node(label=_html, shape='plaintext')
|
||||||
11
electricity.py
Executable file
11
electricity.py
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
from diagrams.custom import Custom
|
||||||
|
|
||||||
|
def Boxx(label='Boxx'):
|
||||||
|
return Custom(label, './icons/boxx.png')
|
||||||
|
|
||||||
|
def CPL(label='CPL'):
|
||||||
|
return Custom(label, './icons/cpl.png')
|
||||||
8
fitbit.py
Executable file
8
fitbit.py
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
from diagrams.custom import Custom
|
||||||
|
|
||||||
|
def Aria(label='Fitbit Aria'):
|
||||||
|
return Custom(label, './icons/fitbit_aria.png')
|
||||||
150
konijnenberg.py
Executable file
150
konijnenberg.py
Executable file
@ -0,0 +1,150 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
"""Home network diagram
|
||||||
|
"""
|
||||||
|
|
||||||
|
from diagrams import Cluster, Diagram
|
||||||
|
from diagrams.generic.network import Firewall, Router, Switch
|
||||||
|
from diagrams.onprem.network import Internet
|
||||||
|
from diagrams.onprem.client import User, Users
|
||||||
|
from diagrams.onprem.compute import Server
|
||||||
|
from diagrams.generic.storage import Storage
|
||||||
|
|
||||||
|
from audio import Amplifier, AudioStreamer, TubeAmp, TurnTable
|
||||||
|
from consoles import NintendoSwitch, PlayStation4
|
||||||
|
from devices import AndroidPhone, IPhone, Laptop, NUC, Printer, Rpi4, WashingMachine
|
||||||
|
from edges import MyEdge, Legend
|
||||||
|
from electricity import Boxx, CPL
|
||||||
|
from fitbit import Aria
|
||||||
|
from lights import HueBridge, HueBulb, HueSpot, SmartPlug, Tradfri
|
||||||
|
from network import Modem, UniFiAP
|
||||||
|
from video import ProximusTV, Television, UltraWideScreen
|
||||||
|
|
||||||
|
GRAPH_ATTRS = {
|
||||||
|
'layout' : 'dot',
|
||||||
|
'compound': 'True',
|
||||||
|
'splines' : 'spline',
|
||||||
|
'clusterrank':'local',
|
||||||
|
'ordering':'in'}
|
||||||
|
|
||||||
|
|
||||||
|
with Diagram('Konijnenberg', direction='BT', graph_attr=GRAPH_ATTRS):
|
||||||
|
|
||||||
|
with Cluster('Users'):
|
||||||
|
alistair = User('Alistair')
|
||||||
|
clement = User('Clément')
|
||||||
|
maithe = User('Maïthé')
|
||||||
|
|
||||||
|
guests = Users('Guests')
|
||||||
|
|
||||||
|
|
||||||
|
with Cluster('Mobile'):
|
||||||
|
laptop_clement = Laptop('Laptop Clément')
|
||||||
|
laptop_maithe = Laptop('Laptop Maïthé')
|
||||||
|
nintendo_switch = NintendoSwitch('Switch Alistair')
|
||||||
|
tel_alistair = AndroidPhone('Téléphone Alistair')
|
||||||
|
tel_clement = AndroidPhone('Téléphone Clément')
|
||||||
|
tel_maithe = IPhone('Téléphone Maïthé')
|
||||||
|
|
||||||
|
wifi_devices = [ nintendo_switch, laptop_clement, laptop_maithe,
|
||||||
|
tel_alistair, tel_maithe, tel_clement ]
|
||||||
|
|
||||||
|
|
||||||
|
with Cluster('Salon'):
|
||||||
|
boxx = Boxx()
|
||||||
|
hue = HueBridge('Hue Bridge')
|
||||||
|
living_cpl = CPL('CPL salon')
|
||||||
|
malkovitch = Firewall('malkovitch')
|
||||||
|
proximus = Internet('Proximus')
|
||||||
|
proximus_router = Modem('Proximus')
|
||||||
|
telenet = Internet('Telenet')
|
||||||
|
telenet_router = Modem('Telenet')
|
||||||
|
wifi_ap = UniFiAP('NanoHD')
|
||||||
|
|
||||||
|
|
||||||
|
with Cluster('Sono'):
|
||||||
|
ampli = Amplifier('Ampli')
|
||||||
|
hifi = AudioStreamer('HiFi')
|
||||||
|
preamp = TubeAmp('Preampli phono')
|
||||||
|
turntable = TurnTable('Platine')
|
||||||
|
|
||||||
|
ampli << MyEdge('audio') >> [ hifi, preamp ]
|
||||||
|
preamp << MyEdge('audio') >> turntable
|
||||||
|
|
||||||
|
|
||||||
|
with Cluster('Video'):
|
||||||
|
tv = Television('TV')
|
||||||
|
jack = Rpi4('Jack')
|
||||||
|
proximus_tv = ProximusTV('Decodeur')
|
||||||
|
|
||||||
|
tv << MyEdge('hdmi') << [ jack, proximus_tv ]
|
||||||
|
|
||||||
|
|
||||||
|
with Cluster('Lights'):
|
||||||
|
with Cluster('Salon'):
|
||||||
|
lumieres_salon = [ HueBulb('Boule Salon'), HueBulb('Lustre Canapé'), HueBulb('Lustre Table'),
|
||||||
|
SmartPlug('Vinyls'), SmartPlug('Mappemonde'),
|
||||||
|
Tradfri('Vaisselier') ]
|
||||||
|
|
||||||
|
with Cluster('Veranda'):
|
||||||
|
lumieres_veranda = [ HueSpot(f'Veranda {x}') for x in range(6) ]
|
||||||
|
|
||||||
|
|
||||||
|
wifi_ap << MyEdge('wifi') >> [ tv, jack, boxx, hifi ]
|
||||||
|
malkovitch << MyEdge('ethernet') >> [telenet_router, proximus_router, wifi_ap]
|
||||||
|
telenet_router << MyEdge('cable') >> telenet
|
||||||
|
proximus_router << MyEdge('adsl') >> proximus
|
||||||
|
malkovitch << MyEdge('ethernet') >> living_cpl
|
||||||
|
proximus_router << MyEdge('ethernet') >> [ hue, proximus_tv ]
|
||||||
|
hue << MyEdge('zigbee') >> lumieres_salon
|
||||||
|
hue << MyEdge('zigbee') >> lumieres_veranda
|
||||||
|
|
||||||
|
|
||||||
|
with Cluster('Bureau'):
|
||||||
|
tv_bureau = Television()
|
||||||
|
ecran_bureau = UltraWideScreen()
|
||||||
|
walter = NUC('walter')
|
||||||
|
switch = Switch('dlink')
|
||||||
|
office_cpl = CPL('CPL bureau')
|
||||||
|
printer = Printer()
|
||||||
|
rainbow = Rpi4('Rainbow')
|
||||||
|
rpi4_1 = Rpi4('RPI4/1')
|
||||||
|
rpi4_2 = Rpi4('RPI4/2')
|
||||||
|
rpi4_3 = Rpi4('RPI4/3')
|
||||||
|
rpi4_4 = Rpi4('RPI4/4')
|
||||||
|
rpi4_5 = Rpi4('RPI4/5')
|
||||||
|
ps4 = PlayStation4()
|
||||||
|
zippo = Storage('Zippo')
|
||||||
|
lumieres_bureau = [ HueSpot('Plafond bureau 1'), HueSpot('Plafond bureau 2') ]
|
||||||
|
|
||||||
|
ecran_bureau << MyEdge('hdmi') >> walter
|
||||||
|
tv_bureau << MyEdge('hdmi') >> [ ps4, rainbow ]
|
||||||
|
switch << MyEdge('ethernet') >> [ office_cpl, printer, walter, ps4,
|
||||||
|
rainbow, rpi4_1, rpi4_2, rpi4_3,
|
||||||
|
rpi4_4, rpi4_5, zippo ]
|
||||||
|
|
||||||
|
|
||||||
|
with Cluster('Salle de bain'):
|
||||||
|
balance = Aria('Balance')
|
||||||
|
|
||||||
|
|
||||||
|
with Cluster('Cuisine'):
|
||||||
|
flex2i = AudioStreamer('Flex 2i')
|
||||||
|
|
||||||
|
|
||||||
|
with Cluster('Garage'):
|
||||||
|
lessiveuse = WashingMachine('Lave linge')
|
||||||
|
|
||||||
|
living_cpl << MyEdge('electric') >> office_cpl
|
||||||
|
wifi_ap << MyEdge('ethernet') >> malkovitch
|
||||||
|
wifi_ap << MyEdge('wifi') >> wifi_devices
|
||||||
|
wifi_ap << MyEdge('wifi') >> balance
|
||||||
|
wifi_ap << MyEdge('wifi') >> flex2i
|
||||||
|
wifi_ap << MyEdge('wifi') >> lessiveuse
|
||||||
|
hue << MyEdge('zigbee') >> lumieres_bureau
|
||||||
|
|
||||||
|
alistair >> [ nintendo_switch, tel_alistair ]
|
||||||
|
maithe >> [ tel_maithe, laptop_maithe ]
|
||||||
|
clement >> [ tel_clement, laptop_clement, walter ]
|
||||||
20
lights.py
Executable file
20
lights.py
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
from diagrams.custom import Custom
|
||||||
|
|
||||||
|
def HueBridge(label='Hue Bridge'):
|
||||||
|
return Custom(label, './icons/hue_bridge.png')
|
||||||
|
|
||||||
|
def HueBulb(label='Hue Bulb'):
|
||||||
|
return Custom(label, './icons/hue_bulb.png')
|
||||||
|
|
||||||
|
def HueSpot(label='Hue Spot'):
|
||||||
|
return Custom(label, './icons/hue_spot.png')
|
||||||
|
|
||||||
|
def SmartPlug(label='Smart Plug'):
|
||||||
|
return Custom(label, './icons/smart_plug.png')
|
||||||
|
|
||||||
|
def Tradfri(label='TRÅDFRI'):
|
||||||
|
return Custom(label, './icons/tradfri.png')
|
||||||
11
network.py
Executable file
11
network.py
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
from diagrams.custom import Custom
|
||||||
|
|
||||||
|
def Modem(label='Modem'):
|
||||||
|
return Custom(label, './icons/modem.png')
|
||||||
|
|
||||||
|
def UniFiAP(label='WiFi AP'):
|
||||||
|
return Custom(label, './icons/uap.png')
|
||||||
14
video.py
Executable file
14
video.py
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
from diagrams.custom import Custom
|
||||||
|
|
||||||
|
def ProximusTV(label='Proximus TV Decoder'):
|
||||||
|
return Custom(label, './icons/proximus_tv.png')
|
||||||
|
|
||||||
|
def Television(label='Television'):
|
||||||
|
return Custom(label, './icons/television.png')
|
||||||
|
|
||||||
|
def UltraWideScreen(label='Ultra wide screen'):
|
||||||
|
return Custom(label, './icons/ultra_wide_screen.png')
|
||||||
Loading…
x
Reference in New Issue
Block a user