Fixed missing attribute in the data model
Querying compute.node.* with Ceilometer requires some additional information in the cluster data model in order to build the resource_id. This patchset add the attribute hostname and change the query. Change-Id: Ifcefcd70a6d0f5967ab4f638ce077e38ef214f64 Closes-Bug: #1521559
This commit is contained in:
@@ -15,11 +15,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
class NamedElement(object):
|
||||
class ComputeResource(object):
|
||||
|
||||
def __init__(self):
|
||||
self._uuid = ""
|
||||
self._human_id = ""
|
||||
self._hostname = ""
|
||||
|
||||
@property
|
||||
def uuid(self):
|
||||
@@ -29,6 +30,14 @@ class NamedElement(object):
|
||||
def uuid(self, u):
|
||||
self._uuid = u
|
||||
|
||||
@property
|
||||
def hostname(self):
|
||||
return self._hostname
|
||||
|
||||
@hostname.setter
|
||||
def hostname(self, h):
|
||||
self._hostname = h
|
||||
|
||||
@property
|
||||
def human_id(self):
|
||||
return self._human_id
|
||||
@@ -13,13 +13,15 @@
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from watcher.decision_engine.model.compute_resource import ComputeResource
|
||||
from watcher.decision_engine.model.hypervisor_state import HypervisorState
|
||||
from watcher.decision_engine.model.named_element import NamedElement
|
||||
from watcher.decision_engine.model.power_state import PowerState
|
||||
|
||||
|
||||
class Hypervisor(NamedElement):
|
||||
class Hypervisor(ComputeResource):
|
||||
def __init__(self):
|
||||
super(Hypervisor, self).__init__()
|
||||
self._state = HypervisorState.ONLINE
|
||||
self._status = HypervisorState.ENABLED
|
||||
self._power_state = PowerState.g0
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from watcher.decision_engine.model.named_element import NamedElement
|
||||
from watcher.decision_engine.model.compute_resource import ComputeResource
|
||||
from watcher.decision_engine.model.vm_state import VMState
|
||||
|
||||
|
||||
class VM(NamedElement):
|
||||
class VM(ComputeResource):
|
||||
def __init__(self):
|
||||
super(VM, self).__init__()
|
||||
self._state = VMState.ACTIVE.value
|
||||
|
||||
@property
|
||||
|
||||
@@ -257,8 +257,10 @@ class BasicConsolidation(BaseStrategy):
|
||||
:param model:
|
||||
:return:
|
||||
"""
|
||||
resource_id = "{0}_{1}".format(hypervisor.uuid,
|
||||
hypervisor.hostname)
|
||||
cpu_avg_vm = self.ceilometer. \
|
||||
statistic_aggregation(resource_id=hypervisor.uuid,
|
||||
statistic_aggregation(resource_id=resource_id,
|
||||
meter_name='compute.node.cpu.percent',
|
||||
period="7200",
|
||||
aggregate='avg'
|
||||
@@ -266,7 +268,7 @@ class BasicConsolidation(BaseStrategy):
|
||||
if cpu_avg_vm is None:
|
||||
LOG.error(
|
||||
"No values returned for {0} compute.node.cpu.percent".format(
|
||||
hypervisor.uuid))
|
||||
resource_id))
|
||||
cpu_avg_vm = 100
|
||||
|
||||
cpu_capacity = model.get_resource_from_id(
|
||||
|
||||
Reference in New Issue
Block a user