2N/A#! /usr/bin/python2.6
2N/A#
2N/A# CDDL HEADER START
2N/A#
2N/A# The contents of this file are subject to the terms of the
2N/A# Common Development and Distribution License (the "License").
2N/A# You may not use this file except in compliance with the License.
2N/A#
2N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A# or http://www.opensolaris.org/os/licensing.
2N/A# See the License for the specific language governing permissions
2N/A# and limitations under the License.
2N/A#
2N/A# When distributing Covered Code, include this CDDL HEADER in each
2N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A# If applicable, add the following below this CDDL HEADER, with the
2N/A# fields enclosed by brackets "[]" replaced with your own identifying
2N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2N/A#
2N/A# CDDL HEADER END
2N/A#
2N/A# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2N/A#
2N/A
2N/A"""
2N/ABootInstance autogenerator Solaris backend for pybootmgmt
2N/A"""
2N/A
2N/Aimport libbe_py
2N/A
2N/Afrom bootmgmt import BootmgmtUnsupportedOperationError
2N/Afrom bootmgmt.bootconfig import BootConfig, SolarisDiskBootInstance
2N/Afrom bootmgmt.bootutil import LoggerMixin
2N/A
2N/A
2N/Aclass SolarisBootInstanceAutogenerator(LoggerMixin):
2N/A pass
2N/A
2N/A
2N/Adef autogenerate_boot_instances(bootconfig):
2N/A sbia = SolarisBootInstanceAutogenerator()
2N/A
2N/A # XXX - Handle bootconfig instances that have boot_class != disk
2N/A if bootconfig.boot_class != BootConfig.BOOT_CLASS_DISK:
2N/A raise BootmgmtUnsupportedOperationError('XXX - Fix Me')
2N/A
2N/A # Use libbe_py to get the list of boot environments, then iterate
2N/A # over the list, creating a new SolarisDiskBootInstance for each
2N/A # Note that the title will just be the last portion of the bootfs
2N/A # (i.e. <pool>/ROOT/<title>)
2N/A retcode, belist = libbe_py.beList()
2N/A if retcode != 0:
2N/A sbia._debug('libbe_py.beList() failed; return code was ' +
2N/A str(retcode))
2N/A return []
2N/A
2N/A inst_list = []
2N/A for bootenv in belist:
2N/A if bootenv.get('orig_be_name', None) is None:
2N/A continue # skip over snapshots
2N/A bootinst = SolarisDiskBootInstance(None, title=bootenv['orig_be_name'],
2N/A bootfs=bootenv['root_ds'])
2N/A if bootenv['active'] is True:
2N/A sbia._debug('default boot instance is:\n' + str(bootinst))
2N/A bootinst.default = True
2N/A
2N/A inst_list.append(bootinst)
2N/A
2N/A return inst_list