From 2c76da5f437c5fc2f4022e8705e74fed0a46bebb Mon Sep 17 00:00:00 2001 From: Luong Anh Tuan Date: Fri, 16 Sep 2016 13:09:10 +0700 Subject: [PATCH] Timing metrics: iRMC drivers Adds timing metrics for methods in the boot, inspect, management, power and vendor modules of iRMC drivers. Change-Id: I743da5510f897fdadf87a51ab28270ee618a8649 Closes-Bug: #1611556 --- ironic/drivers/modules/irmc/boot.py | 8 ++++++++ ironic/drivers/modules/irmc/inspect.py | 6 +++++- ironic/drivers/modules/irmc/management.py | 7 ++++++- ironic/drivers/modules/irmc/power.py | 8 ++++++++ releasenotes/notes/bug-1611556-92cbfde5ee7f44d6.yaml | 3 +++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/bug-1611556-92cbfde5ee7f44d6.yaml diff --git a/ironic/drivers/modules/irmc/boot.py b/ironic/drivers/modules/irmc/boot.py index c1d53bf247..976eb553e2 100644 --- a/ironic/drivers/modules/irmc/boot.py +++ b/ironic/drivers/modules/irmc/boot.py @@ -20,6 +20,7 @@ import os import shutil import tempfile +from ironic_lib import metrics_utils from ironic_lib import utils as ironic_utils from oslo_log import log as logging from oslo_utils import importutils @@ -47,6 +48,8 @@ except Exception: LOG = logging.getLogger(__name__) +METRICS = metrics_utils.get_metrics_logger(__name__) + REQUIRED_PROPERTIES = { 'irmc_deploy_iso': _("Deployment ISO image file name. " "Required."), @@ -533,6 +536,7 @@ class IRMCVirtualMediaBoot(base.BootInterface): def get_properties(self): return COMMON_PROPERTIES + @METRICS.timer('IRMCVirtualMediaBoot.validate') def validate(self, task): """Validate the deployment information for the task's node. @@ -557,6 +561,7 @@ class IRMCVirtualMediaBoot(base.BootInterface): deploy_utils.validate_image_properties(task.context, d_info, props) + @METRICS.timer('IRMCVirtualMediaBoot.prepare_ramdisk') def prepare_ramdisk(self, task, ramdisk_params): """Prepares the deploy ramdisk using virtual media. @@ -587,6 +592,7 @@ class IRMCVirtualMediaBoot(base.BootInterface): _setup_deploy_iso(task, ramdisk_params) + @METRICS.timer('IRMCVirtualMediaBoot.clean_up_ramdisk') def clean_up_ramdisk(self, task): """Cleans up the boot of ironic ramdisk. @@ -599,6 +605,7 @@ class IRMCVirtualMediaBoot(base.BootInterface): """ _cleanup_vmedia_boot(task) + @METRICS.timer('IRMCVirtualMediaBoot.prepare_instance') def prepare_instance(self, task): """Prepares the boot of instance. @@ -620,6 +627,7 @@ class IRMCVirtualMediaBoot(base.BootInterface): root_uuid_or_disk_id = driver_internal_info['root_uuid_or_disk_id'] self._configure_vmedia_boot(task, root_uuid_or_disk_id) + @METRICS.timer('IRMCVirtualMediaBoot.clean_up_instance') def clean_up_instance(self, task): """Cleans up the boot of instance. diff --git a/ironic/drivers/modules/irmc/inspect.py b/ironic/drivers/modules/irmc/inspect.py index 91ef22025e..5f89271364 100644 --- a/ironic/drivers/modules/irmc/inspect.py +++ b/ironic/drivers/modules/irmc/inspect.py @@ -14,7 +14,7 @@ """ iRMC Inspect Interface """ - +from ironic_lib import metrics_utils from oslo_log import log as logging from oslo_utils import importutils @@ -30,6 +30,8 @@ scci = importutils.try_import('scciclient.irmc.scci') LOG = logging.getLogger(__name__) +METRICS = metrics_utils.get_metrics_logger(__name__) + """ SC2.mib: sc2UnitNodeClass returns NIC type. @@ -142,6 +144,7 @@ class IRMCInspect(base.InspectInterface): """ return irmc_common.COMMON_PROPERTIES + @METRICS.timer('IRMCInspect.validate') def validate(self, task): """Validate the driver-specific inspection information. @@ -155,6 +158,7 @@ class IRMCInspect(base.InspectInterface): """ irmc_common.parse_driver_info(task.node) + @METRICS.timer('IRMCInspect.inspect_hardware') def inspect_hardware(self, task): """Inspect hardware. diff --git a/ironic/drivers/modules/irmc/management.py b/ironic/drivers/modules/irmc/management.py index b56e994337..ea85d92160 100644 --- a/ironic/drivers/modules/irmc/management.py +++ b/ironic/drivers/modules/irmc/management.py @@ -14,7 +14,7 @@ """ iRMC Management Driver """ - +from ironic_lib import metrics_utils from oslo_log import log as logging from oslo_utils import importutils @@ -30,6 +30,8 @@ scci = importutils.try_import('scciclient.irmc.scci') LOG = logging.getLogger(__name__) +METRICS = metrics_utils.get_metrics_logger(__name__) + # Boot Option Parameters #5 Data2 defined in # Set/Get System Boot Options Command, IPMI spec v2.0. _BOOTPARAM5_DATA2 = {boot_devices.PXE: '0x04', @@ -113,6 +115,7 @@ class IRMCManagement(ipmitool.IPMIManagement): """ return irmc_common.COMMON_PROPERTIES + @METRICS.timer('IRMCManagement.validate') def validate(self, task): """Validate the driver-specific management information. @@ -127,6 +130,7 @@ class IRMCManagement(ipmitool.IPMIManagement): irmc_common.update_ipmi_properties(task) super(IRMCManagement, self).validate(task) + @METRICS.timer('IRMCManagement.set_boot_device') @task_manager.require_exclusive_lock def set_boot_device(self, task, device, persistent=False): """Set the boot device for a node. @@ -177,6 +181,7 @@ class IRMCManagement(ipmitool.IPMIManagement): cmd8 = bootparam5 % (data1, data2) ipmitool.send_raw(task, cmd8) + @METRICS.timer('IRMCManagement.get_sensors_data') def get_sensors_data(self, task): """Get sensors data method. diff --git a/ironic/drivers/modules/irmc/power.py b/ironic/drivers/modules/irmc/power.py index 5966b8ce62..5dae6e5969 100644 --- a/ironic/drivers/modules/irmc/power.py +++ b/ironic/drivers/modules/irmc/power.py @@ -15,6 +15,8 @@ """ iRMC Power Driver using the Base Server Profile """ + +from ironic_lib import metrics_utils from oslo_log import log as logging from oslo_utils import importutils @@ -32,6 +34,8 @@ scci = importutils.try_import('scciclient.irmc.scci') LOG = logging.getLogger(__name__) +METRICS = metrics_utils.get_metrics_logger(__name__) + if scci: STATES_MAP = {states.POWER_OFF: scci.POWER_OFF, states.POWER_ON: scci.POWER_ON, @@ -83,6 +87,7 @@ class IRMCPower(base.PowerInterface): """ return irmc_common.COMMON_PROPERTIES + @METRICS.timer('IRMCPower.validate') def validate(self, task): """Validate the driver-specific Node power info. @@ -97,6 +102,7 @@ class IRMCPower(base.PowerInterface): """ irmc_common.parse_driver_info(task.node) + @METRICS.timer('IRMCPower.get_power_state') def get_power_state(self, task): """Return the power state of the task's node. @@ -111,6 +117,7 @@ class IRMCPower(base.PowerInterface): ipmi_power = ipmitool.IPMIPower() return ipmi_power.get_power_state(task) + @METRICS.timer('IRMCPower.set_power_state') @task_manager.require_exclusive_lock def set_power_state(self, task, power_state): """Set the power state of the task's node. @@ -124,6 +131,7 @@ class IRMCPower(base.PowerInterface): """ _set_power_state(task, power_state) + @METRICS.timer('IRMCPower.reboot') @task_manager.require_exclusive_lock def reboot(self, task): """Perform a hard reboot of the task's node. diff --git a/releasenotes/notes/bug-1611556-92cbfde5ee7f44d6.yaml b/releasenotes/notes/bug-1611556-92cbfde5ee7f44d6.yaml new file mode 100644 index 0000000000..72532d6409 --- /dev/null +++ b/releasenotes/notes/bug-1611556-92cbfde5ee7f44d6.yaml @@ -0,0 +1,3 @@ +--- +features: + - Adds timing metrics to iRMC drivers. \ No newline at end of file