~smoser/ubuntu/trusty/maas/lp-1172566

« back to all changes in this revision

Viewing changes to src/provisioningserver/boot/install_bootloader.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2014-04-03 13:45:02 UTC
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20140403134502-8a6wvuqwyuekufh0
Tags: upstream-1.5+bzr2227
ImportĀ upstreamĀ versionĀ 1.5+bzr2227

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
__metaclass__ = type
15
15
__all__ = [
16
 
    "add_arguments",
17
 
    "run",
 
16
    "install_bootloader",
 
17
    "make_destination",
18
18
    ]
19
19
 
20
20
import filecmp
22
22
from shutil import copyfile
23
23
 
24
24
from provisioningserver.boot.tftppath import locate_tftp_path
25
 
from provisioningserver.config import Config
26
25
 
27
26
 
28
27
def make_destination(tftproot):
78
77
        os.remove(temp_file)
79
78
    copyfile(loader, temp_file)
80
79
    os.rename(temp_file, destination)
81
 
 
82
 
 
83
 
def add_arguments(parser):
84
 
    parser.add_argument(
85
 
        '--loader', dest='loader', default=None,
86
 
        help="Pre-boot loader to install.")
87
 
 
88
 
 
89
 
def run(args):
90
 
    """Install a pre-boot loader into the TFTP directory structure.
91
 
 
92
 
    This won't overwrite an existing loader if its contents are unchanged.
93
 
    """
94
 
    config = Config.load(args.config_file)
95
 
    tftproot = config["tftp"]["resource_root"]
96
 
    destination_path = make_destination(tftproot)
97
 
    destination = os.path.join(destination_path, os.path.basename(args.loader))
98
 
    install_bootloader(args.loader, destination)