'Idempotent wiring for a trunk\'s subports.
Given a trunk object, delete any vlan subinterfaces belonging to a
trunk that aren\'t on the object. Create any which are on the object
which do not exist.'

def ensure_trunk_subports(self, trunk):

    trunk_dev = self._trunk_device_name(trunk)
    with self._trunk_lock(trunk_dev):
        expected = self._get_subport_devs_and_vlans(trunk.sub_ports)
        existing = self._get_vlan_children(trunk_dev)
        to_delete = (existing - expected)
        to_create = (expected - existing)
        for (devname, vlan_id) in to_delete:
            LOG.debug('Deleting    subport    %(name)s    with    vlan    tag    %(tag)s', dict(name=devname, tag=vlan_id))
            self._safe_delete_device(devname)
        for (devname, vlan_id) in to_create:
            LOG.debug('Creating    subport    %(name)s    with    vlan    tag    %(tag)s', dict(name=devname, tag=vlan_id))
            self._create_vlan_subint(trunk_dev, devname, vlan_id)
