Exemple #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)
Exemple #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)
Exemple #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']

            quantum_port = super(BrocadePluginV2, self).create_port(context,
                                                                    port)
            interface_mac = quantum_port['mac_address']
            port_id = quantum_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 self._extend_port_dict_binding(context, quantum_port)
Exemple #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']

            quantum_port = super(BrocadePluginV2, self).create_port(context,
                                                                    port)
            interface_mac = quantum_port['mac_address']
            port_id = quantum_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 self._extend_port_dict_binding(context, quantum_port)