Esempio n. 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)
Esempio n. 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)
Esempio n. 3
0
    def get_device_details(self, rpc_context, **kwargs):
        """Agent requests device details."""

        agent_id = kwargs.get('agent_id')
        device = kwargs.get('device')
        LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
                  locals())
        port = brocade_db.get_port(rpc_context, device[self.TAP_PREFIX_LEN:])
        if port:
            entry = {'device': device,
                     'vlan_id': port.vlan_id,
                     'network_id': port.network_id,
                     'port_id': port.port_id,
                     'physical_network': port.physical_interface,
                     'admin_state_up': port.admin_state_up
                     }

        else:
            entry = {'device': device}
            LOG.debug(_("%s can not be found in database"), device)
        return entry
Esempio n. 4
0
    def get_device_details(self, rpc_context, **kwargs):
        """Agent requests device details."""

        agent_id = kwargs.get('agent_id')
        device = kwargs.get('device')
        LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
                  {'device': device, 'agent_id': agent_id})
        port = brocade_db.get_port(rpc_context, device[self.TAP_PREFIX_LEN:])
        if port:
            entry = {'device': device,
                     'vlan_id': port.vlan_id,
                     'network_id': port.network_id,
                     'port_id': port.port_id,
                     'physical_network': port.physical_interface,
                     'admin_state_up': port.admin_state_up
                     }

        else:
            entry = {'device': device}
            LOG.debug(_("%s can not be found in database"), device)
        return entry
Esempio n. 5
0
 def _notify_port_updated(self, context, port):
     port_id = port['id']
     bport = brocade_db.get_port(context, port_id)
     self.notifier.port_update(context, port,
                               bport.physical_interface,
                               bport.vlan_id)
Esempio n. 6
0
 def _notify_port_updated(self, context, port):
     port_id = port['id']
     bport = brocade_db.get_port(context, port_id)
     self.notifier.port_update(context, port, bport.physical_interface,
                               bport.vlan_id)