/*
neutron-metadata-dhcp-agent

Edit this file, instead of the corresponding png/svg.
Those can be re-generated by:
sudo apt install graphviz
dot -T svg -o out.svg in.dot
dot -T png -o out.png in.dot
*/

digraph {

    compound = true
    node [
        shape = record
        ]

    subgraph cluster_openstack_controller {
        label = "openstack controller node"
        nova_metadata [
            label = "nova metadata service"
        ]
        public_openstack_api [
            label = "public openstack APIs\n(nova, neutron)"
        ]
    }

    subgraph cluster_openstack_network {
        label = "openstack network node"
        neutron_dhcp_agent [
            label = "neutron-dhcp-agent"
        ]
        neutron_metadata_agent [
            label = "neutron-metadata-agent\n\nadds HTTP headers:\nX-Tenant-ID: project-UUID\nX-Instance-ID: instance-UUID\nX-Instance-ID-Signature: ...\n\nremoves HTTP header:\n X-Neutron-Network-ID"
        ]
        subgraph cluster_neutron_dhcp_namespace {
            label = "neutron DHCP namespace\n(for isolated tenant net)"
            neutron_dhcp_ns_metadata_proxy [
                label = "neutron ns-metadata-proxy\n\nadds HTTP headers:\nX-Forwarded-For: instance-IP\nX-Neutron-Network-ID: network-UUID"
            ]
            metadata_lla [
                label = "169.254.169.254/32\nconfigured in namespace"
            ]
            neutron_dhcp_server [
                label = "neutron DHCP server"
            ]
        }
    }

    subgraph cluster_tenant_net_isolated {
        label = "isolated tenant net\n(i.e. without gateway)"
        instance [
            label = "openstack instance\nno 169.254 IP configured locally"
        ]
    }

    response_omitted [
        label = "the response is omitted for brevity..."
        shape = plaintext
    ]

    metadata_lla -> instance [
        label = "HTTP GET\n169.254.169.254:80"
        dir = back
        align = left
    ]

    neutron_dhcp_ns_metadata_proxy -> metadata_lla [
        label = "metadata\ntraffic"
        dir = back
        align = left
    ]

    neutron_metadata_agent -> neutron_dhcp_ns_metadata_proxy [
        label = "unix socket"
        dir = back
    ]

    neutron_dhcp_server -> instance [
        label = "pushes static route:\n169.254.169.254 via dhcp-port-IP"
    ]

    neutron_dhcp_agent -> neutron_dhcp_server [
        label = "configures\nstatic leases\nand dhcp options"
    ]

    neutron_dhcp_agent -> neutron_dhcp_ns_metadata_proxy [
        label = "starts"
    ]

    nova_metadata -> neutron_metadata_agent [
        dir = back
    ]

    public_openstack_api -> neutron_metadata_agent [
        label = "looks up instance UUID"
        dir = back
    ]

    nova_metadata -> response_omitted
    response_omitted -> neutron_metadata_agent [
        style = invis
    ]

}
