[ansible] add metrics collection

add standard ironic metrics collection decorators to methods of
ansible-deploy driver.

Change-Id: I8f2230e1a1caf2751fb76290e9cc51556392dee1
This commit is contained in:
Pavlo Shchelokovskyy 2017-03-17 15:51:06 +00:00
parent e1ece310fa
commit 1ab7c51edb
2 changed files with 18 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import json
import os
import shlex
from ironic_lib import metrics_utils
from ironic_lib import utils as irlib_utils
from oslo_concurrency import processutils
from oslo_config import cfg
@ -103,6 +104,7 @@ CONF.register_opts(ansible_opts, group='ansible')
LOG = log.getLogger(__name__)
METRICS = metrics_utils.get_metrics_logger(__name__)
DEFAULT_PLAYBOOKS = {
'deploy': 'deploy.yaml',
@ -392,6 +394,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
props.update(agent_base.VENDOR_PROPERTIES)
return props
@METRICS.timer('AnsibleDeploy.validate')
def validate(self, task):
"""Validate the driver-specific Node deployment info."""
task.driver.boot.validate(task)
@ -433,6 +436,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
# any caller should manage exceptions raised from here
_run_playbook(playbook, extra_vars, key, notags=notags)
@METRICS.timer('AnsibleDeploy.deploy')
@task_manager.require_exclusive_lock
def deploy(self, task):
"""Perform a deployment to a node."""
@ -455,6 +459,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
self.reboot_to_instance(task)
return states.DEPLOYDONE
@METRICS.timer('AnsibleDeploy.tear_down')
@task_manager.require_exclusive_lock
def tear_down(self, task):
"""Tear down a previous deployment on the task's node."""
@ -462,6 +467,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
task.driver.network.unconfigure_tenant_networks(task)
return states.DELETED
@METRICS.timer('AnsibleDeploy.prepare')
def prepare(self, task):
"""Prepare the deployment environment for this node."""
node = task.node
@ -477,6 +483,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
boot_opt = deploy_utils.build_agent_options(node)
task.driver.boot.prepare_ramdisk(task, boot_opt)
@METRICS.timer('AnsibleDeploy.clean_up')
def clean_up(self, task):
"""Clean up the deployment environment for this node."""
task.driver.boot.clean_up_ramdisk(task)
@ -504,6 +511,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
return _get_clean_steps(task.node, interface='deploy',
override_priorities=new_priorities)
@METRICS.timer('AnsibleDeploy.execute_clean_step')
def execute_clean_step(self, task, step):
"""Execute a clean step.
@ -541,6 +549,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
'on node %(node)s.'),
{'node': node.uuid, 'step': stepname})
@METRICS.timer('AnsibleDeploy.prepare_cleaning')
def prepare_cleaning(self, task):
"""Boot into the ramdisk to prepare for cleaning.
@ -579,6 +588,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
_run_playbook(playbook, extra_vars, key, tags=['wait'])
LOG.info(_LI('Node %s is ready for cleaning'), node.uuid)
@METRICS.timer('AnsibleDeploy.tear_down_cleaning')
def tear_down_cleaning(self, task):
"""Clean up the PXE and DHCP files after cleaning.
@ -595,6 +605,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
task.driver.boot.clean_up_ramdisk(task)
task.driver.network.remove_cleaning_network(task)
@METRICS.timer('AnsibleDeploy.continue_deploy')
def continue_deploy(self, task):
# NOTE(pas-ha) the lock should be already upgraded in heartbeat,
# just setting its purpose for better logging
@ -606,6 +617,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
self._ansible_deploy(task, node_address)
self.reboot_to_instance(task)
@METRICS.timer('AnsibleDeploy.reboot_to_instance')
def reboot_to_instance(self, task):
node = task.node
LOG.info(_LI('Ansible complete deploy on node %s'), node.uuid)
@ -615,6 +627,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
self.reboot_and_finish_deploy(task)
task.driver.boot.clean_up_ramdisk(task)
@METRICS.timer('AnsibleDeploy.reboot_and_finish_deploy')
def reboot_and_finish_deploy(self, task):
wait = CONF.ansible.post_deploy_get_power_state_retry_interval * 1000
attempts = CONF.ansible.post_deploy_get_power_state_retries + 1

View File

@ -0,0 +1,5 @@
---
features:
- |
ansible-deploy driver now supports standard ironic mechanism of
driver metrics collection.