Metrics for agent client
These are timing metrics for client calls to the agent. Change-Id: I397cb5902e5d8503d924fe6a6693d8a31dcd2dd6 Related-bug: #1526219
This commit is contained in:
parent
4669abbbcd
commit
93d2ba46ef
|
@ -12,6 +12,7 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from ironic_lib import metrics_utils
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import requests
|
import requests
|
||||||
|
@ -24,11 +25,14 @@ from ironic.conf import CONF
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
METRICS = metrics_utils.get_metrics_logger(__name__)
|
||||||
|
|
||||||
DEFAULT_IPA_PORTAL_PORT = 3260
|
DEFAULT_IPA_PORTAL_PORT = 3260
|
||||||
|
|
||||||
|
|
||||||
class AgentClient(object):
|
class AgentClient(object):
|
||||||
"""Client for interacting with nodes via a REST API."""
|
"""Client for interacting with nodes via a REST API."""
|
||||||
|
@METRICS.timer('AgentClient.__init__')
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
self.session.headers.update({'Content-Type': 'application/json'})
|
self.session.headers.update({'Content-Type': 'application/json'})
|
||||||
|
@ -49,6 +53,7 @@ class AgentClient(object):
|
||||||
'params': params,
|
'params': params,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@METRICS.timer('AgentClient._command')
|
||||||
def _command(self, node, method, params, wait=False):
|
def _command(self, node, method, params, wait=False):
|
||||||
url = self._get_command_url(node)
|
url = self._get_command_url(node)
|
||||||
body = self._get_command_body(method, params)
|
body = self._get_command_body(method, params)
|
||||||
|
@ -89,6 +94,7 @@ class AgentClient(object):
|
||||||
'code': response.status_code})
|
'code': response.status_code})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@METRICS.timer('AgentClient.get_commands_status')
|
||||||
def get_commands_status(self, node):
|
def get_commands_status(self, node):
|
||||||
url = self._get_command_url(node)
|
url = self._get_command_url(node)
|
||||||
LOG.debug('Fetching status of agent commands for node %s', node.uuid)
|
LOG.debug('Fetching status of agent commands for node %s', node.uuid)
|
||||||
|
@ -103,6 +109,7 @@ class AgentClient(object):
|
||||||
{'node': node.uuid, 'status': status})
|
{'node': node.uuid, 'status': status})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@METRICS.timer('AgentClient.prepare_image')
|
||||||
def prepare_image(self, node, image_info, wait=False):
|
def prepare_image(self, node, image_info, wait=False):
|
||||||
"""Call the `prepare_image` method on the node."""
|
"""Call the `prepare_image` method on the node."""
|
||||||
LOG.debug('Preparing image %(image)s on node %(node)s.',
|
LOG.debug('Preparing image %(image)s on node %(node)s.',
|
||||||
|
@ -120,6 +127,7 @@ class AgentClient(object):
|
||||||
params=params,
|
params=params,
|
||||||
wait=wait)
|
wait=wait)
|
||||||
|
|
||||||
|
@METRICS.timer('AgentClient.start_iscsi_target')
|
||||||
def start_iscsi_target(self, node, iqn,
|
def start_iscsi_target(self, node, iqn,
|
||||||
portal_port=DEFAULT_IPA_PORTAL_PORT,
|
portal_port=DEFAULT_IPA_PORTAL_PORT,
|
||||||
wipe_disk_metadata=False):
|
wipe_disk_metadata=False):
|
||||||
|
@ -186,6 +194,7 @@ class AgentClient(object):
|
||||||
# required, break from the loop returning the result
|
# required, break from the loop returning the result
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@METRICS.timer('AgentClient.install_bootloader')
|
||||||
def install_bootloader(self, node, root_uuid, efi_system_part_uuid=None):
|
def install_bootloader(self, node, root_uuid, efi_system_part_uuid=None):
|
||||||
"""Install a boot loader on the image."""
|
"""Install a boot loader on the image."""
|
||||||
params = {'root_uuid': root_uuid,
|
params = {'root_uuid': root_uuid,
|
||||||
|
@ -195,6 +204,7 @@ class AgentClient(object):
|
||||||
params=params,
|
params=params,
|
||||||
wait=True)
|
wait=True)
|
||||||
|
|
||||||
|
@METRICS.timer('AgentClient.get_clean_steps')
|
||||||
def get_clean_steps(self, node, ports):
|
def get_clean_steps(self, node, ports):
|
||||||
params = {
|
params = {
|
||||||
'node': node.as_dict(),
|
'node': node.as_dict(),
|
||||||
|
@ -205,6 +215,7 @@ class AgentClient(object):
|
||||||
params=params,
|
params=params,
|
||||||
wait=True)
|
wait=True)
|
||||||
|
|
||||||
|
@METRICS.timer('AgentClient.execute_clean_step')
|
||||||
def execute_clean_step(self, step, node, ports):
|
def execute_clean_step(self, step, node, ports):
|
||||||
params = {
|
params = {
|
||||||
'step': step,
|
'step': step,
|
||||||
|
@ -217,12 +228,14 @@ class AgentClient(object):
|
||||||
method='clean.execute_clean_step',
|
method='clean.execute_clean_step',
|
||||||
params=params)
|
params=params)
|
||||||
|
|
||||||
|
@METRICS.timer('AgentClient.power_off')
|
||||||
def power_off(self, node):
|
def power_off(self, node):
|
||||||
"""Soft powers off the bare metal node by shutting down ramdisk OS."""
|
"""Soft powers off the bare metal node by shutting down ramdisk OS."""
|
||||||
return self._command(node=node,
|
return self._command(node=node,
|
||||||
method='standby.power_off',
|
method='standby.power_off',
|
||||||
params={})
|
params={})
|
||||||
|
|
||||||
|
@METRICS.timer('AgentClient.sync')
|
||||||
def sync(self, node):
|
def sync(self, node):
|
||||||
"""Flush file system buffers forcing changed blocks to disk."""
|
"""Flush file system buffers forcing changed blocks to disk."""
|
||||||
return self._command(node=node,
|
return self._command(node=node,
|
||||||
|
@ -230,6 +243,7 @@ class AgentClient(object):
|
||||||
params={},
|
params={},
|
||||||
wait=True)
|
wait=True)
|
||||||
|
|
||||||
|
@METRICS.timer('AgentClient.collect_system_logs')
|
||||||
def collect_system_logs(self, node):
|
def collect_system_logs(self, node):
|
||||||
"""Collect and package diagnostic and support data from the ramdisk."""
|
"""Collect and package diagnostic and support data from the ramdisk."""
|
||||||
return self._command(node=node,
|
return self._command(node=node,
|
||||||
|
|
Loading…
Reference in New Issue