from diagrams import Cluster, Diagram, Edge

from diagrams.azure.database import DatabaseForMariadbServers

from diagrams.azure.database import SQLDatabases
from diagrams.onprem.inmemory import Redis
from diagrams.onprem.network import Internet
from diagrams.onprem.groupware import Nextcloud
from diagrams.onprem.monitoring import Grafana, Prometheus
from diagrams.onprem.network import Haproxy
from diagrams.onprem.database import Mariadb
from diagrams.onprem.storage import Glusterfs
import diagrams.generic.storage as storage_1
from diagrams.azure.identity import Groups
from diagrams.onprem.storage import Ceph, CephOsd

from diagrams.custom import Custom

mypath="/home/pbarriat/Documents/Boulot/UCL/Brevet/report/assets/"

with Diagram(filename="../assets/dia_nc_test_migration", show=True, direction="TB"):
    out = Internet("Intranet")    
    ldap = Groups("LDAP")
    nfs = storage_1.Storage("NFS")

    with Cluster("Load Balancing"):
        openstack_lb = Custom("", mypath+"openstack.png")
        lb = [Haproxy("SSL proxy")]

    with Cluster("Web server"):
        openstack_web = Custom("", mypath+"openstack.png")
        nc_frontend = [ Nextcloud(), Custom("PHP Caching", mypath+"keydb.png")]

    with Cluster("Database"):
        openstack_db = Custom("", mypath+"openstack.png")
        nc_db = DatabaseForMariadbServers("Backup writer")
 
    with Cluster("Ceph Storage Cluster"):
        ceph_cluster = Ceph()
        ceph_object = CephOsd("Object Gateway")
 
    openstack_lb >> openstack_web << openstack_db
    ldap >> openstack_web << nfs
    ceph_cluster << Edge(label="Migration", color="firebrick") << openstack_web
    out >> lb