Define constants for types of reboot job

Adds constants, instead of arbitrary strings, for specifying the type
of reboot job.

Change-Id: I4f404bdb158899b4d0f50f87a120a222f4bd5939
This commit is contained in:
Mark Beierl 2018-08-15 12:26:48 -04:00
parent 873a86e9c5
commit 6599e7f814
3 changed files with 31 additions and 7 deletions

View File

@ -439,8 +439,9 @@ class DRACClient(object):
reboot=reboot,
start_time=start_time)
def create_reboot_job(self,
reboot_type='graceful_reboot_with_forced_shutdown'):
def create_reboot_job(
self,
reboot_type=constants.RebootJobType.reboot_forced_shutdown):
"""Creates a reboot job.
:param reboot_type: type of reboot

View File

@ -50,3 +50,24 @@ class RebootRequired(object):
@classmethod
def all(cls):
return [cls.true, cls.optional, cls.false]
class RebootJobType(object):
"""Enumeration of different reboot job types."""
power_cycle = 'power_cycle'
"""Hard power off, power on cycle"""
graceful_reboot = 'graceful_reboot'
"""OS level reboot and wait for OS shutdown"""
reboot_forced_shutdown = 'reboot_forced_shutdown'
"""OS level reboot and force power cycle if OS does not shut
down
"""
@classmethod
def all(cls):
return [cls.power_cycle,
cls.graceful_reboot,
cls.reboot_forced_shutdown]

View File

@ -14,6 +14,7 @@
import collections
import logging
from dracclient import constants
import dracclient.exceptions as exceptions
from dracclient.resources import uris
from dracclient import utils
@ -27,9 +28,9 @@ JobTuple = collections.namedtuple(
'percent_complete'])
REBOOT_TYPES = {
'power_cycle': '1',
'graceful_reboot_without_forced_shutdown': '2',
'graceful_reboot_with_forced_shutdown': '3',
constants.RebootJobType.power_cycle: '1',
constants.RebootJobType.graceful_reboot: '2',
constants.RebootJobType.reboot_forced_shutdown: '3',
}
@ -168,8 +169,9 @@ class JobManagement(object):
return self._get_job_id(doc)
def create_reboot_job(self,
reboot_type='graceful_reboot_with_forced_shutdown'):
def create_reboot_job(
self,
reboot_type=constants.RebootJobType.reboot_forced_shutdown):
"""Creates a reboot job.
:param reboot_type: type of reboot