From 47576e780fc41f4e727e88b0fe14cade09b0a927 Mon Sep 17 00:00:00 2001 From: Xinyuan Huang Date: Tue, 30 Jun 2015 01:19:38 +0800 Subject: [PATCH] Replacing '_' with '_LW' for log warnings To comply with new oslo.i18n guidlines. Change-Id: I7cabff37847690f446eb2f0b9b80edd9efc2ccab --- nova_solverscheduler/scheduler/solver_scheduler.py | 3 +-- .../scheduler/solvers/constraints/aggregate_disk.py | 6 +++--- .../scheduler/solvers/constraints/aggregate_ram.py | 6 +++--- .../scheduler/solvers/constraints/aggregate_vcpu.py | 6 +++--- .../scheduler/solvers/constraints/disk_constraint.py | 12 ++++++------ .../solvers/constraints/io_ops_constraint.py | 5 ++--- .../solvers/constraints/num_instances_constraint.py | 5 ++--- .../constraints/pci_passthrough_constraint.py | 8 ++++---- .../scheduler/solvers/constraints/ram_constraint.py | 10 +++++----- .../scheduler/solvers/constraints/vcpu_constraint.py | 10 +++++----- .../scheduler/solvers/costs/ram_cost.py | 4 ++-- .../scheduler/solvers/pulp_solver.py | 6 +++--- 12 files changed, 39 insertions(+), 42 deletions(-) diff --git a/nova_solverscheduler/scheduler/solver_scheduler.py b/nova_solverscheduler/scheduler/solver_scheduler.py index 2b80f3e..47a4d94 100644 --- a/nova_solverscheduler/scheduler/solver_scheduler.py +++ b/nova_solverscheduler/scheduler/solver_scheduler.py @@ -24,7 +24,6 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import importutils -from nova.i18n import _ from nova.scheduler import filter_scheduler from nova.scheduler import weights @@ -105,7 +104,7 @@ class ConstraintSolverScheduler(filter_scheduler.FilterScheduler): list_hosts = list(hosts) host_instance_combinations = self.hosts_solver.solve( list_hosts, filter_properties) - LOG.debug(_("solver results: %(host_instance_tuples_list)s") % + LOG.debug("solver results: %(host_instance_tuples_list)s", {"host_instance_tuples_list": host_instance_combinations}) # NOTE(Yathi): Not using weights in solver scheduler, # but creating a list of WeighedHosts with a default weight of 1 diff --git a/nova_solverscheduler/scheduler/solvers/constraints/aggregate_disk.py b/nova_solverscheduler/scheduler/solvers/constraints/aggregate_disk.py index 5b34b1d..fa6293f 100644 --- a/nova_solverscheduler/scheduler/solvers/constraints/aggregate_disk.py +++ b/nova_solverscheduler/scheduler/solvers/constraints/aggregate_disk.py @@ -17,7 +17,7 @@ from oslo_config import cfg from oslo_log import log as logging from nova import db -from nova.i18n import _ +from nova.i18n import _LW from nova_solverscheduler.scheduler.solvers.constraints import disk_constraint CONF = cfg.CONF @@ -47,14 +47,14 @@ class AggregateDiskConstraint(disk_constraint.DiskConstraint): return CONF.disk_allocation_ratio if num_values > 1: - LOG.warn(_("%(num_values)d ratio values found, " + LOG.warn(_LW("%(num_values)d ratio values found, " "of which the minimum value will be used."), {'num_values': num_values}) try: ratio = min(map(float, aggregate_vals)) except ValueError as e: - LOG.warning(_("Could not decode disk_allocation_ratio: '%s'"), e) + LOG.warning(_LW("Could not decode disk_allocation_ratio: '%s'"), e) ratio = CONF.disk_allocation_ratio return ratio diff --git a/nova_solverscheduler/scheduler/solvers/constraints/aggregate_ram.py b/nova_solverscheduler/scheduler/solvers/constraints/aggregate_ram.py index 9c95e7e..563c9c7 100644 --- a/nova_solverscheduler/scheduler/solvers/constraints/aggregate_ram.py +++ b/nova_solverscheduler/scheduler/solvers/constraints/aggregate_ram.py @@ -17,7 +17,7 @@ from oslo_config import cfg from oslo_log import log as logging from nova import db -from nova.i18n import _ +from nova.i18n import _LW from nova_solverscheduler.scheduler.solvers.constraints import ram_constraint CONF = cfg.CONF @@ -46,14 +46,14 @@ class AggregateRamConstraint(ram_constraint.RamConstraint): return CONF.ram_allocation_ratio if num_values > 1: - LOG.warn(_("%(num_values)d ratio values found, " + LOG.warn(_LW("%(num_values)d ratio values found, " "of which the minimum value will be used."), {'num_values': num_values}) try: ratio = min(map(float, aggregate_vals)) except ValueError as e: - LOG.warning(_("Could not decode ram_allocation_ratio: '%s'"), e) + LOG.warning(_LW("Could not decode ram_allocation_ratio: '%s'"), e) ratio = CONF.ram_allocation_ratio return ratio diff --git a/nova_solverscheduler/scheduler/solvers/constraints/aggregate_vcpu.py b/nova_solverscheduler/scheduler/solvers/constraints/aggregate_vcpu.py index 492ca65..0eb9230 100644 --- a/nova_solverscheduler/scheduler/solvers/constraints/aggregate_vcpu.py +++ b/nova_solverscheduler/scheduler/solvers/constraints/aggregate_vcpu.py @@ -17,7 +17,7 @@ from oslo_config import cfg from oslo_log import log as logging from nova import db -from nova.i18n import _ +from nova.i18n import _LW from nova_solverscheduler.scheduler.solvers.constraints import vcpu_constraint CONF = cfg.CONF @@ -46,14 +46,14 @@ class AggregateVcpuConstraint(vcpu_constraint.VcpuConstraint): return CONF.cpu_allocation_ratio if num_values > 1: - LOG.warning(_("%(num_values)d ratio values found, " + LOG.warning(_LW("%(num_values)d ratio values found, " "of which the minimum value will be used."), {'num_values': num_values}) try: ratio = min(map(float, aggregate_vals)) except ValueError as e: - LOG.warning(_("Could not decode cpu_allocation_ratio: '%s'"), e) + LOG.warning(_LW("Could not decode cpu_allocation_ratio: '%s'"), e) ratio = CONF.cpu_allocation_ratio return ratio diff --git a/nova_solverscheduler/scheduler/solvers/constraints/disk_constraint.py b/nova_solverscheduler/scheduler/solvers/constraints/disk_constraint.py index a1469b7..44ff030 100644 --- a/nova_solverscheduler/scheduler/solvers/constraints/disk_constraint.py +++ b/nova_solverscheduler/scheduler/solvers/constraints/disk_constraint.py @@ -17,7 +17,7 @@ from oslo_config import cfg from oslo_log import log as logging -from nova.i18n import _ +from nova.i18n import _LW from nova_solverscheduler.scheduler.solvers import constraints CONF = cfg.CONF @@ -46,11 +46,11 @@ class DiskConstraint(constraints.BaseLinearConstraint): instance_type.get('swap', 0)) for inst_type_key in ['root_gb', 'ephemeral_gb', 'swap']: if inst_type_key not in instance_type: - LOG.warn(_("Disk information of requested instances\' %s " - "is incomplete, use 0 as the requested size.") % + LOG.warn(_LW("Disk information of requested instances\' %s " + "is incomplete, use 0 as the requested size."), inst_type_key) if requested_disk <= 0: - LOG.warn(_("DiskConstraint is skipped because requested " + LOG.warn(_LW("DiskConstraint is skipped because requested " "instance disk size is 0 or invalid.")) return constraint_matrix @@ -71,8 +71,8 @@ class DiskConstraint(constraints.BaseLinearConstraint): [True for j in xrange(acceptable_num_instances)] + [False for j in xrange(inacceptable_num)]) - LOG.debug(_("%(host)s can accept %(num)s requested instances " - "according to DiskConstraint."), + LOG.debug("%(host)s can accept %(num)s requested instances " + "according to DiskConstraint.", {'host': hosts[i], 'num': acceptable_num_instances}) diff --git a/nova_solverscheduler/scheduler/solvers/constraints/io_ops_constraint.py b/nova_solverscheduler/scheduler/solvers/constraints/io_ops_constraint.py index a8d8e4a..534e143 100644 --- a/nova_solverscheduler/scheduler/solvers/constraints/io_ops_constraint.py +++ b/nova_solverscheduler/scheduler/solvers/constraints/io_ops_constraint.py @@ -16,7 +16,6 @@ from oslo_config import cfg from oslo_log import log as logging -from nova.i18n import _ from nova_solverscheduler.scheduler.solvers import constraints LOG = logging.getLogger(__name__) @@ -51,8 +50,8 @@ class IoOpsConstraint(constraints.BaseLinearConstraint): [True for j in xrange(acceptable_num_instances)] + [False for j in xrange(inacceptable_num)]) - LOG.debug(_("%(host)s can accept %(num)s requested instances " - "according to IoOpsConstraint."), + LOG.debug("%(host)s can accept %(num)s requested instances " + "according to IoOpsConstraint.", {'host': hosts[i], 'num': acceptable_num_instances}) diff --git a/nova_solverscheduler/scheduler/solvers/constraints/num_instances_constraint.py b/nova_solverscheduler/scheduler/solvers/constraints/num_instances_constraint.py index afdb85e..9230fd9 100644 --- a/nova_solverscheduler/scheduler/solvers/constraints/num_instances_constraint.py +++ b/nova_solverscheduler/scheduler/solvers/constraints/num_instances_constraint.py @@ -16,7 +16,6 @@ from oslo_config import cfg from oslo_log import log as logging -from nova.i18n import _ from nova_solverscheduler.scheduler.solvers import constraints CONF = cfg.CONF @@ -51,8 +50,8 @@ class NumInstancesConstraint(constraints.BaseLinearConstraint): [True for j in xrange(acceptable_num_instances)] + [False for j in xrange(inacceptable_num)]) - LOG.debug(_("%(host)s can accept %(num)s requested instances " - "according to NumInstancesConstraint."), + LOG.debug("%(host)s can accept %(num)s requested instances " + "according to NumInstancesConstraint.", {'host': hosts[i], 'num': acceptable_num_instances}) diff --git a/nova_solverscheduler/scheduler/solvers/constraints/pci_passthrough_constraint.py b/nova_solverscheduler/scheduler/solvers/constraints/pci_passthrough_constraint.py index 64c181c..39b5470 100644 --- a/nova_solverscheduler/scheduler/solvers/constraints/pci_passthrough_constraint.py +++ b/nova_solverscheduler/scheduler/solvers/constraints/pci_passthrough_constraint.py @@ -17,7 +17,7 @@ import copy from oslo_log import log as logging -from nova.i18n import _ +from nova.i18n import _LW from nova_solverscheduler.scheduler.solvers import constraints LOG = logging.getLogger(__name__) @@ -57,7 +57,7 @@ class PciPassthroughConstraint(constraints.BaseLinearConstraint): pci_requests = filter_properties.get('pci_requests') if not pci_requests: - LOG.warn(_("PciPassthroughConstraint check is skipped because " + LOG.warn(_LW("PciPassthroughConstraint check is skipped because " "requested instance PCI requests is unavailable.")) return constraint_matrix @@ -73,8 +73,8 @@ class PciPassthroughConstraint(constraints.BaseLinearConstraint): [True for j in xrange(acceptable_num_instances)] + [False for j in xrange(inacceptable_num)]) - LOG.debug(_("%(host)s can accept %(num)s requested instances " - "according to PciPassthroughConstraint."), + LOG.debug("%(host)s can accept %(num)s requested instances " + "according to PciPassthroughConstraint.", {'host': hosts[i], 'num': acceptable_num_instances}) diff --git a/nova_solverscheduler/scheduler/solvers/constraints/ram_constraint.py b/nova_solverscheduler/scheduler/solvers/constraints/ram_constraint.py index 17bc003..c491ad5 100644 --- a/nova_solverscheduler/scheduler/solvers/constraints/ram_constraint.py +++ b/nova_solverscheduler/scheduler/solvers/constraints/ram_constraint.py @@ -17,7 +17,7 @@ from oslo_config import cfg from oslo_log import log as logging -from nova.i18n import _ +from nova.i18n import _LW from nova_solverscheduler.scheduler.solvers import constraints CONF = cfg.CONF @@ -43,10 +43,10 @@ class RamConstraint(constraints.BaseLinearConstraint): instance_type = filter_properties.get('instance_type') or {} requested_ram = instance_type.get('memory_mb', 0) if 'memory_mb' not in instance_type: - LOG.warn(_("No information about requested instances\' RAM size " + LOG.warn(_LW("No information about requested instances\' RAM size " "was found, default value (0) is used.")) if requested_ram <= 0: - LOG.warn(_("RamConstraint is skipped because requested " + LOG.warn(_LW("RamConstraint is skipped because requested " "instance RAM size is 0 or invalid.")) return constraint_matrix @@ -67,8 +67,8 @@ class RamConstraint(constraints.BaseLinearConstraint): [True for j in xrange(acceptable_num_instances)] + [False for j in xrange(inacceptable_num)]) - LOG.debug(_("%(host)s can accept %(num)s requested instances " - "according to RamConstraint."), + LOG.debug("%(host)s can accept %(num)s requested instances " + "according to RamConstraint.", {'host': hosts[i], 'num': acceptable_num_instances}) diff --git a/nova_solverscheduler/scheduler/solvers/constraints/vcpu_constraint.py b/nova_solverscheduler/scheduler/solvers/constraints/vcpu_constraint.py index fa50500..76e12f2 100644 --- a/nova_solverscheduler/scheduler/solvers/constraints/vcpu_constraint.py +++ b/nova_solverscheduler/scheduler/solvers/constraints/vcpu_constraint.py @@ -16,7 +16,7 @@ from oslo_config import cfg from oslo_log import log as logging -from nova.i18n import _ +from nova.i18n import _LW from nova_solverscheduler.scheduler.solvers import constraints CONF = cfg.CONF @@ -45,7 +45,7 @@ class VcpuConstraint(constraints.BaseLinearConstraint): else: instance_vcpus = instance_type['vcpus'] if instance_vcpus <= 0: - LOG.warn(_("VcpuConstraint is skipped because requested " + LOG.warn(_LW("VcpuConstraint is skipped because requested " "instance vCPU number is 0 or invalid.")) return constraint_matrix @@ -54,7 +54,7 @@ class VcpuConstraint(constraints.BaseLinearConstraint): hosts[i], filter_properties) # get available vcpus if not hosts[i].vcpus_total: - LOG.warn(_("vCPUs of %(host)s not set; assuming CPU " + LOG.warn(_LW("vCPUs of %(host)s not set; assuming CPU " "collection broken."), {'host': hosts[i]}) continue else: @@ -68,8 +68,8 @@ class VcpuConstraint(constraints.BaseLinearConstraint): [True for j in xrange(acceptable_num_instances)] + [False for j in xrange(inacceptable_num)]) - LOG.debug(_("%(host)s can accept %(num)s requested instances " - "according to VcpuConstraint."), + LOG.debug("%(host)s can accept %(num)s requested instances " + "according to VcpuConstraint.", {'host': hosts[i], 'num': acceptable_num_instances}) diff --git a/nova_solverscheduler/scheduler/solvers/costs/ram_cost.py b/nova_solverscheduler/scheduler/solvers/costs/ram_cost.py index d92889e..d17b7d2 100644 --- a/nova_solverscheduler/scheduler/solvers/costs/ram_cost.py +++ b/nova_solverscheduler/scheduler/solvers/costs/ram_cost.py @@ -24,7 +24,7 @@ number and the cost has the opposite effect of the default. from oslo_config import cfg from oslo_log import log as logging -from nova.i18n import _ +from nova.i18n import _LW from nova_solverscheduler.scheduler.solvers import costs as solver_costs from nova_solverscheduler.scheduler.solvers.costs import utils @@ -53,7 +53,7 @@ class RamCost(solver_costs.BaseLinearCost): instance_type = filter_properties.get('instance_type') or {} requested_ram = instance_type.get('memory_mb', 0) if 'memory_mb' not in instance_type: - LOG.warn(_("No information about requested instances\' RAM size " + LOG.warn(_LW("No information about requested instances\' RAM size " "was found, default value (0) is used.")) extended_cost_matrix = [[0 for j in xrange(num_instances + 1)] diff --git a/nova_solverscheduler/scheduler/solvers/pulp_solver.py b/nova_solverscheduler/scheduler/solvers/pulp_solver.py index d1b1537..9876af2 100644 --- a/nova_solverscheduler/scheduler/solvers/pulp_solver.py +++ b/nova_solverscheduler/scheduler/solvers/pulp_solver.py @@ -20,7 +20,7 @@ from pulp import solvers as pulp_solver_classes from oslo_config import cfg from oslo_log import log as logging -from nova.i18n import _ +from nova.i18n import _LW from nova_solverscheduler.scheduler import solvers as scheduler_solver pulp_solver_opts = [ @@ -213,8 +213,8 @@ class PulpSolver(scheduler_solver.BaseHostSolver): host_instance_combinations.append( (host_key_map[host_key], instances_iter.next())) else: - LOG.warn(_("Pulp solver didnot find optimal solution! reason: %s") - % pulp.LpStatus[prob.status]) + LOG.warn(_LW("Pulp solver didnot find optimal solution! " + "reason: %s"), pulp.LpStatus[prob.status]) host_instance_combinations = [] return host_instance_combinations