dhcp

Provide an interface for manipulating DHCP configuration snippets for our dynamic/temporary DHCP system.

exception spicerack.dhcp.DHCPError[source]

Bases: spicerack.exceptions.SpicerackError

Base class for DHCP object errors.

exception spicerack.dhcp.DHCPRestartError[source]

Bases: spicerack.dhcp.DHCPError

Raised when the includes generator on target machine returns non-zero.

class spicerack.dhcp.DHCP(hosts: spicerack.remote.RemoteHosts)[source]

Bases: object

A class which provides tools for manipulating DHCP configuration snippets by data center.

Create a DHCP instance.

Parameters

hosts (spicerack.remote.RemoteHosts) -- The target datacenter's install servers.

dhcp_push(dhcp_config: spicerack.dhcp.DHCPConfiguration)Iterator[None][source]

Adapt the DHCP configuration manager to context manager.

Parameters

dhcp_config (spicerack.dhcp.DHCPConfiguration intance) -- The configuration instance to operate with.

push_configuration(configuration: spicerack.dhcp.DHCPConfiguration)None[source]

Push a specified file with specified content to DHCP server and call refresh_dhcp.

Parameters

configuration (spicerack.dhcp.DHCPConfiguration) -- An instance which provides content and filename for a configuration.

refresh_dhcp()None[source]

Regenerate includes on target data center and restart DHCP, or raise if failure at any stage.

remove_configuration(configuration: spicerack.dhcp.DHCPConfiguration, force: bool = False)None[source]

Remove configuration from target DHCP server then call refresh_dhcp.

This will fail if contents do not match unless force is True.

Parameters
  • configuration (spicerack.dhcp.DHCPConfiguration) -- An instance which provides content and filename for a configuration.

  • force (bool, default False) -- If set to True, will remove filename regardless.

class spicerack.dhcp.DHCPConfMgmt(datacenter: str, serial: str, fqdn: str, ip_address: ipaddress.IPv4Address)[source]

Bases: spicerack.dhcp.DHCPConfiguration

A configuration for management network DHCP entries.

property filename: str

Return the filename that corresponds to this configuration.

class spicerack.dhcp.DHCPConfOpt82(hostname: str, fqdn: str, switch_hostname: str, switch_port: str, vlan: str, ttys: int = 1, distro: Optional[str] = None)[source]

Bases: spicerack.dhcp.DHCPConfiguration

A configuration generator for host installation DHCP entries.

property filename: str

Return the proposed filename based on this configuration.

class spicerack.dhcp.DHCPConfiguration[source]

Bases: abc.ABC

abstract An abstract class which defines the interface for the DHCP configuration generators.

abstract property filename: str

Return a string of the proposed filename for this configuration, from the automation directory.

spicerack.dhcp.DHCP_TARGET_PATH = '/etc/dhcp/automation'

The path to the top of the DHCPd automation directory.

Type

str

spicerack.dhcp.MGMT_HOSTNAME_RE = '\\.mgmt\\.{dc}\\.wmnet'

A regular expression when formatted with a dc parameter will match a management hostname.

Type

str