dhcpkit.ipv6.server.extensions.leasequery.sqlite module

SQLIte based implementation of a leasequery store

class dhcpkit.ipv6.server.extensions.leasequery.sqlite.LeasequerySqliteStore(filename: str)[source]

Bases: dhcpkit.ipv6.server.extensions.leasequery.LeasequeryStore

A leasequery store using a SQLite database.

create_tables()[source]

Create the tables required for this leasequery implementation

db = None

Workers store the database connection here

find_client_by_address(query: dhcpkit.ipv6.extensions.leasequery.LQQueryOption) → List[source]

Get the row ids of the clients we want to return.

Parameters:query – The query
Returns:A list of row ids
find_client_by_client_id(query: dhcpkit.ipv6.extensions.leasequery.LQQueryOption) → List[source]

Get the row ids of the clients we want to return.

Parameters:query – The query
Returns:A list of row ids

Get the row ids of the clients we want to return.

Parameters:query – The query
Returns:A list of row ids
find_client_by_relay_id(query: dhcpkit.ipv6.extensions.leasequery.LQQueryOption) → List[source]

Get the row ids of the clients we want to return.

Parameters:query – The query
Returns:A list of row ids
find_client_by_remote_id(query: dhcpkit.ipv6.extensions.leasequery.LQQueryOption) → List[source]

Get the row ids of the clients we want to return.

Parameters:query – The query
Returns:A list of row ids
find_leases(query: dhcpkit.ipv6.extensions.leasequery.LQQueryOption) → Tuple[source]

Find all leases that match the given query.

Parameters:query – The query
Returns:The number of leases and an iterator over tuples of link-address and corresponding client data
generate_client_data_options(client_row_ids: Iterable, requested_options: Iterable) → Iterable[source]

Create a generator for the data of the specified client rows/

Parameters:
  • client_row_ids – The list of client rows what we are interested in
  • requested_options – Option types explicitly requested by the leasequery client
Returns:

The client data options for those rows

get_client_row_id(client_id_str: str, link_address_long: str, create: bool = True) → Union[source]

Get the client’s row id, creating the client row if necessary.

Parameters:
  • client_id_str – The DUID of the client as a string
  • link_address_long – The fully expanded link address
  • create – Should we create this record if it doesn’t exist?
Returns:

The row id

open_database() → sqlite3.Connection[source]

Open the database with the right settings.

Returns:The database connection
remember_lease(bundle: dhcpkit.ipv6.server.transaction_bundle.TransactionBundle)[source]

Remember the leases in the given transaction bundle so they can be queried later.

Parameters:bundle – The transaction to remember
replace_relay_ids(client_row_id: int, relay_ids: Iterable)[source]

Replace the existing relay-id records with the relay-ids provided.

Parameters:
  • client_row_id – The id of the client record
  • relay_ids – The new relay-ids
replace_remote_ids(client_row_id: int, remote_ids: Iterable)[source]

Replace the existing remote-id records with the remote-ids provided.

Parameters:
  • client_row_id – The id of the client record
  • remote_ids – The new remote-ids
sqlite_filename = None

Name of the database file

update_address_leases(client_row_id: int, address_leases: Iterator)[source]

Update address leases in the database and remove expired ones.

Parameters:
  • client_row_id – The id of the client record
  • address_leases – The updated leases to record
update_last_interaction(client_row_id: int, options: Iterable, relay_chain: Union)[source]

Keep track of when we last communicated with this client.

Parameters:
  • client_row_id – The row id of the client
  • options – Options of the last response
  • relay_chain – The incoming relay messages
update_prefix_leases(client_row_id: int, prefix_leases: Iterator)[source]

Update prefix leases in the database and remove expired ones.

Parameters:
  • client_row_id – The id of the client record
  • prefix_leases – The updated leases to record
worker_init(sensitive_options: Iterable)[source]

Worker initialisation: open database connection

Parameters:sensitive_options – The type-numbers of options that are not allowed to be stored