Python neutron_lib.api.definitions.portbindings.HOST_ID Examples

The following are 30 code examples of neutron_lib.api.definitions.portbindings.HOST_ID(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module neutron_lib.api.definitions.portbindings , or try the search function .
Example #1
Source File: test_driver.py    From networking-sfc with Apache License 2.0 6 votes vote down vote up
def test_create_flow_classifier_precommit(self):
        with self.port(
            name='port1',
            device_owner='compute',
            device_id='test',
            arg_list=(
                portbindings.HOST_ID,
            ),
            **{portbindings.HOST_ID: 'test'}
        ) as src_port:
            with self.flow_classifier(flow_classifier={
                'name': 'test1',
                'logical_source_port': src_port['port']['id']
            }) as fc:
                fc_context = fc_ctx.FlowClassifierContext(
                    self.flowclassifier_plugin, self.ctx,
                    fc['flow_classifier']
                )
                self.driver.create_flow_classifier_precommit(fc_context) 
Example #2
Source File: test_midonet_plugin_ml2.py    From networking-midonet with Apache License 2.0 6 votes vote down vote up
def test_create_mido_portbinding_no_interface(self):
        # Create binding with no interface name.
        # ML2 allows it.
        # (Unlike midonet_v2, where a non empty profile should always have
        # a valid interface_name and otherwise fails with 400.)
        with self.network() as net:
            args = {'port': {'tenant_id': net['network']['tenant_id'],
                             'network_id': net['network']['id'],
                             portbindings.PROFILE: {'foo': ''},
                             portbindings.HOST_ID: 'host'}}
            req = self.new_create_request('ports', args, self.fmt)
            res = req.get_response(self.api)
            self.assertEqual(201, res.status_int)
            result = self.deserialize(self.fmt, res)
            self.assertDictSupersetOf({
                portbindings.PROFILE: {'foo': ''},
                portbindings.VIF_TYPE: m_const.VIF_TYPE_MIDONET,
            }, result['port']) 
Example #3
Source File: test_midonet_plugin_ml2.py    From networking-midonet with Apache License 2.0 6 votes vote down vote up
def test_create_mido_portbinding_no_host_binding(self):
        # Create a binding when there is no host binding.
        # ML2 allows it and makes the port UNBOUND.
        # (Unlike midonet_v2, where it fails with 400.)
        with self.network() as net:
            args = {'port': {'tenant_id': net['network']['tenant_id'],
                             'network_id': net['network']['id'],
                             portbindings.PROFILE:
                                 {'interface_name': 'if_name'},
                             portbindings.HOST_ID: None}}
            req = self.new_create_request('ports', args, self.fmt)
            res = req.get_response(self.api)
            self.assertEqual(201, res.status_int)
            result = self.deserialize(self.fmt, res)
            self.assertDictSupersetOf({
                portbindings.PROFILE: {'interface_name': 'if_name'},
                portbindings.VIF_TYPE: portbindings.VIF_TYPE_UNBOUND,
            }, result['port']) 
Example #4
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 6 votes vote down vote up
def test_bagpipe_callback_to_rpc_deleted_ignore_external_net(self):
        with self.subnet(network=self.external_net) as subnet, \
                self.port(subnet=subnet,
                          arg_list=(portbindings.HOST_ID,),
                          **{portbindings.HOST_ID: helpers.HOST}) as port:
            self._update_port_status(port, const.PORT_STATUS_DOWN)
            self.mock_attach_rpc.reset_mock()
            self.mock_detach_rpc.reset_mock()

            self.bagpipe_driver.registry_port_deleted(
                None, None, None,
                context=self.ctxt,
                port_id=port['port']['id']
            )
            self.assertFalse(self.mock_attach_rpc.called)
            self.assertFalse(self.mock_detach_rpc.called) 
Example #5
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 6 votes vote down vote up
def test_delete_port_to_bgpvpn_rpc(self):
        with self.network() as net, \
            self.subnet(network=net) as subnet, \
            self.port(subnet=subnet,
                      arg_list=(portbindings.HOST_ID,),
                      **{portbindings.HOST_ID: helpers.HOST}) as port, \
            mock.patch.object(self.plugin, 'get_port',
                              return_value=port['port']), \
            mock.patch.object(self.plugin, 'get_network',
                              return_value=net['network']):

            self.plugin.delete_port(self.ctxt, port['port']['id'])

            self.mock_detach_rpc.assert_called_once_with(
                mock.ANY,
                self._build_expected_return_down(port['port']),
                helpers.HOST) 
Example #6
Source File: test_bgp_db.py    From neutron-dynamic-routing with Apache License 2.0 6 votes vote down vote up
def _create_scenario_test_ports(self, tenant_id, port_configs):
        ports = []
        for item in port_configs:
            port_data = {
                'port': {'name': 'test1',
                         'network_id': item['net_id'],
                         'tenant_id': tenant_id,
                         'admin_state_up': True,
                         'device_id': _uuid(),
                         'device_owner': 'compute:nova',
                         'mac_address': n_const.ATTR_NOT_SPECIFIED,
                         'fixed_ips': n_const.ATTR_NOT_SPECIFIED,
                         portbindings.HOST_ID: item['host']}}
            port = self.plugin.create_port(self.context, port_data)
            ports.append(port)
        return ports 
Example #7
Source File: l2.py    From dragonflow with Apache License 2.0 5 votes vote down vote up
def build_port_binding(port):
    profile = port.get(portbindings.PROFILE)
    if profile:
        port_key = profile.get(df_const.DF_BINDING_PROFILE_PORT_KEY)
        if port_key == df_const.DF_REMOTE_PORT_TYPE:
            return l2.PortBinding(
                type=l2.BINDING_VTEP,
                vtep_address=profile.get(df_const.DF_BINDING_PROFILE_HOST_IP)
            )

    chassis = port.get(portbindings.HOST_ID)
    if chassis:
        return l2.PortBinding(type=l2.BINDING_CHASSIS, chassis=chassis) 
Example #8
Source File: bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def notify_port_updated(self, context, port, original_port):

        if self._ignore_port(context, port):
            return

        agent_host = port[portbindings.HOST_ID]

        port_bgpvpn_info = {'id': port['id'],
                            'network_id': port['network_id']}

        if (port['status'] == const.PORT_STATUS_ACTIVE and
                original_port['status'] != const.PORT_STATUS_ACTIVE):
            LOG.debug("notify_port_updated, port became ACTIVE")

            bgpvpn_network_info = (
                self._retrieve_bgpvpn_network_info_for_port(context, port)
            )

            if bgpvpn_network_info:
                port_bgpvpn_info.update(bgpvpn_network_info)

                self.agent_rpc.attach_port_on_bgpvpn(context,
                                                     port_bgpvpn_info,
                                                     agent_host)
            else:
                # currently not reached, because we need
                # _retrieve_bgpvpn_network_info_for_port to always
                # return network information, even in the absence
                # of any BGPVPN port bound.
                pass

        elif (port['status'] == const.PORT_STATUS_DOWN and
                original_port['status'] != const.PORT_STATUS_DOWN):
            LOG.debug("notify_port_updated, port became DOWN")
            self.agent_rpc.detach_port_from_bgpvpn(context,
                                                   port_bgpvpn_info,
                                                   agent_host)
        else:
            LOG.debug("new port status is %s, origin status was %s,"
                      " => no action", port['status'], original_port['status']) 
Example #9
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def test_l3agent_add_remove_router_interface_to_bgpvpn_rpc(self):
        with self.network() as net, \
                self.subnet(network=net) as subnet, \
                self.router(tenant_id=self._tenant_id) as router, \
                self.bgpvpn() as bgpvpn, \
                self.port(subnet=subnet,
                          arg_list=(portbindings.HOST_ID,),
                          **{portbindings.HOST_ID: helpers.HOST}), \
                mock.patch.object(bagpipe,
                                  'get_router_bgpvpn_assocs',
                                  return_value=[{
                                      'bgpvpn_id': bgpvpn['bgpvpn']['id']
                                  }]).start():
            self._router_interface_action('add',
                                          router['router']['id'],
                                          subnet['subnet']['id'],
                                          None)
            self.mock_update_rpc.assert_called_once_with(
                mock.ANY,
                self.bagpipe_driver._format_bgpvpn(self.ctxt,
                                                   bgpvpn['bgpvpn'],
                                                   net['network']['id']))
            self._router_interface_action('remove',
                                          router['router']['id'],
                                          subnet['subnet']['id'],
                                          None)
            self.mock_delete_rpc.assert_called_once_with(
                mock.ANY,
                self.bagpipe_driver._format_bgpvpn(self.ctxt,
                                                   bgpvpn['bgpvpn'],
                                                   net['network']['id'])) 
Example #10
Source File: mech_driver.py    From dragonflow with Apache License 2.0 5 votes vote down vote up
def _process_portbindings_create_and_update(self, context, port_data,
                                                port):
        binding_profile = port.get(portbindings.PROFILE)
        binding_profile_set = validators.is_attr_set(binding_profile)
        if not binding_profile_set and binding_profile is not None:
            del port[portbindings.PROFILE]

        binding_vnic = port.get(portbindings.VNIC_TYPE)
        binding_vnic_set = validators.is_attr_set(binding_vnic)
        if not binding_vnic_set and binding_vnic is not None:
            del port[portbindings.VNIC_TYPE]

        host = port_data.get(portbindings.HOST_ID)
        host_set = validators.is_attr_set(host)
        with context.session.begin(subtransactions=True):
            bind_port = context.session.query(
                models.PortBinding).filter_by(port_id=port['id']).first()
            if host_set:
                if not bind_port:
                    context.session.add(models.PortBinding(
                        port_id=port['id'],
                        host=host,
                        vif_type=self.vif_type))
                else:
                    bind_port.host = host
            else:
                host = bind_port.host if bind_port else None
        self._extend_port_dict_binding_host(port, host) 
Example #11
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def test_bagpipe_callback_to_rpc_update_active_ignore_external_net(self):
        with self.subnet(network=self.external_net) as subnet, \
                self.port(subnet=subnet,
                          arg_list=(portbindings.HOST_ID,),
                          **{portbindings.HOST_ID: helpers.HOST}) as port:
            self._update_port_status(port, const.PORT_STATUS_DOWN)
            self.mock_attach_rpc.reset_mock()
            self.mock_detach_rpc.reset_mock()
            self._update_port_status(port, const.PORT_STATUS_ACTIVE)

            self.assertFalse(self.mock_attach_rpc.called)
            self.assertFalse(self.mock_detach_rpc.called) 
Example #12
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def test_bagpipe_callback_to_rpc_deleted_ignore_net_ports(self):
        with self.port(device_owner=const.DEVICE_OWNER_NETWORK_PREFIX,
                       arg_list=(portbindings.HOST_ID,),
                       **{portbindings.HOST_ID: helpers.HOST}) as port:
            self._update_port_status(port, const.PORT_STATUS_DOWN)
            self.mock_attach_rpc.reset_mock()
            self.mock_detach_rpc.reset_mock()

            self.bagpipe_driver.registry_port_deleted(
                None, None, None,
                context=self.ctxt,
                port_id=port['port']['id']
            )
            self.assertFalse(self.mock_attach_rpc.called)
            self.assertFalse(self.mock_detach_rpc.called) 
Example #13
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def test_bagpipe_callback_to_rpc_update_down_ignore_net_ports(self):
        with self.port(device_owner=const.DEVICE_OWNER_NETWORK_PREFIX,
                       arg_list=(portbindings.HOST_ID,),
                       **{portbindings.HOST_ID: helpers.HOST}) as port:
            self._update_port_status(port, const.PORT_STATUS_DOWN)
            self.mock_attach_rpc.reset_mock()
            self.mock_detach_rpc.reset_mock()
            self._update_port_status(port, const.PORT_STATUS_ACTIVE)

            self.assertFalse(self.mock_attach_rpc.called)
            self.assertFalse(self.mock_detach_rpc.called) 
Example #14
Source File: driver_v2.py    From f5-openstack-lbaasv2-driver with Apache License 2.0 5 votes vote down vote up
def create(self, context, member):
        """Create a member."""

        self.loadbalancer = member.pool.loadbalancer

        if self.driver.unlegacy_setting_placeholder_driver_side:
            LOG.debug('running un-legacy way for member create p1:')
            driver = self.driver
            subnet = driver.plugin.db._core_plugin.get_subnet(
                context, member.subnet_id
            )
            agent_host, service = self._setup_crud(context, member)
            p = driver.plugin.db._core_plugin.create_port(context, {
                'port': {
                    'tenant_id': subnet['tenant_id'],
                    'network_id': subnet['network_id'],
                    'mac_address': n_const.ATTR_NOT_SPECIFIED,
                    'fixed_ips': n_const.ATTR_NOT_SPECIFIED,
                    'device_id': member.id,
                    'device_owner': 'network:f5lbaasv2',
                    'admin_state_up': member.admin_state_up,
                    'name': 'fake_pool_port_' + member.id,
                    portbindings.HOST_ID: agent_host}})
            LOG.debug('the port created here is: %s' % p)
        self.api_dict = member.to_dict(pool=False)
        self._call_rpc(context, member, 'create_member')

        if self.driver.unlegacy_setting_placeholder_driver_side:
            LOG.debug('running un-legacy way for member create p2:')
            port_id = None
            if p.get('id'):
                port_id = p['id']
            if port_id:
                driver.plugin.db._core_plugin.delete_port(context, port_id)
                LOG.debug('XXXXXX delete port: %s' % port_id)
            else:
                LOG.error('port_id seems none') 
Example #15
Source File: bgp_plugin.py    From neutron-dynamic-routing with Apache License 2.0 5 votes vote down vote up
def port_callback(self, resource, event, trigger, **kwargs):
        if event != events.AFTER_UPDATE:
            return

        original_port = kwargs['original_port']
        updated_port = kwargs['port']
        if not updated_port.get('fixed_ips'):
            return

        original_host = original_port.get(portbindings.HOST_ID)
        updated_host = updated_port.get(portbindings.HOST_ID)
        device_owner = updated_port.get('device_owner')

        # if host in the port binding has changed, update next-hops
        if original_host != updated_host and bool('compute:' in device_owner):
            ctx = context.get_admin_context()
            with ctx.session.begin(subtransactions=True):
                ext_nets = self.get_external_networks_for_port(ctx,
                                                               updated_port)
                for ext_net in ext_nets:
                    bgp_speakers = (
                        self._get_bgp_speaker_ids_by_binding_network(
                            ctx, ext_nets))

                    # Refresh any affected BGP speakers
                    for bgp_speaker in bgp_speakers:
                        routes = self.get_advertised_routes(ctx, bgp_speaker)
                        self.start_route_advertisements(ctx, self._bgp_rpc,
                                                        bgp_speaker, routes) 
Example #16
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def test_bagpipe_callback_to_rpc_dont_ignore_probe_ports_network(self):
        with self.port(device_owner=debug_agent.DEVICE_OWNER_NETWORK_PROBE,
                       arg_list=(portbindings.HOST_ID,),
                       **{portbindings.HOST_ID: helpers.HOST}) as port:
            self._update_port_status(port, const.PORT_STATUS_DOWN)
            self.mock_attach_rpc.reset_mock()
            self.mock_detach_rpc.reset_mock()
            self._update_port_status(port, const.PORT_STATUS_ACTIVE)

            self.mock_attach_rpc.assert_called_once_with(
                mock.ANY,
                self._build_expected_return_active(port['port']),
                helpers.HOST)
            self.assertFalse(self.mock_detach_rpc.called) 
Example #17
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def test_bagpipe_callback_to_rpc_dont_ignore_probe_ports_compute(self):
        with self.port(device_owner=debug_agent.DEVICE_OWNER_COMPUTE_PROBE,
                       arg_list=(portbindings.HOST_ID,),
                       **{portbindings.HOST_ID: helpers.HOST}) as port:
            self._update_port_status(port, const.PORT_STATUS_DOWN)
            self.mock_attach_rpc.reset_mock()
            self.mock_detach_rpc.reset_mock()
            self._update_port_status(port, const.PORT_STATUS_ACTIVE)

            self.mock_attach_rpc.assert_called_once_with(
                mock.ANY,
                self._build_expected_return_active(port['port']),
                helpers.HOST)
            self.assertFalse(self.mock_detach_rpc.called) 
Example #18
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def test_bagpipe_callback_to_rpc_deleted(self):
        with self.port(arg_list=(portbindings.HOST_ID,),
                       **{portbindings.HOST_ID: helpers.HOST}) as port:
            self._update_port_status(port, const.PORT_STATUS_DOWN)
            self.mock_attach_rpc.reset_mock()
            self.mock_detach_rpc.reset_mock()

            self.plugin.delete_port(self.ctxt, port['port']['id'])

            self.mock_detach_rpc.assert_called_once_with(
                mock.ANY,
                self._build_expected_return_down(port['port']),
                helpers.HOST)
            self.assertFalse(self.mock_attach_rpc.called) 
Example #19
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def test_bagpipe_callback_to_rpc_update_down2down(self):
        with self.port(arg_list=(portbindings.HOST_ID,),
                       **{portbindings.HOST_ID: helpers.HOST}) as port:

            self._update_port_status(port, const.PORT_STATUS_DOWN)
            self.mock_attach_rpc.reset_mock()
            self.mock_detach_rpc.reset_mock()
            self._update_port_status(port, const.PORT_STATUS_DOWN)

            self.assertFalse(self.mock_attach_rpc.called)
            self.assertFalse(self.mock_detach_rpc.called) 
Example #20
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def test_bagpipe_callback_to_rpc_update_active2down(self):
        with self.port(arg_list=(portbindings.HOST_ID,),
                       **{portbindings.HOST_ID: helpers.HOST}) as port:

            self._update_port_status(port, const.PORT_STATUS_ACTIVE)
            self.mock_attach_rpc.reset_mock()
            self.mock_detach_rpc.reset_mock()
            self._update_port_status(port, const.PORT_STATUS_DOWN)

            self.mock_detach_rpc.assert_called_once_with(
                mock.ANY,
                self._build_expected_return_down(port['port']),
                helpers.HOST)
            self.assertFalse(self.mock_attach_rpc.called) 
Example #21
Source File: rpc_l2gw.py    From networking-l2gw with Apache License 2.0 5 votes vote down vote up
def _get_ip_details(self, context, port):
        host = port[portbindings.HOST_ID]
        if (not host and
                (port['device_owner'] == n_const.DEVICE_OWNER_DVR_INTERFACE)):
            return self._get_l3_dvr_agent_details(context, port)
        agent = self._get_agent_details(context, host)
        conf_dict = agent.get("configurations")
        dst_ip = conf_dict.get("tunneling_ip")
        fixed_ip_list = port.get('fixed_ips')
        fixed_ip_list = fixed_ip_list[0]
        return dst_ip, fixed_ip_list.get('ip_address') 
Example #22
Source File: data.py    From networking-l2gw with Apache License 2.0 5 votes vote down vote up
def _get_agent_by_mac(self, context, mac):
        host = None
        mac_addr = mac.get('mac')
        port = self._get_port_by_mac(context, mac_addr)
        for port_dict in port:
            host = port_dict[portbindings.HOST_ID]
        agent_l2_pop_enabled = self._get_agent_details_by_host(context, host)
        return agent_l2_pop_enabled 
Example #23
Source File: test_pseudo_agentdb_binding.py    From networking-odl with Apache License 2.0 5 votes vote down vote up
def _call_before_port_binding(self, host):
        kwargs = {
            'context': mock.Mock(),
            'port': {
                portbindings.HOST_ID: host
            }
        }
        registry.notify(resources.PORT, events.BEFORE_CREATE, self.ml2_plugin,
                        **kwargs) 
Example #24
Source File: pseudo_agentdb_binding.py    From networking-odl with Apache License 2.0 5 votes vote down vote up
def before_port_binding(self, resource, event, trigger, **kwargs):
        LOG.debug("before_port resource %s event %s %s",
                  resource, event, kwargs)
        assert resource == resources.PORT
        assert event in [events.BEFORE_CREATE, events.BEFORE_UPDATE]
        ml2_plugin = trigger
        context = kwargs['context']
        port = kwargs['port']

        host = nl_const.ATTR_NOT_SPECIFIED
        if port and portbindings.HOST_ID in port:
            host = port.get(portbindings.HOST_ID)
        if host == nl_const.ATTR_NOT_SPECIFIED or not host:
            return
        agent_type = PseudoAgentDBBindingWorker.L2_TYPE
        if self._worker.known_agent(host, agent_type):
            return
        agents = ml2_plugin.get_agents(
            context, filters={'agent_type': [agent_type], 'host': [host]})
        if agents and all(agent['alive'] for agent in agents):
            self._worker.add_known_agents(agents)
            LOG.debug("agents %s", agents)
            return

        # This host may not be created/updated by worker.
        # try to populate it.
        urlpath = "hostconfig/{0}/{1}".format(
            host, PseudoAgentDBBindingWorker.L2_TYPE)
        try:
            response = self.odl_rest_client.get(urlpath)
            response.raise_for_status()
        except Exception:
            LOG.warning("REST/GET odl hostconfig/%s failed.", host,
                        exc_info=True)
            return
        LOG.debug("response %s", response.json())
        hostconfig = response.json().get('hostconfig', [])
        if hostconfig:
            self._worker.update_agents_db_row(hostconfig[0]) 
Example #25
Source File: test_midonet_plugin_ml2.py    From networking-midonet with Apache License 2.0 5 votes vote down vote up
def port_with_binding_profile(self, host='host', if_name='if_name'):
        args = {portbindings.PROFILE: {'interface_name': if_name},
                portbindings.HOST_ID: host}
        with test_plugin.optional_ctx(None, self.subnet) as subnet_to_use:
            net_id = subnet_to_use['subnet']['network_id']
            port = self._make_port(self.fmt, net_id,
                                   arg_list=(portbindings.PROFILE,
                                             portbindings.HOST_ID,), **args)
            yield port 
Example #26
Source File: test_midonet_plugin_ml2.py    From networking-midonet with Apache License 2.0 5 votes vote down vote up
def test_create_mido_portbinding(self):
        keys = {portbindings.PROFILE: {'interface_name': 'if_name'},
                portbindings.HOST_ID: 'host'}
        with self.port_with_binding_profile() as port:
            self.assertDictSupersetOf(keys, port['port']) 
Example #27
Source File: test_midonet_plugin_ml2.py    From networking-midonet with Apache License 2.0 5 votes vote down vote up
def test_show_mido_portbinding(self):
        keys = {portbindings.PROFILE: {'interface_name': 'if_name'},
                portbindings.HOST_ID: 'host'}
        with self.port_with_binding_profile() as port:
            self.assertDictSupersetOf(keys, port['port'])
            req = self.new_show_request('ports', port['port']['id'])
            res = self.deserialize(self.fmt, req.get_response(self.api))
            self.assertDictSupersetOf(keys, res['port']) 
Example #28
Source File: test_midonet_plugin_ml2.py    From networking-midonet with Apache License 2.0 5 votes vote down vote up
def test_update_mido_portbinding(self):
        keys = {portbindings.HOST_ID: 'host2',
                portbindings.PROFILE: {'interface_name': 'if_name2'},
                'admin_state_up': False,
                'name': 'test_port2'}
        with self.port_with_binding_profile() as port:
            args = {
                'port': {portbindings.PROFILE: {'interface_name': 'if_name2'},
                         portbindings.HOST_ID: 'host2',
                         'admin_state_up': False,
                         'name': 'test_port2'}}
            req = self.new_update_request('ports', args, port['port']['id'])
            res = self.deserialize(self.fmt, req.get_response(self.api))
            self.assertDictSupersetOf(keys, res['port']) 
Example #29
Source File: test_midonet_plugin_ml2.py    From networking-midonet with Apache License 2.0 5 votes vote down vote up
def test_update_mido_portbinding_no_profile_specified(self):
        # Modify binding without specifying the profile.
        keys = {portbindings.HOST_ID: 'host2',
                portbindings.PROFILE: {'interface_name': 'if_name'},
                'admin_state_up': False,
                'name': 'test_port2'}
        with self.port_with_binding_profile() as port:
            args = {'port': {portbindings.HOST_ID: 'host2',
                             'admin_state_up': False,
                             'name': 'test_port2'}}
            req = self.new_update_request('ports', args, port['port']['id'])
            res = self.deserialize(self.fmt, req.get_response(self.api))
            self.assertDictSupersetOf(keys, res['port']) 
Example #30
Source File: test_bagpipe.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def test_bagpipe_callback_to_rpc_update_down2active(self):
        with self.port(arg_list=(portbindings.HOST_ID,),
                       **{portbindings.HOST_ID: helpers.HOST}) as port:

            self._update_port_status(port, const.PORT_STATUS_DOWN)
            self.mock_attach_rpc.reset_mock()
            self.mock_detach_rpc.reset_mock()
            self._update_port_status(port, const.PORT_STATUS_ACTIVE)

            self.mock_attach_rpc.assert_called_once_with(
                mock.ANY,
                self._build_expected_return_active(port['port']),
                helpers.HOST)
            self.assertFalse(self.mock_detach_rpc.called)