scope for datamodel

This patch adds a scope to the datamodel, which only gets the VMs
 of the specified nodes, and no longer gets all VMs from nova.

Implements: blueprint scope-for-watcher-datamodel
Change-Id: Ic4659d1f18af181203439a8bf1b38805ff34c309
This commit is contained in:
licanwei
2019-03-02 14:53:21 +08:00
parent 2ea1f524e4
commit f337c67bfe
4 changed files with 145 additions and 14 deletions

View File

@@ -53,6 +53,9 @@ class NovaHelper(object):
# We need to pass an object with an 'id' attribute to make it work
return self.nova.hypervisors.get(utils.Struct(id=node_id))
def get_compute_node_by_name(self, node_name, servers=False):
return self.nova.hypervisors.search(node_name, servers)
def get_compute_node_by_hostname(self, node_hostname):
"""Get compute node by hostname"""
try: