Browse Source

Define constants for types of reboot job

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

Change-Id: I4f404bdb158899b4d0f50f87a120a222f4bd5939
changes/62/592162/6
Mark Beierl 3 years ago
parent
commit
6599e7f814
3 changed files with 31 additions and 7 deletions
  1. +3
    -2
      dracclient/client.py
  2. +21
    -0
      dracclient/constants.py
  3. +7
    -5
      dracclient/resources/job.py

+ 3
- 2
dracclient/client.py 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


+ 21
- 0
dracclient/constants.py 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]

+ 7
- 5
dracclient/resources/job.py 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


Loading…
Cancel
Save