usr/src/cmd/distro_const/__init__.py
author Ginnie Wray<virginia.wray@oracle.com>
Mon, 25 Jun 2012 23:37:20 -0600
changeset 1729 f381cfe49a42
parent 1725 8894eefc65a8
child 1741 d79b92c1bded
permissions -rw-r--r--
7178978 still cannot do concurrent DC build after fix for 7178336 went in
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
947
29603af1b942 6999599 Missing shebang lines in python modules leads to incorrect dependency generation
Keith Mitchell <keith.mitchell@oracle.com>
parents: 649
diff changeset
     1
#!/usr/bin/python
197
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
     2
#
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
     3
# CDDL HEADER START
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
     4
#
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
     8
#
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    12
# and limitations under the License.
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    13
#
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    19
#
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    20
# CDDL HEADER END
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    21
#
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    22
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    23
#
1680
902e7dbd8043 7155706 pylint errors in usr/src/lib/install_transfer/ips.py
Mary Ding <mary.ding@oracle.com>
parents: 1268
diff changeset
    24
# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    25
#
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    26
649
ba353c37b287 12670 Change nested try/except in distro_const.py missed during 2.6 python porting
Clay Baenziger <ClayB@OpenSolaris.ORG>
parents: 609
diff changeset
    27
"""init module for the distribution constructor"""
197
ac1383e6038c 2618 Move install related modules in slim_source to a common place
Karen Tung <Karen.Tung@Sun.COM>
parents:
diff changeset
    28
1160
6f7e708c38ec 16257 Support for zones configuration and installation should be included in AI
Ethan Quach <Ethan.Quach@sun.com>
parents: 1111
diff changeset
    29
__all__ = ["cli", "distro_const", "execution_checkpoint", "distro_spec"]
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    30
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    31
import logging
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    32
import optparse
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    33
import os
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    34
import shutil
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    35
import sys
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    36
import time
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    37
1680
902e7dbd8043 7155706 pylint errors in usr/src/lib/install_transfer/ips.py
Mary Ding <mary.ding@oracle.com>
parents: 1268
diff changeset
    38
import solaris_install.distro_const.distro_spec
902e7dbd8043 7155706 pylint errors in usr/src/lib/install_transfer/ips.py
Mary Ding <mary.ding@oracle.com>
parents: 1268
diff changeset
    39
import solaris_install.distro_const.execution_checkpoint
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    40
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    41
import osol_install.errsvc as errsvc
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    42
import solaris_install.transfer.info as transfer
1163
b46f8cd05817 7050466 DC needs to import solaris_install.configuration once more
Drew Fisher <drew.fisher@oracle.com>
parents: 1160
diff changeset
    43
import solaris_install.configuration
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    44
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    45
from osol_install.install_utils import set_http_proxy
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    46
from osol_install.liberrsvc import ES_DATA_EXCEPTION
1268
25dda32568b2 7046402 provide a functools.partial object for common Popen.check_call invocations
Drew Fisher <drew.fisher@oracle.com>
parents: 1173
diff changeset
    47
from solaris_install import CalledProcessError, run, DC_LABEL
1111
0c6c862af34f 7038421 Provide a boot checkpoint implementation based on pybootmgmt
Niall Power <niall@brawndo.local>
parents: 1077
diff changeset
    48
from solaris_install.boot.boot_spec import BootMods
1717
10cb4d15a248 7066254 Problem with install/logging
Ginnie Wray<virginia.wray@oracle.com>
parents: 1695
diff changeset
    49
from solaris_install import system_temp_path
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    50
from solaris_install.data_object import DataObject, ObjectNotFoundError
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    51
from solaris_install.data_object.cache import DataObjectCache
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    52
from solaris_install.data_object.data_dict import DataObjectDict
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    53
from solaris_install.distro_const.execution_checkpoint import Execution
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    54
from solaris_install.distro_const.distro_spec import Distro
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    55
from solaris_install.engine import FileNotFoundError, InstallEngine, \
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    56
    NoDatasetError, RollbackError, UsageError, UnknownChkptError
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    57
from solaris_install.engine import INSTALL_LOGGER_NAME
1717
10cb4d15a248 7066254 Problem with install/logging
Ginnie Wray<virginia.wray@oracle.com>
parents: 1695
diff changeset
    58
from solaris_install.logger import FileHandler, InstallFormatter
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    59
from solaris_install.manifest.parser import ManifestError
1070
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
    60
from solaris_install.target import Target
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
    61
from solaris_install.target.logical import Filesystem, Zpool
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
    62
from solaris_install.transfer.info import Destination, Dir, Image, Software, \
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
    63
    Source
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    64
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    65
DC_LOCKFILE = "distro_const.lock"
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    66
DC_LOGGER = None
1717
10cb4d15a248 7066254 Problem with install/logging
Ginnie Wray<virginia.wray@oracle.com>
parents: 1695
diff changeset
    67
LOG_TIMESTAMP = time.strftime("%Y-%m-%d.%H:%M")
1729
f381cfe49a42 7178978 still cannot do concurrent DC build after fix for 7178336 went in
Ginnie Wray<virginia.wray@oracle.com>
parents: 1725
diff changeset
    68
DEFAULTLOG = system_temp_path("dc" + str(os.getpid()) + "/default_log")
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    69
960
0b70d3926a5a 7006443 transfer-ips-install checkpoint created image in wrong location
Drew Fisher <Drew.Fisher@Sun.COM>
parents: 958
diff changeset
    70
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    71
class Lockfile(object):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    72
    """ Lockfile - context manager for locking the distro_const dataset to
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    73
    prevent multiple invocations of distro_const from running at the same time
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    74
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    75
    def __init__(self, filename):
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
    76
        """ filename is the path of the file to use to lock the dataset
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    77
        """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    78
        self.filename = filename
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    79
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    80
    def __enter__(self):
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
    81
        """ method which checks for the lockfile before creating one.  If the
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
    82
        lockfile exists, exit with an error
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    83
        """
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
    84
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    85
        if os.path.exists(self.filename):
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
    86
            raise RuntimeError("distro_const: An instance of distro_const "
1717
10cb4d15a248 7066254 Problem with install/logging
Ginnie Wray<virginia.wray@oracle.com>
parents: 1695
diff changeset
    87
                               "is already running in %s" %
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
    88
                               os.path.split(self.filename)[0])
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    89
        else:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    90
            # touch the lockfile
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    91
            with open(self.filename, "w"):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    92
                pass
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    93
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    94
    def __exit__(self, *exc_info):
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
    95
        """ method to remove the lockfile
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    96
        """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    97
        if os.path.exists(self.filename):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    98
            try:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
    99
                os.remove(self.filename)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   100
            except BaseException as err:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   101
                raise RuntimeError("Could not remove %s: %s" % \
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   102
                                   (self.filename, err))
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   103
960
0b70d3926a5a 7006443 transfer-ips-install checkpoint created image in wrong location
Drew Fisher <Drew.Fisher@Sun.COM>
parents: 958
diff changeset
   104
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   105
class DCScreenHandler(logging.Formatter):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   106
    """ DC-specific StreamHandler class.  Suppresses traceback printing to the
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   107
    screen by overloading the format() method
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   108
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   109
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   110
    def format(self, record):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   111
        """ overloaded method to prevent the traceback from being printed
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   112
        """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   113
        record.message = record.getMessage()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   114
        record.asctime = self.formatTime(record, self.datefmt)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   115
        s = self._fmt % record.__dict__
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   116
        return s
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   117
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   118
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   119
def parse_args(baseargs=sys.argv[1:]):
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   120
    """ parse_args() - function used to parse the command line arguments to
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   121
    distro_const.
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   122
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   123
    usage = "%prog build [-v] [-r <checkpoint name>] " + \
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   124
            "[-p <checkpoint name>] " + \
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   125
            "[-l] manifest"
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   126
    parser = optparse.OptionParser(usage=usage)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   127
    parser.add_option("-v", "--verbose", dest="verbose", default=False,
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   128
                      action="store_true", help="Specifies verbose mode")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   129
    parser.add_option("-r", "--resume", dest="resume_checkpoint",
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   130
                      help="Checkpoint to resume execution from")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   131
    parser.add_option("-p", "--pause", dest="pause_checkpoint",
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   132
                      help="Checkpoint to pause execution on")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   133
    parser.add_option("-l", "--list", dest="list_checkpoints",
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   134
                      action="store_true",
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   135
                      help="List all possible checkpoints")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   136
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   137
    (options, args) = parser.parse_args(baseargs)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   138
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   139
    # verify there are exactly two arguments (subcommand and manifest)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   140
    if not args:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   141
        parser.error("subcommand and manifest not specified")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   142
    # currently only the 'build' subcommand is supported
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   143
    elif args[0] != "build":
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   144
        parser.error("invalid or missing subcommand")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   145
    elif len(args) != 2:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   146
        parser.error("invalid number of arguments to distro_const")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   147
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   148
    return (options, args)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   149
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   150
1077
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   151
def set_stream_handler(DC_LOGGER, list_cps, verbose):
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   152
    """ function to setup the stream_handler of the logging module for output
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   153
    to the screen.
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   154
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   155
    # create a simple StreamHandler to output messages to the screen
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   156
    screen_sh = logging.StreamHandler()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   157
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   158
    # set the verbosity of the output
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   159
    if verbose:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   160
        screen_sh.setLevel(logging.DEBUG)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   161
    else:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   162
        screen_sh.setLevel(logging.INFO)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   163
1077
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   164
    # set the columns.  If the user only wants to list the checkpoints, omit
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   165
    # the timestamps
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   166
    if list_cps:
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   167
        fmt = "%(message)s"
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   168
        screen_sh.setFormatter(DCScreenHandler(fmt=fmt))
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   169
    else:
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   170
        fmt = "%(asctime)-11s %(message)s"
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   171
        datefmt = "%H:%M:%S"
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   172
        screen_sh.setFormatter(DCScreenHandler(fmt=fmt, datefmt=datefmt))
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   173
    DC_LOGGER.addHandler(screen_sh)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   174
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   175
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   176
def register_checkpoints(DC_LOGGER):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   177
    """ register each checkpoint in the execution section of the
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   178
    manifest with the InstallEngine.
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   179
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   180
    Also set the stop_on_error property of the InstallEngine based on what
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   181
    that property is set to in the manifest.
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   182
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   183
    eng = InstallEngine.get_instance()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   184
    doc = eng.data_object_cache
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   185
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   186
    # get the execution_list from the Distro object
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   187
    execution_obj = doc.volatile.get_descendants(class_type=Execution)
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   188
    if not execution_obj:
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   189
        raise RuntimeError("No Execution section found in the manifest")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   190
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   191
    # verify the manifest contains checkpoints to execute
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   192
    checkpoints = execution_obj[0].get_children()
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   193
    if not checkpoints:
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   194
        raise RuntimeError("No checkpoints found in the Execution section "
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   195
                           "of the manifest")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   196
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   197
    eng.stop_on_error = (execution_obj[0].stop_on_error.capitalize() == "True")
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   198
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   199
    # register the checkpoints with the engine
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   200
    registered_checkpoints = []
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   201
    for checkpoint in checkpoints:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   202
        try:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   203
            DC_LOGGER.debug("Registering Checkpoint:  " + checkpoint.name)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   204
            eng.register_checkpoint(checkpoint.name, checkpoint.mod_path,
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   205
                checkpoint.checkpoint_class, insert_before=None,
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   206
                loglevel=checkpoint.log_level, args=checkpoint.args,
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   207
                kwargs=checkpoint.kwargs)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   208
974
356b23696c62 7009607 DC doesn't abort when a checkpoint fails to register
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 968
diff changeset
   209
        except ImportError as err:
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   210
            DC_LOGGER.exception("Error registering checkpoint "
974
356b23696c62 7009607 DC doesn't abort when a checkpoint fails to register
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 968
diff changeset
   211
                                "'%s'\n" % checkpoint.name + \
356b23696c62 7009607 DC doesn't abort when a checkpoint fails to register
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 968
diff changeset
   212
                                "Check the 'mod_path' and 'checkpoint_class' "
356b23696c62 7009607 DC doesn't abort when a checkpoint fails to register
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 968
diff changeset
   213
                                "specified for this checkpoint")
356b23696c62 7009607 DC doesn't abort when a checkpoint fails to register
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 968
diff changeset
   214
            raise
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   215
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   216
        registered_checkpoints.append((checkpoint.name, checkpoint.desc))
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   217
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   218
    return registered_checkpoints
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   219
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   220
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   221
def execute_checkpoint(log=DEFAULTLOG, resume_checkpoint=None,
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   222
                       pause_checkpoint=None):
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   223
    """ wrapper to the execute_checkpoints methods
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   224
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   225
    eng = InstallEngine.get_instance()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   226
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   227
    if resume_checkpoint is not None:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   228
        (status, failed_cps) = eng.resume_execute_checkpoints(
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   229
            start_from=resume_checkpoint, pause_before=pause_checkpoint,
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   230
            dry_run=False, callback=None)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   231
    else:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   232
        (status, failed_cps) = eng.execute_checkpoints(start_from=None,
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   233
            pause_before=pause_checkpoint, dry_run=False, callback=None)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   234
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   235
    if status != InstallEngine.EXEC_SUCCESS:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   236
        for failed_cp in failed_cps:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   237
            for err in errsvc.get_errors_by_mod_id(failed_cp):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   238
                DC_LOGGER.info("'%s' checkpoint failed" % failed_cp)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   239
                DC_LOGGER.info(err.error_data[ES_DATA_EXCEPTION])
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   240
                # if a CalledProcessError is raised during execution of a
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   241
                # checkpoint, make sure the strerror() is also logged to give
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   242
                # the user additional feedback
960
0b70d3926a5a 7006443 transfer-ips-install checkpoint created image in wrong location
Drew Fisher <Drew.Fisher@Sun.COM>
parents: 958
diff changeset
   243
                if isinstance(err.error_data[ES_DATA_EXCEPTION],
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   244
                              CalledProcessError):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   245
                    DC_LOGGER.debug(os.strerror(
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   246
                        err.error_data[ES_DATA_EXCEPTION].returncode))
967
524de3368b08 7007793 target instantiation does not handle 'preserve' action correctly
Alok Aggarwal <Alok.Aggarwal@Sun.COM>
parents: 960
diff changeset
   247
        raise RuntimeError("Please check the log for additional error "
1047
22098f6a68c4 7024495 DC changes for PSARC 2010/368 EOF 32-bit x86 kernel support
Mary Ding <mary.ding@oracle.com>
parents: 974
diff changeset
   248
                           "messages. \nLog: " + log)
22098f6a68c4 7024495 DC changes for PSARC 2010/368 EOF 32-bit x86 kernel support
Mary Ding <mary.ding@oracle.com>
parents: 974
diff changeset
   249
960
0b70d3926a5a 7006443 transfer-ips-install checkpoint created image in wrong location
Drew Fisher <Drew.Fisher@Sun.COM>
parents: 958
diff changeset
   250
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   251
def parse_manifest(manifest):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   252
    """ function to parse the manifest
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   253
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   254
    eng = InstallEngine.get_instance()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   255
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   256
    kwargs = dict()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   257
    kwargs["call_xinclude"] = True
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   258
    args = [manifest]
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   259
    eng.register_checkpoint("manifest-parser",
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   260
                            "solaris_install/manifest/parser",
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   261
                            "ManifestParser", args=args, kwargs=kwargs)
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   262
    execute_checkpoint()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   263
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   264
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   265
def validate_target():
960
0b70d3926a5a 7006443 transfer-ips-install checkpoint created image in wrong location
Drew Fisher <Drew.Fisher@Sun.COM>
parents: 958
diff changeset
   266
    """ validate_target() - function to validate the target element specified
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   267
    in the manifest.
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   268
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   269
    eng = InstallEngine.get_instance()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   270
    doc = eng.data_object_cache
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   271
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   272
    # retrieve the build dataset
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   273
    fs = doc.get_descendants(class_type=Filesystem)
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   274
    if not fs:
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   275
        raise RuntimeError("distro_const: No dataset specified")
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   276
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   277
    if len(fs) > 1:
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   278
        raise RuntimeError("distro_const: More than one dataset specified "
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   279
                           "as the build dataset")
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   280
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   281
    # verify the base_action is not "delete" for the Filesystem
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   282
    if fs[0].action == "delete":
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   283
        raise RuntimeError("distro_const: 'delete' action not supported "
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   284
                           "for Filesystems")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   285
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   286
    # get the zpool name and action
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   287
    zpool = doc.get_descendants(class_type=Zpool)
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   288
    if not zpool:
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   289
        raise RuntimeError("distro_const: No zpool specified")
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   290
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   291
    if len(zpool) > 1:
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   292
        raise RuntimeError("distro_const: More than one zpool specified")
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   293
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   294
    if zpool[0].action in ["delete", "create"]:
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   295
        raise RuntimeError("distro_const: '%s' action not supported for "
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   296
                           "Zpools" % zpool[0].action)
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   297
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   298
    if not zpool[0].exists:
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   299
        raise RuntimeError("distro_const: Zpool '%s' does not exist" %
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   300
                           zpool[0].name)
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   301
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   302
    return zpool[0], fs[0]
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   303
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   304
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   305
def setup_build_dataset(zpool, fs, resume_checkpoint=None):
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   306
    """ Setup the build datasets for use by DC. This includes setting up:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   307
    - top level build dataset
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   308
    - a child dataset named 'build_data'
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   309
    - a child dataset named 'media'
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   310
    - a child dataset named 'logs'
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   311
    - a snapshot of the empty build_data dataset - build_data@empty
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   312
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   313
    eng = InstallEngine.get_instance()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   314
    doc = eng.data_object_cache
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   315
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   316
    build_data = eng.dataset
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   317
    empty_snap = Filesystem(os.path.join(zpool.name, fs.name,
1070
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   318
                                         "build_data@empty"))
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   319
    logs = Filesystem(os.path.join(zpool.name, fs.name, "logs"))
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   320
    media = Filesystem(os.path.join(zpool.name, fs.name, "media"))
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   321
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   322
    if fs.action == "create":
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   323
        # recursively destroy the Filesystem dataset before creating it
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   324
        fs.destroy(dry_run=False, recursive=True)
960
0b70d3926a5a 7006443 transfer-ips-install checkpoint created image in wrong location
Drew Fisher <Drew.Fisher@Sun.COM>
parents: 958
diff changeset
   325
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   326
    fs.create()
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   327
    build_data.create()
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   328
    logs.create()
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   329
    media.create()
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   330
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   331
    if fs.action == "preserve":
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   332
        # check to see if base_dataset/build_data@empty exists.
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   333
        if resume_checkpoint is None and empty_snap.exists:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   334
            # rollback the dataset only if DC is not resuming from a specific
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   335
            # checkpoint
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   336
            build_data.rollback("empty", recursive=True)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   337
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   338
    if not empty_snap.exists:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   339
        build_data.snapshot("empty")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   340
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   341
    # Now that the base dataset is created, store the mountpoint ZFS calculated
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   342
    base_dataset_mp = fs.get("mountpoint")
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   343
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   344
    # check for the existence of a lock file, bail out if one exists.
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   345
    if os.path.exists(base_dataset_mp):
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   346
        if os.path.exists(os.path.join(base_dataset_mp, DC_LOCKFILE)):
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   347
            raise RuntimeError("distro_const: An instance of distro_const "
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   348
                               "is already running in %s" % base_dataset_mp)
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   349
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   350
    DC_LOGGER.info("Build datasets successfully setup")
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   351
    return (base_dataset_mp, build_data.get("mountpoint"),
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   352
            logs.get("mountpoint"), media.get("mountpoint"))
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   353
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   354
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   355
def dc_set_http_proxy(DC_LOGGER):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   356
    """ set the http_proxy and HTTP_PROXY environment variables
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   357
    if an http_proxy is specified in the manifest.
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   358
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   359
    eng = InstallEngine.get_instance()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   360
    doc = eng.data_object_cache
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   361
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   362
    # get the Distro object from the DOC that contains all of the
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   363
    # checkpoint objects as the children
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   364
    distro = doc.volatile.get_descendants(class_type=Distro)
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   365
    if not distro:
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   366
        return
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   367
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   368
    if distro[0].http_proxy is not None:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   369
        DC_LOGGER.debug("Setting http_proxy to %s" % distro[0].http_proxy)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   370
        set_http_proxy(distro[0].http_proxy)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   371
    else:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   372
        DC_LOGGER.debug("No http_proxy specified in the manifest")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   373
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   374
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   375
def list_checkpoints(DC_LOGGER):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   376
    """ List the checkpoints listed in the manifest
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   377
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   378
    eng = InstallEngine.get_instance()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   379
    # register each checkpoint listed in the execution section
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   380
    registered_checkpoints = register_checkpoints(DC_LOGGER)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   381
    resumable_checkpoints = None
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   382
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   383
    try:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   384
        resumable_checkpoints = eng.get_resumable_checkpoints()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   385
    except (NoDatasetError, FileNotFoundError) as err:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   386
        # the build dataset is probably a virgin dataset
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   387
        DC_LOGGER.debug("No checkpoints are resumable: %s" % err)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   388
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   389
    DC_LOGGER.info("Checkpoint           Resumable Description")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   390
    DC_LOGGER.info("----------           --------- -----------")
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   391
    for (name, desc) in registered_checkpoints:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   392
        if resumable_checkpoints is not None and \
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   393
            name in resumable_checkpoints:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   394
            DC_LOGGER.info("%-20s%6s     %-20s" % (name, "X", desc))
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   395
        else:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   396
            DC_LOGGER.info("%-20s%6s     %-20s" % (name, " ", desc))
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   397
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   398
1070
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   399
def update_doc_paths(build_data_mp):
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   400
    """ function to replace placeholder strings in the DOC with actual paths
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   401
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   402
    build_data_mp - mountpoint of the build_data dataset
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   403
    """
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   404
    eng = InstallEngine.get_instance()
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   405
    doc = eng.data_object_cache
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   406
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   407
    # find all of the Software nodes
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   408
    software_list = doc.volatile.get_descendants(class_type=Software)
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   409
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   410
    # iterate over each node, looking for Dir and/or Image nodes
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   411
    for software_node in software_list:
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   412
        for dir_node in software_node.get_descendants(class_type=Dir):
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   413
            path = dir_node.dir_path
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   414
            path = path.replace("{BUILD_DATA}", build_data_mp)
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   415
            path = path.replace("{BOOT_ARCHIVE}",
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   416
               os.path.join(build_data_mp, "boot_archive"))
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   417
            path = path.replace("{PKG_IMAGE_PATH}",
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   418
               os.path.join(build_data_mp, "pkg_image"))
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   419
            dir_node.dir_path = path
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   420
        for image_node in software_node.get_descendants(class_type=Image):
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   421
            path = image_node.img_root
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   422
            path = path.replace("{BUILD_DATA}", build_data_mp)
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   423
            path = path.replace("{BOOT_ARCHIVE}",
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   424
               os.path.join(build_data_mp, "boot_archive"))
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   425
            path = path.replace("{PKG_IMAGE_PATH}",
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   426
               os.path.join(build_data_mp, "pkg_image"))
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   427
            image_node.img_root = path
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   428
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   429
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   430
def main():
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   431
    """ primary execution function for distro_const
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   432
    """
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   433
    # clear the error service to be sure that we start with a clean slate
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   434
    errsvc.clear_error_list()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   435
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   436
    options, args = parse_args()
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   437
    manifest = args[-1]
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   438
    pause_checkpoint = None
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   439
    resume_checkpoint = None
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   440
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   441
    verbose = options.verbose
1077
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   442
    list_cps = options.list_checkpoints
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   443
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   444
    try:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   445
        # We initialize the Engine with stop_on_error set so that if there are
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   446
        # errors during manifest parsing, the processing stops
1717
10cb4d15a248 7066254 Problem with install/logging
Ginnie Wray<virginia.wray@oracle.com>
parents: 1695
diff changeset
   447
        eng = InstallEngine(DEFAULTLOG, debug=False, exclusive_rw=True,
10cb4d15a248 7066254 Problem with install/logging
Ginnie Wray<virginia.wray@oracle.com>
parents: 1695
diff changeset
   448
            stop_on_error=True)
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   449
        doc = eng.data_object_cache
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   450
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   451
        global DC_LOGGER
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   452
        DC_LOGGER = logging.getLogger(INSTALL_LOGGER_NAME)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   453
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   454
        # set the logfile name
1717
10cb4d15a248 7066254 Problem with install/logging
Ginnie Wray<virginia.wray@oracle.com>
parents: 1695
diff changeset
   455
        log_name = "log.%s" % LOG_TIMESTAMP
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   456
        detail_log_name = "detail-%s" % log_name
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   457
        simple_log_name = "simple-%s" % log_name
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   458
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   459
        # create an additional FileHandler for a simple log
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   460
        base, logfile = os.path.split(DEFAULTLOG)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   461
        simple_logname = os.path.join(base, "simple-" + logfile)
1717
10cb4d15a248 7066254 Problem with install/logging
Ginnie Wray<virginia.wray@oracle.com>
parents: 1695
diff changeset
   462
        simple_fh = FileHandler(simple_logname, exclusive_rw=True)
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   463
        simple_fh.setLevel(logging.INFO)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   464
        DC_LOGGER.addHandler(simple_fh)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   465
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   466
        if options.resume_checkpoint:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   467
            resume_checkpoint = options.resume_checkpoint
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   468
            DC_LOGGER.info("distro_const will resume from:  " + \
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   469
                           resume_checkpoint)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   470
        if options.pause_checkpoint:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   471
            pause_checkpoint = options.pause_checkpoint
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   472
            DC_LOGGER.info("distro_const will pause at:  " + pause_checkpoint)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   473
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   474
        # create a simple StreamHandler to output messages to the screen
1077
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   475
        set_stream_handler(DC_LOGGER, list_cps, verbose)
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   476
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   477
        parse_manifest(manifest)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   478
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   479
        # validate the target section of the manifest
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   480
        zpool, fs = validate_target()
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   481
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   482
        # set the engine's dataset to enable snapshots
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   483
        eng.dataset = os.path.join(zpool.name, fs.name, "build_data")
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   484
1077
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   485
        if list_cps:
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   486
            list_checkpoints(DC_LOGGER)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   487
        else:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   488
            (base_dataset_mp, build_data_mp, logs_mp, media_mp) = \
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   489
                setup_build_dataset(zpool, fs, resume_checkpoint)
1070
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   490
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   491
            # update the DOC with actual directory values
ef77609251f5 7021591 provide an implementation of TI/TD based on CUD
Drew Fisher <drew.fisher@oracle.com>
parents: 1047
diff changeset
   492
            update_doc_paths(build_data_mp)
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   493
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   494
            # lock the dataset
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   495
            with Lockfile(os.path.join(base_dataset_mp, DC_LOCKFILE)):
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   496
                # output the log file path to the screen and transfer the logs
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   497
                new_detaillog = os.path.join(logs_mp, detail_log_name)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   498
                new_simplelog = os.path.join(logs_mp, simple_log_name)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   499
                DC_LOGGER.info("Simple log: %s" % new_simplelog)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   500
                DC_LOGGER.info("Detail Log: %s" % new_detaillog)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   501
                DC_LOGGER.transfer_log(destination=new_detaillog)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   502
                simple_fh.transfer_log(destination=new_simplelog)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   503
1729
f381cfe49a42 7178978 still cannot do concurrent DC build after fix for 7178336 went in
Ginnie Wray<virginia.wray@oracle.com>
parents: 1725
diff changeset
   504
                # Remove the directory containing DEFAULTLOG and the original
f381cfe49a42 7178978 still cannot do concurrent DC build after fix for 7178336 went in
Ginnie Wray<virginia.wray@oracle.com>
parents: 1725
diff changeset
   505
		# simple log. Their contents have been transferred to the DC
f381cfe49a42 7178978 still cannot do concurrent DC build after fix for 7178336 went in
Ginnie Wray<virginia.wray@oracle.com>
parents: 1725
diff changeset
   506
		# log location.
f381cfe49a42 7178978 still cannot do concurrent DC build after fix for 7178336 went in
Ginnie Wray<virginia.wray@oracle.com>
parents: 1725
diff changeset
   507
		shutil.rmtree(os.path.dirname(DEFAULTLOG))
1717
10cb4d15a248 7066254 Problem with install/logging
Ginnie Wray<virginia.wray@oracle.com>
parents: 1695
diff changeset
   508
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   509
                # set the http_proxy if one is specified in the manifest
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   510
                dc_set_http_proxy(DC_LOGGER)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   511
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   512
                # register each checkpoint listed in the execution section
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   513
                registered_checkpoints = register_checkpoints(DC_LOGGER)
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   514
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   515
                # if we're trying to pause at the very first checkpoint,
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   516
                # there's nothing to execute, so return 0
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   517
                if pause_checkpoint == registered_checkpoints[0][0]:
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   518
                    return 0
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   519
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   520
                # populate the DOC with the common information needed by the
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   521
                # various checkpoints
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   522
                doc_dict = {"pkg_img_path": os.path.join(build_data_mp,
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   523
                                                         "pkg_image"),
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   524
                            "ba_build": os.path.join(build_data_mp,
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   525
                                                     "boot_archive"),
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   526
                            "tmp_dir": os.path.join(build_data_mp, "tmp"),
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   527
                            "media_dir": media_mp}
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   528
                doc.volatile.insert_children(DataObjectDict(DC_LABEL, doc_dict,
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   529
                                                            generate_xml=True))
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   530
960
0b70d3926a5a 7006443 transfer-ips-install checkpoint created image in wrong location
Drew Fisher <Drew.Fisher@Sun.COM>
parents: 958
diff changeset
   531
                execute_checkpoint(new_detaillog, resume_checkpoint,
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   532
                    pause_checkpoint)
1695
7e11a6b0de11 7057261 Automated Installer trying to mount non-existent datasets
Matt Keenan <matt.keenan@oracle.com>
parents: 1680
diff changeset
   533
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   534
    # catch any errors and log them.
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   535
    except BaseException as msg:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   536
        if DC_LOGGER is not None:
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   537
            DC_LOGGER.exception(msg)
960
0b70d3926a5a 7006443 transfer-ips-install checkpoint created image in wrong location
Drew Fisher <Drew.Fisher@Sun.COM>
parents: 958
diff changeset
   538
        else:
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   539
            # DC_LOGGER hasn't even been setup and we ran into an error
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   540
            print msg
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   541
        return 1
1077
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   542
    finally:
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   543
        if DC_LOGGER is not None:
99506d2f9cf7 7006574 DC build should complain if "none" is not a valid option for LiveCDPkgImgMod
Drew Fisher <drew.fisher@oracle.com>
parents: 1070
diff changeset
   544
            DC_LOGGER.close()
958
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   545
552c24933bed 7000990 The logging module needs a transfer_log method for the FileHandler class
Alok Aggarwal <alok.aggarwal@oracle.com>
parents: 947
diff changeset
   546
    return 0