/usr/share/pyshared/provisioningserver/dhcp/writer.py is in python-maas-provisioningserver 1.2+bzr1373+dfsg-0ubuntu1~12.04.6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Generate a DHCP server configuration."""
from __future__ import (
absolute_import,
print_function,
unicode_literals,
)
__metaclass__ = type
__all__ = [
"add_arguments",
"run",
]
import sys
from provisioningserver.dhcp import config
def add_arguments(parser):
"""Initialise options for generating DHCP configuration.
:param parser: An instance of :class:`ArgumentParser`.
"""
parser.add_argument(
"--subnet", action="store", required=True, help=(
"Base subnet declaration, e.g. 192.168.1.0"))
parser.add_argument(
"--subnet-mask", action="store", required=True, help=(
"The mask for the subnet, e.g. 255.255.255.0"))
parser.add_argument(
"--broadcast-ip", action="store", required=True, help=(
"The broadcast IP address for the subnet, e.g. 192.168.1.255"))
parser.add_argument(
"--dns-servers", action="store", required=True, help=(
"One or more IP addresses of the DNS server for the subnet "
"separated by spaces."))
parser.add_argument(
"--router-ip", action="store", required=True, help=(
"The router/gateway IP address for the subnet"))
parser.add_argument(
"--ip-range-low", action="store", required=True, help=(
"The first IP address in the range of IP addresses to "
"allocate"))
parser.add_argument(
"--ip-range-high", action="store", required=True, help=(
"The last IP address in the range of IP addresses to "
"allocate"))
parser.add_argument(
"--omapi-key", action="store", required=True, help=(
"The shared key for authentication to OMAPI"))
parser.add_argument(
"-o", "--outfile", action="store", required=False, help=(
"A file to save to. When left unspecified the configuration "
"will be written to stdout. This option is useful when "
"running outside of a shell."))
def run(args):
"""Generate a DHCP server configuration, and write it to stdout."""
params = vars(args)
output = config.get_config(**params).encode("ascii")
if args.outfile is None:
sys.stdout.write(output)
else:
with open(args.outfile, "wb") as out:
out.write(output)
|