def bind_port(self, context):
     LOG.debug(
         "Attempting to bind port %(port)s on network %(network)s", {
             'port': context.current['id'],
             'network': context.network.current['id']
         })
     for segment in context.segments_to_bind:
         context._new_bound_segment = segment[api.ID]
         vif_details = {portbindings.OVS_HYBRID_PLUG: True}
         context.set_binding(segment[api.ID], 'ovs', vif_details)
Example #2
0
 def bind_port(self, context):
     LOG.debug("Attempting to bind port %(port)s on network %(network)s",
               {'port': context.current['id'],
                'network': context.network.current['id']})
     for segment in context.segments_to_bind:
         context._new_bound_segment = segment[api.ID]
         vif_details = {portbindings.OVS_HYBRID_PLUG: True}
         context.set_binding(segment[api.ID],
                             'ovs',
                             vif_details)
Example #3
0
 def bind_port(self, context):
     print context.host
     b_port = self.dvs_notifier.bind_port_call(
         context.current, context.network.network_segments,
         context.network.current, context.host)
     # TODO(ekosareva): currently a hack, need to check results from agent
     #                  and store port_key
     vif_details = dict(self.vif_details)
     vif_details['dvs_port_key'] = b_port
     for segment in context.network.network_segments:
         context.set_binding(segment[driver_api.ID],
                             self.vif_type,
                             vif_details,
                             status=n_const.PORT_STATUS_ACTIVE)
Example #4
0
 def bind_port(self, context):
     if self._check_net_type(context.network):
         booked_port_key = self.dvs_notifier.bind_port_call(
             context.current, context.network.network_segments,
             context.network.current, context.host)
         vif_details = dict(self.vif_details)
         vif_details['dvs_port_key'] = booked_port_key
         for segment in context.network.network_segments:
             context.set_binding(segment[driver_api.ID],
                                 self.vif_type,
                                 vif_details,
                                 status=n_const.PORT_STATUS_ACTIVE)
     else:
         nt = context.network.network_segments[0]['network_type']
         raise exceptions.NotSupportedNetworkType(network_type=nt)
 def bind_port(self, context):
     print context.host
     b_port = self.dvs_notifier.bind_port_call(context.current,
                                      context.network.network_segments,
                                      context.network.current, context.host)
     # TODO(ekosareva): currently a hack, need to check results from agent
     #                  and store port_key
     vif_details = dict(self.vif_details)
     vif_details['dvs_port_key'] = b_port
     for segment in context.network.network_segments:
         context.set_binding(
             segment[driver_api.ID],
             self.vif_type,
             vif_details,
             status=n_const.PORT_STATUS_ACTIVE)
 def bind_port(self, context):
     booked_port_key = self.dvs_notifier.bind_port_call(
         context.current,
         context.network.network_segments,
         context.network.current,
         context.host
     )
     vif_details = dict(self.vif_details)
     vif_details['dvs_port_key'] = booked_port_key
     for segment in context.network.network_segments:
         context.set_binding(
             segment[driver_api.ID],
             self.vif_type,
             vif_details,
             status=n_const.PORT_STATUS_ACTIVE)
 def bind_port(self, context):
     if self._check_net_type(context.network):
         booked_port_key = self.dvs_notifier.bind_port_call(
             context.current,
             context.network.network_segments,
             context.network.current,
             context.host
         )
         vif_details = dict(self.vif_details)
         vif_details['dvs_port_key'] = booked_port_key
         for segment in context.network.network_segments:
             context.set_binding(
                 segment[driver_api.ID],
                 self.vif_type,
                 vif_details,
                 status=n_const.PORT_STATUS_ACTIVE)
     else:
         nt = context.network.network_segments[0]['network_type']
         raise exceptions.NotSupportedNetworkType(network_type=nt)
Example #8
0
    def try_to_bind_segment_for_agent(self, context, segment, agent):
        port = context.current
        # We only do compute devices
        device_owner = port['device_owner']

        if not device_owner or not device_owner.startswith('compute'):
            return False

        if not agent.get('admin_state_up', False) \
                or not agent.get('alive', False) \
                or agent['agent_type'].lower() != dvs_constants.AGENT_TYPE_DVS.lower():
            return False

        agent_host = agent.get('host', None)

        # If the agent is bound to a host, then it can only handle those
        if agent_host != port['binding:host_id']:
            return False

        mappings = self.get_mappings(agent)

        if not mappings:
            return False

        LOG.debug(_LI("Agent: {}, Segment: {}".format(agent, segment)))

        bridge_name = mappings.get(segment['physical_network'], None)

        if not bridge_name:
            return False

        if self.version == 2:
            response = self.dvs_notifier.bind_port_call(
                port, [segment], context.network.current, context.host)
            if response and 'bridge_name' in response:
                bridge_name = response['bridge_name']

        vif_details = self.vif_details.copy()
        vif_details['bridge_name'] = bridge_name

        context.set_binding(segment[api.ID], self.vif_type, vif_details)
        return True
Example #9
0
    def bind_port(self, context):
        """This function sends bind port to VM message to AC

        :param context: DB context for the port binding
        :return: None
        """
        for segment in context.segments_to_bind:
            if self.check_segment(segment):
                context._new_bound_segment = segment[api.ID]
                vif_details = {portbindings.OVS_HYBRID_PLUG: True}
                context.set_binding(segment[api.ID], 'ovs', vif_details)
            else:
                LOG.debug(
                    "Port bound un-successfull for segment ID %(id)s, "
                    "segment %(seg)s, phys net %(physnet)s, and "
                    "network type %(nettype)s", {
                        'id': segment[api.ID],
                        'seg': segment[api.SEGMENTATION_ID],
                        'physnet': segment[api.PHYSICAL_NETWORK],
                        'nettype': segment[api.NETWORK_TYPE]
                    })