/*
neutron-metadata-l3-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_l3_agent [
            label = "neutron-l3-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-Router-ID"
        ]
        subgraph cluster_neutron_router_namespace {
            label = "neutron router namespace\n(for tenant router)"
            neutron_l3_ns_metadata_proxy [
                label = "neutron ns-metadata-proxy\n\nadds HTTP headers:\nX-Forwarded-For: instance-IP\nX-Neutron-Router-ID: router-UUID"
            ]
            neutron_iptables [
                label = "iptables\nnat table, PREROUTING chain\nrule dst=169.254.169.254:80\ntarget REDIRECT to=127.0.0.1:9697"
            ]
            neutron_router [
                label = "neutron router"
            ]
        }
    }

    subgraph cluster_tenant_net_with_gateway {
        label = "tenant net with gateway"
        instance [
            label = "openstack instance\nno 169.254 IP configured locally\nroute: 169.254.169.254 via subnet-gw-IP"
        ]
    }

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

    traffic_omitted [
        label = "omitted..."
        shape = plaintext
    ]

    traffic_omitted -> neutron_router [
        dir = back
        label = "normal traffic"
    ]

    neutron_router -> instance [
        dir = back
        label = "normal\ntraffic"
    ]

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

    neutron_l3_ns_metadata_proxy -> neutron_iptables [
        dir = back
        label = "metadata\ntraffic"
    ]

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

    neutron_l3_agent -> neutron_router [
        label = "configures\nroutes"
    ]

    neutron_l3_agent -> neutron_l3_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
    ]

}
