コード例 #1
0
    def test_nexus_vxlan_two_network(self):
        """Test processing for creating one VXLAN segment."""

        self._basic_create_verify_port_vlan(
            'test_vxlan_config5',
            self.results.get_test_results('add_port_driver_result4'))

        self._create_port(self.test_configs['test_vxlan_config6'],
                          override_netid=888)
        self._verify_results(
            self.results.get_test_results('add_port_driver_result2'))

        binding = nexus_db_v2.get_nve_switch_bindings(
            test_cisco_nexus_base.NEXUS_IP_ADDRESS_8)
        self.assertEqual(2, len(binding))

        # Clean all the ncclient mock_calls so we can evaluate
        # results of delete operations.
        self.mock_ncclient.reset_mock()

        self._basic_delete_verify_port_vlan(
            'test_vxlan_config6',
            self.results.get_test_results('delete_port_driver_result2'),
            nbr_of_bindings=1)

        self._basic_delete_verify_port_vlan(
            'test_vxlan_config5',
            self.results.get_test_results('delete_port_driver_result4'))

        try:
            binding = nexus_db_v2.get_nve_switch_bindings(
                test_cisco_nexus_base.NEXUS_IP_ADDRESS_8)
        except exceptions.NexusPortBindingNotFound:
            binding = []
        self.assertEqual(0, len(binding))
コード例 #2
0
    def test_nexus_vxlan_two_network(self):
        """Test processing for creating one VXLAN segment."""

        add_port_driver_result2 = (
            [test_cisco_nexus_base.RESULT_ADD_NVE_INTERFACE.
                format(1, 70001, '255.1.1.1'),
            test_cisco_nexus_base.RESULT_ADD_VLAN_VNI.
                format(265, 70001),
            test_cisco_nexus_base.RESULT_ADD_INTERFACE.
                format('ethernet', '1\/20', 265)])

        delete_port_driver_result2 = (
            [test_cisco_nexus_base.RESULT_DEL_NVE_INTERFACE.
                format(1, 70001, 265),
            test_cisco_nexus_base.RESULT_DEL_INTERFACE.
                format('ethernet', '1\/20', 265),
            test_cisco_nexus_base.RESULT_DEL_VLAN.format(265)])

        self._basic_create_verify_port_vlan(
            'test_vxlan_config5',
            self.add_port_driver_result)

        self._create_port(
            self.test_configs['test_vxlan_config6'],
            override_netid=888)
        self._verify_results(add_port_driver_result2)

        binding = nexus_db_v2.get_nve_switch_bindings(
            test_cisco_nexus_base.NEXUS_IP_ADDRESS_1)
        self.assertEqual(2, len(binding))

        # Clean all the ncclient mock_calls so we can evaluate
        # results of delete operations.
        self.mock_ncclient.reset_mock()

        self._basic_delete_verify_port_vlan(
            'test_vxlan_config6',
            delete_port_driver_result2, nbr_of_bindings=1)

        self._basic_delete_verify_port_vlan(
            'test_vxlan_config5',
            self.delete_port_driver_result)

        try:
            binding = nexus_db_v2.get_nve_switch_bindings(
                test_cisco_nexus_base.NEXUS_IP_ADDRESS_1)
        except exceptions.NexusPortBindingNotFound:
            binding = []
        self.assertEqual(0, len(binding))
コード例 #3
0
    def _configure_nve_member(self, vni, device_id, mcast_group, host_id):
        """Add "member vni" configuration to the NVE interface.

        Called during update postcommit port event.
        """
        host_nve_connections = self._get_switch_nve_info(host_id)

        for switch_ip in host_nve_connections:

            # If configured to set global VXLAN values then
            #   If this is the first database entry for this switch_ip
            #   then configure the "interface nve" entry on the switch.
            if cfg.CONF.ml2_cisco.vxlan_global_config:
                nve_bindings = nxos_db.get_nve_switch_bindings(switch_ip)
                if len(nve_bindings) == 1:
                    LOG.debug("Nexus: create NVE interface")
                    loopback = self._nexus_switches.get(
                        (switch_ip, 'nve_src_intf'), '0')
                    self.driver.enable_vxlan_feature(switch_ip,
                                                     const.NVE_INT_NUM,
                                                     loopback)

            # If this is the first database entry for this (VNI, switch_ip)
            # then configure the "member vni #" entry on the switch.
            member_bindings = nxos_db.get_nve_vni_switch_bindings(
                vni, switch_ip)
            if len(member_bindings) == 1:
                LOG.debug("Nexus: add member")
                self.driver.create_nve_member(switch_ip, const.NVE_INT_NUM,
                                              vni, mcast_group)
コード例 #4
0
    def _delete_port_failure(self, attr, match_str, test_case, test_id):
        """Verifies exception handling during object deletion.

        This method is a shared method to initiate an exception
        at various point of object deletion.  The points of failure
        are identified by the caller which can be get operations or
        edit operations.  When the mechanism replay is functioning,
        the exception should be suppressed and the switch is marked
        as inactive.

        attr:      Which mock attribute to contain side_effect exception
        match_str: String for side_effect method to match for exception
        test_case: which configuration test case to run thru test
        test_id:   String to put in the exception.
        """

        # Set switch state to active
        switch_ip = self.test_configs[test_case].nexus_ip_addr
        self._cisco_mech_driver.set_switch_ip_and_active_state(
            switch_ip, const.SWITCH_ACTIVE)

        self._create_port(self.test_configs[test_case])

        # _create_port should complete successfully and no switch state change.
        self.assertEqual(
            self._cisco_mech_driver.get_switch_ip_and_active_state(switch_ip),
            const.SWITCH_ACTIVE)

        # Clean all the ncclient mock_calls to clear exception
        # and other mock_call history.
        self.mock_ncclient.reset_mock()

        # Set up driver exception
        config = {
            attr: self._config_side_effects_on_count(match_str,
                                                     Exception(test_id))
        }
        self.mock_ncclient.configure_mock(**config)

        self.assertRaises(exceptions.NexusConfigFailed, self._delete_port,
                          self.test_configs[test_case])

        # Verify nothing in the port binding data base
        # except Reserved Port Binding if replay is enabled
        nbr_bindings = 1 if self._cisco_mech_driver.is_replay_enabled() else 0
        try:
            port_bindings = nexus_db_v2.get_nexusport_switch_bindings(
                switch_ip)
        except exceptions.NexusPortBindingNotFound:
            port_bindings = []

        assert (len(port_bindings) == nbr_bindings)

        # Verify nothing in the nve data base
        assert (len(nexus_db_v2.get_nve_switch_bindings(switch_ip)) == 0)

        # _delete_port should complete with no switch state change.
        self.assertEqual(
            self._cisco_mech_driver.get_switch_ip_and_active_state(switch_ip),
            const.SWITCH_ACTIVE)
コード例 #5
0
    def _configure_nve_member(self, vni, device_id, mcast_group, host_id):
        """Add "member vni" configuration to the NVE interface.

        Called during update postcommit port event.
        """
        host_nve_connections = self._get_switch_nve_info(host_id)

        for switch_ip in host_nve_connections:

            # If configured to set global VXLAN values then
            #   If this is the first database entry for this switch_ip
            #   then configure the "interface nve" entry on the switch.
            if cfg.CONF.ml2_cisco.vxlan_global_config:
                nve_bindings = nxos_db.get_nve_switch_bindings(switch_ip)
                if len(nve_bindings) == 1:
                    LOG.debug("Nexus: create NVE interface")
                    loopback = self._nexus_switches.get(
                                        (switch_ip, 'nve_src_intf'), '0')
                    self.driver.enable_vxlan_feature(switch_ip,
                        const.NVE_INT_NUM, loopback)

            # If this is the first database entry for this (VNI, switch_ip)
            # then configure the "member vni #" entry on the switch.
            member_bindings = nxos_db.get_nve_vni_switch_bindings(vni,
                                                                  switch_ip)
            if len(member_bindings) == 1:
                LOG.debug("Nexus: add member")
                self.driver.create_nve_member(switch_ip, const.NVE_INT_NUM,
                                              vni, mcast_group)
コード例 #6
0
    def replay_config(self, switch_ip):
        """Sends pending config data in OpenStack to Nexus."""
        LOG.debug("Replaying config for switch ip %(switch_ip)s",
                  {'switch_ip': switch_ip})

        nve_bindings = nxos_db.get_nve_switch_bindings(switch_ip)

        for x in nve_bindings:
            try:
                self._driver.create_nve_member(switch_ip,
                    const.NVE_INT_NUM, x.vni, x.mcast_group)
            except Exception as e:
                LOG.error(_LE("Failed to configure nve_member for "
                    "switch %(switch_ip)s, vni %(vni)s"
                    "Reason:%(reason)s "),
                    {'switch_ip': switch_ip, 'vni': x.vni,
                     'reason': e})
                if self.monitor_timeout > 0:
                    self._mdriver.register_switch_as_inactive(switch_ip,
                    'replay create_nve_member')
                return

        try:
            port_bindings = nxos_db.get_nexusport_switch_bindings(switch_ip)
        except excep.NexusPortBindingNotFound:
            LOG.warn(_LW("No port entries found for switch ip "
                      "%(switch_ip)s during replay."),
                      {'switch_ip': switch_ip})
            return

        self._mdriver.configure_switch_entries(switch_ip,
            port_bindings)
コード例 #7
0
    def replay_config(self, switch_ip):
        """Sends pending config data in OpenStack to Nexus."""
        LOG.debug("Replaying config for switch ip %(switch_ip)s",
                  {'switch_ip': switch_ip})

        nve_bindings = nxos_db.get_nve_switch_bindings(switch_ip)

        for x in nve_bindings:
            try:
                self._driver.create_nve_member(switch_ip, const.NVE_INT_NUM,
                                               x.vni, x.mcast_group)
            except Exception as e:
                LOG.error(
                    _LE("Failed to configure nve_member for "
                        "switch %(switch_ip)s, vni %(vni)s"
                        "Reason:%(reason)s "), {
                            'switch_ip': switch_ip,
                            'vni': x.vni,
                            'reason': e
                        })
                if self.monitor_timeout > 0:
                    self._mdriver.register_switch_as_inactive(
                        switch_ip, 'replay create_nve_member')
                return

        try:
            port_bindings = nxos_db.get_nexusport_switch_bindings(switch_ip)
        except excep.NexusPortBindingNotFound:
            LOG.warn(
                _LW("No port entries found for switch ip "
                    "%(switch_ip)s during replay."), {'switch_ip': switch_ip})
            return

        self._mdriver.configure_switch_entries(switch_ip, port_bindings)
コード例 #8
0
    def test_nexus_vxlan_two_network(self):
        """Test processing for creating one VXLAN segment."""

        add_port_driver_result2 = ([
            test_cisco_nexus_base.RESULT_ADD_NVE_INTERFACE.format(
                1, 70001, '255.1.1.1'),
            test_cisco_nexus_base.RESULT_ADD_VLAN_VNI.format(265, 70001),
            test_cisco_nexus_base.RESULT_ADD_INTERFACE.format(
                'ethernet', '1\/20', 265)
        ])

        delete_port_driver_result2 = ([
            test_cisco_nexus_base.RESULT_DEL_NVE_INTERFACE.format(
                1, 70001, 265),
            test_cisco_nexus_base.RESULT_DEL_INTERFACE.format(
                'ethernet', '1\/20', 265),
            test_cisco_nexus_base.RESULT_DEL_VLAN.format(265)
        ])

        self._basic_create_verify_port_vlan('test_vxlan_config5',
                                            self.add_port_driver_result)

        self._create_port(self.test_configs['test_vxlan_config6'],
                          override_netid=888)
        self._verify_results(add_port_driver_result2)

        binding = nexus_db_v2.get_nve_switch_bindings(
            test_cisco_nexus_base.NEXUS_IP_ADDRESS_1)
        self.assertEqual(2, len(binding))

        # Clean all the ncclient mock_calls so we can evaluate
        # results of delete operations.
        self.mock_ncclient.reset_mock()

        self._basic_delete_verify_port_vlan('test_vxlan_config6',
                                            delete_port_driver_result2,
                                            nbr_of_bindings=1)

        self._basic_delete_verify_port_vlan('test_vxlan_config5',
                                            self.delete_port_driver_result)

        try:
            binding = nexus_db_v2.get_nve_switch_bindings(
                test_cisco_nexus_base.NEXUS_IP_ADDRESS_1)
        except exceptions.NexusPortBindingNotFound:
            binding = []
        self.assertEqual(0, len(binding))
コード例 #9
0
    def test_nexus_vxlan_one_network(self):
        """Test processing for creating one VXLAN segment."""

        # Since test_vxlan_config3 & test_vxlan_config4 share
        # the same host name they both get processed in the
        # next call.
        self._basic_create_verify_port_vlan(
            'test_vxlan_config3',
            self.results.get_test_results(
                'add_port_driver_result3'))

        for switch_ip, nbr_bind in [
            (test_cisco_nexus_base.NEXUS_IP_ADDRESS_1, 1),
            (test_cisco_nexus_base.NEXUS_IP_ADDRESS_2, 2)]:
            bindings = nexus_db_v2.get_nexusvlan_binding(
                           test_cisco_nexus_base.VLAN_ID_1,
                           switch_ip)
            self.assertEqual(nbr_bind, len(bindings))
            binding = nexus_db_v2.get_nve_switch_bindings(switch_ip)
            self.assertEqual(1, len(binding))

        # Since test_vxlan_config3 & test_vxlan_config4 share
        # the same host name they both get processed in the
        # next call.
        self._basic_delete_verify_port_vlan(
            'test_vxlan_config3',
            self.results.get_test_results(
                'delete_port_driver_result3'))

        for switch_ip in [
            test_cisco_nexus_base.NEXUS_IP_ADDRESS_1,
            test_cisco_nexus_base.NEXUS_IP_ADDRESS_2]:
            try:
                bindings = nexus_db_v2.get_nexusvlan_binding(
                               test_cisco_nexus_base.VLAN_ID_1,
                               switch_ip)
            except exceptions.NexusPortBindingNotFound:
                bindings = []
            self.assertEqual(0, len(bindings))
            try:
                binding = nexus_db_v2.get_nve_switch_bindings(switch_ip)
            except exceptions.NexusPortBindingNotFound:
                binding = []
            self.assertEqual(0, len(binding))
コード例 #10
0
    def _delete_nve_member(self, vni, device_id, mcast_group, host_id):
        """Remove "member vni" configuration from the NVE interface.

        Called during delete postcommit port event.
        """
        host_nve_connections = self._get_switch_nve_info(host_id)
        for switch_ip in host_nve_connections:
            if not nxos_db.get_nve_vni_switch_bindings(vni, switch_ip):
                self.driver.delete_nve_member(switch_ip, const.NVE_INT_NUM,
                                              vni)
            if (cfg.CONF.ml2_cisco.vxlan_global_config
                    and not nxos_db.get_nve_switch_bindings(switch_ip)):
                self.driver.disable_vxlan_feature(switch_ip)
コード例 #11
0
    def _delete_nve_member(self, vni, device_id, mcast_group, host_id):
        """Remove "member vni" configuration from the NVE interface.

        Called during delete postcommit port event.
        """
        host_nve_connections = self._get_switch_nve_info(host_id)
        for switch_ip in host_nve_connections:
            if not nxos_db.get_nve_vni_switch_bindings(vni, switch_ip):
                self.driver.delete_nve_member(switch_ip,
                    const.NVE_INT_NUM, vni)
            if (cfg.CONF.ml2_cisco.vxlan_global_config and
                not nxos_db.get_nve_switch_bindings(switch_ip)):
                self.driver.disable_vxlan_feature(switch_ip)
コード例 #12
0
    def _configure_nve_member(self, vni, device_id, mcast_group, host_id):
        """Add "member vni" configuration to the NVE interface.

        Called during update postcommit port event.
        """
        host_nve_connections = self._get_switch_nve_info(host_id)

        for switch_ip in host_nve_connections:
            if self.is_switch_configurable(switch_ip) is False:
                self.reset_switch_retry_count(switch_ip)
                continue
            # If configured to set global VXLAN values then
            #   If this is the first database entry for this switch_ip
            #   then configure the "interface nve" entry on the switch.
            if cfg.CONF.ml2_cisco.vxlan_global_config:
                nve_bindings = nxos_db.get_nve_switch_bindings(switch_ip)
                if len(nve_bindings) == 1:
                    LOG.debug("Nexus: create NVE interface")
                    loopback = self._nexus_switches.get(
                                        (switch_ip, 'nve_src_intf'), '0')
                    try:
                        self.driver.enable_vxlan_feature(switch_ip,
                            const.NVE_INT_NUM, loopback)
                    except Exception:
                        with excutils.save_and_reraise_exception() as ctxt:
                            ctxt.reraise = (
                                self.choose_to_reraise_driver_exception(
                                    switch_ip, 'enable_vxlan_feature'))
                        continue

            # If this is the first database entry for this (VNI, switch_ip)
            # then configure the "member vni #" entry on the switch.
            member_bindings = nxos_db.get_nve_vni_switch_bindings(vni,
                                                                  switch_ip)
            if len(member_bindings) == 1:
                LOG.debug("Nexus: add member")
                try:
                    self.driver.create_nve_member(switch_ip, const.NVE_INT_NUM,
                                                  vni, mcast_group)
                except Exception:
                    with excutils.save_and_reraise_exception() as ctxt:
                        ctxt.reraise = (
                            self.choose_to_reraise_driver_exception(switch_ip,
                                'create_nve_member'))
コード例 #13
0
    def _configure_nve_member(self, vni, device_id, mcast_group, host_id):
        """Add "member vni" configuration to the NVE interface.

        Called during update postcommit port event.
        """
        host_nve_connections = self._get_switch_nve_info(host_id)

        for switch_ip in host_nve_connections:
            if self.is_switch_configurable(switch_ip) is False:
                self.reset_switch_retry_count(switch_ip)
                continue
            # If configured to set global VXLAN values then
            #   If this is the first database entry for this switch_ip
            #   then configure the "interface nve" entry on the switch.
            if cfg.CONF.ml2_cisco.vxlan_global_config:
                nve_bindings = nxos_db.get_nve_switch_bindings(switch_ip)
                if len(nve_bindings) == 1:
                    LOG.debug("Nexus: create NVE interface")
                    loopback = self._nexus_switches.get(
                        (switch_ip, 'nve_src_intf'), '0')
                    try:
                        self.driver.enable_vxlan_feature(
                            switch_ip, const.NVE_INT_NUM, loopback)
                    except Exception:
                        with excutils.save_and_reraise_exception() as ctxt:
                            ctxt.reraise = (
                                self.choose_to_reraise_driver_exception(
                                    switch_ip, 'enable_vxlan_feature'))
                        continue

            # If this is the first database entry for this (VNI, switch_ip)
            # then configure the "member vni #" entry on the switch.
            member_bindings = nxos_db.get_nve_vni_switch_bindings(
                vni, switch_ip)
            if len(member_bindings) == 1:
                LOG.debug("Nexus: add member")
                try:
                    self.driver.create_nve_member(switch_ip, const.NVE_INT_NUM,
                                                  vni, mcast_group)
                except Exception:
                    with excutils.save_and_reraise_exception() as ctxt:
                        ctxt.reraise = (
                            self.choose_to_reraise_driver_exception(
                                switch_ip, 'create_nve_member'))
コード例 #14
0
    def _delete_nve_member(self, vni, device_id, mcast_group, host_id):
        """Remove "member vni" configuration from the NVE interface.

        Called during delete postcommit port event.
        """
        host_nve_connections = self._get_switch_nve_info(host_id)
        for switch_ip in host_nve_connections:
            if self.is_switch_configurable(switch_ip) is False:
                continue
            try:
                if not nxos_db.get_nve_vni_switch_bindings(vni, switch_ip):
                    self.driver.delete_nve_member(switch_ip,
                        const.NVE_INT_NUM, vni)
                if (cfg.CONF.ml2_cisco.vxlan_global_config and
                    not nxos_db.get_nve_switch_bindings(switch_ip)):
                    self.driver.disable_vxlan_feature(switch_ip)
            except Exception:
                with excutils.save_and_reraise_exception() as ctxt:
                    ctxt.reraise = (
                        self.choose_to_reraise_driver_exception(switch_ip,
                            '(delete_nve_member||disable_vxlan_feature)'))
コード例 #15
0
    def test_nexus_vxlan_one_network(self):
        """Test processing for creating one VXLAN segment."""

        add_port_driver_result3 = (
            [test_cisco_nexus_base.RESULT_ADD_NVE_INTERFACE.
                format(1, 70000, '255.1.1.1'),
            test_cisco_nexus_base.RESULT_ADD_NVE_INTERFACE.
                format(1, 70000, '255.1.1.1'),
            test_cisco_nexus_base.RESULT_ADD_VLAN_VNI.
                format(267, 70000),
            test_cisco_nexus_base.RESULT_ADD_INTERFACE.
                format('ethernet', '1\/10', 267),
            test_cisco_nexus_base.RESULT_ADD_VLAN_VNI.
                format(267, 70000),
            test_cisco_nexus_base.RESULT_ADD_INTERFACE.
                format('ethernet', '1\/2', 267),
            test_cisco_nexus_base.RESULT_ADD_VLAN_VNI.
                format(267, 70000),
            test_cisco_nexus_base.RESULT_ADD_INTERFACE.
                format('ethernet', '1\/3', 267)])

        delete_port_driver_result3 = (
            [test_cisco_nexus_base.RESULT_DEL_NVE_INTERFACE.
                format(1, 70000, 267),
             test_cisco_nexus_base.RESULT_DEL_NVE_INTERFACE.
                format(1, 70000, 267),
            test_cisco_nexus_base.RESULT_DEL_INTERFACE.
                format('ethernet', '1\/10', 267),
            test_cisco_nexus_base.RESULT_DEL_VLAN.format(267),
            test_cisco_nexus_base.RESULT_DEL_INTERFACE.
                format('ethernet', '1\/2', 267),
            test_cisco_nexus_base.RESULT_DEL_VLAN.format(267),
            test_cisco_nexus_base.RESULT_DEL_INTERFACE.
                format('ethernet', '1\/3', 267)])

        # Since test_vxlan_config3 & test_vxlan_config4 share
        # the same host name they both get processed in the
        # next call.
        self._basic_create_verify_port_vlan(
            'test_vxlan_config3',
            add_port_driver_result3)

        for switch_ip, nbr_bind in [
            (test_cisco_nexus_base.NEXUS_IP_ADDRESS_1, 1),
            (test_cisco_nexus_base.NEXUS_IP_ADDRESS_2, 2)]:
            bindings = nexus_db_v2.get_nexusvlan_binding(
                           test_cisco_nexus_base.VLAN_ID_1,
                           switch_ip)
            self.assertEqual(nbr_bind, len(bindings))
            binding = nexus_db_v2.get_nve_switch_bindings(switch_ip)
            self.assertEqual(1, len(binding))

        # Since test_vxlan_config3 & test_vxlan_config4 share
        # the same host name they both get processed in the
        # next call.
        self._basic_delete_verify_port_vlan(
            'test_vxlan_config3',
            delete_port_driver_result3)

        for switch_ip in [
            test_cisco_nexus_base.NEXUS_IP_ADDRESS_1,
            test_cisco_nexus_base.NEXUS_IP_ADDRESS_2]:
            try:
                bindings = nexus_db_v2.get_nexusvlan_binding(
                               test_cisco_nexus_base.VLAN_ID_1,
                               switch_ip)
            except exceptions.NexusPortBindingNotFound:
                bindings = []
            self.assertEqual(0, len(bindings))
            try:
                binding = nexus_db_v2.get_nve_switch_bindings(switch_ip)
            except exceptions.NexusPortBindingNotFound:
                binding = []
            self.assertEqual(0, len(binding))
コード例 #16
0
    def _delete_port_failure(self, attr, match_str, test_case, test_id):
        """Verifies exception handling during object deletion.

        This method is a shared method to initiate an exception
        at various point of object deletion.  The points of failure
        are identified by the caller which can be get operations or
        edit operations.  When the mechanism replay is functioning,
        the exception should be suppressed and the switch is marked
        as inactive.

        attr:      Which mock attribute to contain side_effect exception
        match_str: String for side_effect method to match for exception
        test_case: which configuration test case to run thru test
        test_id:   String to put in the exception.
        """

        # Set switch state to active
        switch_ip = self.test_configs[test_case].nexus_ip_addr
        self._cisco_mech_driver.set_switch_ip_and_active_state(
            switch_ip, const.SWITCH_ACTIVE)

        self._create_port(
            self.test_configs[test_case])

        # _create_port should complete successfully and no switch state change.
        self.assertEqual(
            self._cisco_mech_driver.get_switch_ip_and_active_state(switch_ip),
            const.SWITCH_ACTIVE)

        # Clean all the ncclient mock_calls to clear exception
        # and other mock_call history.
        self.mock_ncclient.reset_mock()

        # Set up driver exception
        config = {attr:
            self._config_side_effects_on_count(match_str,
            Exception(test_id))}
        self.mock_ncclient.configure_mock(**config)

        self.assertRaises(
             exceptions.NexusConfigFailed,
             self._delete_port,
             self.test_configs[test_case])

        # Verify nothing in the port binding data base
        # except Reserved Port Binding if replay is enabled
        nbr_bindings = 1 if self._cisco_mech_driver.is_replay_enabled() else 0
        try:
            port_bindings = nexus_db_v2.get_nexusport_switch_bindings(
                switch_ip)
        except exceptions.NexusPortBindingNotFound:
            port_bindings = []

        assert(len(port_bindings) == nbr_bindings)

        # Verify nothing in the nve data base
        assert(len(nexus_db_v2.get_nve_switch_bindings(
               switch_ip)) == 0)

        # _delete_port should complete with no switch state change.
        self.assertEqual(
            self._cisco_mech_driver.get_switch_ip_and_active_state(switch_ip),
            const.SWITCH_ACTIVE)
コード例 #17
0
    def test_nexus_vxlan_one_network(self):
        """Test processing for creating one VXLAN segment."""

        add_port_driver_result3 = ([
            test_cisco_nexus_base.RESULT_ADD_NVE_INTERFACE.format(
                1, 70000, '255.1.1.1'),
            test_cisco_nexus_base.RESULT_ADD_NVE_INTERFACE.format(
                1, 70000, '255.1.1.1'),
            test_cisco_nexus_base.RESULT_ADD_VLAN_VNI.format(267, 70000),
            test_cisco_nexus_base.RESULT_ADD_INTERFACE.format(
                'ethernet', '1\/10', 267),
            test_cisco_nexus_base.RESULT_ADD_VLAN_VNI.format(267, 70000),
            test_cisco_nexus_base.RESULT_ADD_INTERFACE.format(
                'ethernet', '1\/2', 267),
            test_cisco_nexus_base.RESULT_ADD_VLAN_VNI.format(267, 70000),
            test_cisco_nexus_base.RESULT_ADD_INTERFACE.format(
                'ethernet', '1\/3', 267)
        ])

        delete_port_driver_result3 = ([
            test_cisco_nexus_base.RESULT_DEL_NVE_INTERFACE.format(
                1, 70000, 267),
            test_cisco_nexus_base.RESULT_DEL_NVE_INTERFACE.format(
                1, 70000, 267),
            test_cisco_nexus_base.RESULT_DEL_INTERFACE.format(
                'ethernet', '1\/10', 267),
            test_cisco_nexus_base.RESULT_DEL_VLAN.format(267),
            test_cisco_nexus_base.RESULT_DEL_INTERFACE.format(
                'ethernet', '1\/2', 267),
            test_cisco_nexus_base.RESULT_DEL_VLAN.format(267),
            test_cisco_nexus_base.RESULT_DEL_INTERFACE.format(
                'ethernet', '1\/3', 267)
        ])

        # Since test_vxlan_config3 & test_vxlan_config4 share
        # the same host name they both get processed in the
        # next call.
        self._basic_create_verify_port_vlan('test_vxlan_config3',
                                            add_port_driver_result3)

        for switch_ip, nbr_bind in [
            (test_cisco_nexus_base.NEXUS_IP_ADDRESS_1, 1),
            (test_cisco_nexus_base.NEXUS_IP_ADDRESS_2, 2)
        ]:
            bindings = nexus_db_v2.get_nexusvlan_binding(
                test_cisco_nexus_base.VLAN_ID_1, switch_ip)
            self.assertEqual(nbr_bind, len(bindings))
            binding = nexus_db_v2.get_nve_switch_bindings(switch_ip)
            self.assertEqual(1, len(binding))

        # Since test_vxlan_config3 & test_vxlan_config4 share
        # the same host name they both get processed in the
        # next call.
        self._basic_delete_verify_port_vlan('test_vxlan_config3',
                                            delete_port_driver_result3)

        for switch_ip in [
                test_cisco_nexus_base.NEXUS_IP_ADDRESS_1,
                test_cisco_nexus_base.NEXUS_IP_ADDRESS_2
        ]:
            try:
                bindings = nexus_db_v2.get_nexusvlan_binding(
                    test_cisco_nexus_base.VLAN_ID_1, switch_ip)
            except exceptions.NexusPortBindingNotFound:
                bindings = []
            self.assertEqual(0, len(bindings))
            try:
                binding = nexus_db_v2.get_nve_switch_bindings(switch_ip)
            except exceptions.NexusPortBindingNotFound:
                binding = []
            self.assertEqual(0, len(binding))