Example #1
0
    def test_get_nexusport_binding_no_result_found_handling(self):
        with mock.patch('sqlalchemy.orm.Query.all') as mock_all:
            mock_all.return_value = []

            with self.assertRaises(c_exc.NexusPortBindingNotFound):
                nexus_db.get_nexusport_binding(port_id=10,
                                               vlan_id=20,
                                               switch_ip='10.0.0.1',
                                               instance_id=1)
 def delete_network(self, tenant_id, net_id, **kwargs):
     """
     Deletes a VLAN in the switch, and removes the VLAN configuration
     from the relevant interfaces
     """
     LOG.debug("NexusPlugin:delete_network() called\n")
     vlan_id = None
     for key in kwargs:
         if key == const.CONTEXT:
             context = kwargs[const.CONTEXT]
         elif key == const.BASE_PLUGIN_REF:
             base_plugin_ref = kwargs[const.BASE_PLUGIN_REF]
         elif key == 'vlan_id':
             vlan_id = kwargs['vlan_id']
     if vlan_id is None:
         vlan_id = self._get_vlan_id_for_network(tenant_id, net_id,
                                                 context, base_plugin_ref)
     ports_id = nxos_db.get_nexusport_binding(vlan_id)
     LOG.debug("NexusPlugin: Interfaces to be disassociated: %s" % ports_id)
     nxos_db.remove_nexusport_binding(vlan_id)
     if net_id:
         self._client.delete_vlan(
             str(vlan_id), self._nexus_ip,
             self._nexus_username, self._nexus_password,
             self._nexus_ports, self._nexus_ssh_port)
         return net_id
     # Network not found
     raise exc.NetworkNotFound(net_id=net_id)
 def delete_network(self, tenant_id, net_id, **kwargs):
     """
     Deletes a VLAN in the switch, and removes the VLAN configuration
     from the relevant interfaces
     """
     LOG.debug("NexusPlugin:delete_network() called\n")
     vlan_id = None
     for key in kwargs:
         if key == const.CONTEXT:
             context = kwargs[const.CONTEXT]
         elif key == const.BASE_PLUGIN_REF:
             base_plugin_ref = kwargs[const.BASE_PLUGIN_REF]
         elif key == 'vlan_id':
             vlan_id = kwargs['vlan_id']
     if vlan_id is None:
         vlan_id = self._get_vlan_id_for_network(tenant_id, net_id,
                                                 context, base_plugin_ref)
     ports_id = nxos_db.get_nexusport_binding(vlan_id)
     LOG.debug("NexusPlugin: Interfaces to be disassociated: %s" % ports_id)
     nxos_db.remove_nexusport_binding(vlan_id)
     if net_id:
         self._client.delete_vlan(
             str(vlan_id), self._nexus_ip,
             self._nexus_username, self._nexus_password,
             self._nexus_ports, self._nexus_ssh_port)
         return net_id
     # Network not found
     raise exc.NetworkNotFound(net_id=net_id)
Example #4
0
 def get_nexusportbinding(self, vlan_id):
     """get nexus port binding."""
     binding = []
     try:
         for bind in nexus_db.get_nexusport_binding(vlan_id):
             LOG.debug("Getting nexus port binding : %s" % bind.port_id)
             bind_dict = {}
             bind_dict["port-id"] = str(bind.port_id)
             bind_dict["vlan-id"] = str(bind.vlan_id)
             binding.append(bind_dict)
     except Exception, exc:
         LOG.error("Failed to get all bindings: %s" % str(exc))
Example #5
0
 def get_nexusportbinding(self, vlan_id):
     """get nexus port binding"""
     binding = []
     try:
         for bind in nexus_db.get_nexusport_binding(vlan_id):
             LOG.debug("Getting nexus port binding : %s" % bind.port_id)
             bind_dict = {}
             bind_dict["port-id"] = str(bind.port_id)
             bind_dict["vlan-id"] = str(bind.vlan_id)
             binding.append(bind_dict)
     except Exception, exc:
         LOG.error("Failed to get all bindings: %s" % str(exc))