#cloud-config
password: osm4u
chpasswd: { expire: False }
ssh_pwauth: True

write_files:
-   content: |
        # Example of jinja2 template for parsing OSM variables

        I am vdu_id='{{ OSM.vdu_id }}' count_index='{{ OSM.count_index }}' ip_address='{{ OSM.ip_address|default('not set') }}'
        Parameters:
         ns_id: {{ OSM.ns_id }}
         vnf_id: {{ OSM.vnf_id }}
         member_vnf_index: {{ OSM.member_vnf_index }}
         list of vdus:{% for vdu_id_index,vdu in OSM.vdu.items() %}
          vdu {{ vdu_id_index }}:
            vdu_id: {{ vdu.vdu_id }}
            count_index: {{ vdu.count_index }}
            ip_address: {{ vdu.ip_address|default('not set') }}
            interfaces:{% for iface_id,iface in vdu.interfaces.items() %}
              iface='{{ iface_id }}' ip_address='{{ iface.ip_address|default('no ip') }} mac_adress={{ iface.mac_address|default('no mac') }}'{% endfor %}
        {% endfor %}

        global variable OSM:
        """{{ OSM|default('OSM variable is not defined') }}"""

    owner: ubuntu:ubuntu
    permissions: '0644'
    path: /home/ubuntu/helloworld.txt

