'Plug into Contrail\'s network port
Bind the vif to a Contrail virtual port.'

def plug_vrouter(self, instance, vif):

    dev = self.get_vif_devname(vif)
    ip_addr = '0.0.0.0'
    ip6_addr = None
    subnets = vif['network']['subnets']
    for subnet in subnets:
        if (not subnet['ips']):
            continue
        ips = subnet['ips'][0]
        if (not ips['address']):
            continue
        if (ips['version'] == 4):
            if (ips['address'] is not None):
                ip_addr = ips['address']
        if (ips['version'] == 6):
            if (ips['address'] is not None):
                ip6_addr = ips['address']
    ptype = 'NovaVMPort'
    if (CONF.libvirt.virt_type == 'lxc'):
        ptype = 'NameSpacePort'
    cmd_args = ('--oper=add    --uuid=%s    --instance_uuid=%s    --vn_uuid=%s    --vm_project_uuid=%s    --ip_address=%s    --ipv6_address=%s    --vm_name=%s    --mac=%s    --tap_name=%s    --port_type=%s    --tx_vlan_id=%d    --rx_vlan_id=%d' % (vif['id'], instance.uuid, vif['network']['id'], instance.project_id, ip_addr, ip6_addr, instance.display_name, vif['address'], vif['devname'], ptype, (-1), (-1)))
    try:
        multiqueue = self._is_multiqueue_enabled(instance.image_meta, instance.flavor)
        linux_net.create_tap_dev(dev, multiqueue=multiqueue)
        utils.execute('vrouter-port-control', cmd_args, run_as_root=True)
    except processutils.ProcessExecutionError:
        LOG.exception(_('Failed    while    plugging    vif'), instance=instance)
