Пример #1
0
    def test_create_port(self):
        """Test brocade specific port db."""

        net_id = str(uuid.uuid4())
        port_id = str(uuid.uuid4())
        # port_id is truncated: since the linux-bridge tap device names are
        # based on truncated port id, this enables port lookups using
        # tap devices
        port_id = port_id[0:11]
        tenant_id = str(uuid.uuid4())
        admin_state_up = True

        # Create Port

        # To create a port a network must exists, Create a network
        self.context = context.get_admin_context()
        brocade_db.create_network(self.context, net_id, TEST_VLAN)

        physical_interface = "em1"
        brocade_db.create_port(self.context, port_id, net_id,
                               physical_interface, TEST_VLAN, tenant_id,
                               admin_state_up)

        port = brocade_db.get_port(self.context, port_id)
        self.assertEqual(port['port_id'], port_id)
        self.assertEqual(port['network_id'], net_id)
        self.assertEqual(port['physical_interface'], physical_interface)
        self.assertEqual(int(port['vlan_id']), TEST_VLAN)
        self.assertEqual(port['tenant_id'], tenant_id)
        self.assertEqual(port['admin_state_up'], admin_state_up)

        admin_state_up = True
        brocade_db.update_port_state(self.context, port_id, admin_state_up)
        port = brocade_db.get_port(self.context, port_id)
        self.assertEqual(port['admin_state_up'], admin_state_up)

        admin_state_up = False
        brocade_db.update_port_state(self.context, port_id, admin_state_up)
        port = brocade_db.get_port(self.context, port_id)
        self.assertEqual(port['admin_state_up'], admin_state_up)

        admin_state_up = True
        brocade_db.update_port_state(self.context, port_id, admin_state_up)
        port = brocade_db.get_port(self.context, port_id)
        self.assertEqual(port['admin_state_up'], admin_state_up)

        # Delete Port
        brocade_db.delete_port(self.context, port_id)
        self.assertFalse(brocade_db.get_ports(self.context))
Пример #2
0
    def test_create_port(self):
        """Test brocade specific port db."""

        net_id = str(uuid.uuid4())
        port_id = str(uuid.uuid4())
        # port_id is truncated: since the linux-bridge tap device names are
        # based on truncated port id, this enables port lookups using
        # tap devices
        port_id = port_id[0:11]
        tenant_id = str(uuid.uuid4())
        admin_state_up = True

        # Create Port

        # To create a port a network must exists, Create a network
        self.context = context.get_admin_context()
        brocade_db.create_network(self.context, net_id, TEST_VLAN)

        physical_interface = "em1"
        brocade_db.create_port(self.context, port_id, net_id,
                               physical_interface,
                               TEST_VLAN, tenant_id, admin_state_up)

        port = brocade_db.get_port(self.context, port_id)
        self.assertEqual(port['port_id'], port_id)
        self.assertEqual(port['network_id'], net_id)
        self.assertEqual(port['physical_interface'], physical_interface)
        self.assertEqual(int(port['vlan_id']), TEST_VLAN)
        self.assertEqual(port['tenant_id'], tenant_id)
        self.assertEqual(port['admin_state_up'], admin_state_up)

        admin_state_up = True
        brocade_db.update_port_state(self.context, port_id, admin_state_up)
        port = brocade_db.get_port(self.context, port_id)
        self.assertEqual(port['admin_state_up'], admin_state_up)

        admin_state_up = False
        brocade_db.update_port_state(self.context, port_id, admin_state_up)
        port = brocade_db.get_port(self.context, port_id)
        self.assertEqual(port['admin_state_up'], admin_state_up)

        admin_state_up = True
        brocade_db.update_port_state(self.context, port_id, admin_state_up)
        port = brocade_db.get_port(self.context, port_id)
        self.assertEqual(port['admin_state_up'], admin_state_up)

        # Delete Port
        brocade_db.delete_port(self.context, port_id)
        self.assertFalse(brocade_db.get_ports(self.context))
Пример #3
0
    def create_port(self, context, port):
        """Create logical port on the switch."""

        tenant_id = port['port']['tenant_id']
        network_id = port['port']['network_id']
        admin_state_up = port['port']['admin_state_up']

        physical_interface = self.physical_interface

        with context.session.begin(subtransactions=True):
            bnet = brocade_db.get_network(context, network_id)
            vlan_id = bnet['vlan']

            neutron_port = super(BrocadePluginV2, self).create_port(context,
                                                                    port)
            self._process_portbindings_create_and_update(context,
                                                         port['port'],
                                                         neutron_port)
            interface_mac = neutron_port['mac_address']
            port_id = neutron_port['id']

            switch = self._switch

            # convert mac format: xx:xx:xx:xx:xx:xx -> xxxx.xxxx.xxxx
            mac = self.mac_reformat_62to34(interface_mac)
            try:
                self._driver.associate_mac_to_network(switch['address'],
                                                      switch['username'],
                                                      switch['password'],
                                                      vlan_id,
                                                      mac)
            except Exception as e:
                # Proper formatting
                LOG.warning(_("Brocade NOS driver:"))
                LOG.warning(_("%s"), e)
                raise Exception(_("Brocade plugin raised exception, "
                                  "check logs"))

            # save to brocade persistent db
            brocade_db.create_port(context, port_id, network_id,
                                   physical_interface,
                                   vlan_id, tenant_id, admin_state_up)

        # apply any extensions
        return neutron_port
Пример #4
0
    def create_port(self, context, port):
        """Create logical port on the switch."""

        tenant_id = port['port']['tenant_id']
        network_id = port['port']['network_id']
        admin_state_up = port['port']['admin_state_up']

        physical_interface = self.physical_interface

        with context.session.begin(subtransactions=True):
            bnet = brocade_db.get_network(context, network_id)
            vlan_id = bnet['vlan']

            neutron_port = super(BrocadePluginV2, self).create_port(context,
                                                                    port)
            self._process_portbindings_create_and_update(context,
                                                         port['port'],
                                                         neutron_port)
            interface_mac = neutron_port['mac_address']
            port_id = neutron_port['id']

            switch = self._switch

            # convert mac format: xx:xx:xx:xx:xx:xx -> xxxx.xxxx.xxxx
            mac = self.mac_reformat_62to34(interface_mac)
            try:
                self._driver.associate_mac_to_network(switch['address'],
                                                      switch['username'],
                                                      switch['password'],
                                                      vlan_id,
                                                      mac)
            except Exception:
                # Proper formatting
                LOG.exception(_LE("Brocade NOS driver error"))
                raise Exception(_("Brocade plugin raised exception, "
                                  "check logs"))

            # save to brocade persistent db
            brocade_db.create_port(context, port_id, network_id,
                                   physical_interface,
                                   vlan_id, tenant_id, admin_state_up)

        # apply any extensions
        return neutron_port