Merge "Add hacking checks to watcher"

This commit is contained in:
Jenkins
2016-07-27 09:10:06 +00:00
committed by Gerrit Code Review
31 changed files with 398 additions and 75 deletions

View File

@@ -24,7 +24,7 @@ calculating its :ref:`global efficacy <efficacy_definition>`.
"""
import abc
import json
from oslo_serialization import jsonutils
import six
import voluptuous
@@ -81,4 +81,4 @@ class EfficacySpecification(object):
for indicator in self.indicators_specs]
def serialize_indicators_specs(self):
return json.dumps(self.get_indicators_specs_dicts())
return jsonutils.dumps(self.get_indicators_specs_dicts())

View File

@@ -13,9 +13,12 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log
import threading
from watcher._i18n import _LW
LOG = log.getLogger(__name__)
@@ -72,10 +75,10 @@ class Mapping(object):
# remove vm
self.mapping_vm.pop(vm_uuid)
else:
LOG.warning(
"trying to delete the virtual machine {0} but it was not "
"found on hypervisor {1}".format(
vm_uuid, node_uuid))
LOG.warning(_LW(
"trying to delete the virtual machine %(vm)s but it was "
"not found on hypervisor %(hyp)s"),
{'vm': vm_uuid, 'hyp': node_uuid})
finally:
self.lock.release()

View File

@@ -30,7 +30,7 @@ telemetries to measure thermal/workload status of server.
from oslo_log import log
from watcher._i18n import _, _LE, _LI
from watcher._i18n import _, _LI, _LW
from watcher.common import exception as wexc
from watcher.decision_engine.model import resource
from watcher.decision_engine.model import vm_state
@@ -159,7 +159,7 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy):
aggregate='avg')
# some hosts may not have outlet temp meters, remove from target
if outlet_temp is None:
LOG.warning(_LE("%s: no outlet temp data"), resource_id)
LOG.warning(_LW("%s: no outlet temp data"), resource_id)
continue
LOG.debug("%s: outlet temperature %f" % (resource_id, outlet_temp))
@@ -183,7 +183,7 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy):
# select the first active VM to migrate
vm = self.model.get_vm_from_id(vm_id)
if vm.state != vm_state.VMState.ACTIVE.value:
LOG.info(_LE("VM not active, skipped: %s"),
LOG.info(_LI("VM not active, skipped: %s"),
vm.uuid)
continue
return mig_src_hypervisor, vm
@@ -243,7 +243,7 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy):
return self.solution
if len(hosts_target) == 0:
LOG.warning(_LE("No hosts under outlet temp threshold found"))
LOG.warning(_LW("No hosts under outlet temp threshold found"))
return self.solution
# choose the server with highest outlet t
@@ -263,7 +263,7 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy):
if len(dest_servers) == 0:
# TODO(zhenzanz): maybe to warn that there's no resource
# for instance.
LOG.info(_LE("No proper target host could be found"))
LOG.info(_LI("No proper target host could be found"))
return self.solution
dest_servers = sorted(dest_servers, key=lambda x: (x["outlet_temp"]))

View File

@@ -179,7 +179,7 @@ class UniformAirflow(base.BaseStrategy):
try:
vm = self.model.get_vm_from_id(vm_id)
if vm.state != vm_state.VMState.ACTIVE.value:
LOG.info(_LE("VM not active; skipped: %s"),
LOG.info(_LI("VM not active; skipped: %s"),
vm.uuid)
continue
vms_tobe_migrate.append(vm)
@@ -255,7 +255,7 @@ class UniformAirflow(base.BaseStrategy):
aggregate='avg')
# some hosts may not have airflow meter, remove from target
if airflow is None:
LOG.warning(_LE("%s: no airflow data"), resource_id)
LOG.warning(_LW("%s: no airflow data"), resource_id)
continue
LOG.debug("%s: airflow %f" % (resource_id, airflow))

View File

@@ -170,7 +170,7 @@ class WorkloadStabilization(base.WorkloadStabilizationBaseStrategy):
:param vm_uuid: vm for which statistic is gathered.
:return: dict
"""
LOG.debug(_LI('get_vm_load started'))
LOG.debug('get_vm_load started')
vm_vcpus = self.model.get_resource_from_id(
resource.ResourceType.cpu_cores).get_capacity(
self.model.get_vm_from_id(vm_uuid))

View File

@@ -18,7 +18,7 @@ import collections
from oslo_log import log
from watcher._i18n import _LE, _LI
from watcher._i18n import _LI, _LW
from watcher.common import context
from watcher.decision_engine.loading import default
from watcher import objects
@@ -238,7 +238,7 @@ class Syncer(object):
invalid_ats = objects.AuditTemplate.list(self.ctx, filters=filters)
for at in invalid_ats:
LOG.warning(
_LE("Audit Template '%(audit_template)s' references a "
_LW("Audit Template '%(audit_template)s' references a "
"goal that does not exist"),
audit_template=at.uuid)
@@ -275,7 +275,7 @@ class Syncer(object):
strategy_loader = default.DefaultStrategyLoader()
implemented_strategies = strategy_loader.list_available()
for _, goal_cls in implemented_goals.items():
for goal_cls in implemented_goals.values():
goals_map[goal_cls.get_name()] = GoalMapping(
name=goal_cls.get_name(),
display_name=goal_cls.get_translatable_display_name(),
@@ -284,7 +284,7 @@ class Syncer(object):
for indicator in goal_cls.get_efficacy_specification(
).get_indicators_specifications()))
for _, strategy_cls in implemented_strategies.items():
for strategy_cls in implemented_strategies.values():
strategies_map[strategy_cls.get_name()] = StrategyMapping(
name=strategy_cls.get_name(),
goal_name=strategy_cls.get_goal_name(),