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