def is_vlanid_used(vlan_id): """Checks if a vlanid is in use""" LOG.debug("is_vlanid_used() called") session = db.get_session() try: vlanid = (session.query( l2network_models.VlanID).filter_by(vlan_id=vlan_id).one()) return vlanid["vlan_used"] except exc.NoResultFound: raise c_exc.VlanIDNotFound(vlan_id=vlan_id)
def delete_vlanid(vlan_id): """Deletes a vlanid entry from db""" LOG.debug("delete_vlanid() called") session = db.get_session() try: vlanid = (session.query( l2network_models.VlanID).filter_by(vlan_id=vlan_id).one()) session.delete(vlanid) session.flush() return vlanid except exc.NoResultFound: raise c_exc.VlanIDNotFound(vlan_id=vlan_id)
def release_vlanid(vlan_id): """Sets the vlanid state to be unused""" LOG.debug("release_vlanid() called") session = db.get_session() try: vlanid = (session.query( l2network_models.VlanID).filter_by(vlan_id=vlan_id).one()) vlanid["vlan_used"] = False session.merge(vlanid) session.flush() return vlanid["vlan_used"] except exc.NoResultFound: raise c_exc.VlanIDNotFound(vlan_id=vlan_id) return