Skip to content

Commit

Permalink
Merge pull request #23 from nvgoldin/match_cluster_cpu
Browse files Browse the repository at this point in the history
lago ovirt start: Match cluster CPU compatibility
  • Loading branch information
ovirt-infra authored Aug 29, 2017
2 parents efbc57d + 620cf6f commit 8111ca3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion automation/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ die() {
}

setup_tox() {
pip install --upgrade pip setuptools virtualenv tox || return 1
for package in "pip" "setuptools" "virtualenv" "tox" ; do
pip install --upgrade "$package" || return 1
done
}

build_docs() {
Expand Down
2 changes: 2 additions & 0 deletions ovirtlago/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ def do_ovirt_start(prefix, with_vms, vms_timeout, **kwargs):
prefix.virt_env.assert_engine_alive(timeout=3 * 60)
with LogTask('Waiting for vdsmd status'):
prefix.virt_env.assert_vdsm_alive(timeout=3 * 60)
with LogTask('Updating Clusters CPU'):
prefix.virt_env.update_clusters_cpu()
with LogTask('Activating Engine Hosts'):
prefix.virt_env.engine_vm().start_all_hosts(timeout=5 * 60)
if with_vms:
Expand Down
36 changes: 36 additions & 0 deletions ovirtlago/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,42 @@ def get_ovirt_cpu_family(self, host=None):
)
return cpu_map[host.cpu_vendor][host.cpu_model]

@require_sdk(version='4')
def update_clusters_cpu(self, timeout=2 * 60):
cpu_family = self.get_ovirt_cpu_family()
api = self.engine_vm().get_api_v4(check=True)
clusters_service = api.system_service().clusters_service()
clusters = clusters_service.list()

if clusters is None:
LOGGER.debug('no clusters found: skipping')
return

for cluster in clusters:
if cluster.cpu.type == cpu_family:
continue
LOGGER.debug(
('found CPU cluster mismatch, current: {0}, required: '
'{1}').format(cluster.cpu.type, cpu_family)
)

cluster_service = clusters_service.cluster_service(cluster.id)
cluster_service.update(
otypes.Cluster(cpu=otypes.Cpu(type=cpu_family))
)

def _assert_cluster_cpu(cluster):
cluster = clusters_service.cluster_service(cluster.id).get()
return cluster.cpu.type == cpu_family

testlib.assert_true_within(
partial(_assert_cluster_cpu, cluster), timeout=timeout
)
LOGGER.debug(
('successfuly changed cluster id {0} to cpu family: '
'{1}').format(cluster.id, cpu_family)
)

def assert_vdsm_alive(self, timeout=2 * 60):
"""
Assert service 'vdsmd' reports running on all vdsm hosts
Expand Down

0 comments on commit 8111ca3

Please sign in to comment.