'Create a vlan unless it already exists.'

def ensure_vlan(self, physical_interface, vlan_id):

    interface = self.get_subinterface_name(physical_interface, vlan_id)
    if (not ip_lib.device_exists(interface)):
        LOG.debug('Creating    subinterface    %(interface)s    for    VLAN    %(vlan_id)s    on    interface    %(physical_interface)s', {'interface': interface, 'vlan_id': vlan_id, 'physical_interface': physical_interface})
        try:
            int_vlan = self.ip.add_vlan(interface, physical_interface, vlan_id)
        except RuntimeError:
            with excutils.save_and_reraise_exception() as ctxt:
                if ip_lib.vlan_in_use(vlan_id):
                    ctxt.reraise = False
                    LOG.error(_LE('Unable    to    create    VLAN    interface    for    VLAN    ID    %s    because    it    is    in    use    by    another    interface.'), vlan_id)
                    return
        int_vlan.disable_ipv6()
        int_vlan.link.set_up()
        LOG.debug('Done    creating    subinterface    %s', interface)
    return interface
