def api_get_command(self, request, cmd): with metrics_utils.get_metrics_logger(__name__).timer('get_command'): result = self.agent.get_command_result(cmd) wait = request.args.get('wait') if wait and wait.lower() == 'true': result.join() return jsonify(result)
def test_prepend_host_reverse_backend(self): CONF.set_override('prepend_host', True, group='metrics') CONF.set_override('prepend_host_reverse', True, group='metrics') metrics = metrics_utils.get_metrics_logger('foo', host="host.example.com") self.assertIsInstance(metrics, metricslib.NoopMetricLogger) self.assertEqual(metrics.get_metric_name("bar"), "com.example.host.foo.bar") CONF.clear_override('prepend_host', group='metrics') CONF.clear_override('prepend_host_reverse', group='metrics')
def api_run_command(self, request): body = request.get_json(force=True) if ('name' not in body or 'params' not in body or not isinstance(body['params'], dict)): raise http_exc.BadRequest('Missing or invalid name or params') with metrics_utils.get_metrics_logger(__name__).timer('run_command'): result = self.agent.execute_command(body['name'], **body['params']) wait = request.args.get('wait') if wait and wait.lower() == 'true': result.join() return jsonify(result)
def get_one(self, result_id, wait=None): """Get a command result by ID. :param result_id: the ID of the result to get. :param wait: if 'true', block until the command completes. :returns: a :class:`ironic_python_agent.api.controller.v1.command. CommandResult` object. """ with metrics_utils.get_metrics_logger(__name__).timer('get_one'): agent = pecan.request.agent result = agent.get_command_result(result_id) if wait and wait.lower() == 'true': result.join() return CommandResult.from_result(result)
def get_one(self, result_id, wait=None): """Get a command result by ID. :param result_id: the ID of the result to get. :param wait: if 'true', block until the command completes. :returns: a :class:`ironic_python_agent.api.controller.v1.command. CommandResult` object. """ with metrics_utils.get_metrics_logger(__name__).timer('get_one'): agent = pecan.request.agent result = agent.get_command_result(result_id) if wait and wait.lower() == 'true': result.join() return CommandResult.from_result(result)
def post(self, wait=None, command=None): """Post a command for the agent to run. :param wait: if 'true', block until the command completes. :param command: the command to execute. If None, an InvalidCommandError will be returned. :returns: a :class:`ironic_python_agent.api.controller.v1.command. CommandResult` object. """ with metrics_utils.get_metrics_logger(__name__).timer('post'): # the POST body is always the last arg, # so command must be a kwarg here if command is None: command = Command() agent = pecan.request.agent result = agent.execute_command(command.name, **command.params) if wait and wait.lower() == 'true': result.join() return result
def post(self, wait=None, command=None): """Post a command for the agent to run. :param wait: if 'true', block until the command completes. :param command: the command to execute. If None, an InvalidCommandError will be returned. :returns: a :class:`ironic_python_agent.api.controller.v1.command. CommandResult` object. """ with metrics_utils.get_metrics_logger(__name__).timer('post'): # the POST body is always the last arg, # so command must be a kwarg here if command is None: command = Command() agent = pecan.request.agent result = agent.execute_command(command.name, **command.params) if wait and wait.lower() == 'true': result.join() return result
from ironic.common.glance_service import service_utils from ironic.common.i18n import _, _LE, _LW from ironic.common import image_service as service from ironic.common import images from ironic.common import pxe_utils from ironic.common import states from ironic.common import utils from ironic.conf import CONF from ironic.drivers import base from ironic.drivers.modules import deploy_utils from ironic.drivers.modules import image_cache from ironic.drivers import utils as driver_utils LOG = logging.getLogger(__name__) METRICS = metrics_utils.get_metrics_logger(__name__) REQUIRED_PROPERTIES = { 'deploy_kernel': _("UUID (from Glance) of the deployment kernel. " "Required."), 'deploy_ramdisk': _("UUID (from Glance) of the ramdisk that is " "mounted at boot time. Required."), } COMMON_PROPERTIES = REQUIRED_PROPERTIES def _parse_driver_info(node): """Gets the driver specific Node deployment info. This method validates whether the 'driver_info' property of the supplied node contains the required information for this driver to
from ironic.drivers.modules.irmc import common as irmc_common from ironic.drivers.modules.irmc import management as irmc_management from ironic.drivers.modules import pxe scci = importutils.try_import('scciclient.irmc.scci') viom = importutils.try_import('scciclient.irmc.viom.client') try: if CONF.debug: scci.DEBUG = True except Exception: pass LOG = logging.getLogger(__name__) METRICS = metrics_utils.get_metrics_logger(__name__) REQUIRED_PROPERTIES = { 'irmc_deploy_iso': _("Deployment ISO image file name. " "Required."), } OPTIONAL_PROPERTIES = { 'irmc_pci_physical_ids': _("Physical IDs of PCI cards. A dictionary of pairs of resource UUID " "and its physical ID like '<UUID>:<Physical ID>,...'. The resources " "are Ports and Volume connectors. The Physical ID consists of card " "type, slot No, and port No. The format is " "{LAN|FC|CNA}<slot-No>-<Port-No>. This parameter is necessary for " "booting a node from a remote volume. Optional."), 'irmc_storage_network_size':
def api_list_commands(self, request): with metrics_utils.get_metrics_logger(__name__).timer('list_commands'): results = self.agent.list_command_results() return jsonify({'commands': results})
def get_all(self): """Get current status of the running agent.""" with metrics_utils.get_metrics_logger(__name__).timer('get_all'): agent = pecan.request.agent status = agent.get_status() return AgentStatus.from_agent_status(status)
def get(self): # NOTE: The reason why convert() it's being called for every # request is because we need to get the host url from # the request object to make the links. with metrics_utils.get_metrics_logger(__name__).timer('get'): return Root.convert()
def api_status(self, request): with metrics_utils.get_metrics_logger(__name__).timer('get_status'): status = self.agent.get_status() return jsonify(status)
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import types import mock from oslo_utils import reflection from ironic_lib import metrics as metricslib from ironic_lib import metrics_utils from ironic_lib.tests import base METRICS = metrics_utils.get_metrics_logger(prefix='foo', backend='noop') @METRICS.timer('testing1') def timer_check(run, timer=None): pass @METRICS.counter('testing2') def counter_check(run, counter=None): pass @METRICS.gauge('testing2') def gauge_check(run, gauge=None): pass
def get(self): # NOTE: The reason why convert() it's being called for every # request is because we need to get the host url from # the request object to make the links. with metrics_utils.get_metrics_logger(__name__).timer('get'): return Root.convert()
def get_all(self): """Get all command results.""" with metrics_utils.get_metrics_logger(__name__).timer('get_all'): agent = pecan.request.agent results = agent.list_command_results() return CommandResultList.from_results(results)
def get_all(self): """Get all command results.""" with metrics_utils.get_metrics_logger(__name__).timer('get_all'): agent = pecan.request.agent results = agent.list_command_results() return CommandResultList.from_results(results)
def get_all(self): """Get current status of the running agent.""" with metrics_utils.get_metrics_logger(__name__).timer('get_all'): agent = pecan.request.agent status = agent.get_status() return AgentStatus.from_agent_status(status)
def test_prepend_other_delim(self): metrics = metrics_utils.get_metrics_logger('foo', delimiter='*') self.assertIsInstance(metrics, metricslib.NoopMetricLogger) self.assertEqual(metrics.get_metric_name("bar"), "foo*bar")
def test_default_prefix(self): metrics = metrics_utils.get_metrics_logger() self.assertIsInstance(metrics, metricslib.NoopMetricLogger) self.assertEqual(metrics.get_metric_name("bar"), "bar")
def test_statsd_backend(self): CONF.set_override('backend', 'statsd', group='metrics') metrics = metrics_utils.get_metrics_logger('foo') self.assertIsInstance(metrics, metrics_statsd.StatsdMetricLogger) CONF.clear_override('backend', group='metrics')
def test_default_backend(self): metrics = metrics_utils.get_metrics_logger('foo') self.assertIsInstance(metrics, metricslib.NoopMetricLogger)