Skip to content

Commit

Permalink
adding api to enable file logging. adding reapply to bios_boot_oder (C…
Browse files Browse the repository at this point in the history
…iscoUcs#91)

Signed-off-by: vvb <vvb@cisco.com>
  • Loading branch information
vvb authored Jan 18, 2017
1 parent b0bfde5 commit 9863459
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
7 changes: 7 additions & 0 deletions imcsdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


import logging
import logging.handlers

log = logging.getLogger('imc')
console = logging.StreamHandler()
Expand All @@ -21,6 +22,12 @@
console.setFormatter(formatter)


def enable_file_logging(filename="imcsdk.log"):
file_handler = logging.handlers.RotatingFileHandler(
filename, maxBytes=10*1024*1024, backupCount=5)
log.addHandler(file_handler)


def set_log_level(level=logging.DEBUG):
"""
Allows setting log level
Expand Down
23 changes: 16 additions & 7 deletions imcsdk/apis/server/bios.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,12 @@ def _add_boot_device(handle, parent_dn, boot_device):


def boot_order_precision_set(
handle, reboot_on_update=False, configured_boot_mode="Legacy",
boot_devices=[], server_id=1):
handle,
reboot_on_update=False,
reapply=False,
configured_boot_mode="Legacy",
boot_devices=[],
server_id=1):
"""
This method will replace the existing boot order precision with the new one
and also set the boot mode
Expand All @@ -215,6 +219,7 @@ def boot_order_precision_set(
Args:
handle (ImcHandle)
reboot_on_update (bool): True, False
reapply(bool): True, False
configured_boot_mode(string): "Legacy", "Uefi", "None"
boot_devices (list of dict): format
[{"order":'1', "device-type":"vmedia", "name":"vmedia"},
Expand All @@ -234,10 +239,11 @@ def boot_order_precision_set(
Examples:
boot_order_precision_set(
handle,
reboot_on_update=False,
configured_boot_mode="Uefi",
boot_devices = [{"order":'1', "device-type":"vmedia", "name":"vmedia"},
{"order":'2', "device-type":"hdd", "name":"hdd"}]
reboot_on_update=False,
reapply=False,
configured_boot_mode="Uefi",
boot_devices = [{"order":'1', "device-type":"vmedia", "name":"vmedia"},
{"order":'2', "device-type":"hdd", "name":"hdd"}]
"""

# Insert version check here to gracefully handle older versions of CIMC
Expand All @@ -247,12 +253,15 @@ def boot_order_precision_set(

server_dn = imccoreutils.get_server_dn(handle, server_id)
lsbootdevprecision_mo = LsbootDevPrecision(parent_mo_or_dn=server_dn)
# lsbootdevprecision_mo.reboot_on_update = ("no", "yes")[reboot_on_update]

lsbootdevprecision_mo.reboot_on_update = "no"
if reboot_on_update:
lsbootdevprecision_mo.reboot_on_update = "yes"

lsbootdevprecision_mo.reapply = "no"
if reapply:
lsbootdevprecision_mo.reapply = "yes"

lsbootdevprecision_mo.configured_boot_mode = configured_boot_mode

handle.set_mo(lsbootdevprecision_mo)
Expand Down

0 comments on commit 9863459

Please sign in to comment.