def _get_neutron_network(session, cluster, vif):
    if vif['type'] == model.VIF_TYPE_OVS:
        _check_ovs_supported_version(session)

        # Check if this is the NSX-MH plugin is used
        if CONF.vmware.integration_bridge:
            network_id = CONF.vmware.integration_bridge
            network_ref = None  # Not supported with Nuage
        else:
            network_id = vif['network']['bridge']
            network_ref = network_util.get_network_with_the_name(
                session, network_id, cluster)
        if not network_ref:
            raise exception.NetworkNotFoundForBridge(bridge=network_id)

    elif vif['type'] == model.VIF_TYPE_DVS:
        network_id = vif['network']['bridge']
        network_ref = network_util.get_network_with_the_name(
            session, network_id, cluster)
        if not network_ref:
            raise exception.NetworkNotFoundForBridge(bridge=network_id)
    else:
        reason = _('vif type %s not supported') % vif['type']
        raise exception.InvalidInput(reason=reason)
    return network_ref
Exemple #2
0
 def _check_if_network_bridge_exists(network_name):
     network_ref = \
         network_utils.get_network_with_the_name(self._session,
                                                 network_name)
     if network_ref is None:
         raise exception.NetworkNotFoundForBridge(bridge=network_name)
     return network_ref
Exemple #3
0
def _get_neutron_network(session, cluster, vif):
    if vif['type'] == model.VIF_TYPE_OVS:
        _check_ovs_supported_version(session)
        # Check if this is the NSX-MH plugin is used
        if CONF.vmware.integration_bridge:
            net_id = CONF.vmware.integration_bridge
            use_external_id = False
            network_type = 'opaque'
        else:
            net_id = vif['network']['id']
            use_external_id = True
            network_type = 'nsx.LogicalSwitch'
        network_ref = {
            'type': 'OpaqueNetwork',
            'network-id': net_id,
            'network-type': network_type,
            'use-external-id': use_external_id
        }
    elif vif['type'] == model.VIF_TYPE_DVS:
        network_id = vif['network']['bridge']
        network_ref = network_util.get_network_with_the_name(
            session, network_id, cluster)
        if not network_ref:
            raise exception.NetworkNotFoundForBridge(bridge=network_id)
    else:
        reason = _('vif type %s not supported') % vif['type']  # noqa
        raise exception.InvalidInput(reason=reason)
    return network_ref
Exemple #4
0
def get_neutron_network(session, network_name, cluster, vif):
    host = vm_util.get_host_ref(session, cluster)
    try:
        opaque = session._call_method(vim_util, "get_dynamic_property", host,
                                      "HostSystem",
                                      "config.network.opaqueNetwork")
    except error_util.VimFaultException:
        opaque = None
    network_ref = None
    if opaque:
        bridge = vif['network']['id']
        opaque_networks = opaque.HostOpaqueNetworkInfo
        for network in opaque_networks:
            if network['opaqueNetworkId'] == bridge:
                network_ref = {'type': 'OpaqueNetwork',
                               'network-id': network['opaqueNetworkId'],
                               'network-name': network['opaqueNetworkName'],
                               'network-type': network['opaqueNetworkType']}
                break
    else:
        bridge = network_name
        network_ref = network_util.get_network_with_the_name(
                session, network_name, cluster)
    if network_ref is None:
        raise exception.NetworkNotFoundForBridge(bridge=bridge)
    return network_ref
Exemple #5
0
def get_network_ref(session, cluster, vif):
    if vif['type'] == model.VIF_TYPE_OVS:
        _check_ovs_supported_version(session)
        # Check if this is the NSX-MH plugin is used
        if CONF.vmware.integration_bridge:
            net_id = CONF.vmware.integration_bridge
            use_external_id = False
            network_type = 'opaque'
        else:
            # The NSX|V3 plugin will pass the nsx-logical-switch-id as part
            # of the port details. This will enable the VC to connect to
            # that specific opaque network
            net_id = (vif.get('details')
                      and vif['details'].get('nsx-logical-switch-id'))
            if not net_id:
                # Make use of the original one, in the event that the
                # plugin does not pass the aforementioned id
                LOG.info('NSX Logical switch ID is not present. '
                         'Using network ID to attach to the '
                         'opaque network.')
                net_id = vif['network']['id']
            use_external_id = True
            network_type = 'nsx.LogicalSwitch'
        network_ref = {
            'type': 'OpaqueNetwork',
            'network-id': net_id,
            'network-type': network_type,
            'use-external-id': use_external_id
        }
    elif vif['type'] == model.VIF_TYPE_DVS:
        # Port binding for DVS VIF types may pass the name
        # of the port group, so use it if present
        vif_details = vif.get('details', {})

        dvs_uuid = vif_details.get('dvs_id')
        dvs_port_group_key = vif_details.get('pg_id')
        if dvs_uuid and dvs_port_group_key:
            network_ref = {
                'type': 'DistributedVirtualPortgroup',
                'dvpg': dvs_port_group_key,
                'dvsw': dvs_uuid
            }
        else:
            network_id = vif_details.get('dvs_port_group_name')
            if network_id is None:
                # Make use of the original one, in the event that the
                # port binding does not provide this key in VIF details
                network_id = vif['network']['bridge']
            network_ref = network_util.get_network_with_the_name(
                session, network_id, cluster)
        if not network_ref:
            raise exception.NetworkNotFoundForBridge(bridge=network_id)
        if vif_details.get('dvs_port_key'):
            network_ref['dvs_port_key'] = vif_details['dvs_port_key']
    else:
        reason = _('vif type %s not supported') % vif['type']
        raise exception.InvalidInput(reason=reason)
    return network_ref
Exemple #6
0
def get_neutron_network(session, network_name, cluster, vif):
    opaque = None
    if vif['type'] != model.VIF_TYPE_DVS:
        opaque = _get_opaque_network(session, cluster)
    if opaque:
        bridge = vif['network']['id']
        opaque_networks = opaque.HostOpaqueNetworkInfo
        network_ref = _get_network_ref_from_opaque(
            opaque_networks, CONF.vmware.integration_bridge, bridge)
    else:
        bridge = network_name
        network_ref = network_util.get_network_with_the_name(
            session, network_name, cluster)
    if not network_ref:
        raise exception.NetworkNotFoundForBridge(bridge=bridge)
    return network_ref
Exemple #7
0
def get_neutron_network(session, network_name, cluster, vif):
    host = vm_util.get_host_ref(session, cluster)
    try:
        opaque = session._call_method(vim_util, "get_dynamic_property", host,
                                      "HostSystem",
                                      "config.network.opaqueNetwork")
    except error_util.InvalidPropertyException:
        opaque = None
    if opaque:
        bridge = vif['network']['id']
        opaque_networks = opaque.HostOpaqueNetworkInfo
        network_ref = _get_network_ref_from_opaque(
            opaque_networks, CONF.vmware.integration_bridge, bridge)
    else:
        bridge = network_name
        network_ref = network_util.get_network_with_the_name(
            session, network_name, cluster)
    if not network_ref:
        raise exception.NetworkNotFoundForBridge(bridge=bridge)
    return network_ref
def _get_neutron_network(session, cluster, vif):
    if vif['type'] == model.VIF_TYPE_OVS:
        _check_ovs_supported_version(session)
        # Check if this is the NSX-MH plugin is used
        if CONF.vmware.integration_bridge:
            net_id = CONF.vmware.integration_bridge
            use_external_id = False
            network_type = 'opaque'
        else:
            # The NSX|V3 plugin will pass the nsx-logical-switch-id as part
            # of the port details. This will enable the VC to connect to
            # that specific opaque network
            net_id = (vif.get('details')
                      and vif['details'].get('nsx-logical-switch-id'))
            if not net_id:
                # Make use of the original one, in the event that the
                # plugin does not pass the aforementioned id
                LOG.info(
                    _LI('NSX Logical switch ID is not present. '
                        'Using network ID to attach to the '
                        'opaque network.'))
                net_id = vif['network']['id']
            use_external_id = True
            network_type = 'nsx.LogicalSwitch'
        network_ref = {
            'type': 'OpaqueNetwork',
            'network-id': net_id,
            'network-type': network_type,
            'use-external-id': use_external_id
        }
    elif vif['type'] == model.VIF_TYPE_DVS:
        network_id = vif['network']['bridge']
        network_ref = network_util.get_network_with_the_name(
            session, network_id, cluster)
        if not network_ref:
            raise exception.NetworkNotFoundForBridge(bridge=network_id)
    else:
        reason = _('vif type %s not supported') % vif['type']
        raise exception.InvalidInput(reason=reason)
    return network_ref
Exemple #9
0
def _get_neutron_network(session, cluster, vif):
    if vif['type'] == model.VIF_TYPE_OVS:
        _check_ovs_supported_version(session)
        # Check if this is the NSX-MH plugin is used
        if CONF.vmware.integration_bridge:
            net_id = CONF.vmware.integration_bridge
            use_external_id = False
            network_type = 'opaque'
        else:
            net_id = vif['network']['id']
            use_external_id = True
            network_type = 'nsx.LogicalSwitch'
        network_ref = {
            'type': 'OpaqueNetwork',
            'network-id': net_id,
            'network-type': network_type,
            'use-external-id': use_external_id
        }
    elif vif['type'] == model.VIF_TYPE_DVS:
        # Port binding for DVS VIF types may pass the name
        # of the port group, so use it if present
        network_id = vif.get('details', {}).get('dvs_port_group_name')
        if network_id is None:
            # Make use of the original one, in the event that the
            # port binding does not provide this key in VIF details
            #network_id = vif['network']['bridge']

            network_id = (CONF.vmware.integration_bridge or "br-int")

        network_ref = network_util.get_network_with_the_name(
            session, network_id, cluster)
        if not network_ref:
            raise exception.NetworkNotFoundForBridge(bridge=network_id)
        if vif.get('details') and vif['details'].get('dvs_port_key'):
            network_ref['dvs_port_key'] = vif['details']['dvs_port_key']
    else:
        reason = _('vif type %s not supported') % vif['type']
        raise exception.InvalidInput(reason=reason)
    return network_ref