You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virt-who/SOURCES/virt-who-1.31.23-1-to-virt-...

162 lines
6.3 KiB

diff --git a/rel-eng/packages/virt-who b/rel-eng/packages/virt-who
index 2c0169e..30ea970 100644
--- a/rel-eng/packages/virt-who
+++ b/rel-eng/packages/virt-who
@@ -1 +1 @@
-1.31.23-1 ./
+1.31.23-2 ./
diff --git a/rel-eng/releasers.conf b/rel-eng/releasers.conf
index 272f0ab..b233d99 100644
--- a/rel-eng/releasers.conf
+++ b/rel-eng/releasers.conf
@@ -6,3 +6,11 @@ branches = main f35 f34
releaser = tito.release.CentosGitReleaser
branches = c9s
required_bz_flags = release+
+
+[rhel-9.1]
+releaser = tito.release.DistGitReleaser
+branches = rhel-9.1.0
+required_bz_flags = release+
+# Change this if you wish to use a placeholder "rebase" bug if none
+# are found in the changelog.
+placeholder_bz =
diff --git a/virt-who.spec b/virt-who.spec
index 87baecc..cc0d876 100644
--- a/virt-who.spec
+++ b/virt-who.spec
@@ -21,7 +21,7 @@
Name: virt-who
Version: 1.31.23
-Release: %{release_number}%{?dist}
+Release: 2%{?dist}
Summary: Agent for reporting virtual guest IDs to subscription-manager
@@ -165,6 +165,11 @@ fi
%changelog
+* Mon Nov 14 2022 William Poteat <wpoteat@redhat.com> 1.31.23-2
+- Added configuration for rhel-9.1 into releasers.conf (jhnidek@redhat.com)
+- 2127045: [1.31.23] Nutanix: Gather information about VMs correctly
+ (jhnidek@redhat.com)
+
* Thu Apr 21 2022 William Poteat <wpoteat@redhat.com> 1.31.23-1
- 2054504: Use usedforsecurity=False for md5() calls to make suds work on FIPS
enabled systems (oalbrigt@redhat.com)
diff --git a/virtwho/virt/ahv/ahv_constants.py b/virtwho/virt/ahv/ahv_constants.py
index 4c78a10..f6d0911 100644
--- a/virtwho/virt/ahv/ahv_constants.py
+++ b/virtwho/virt/ahv/ahv_constants.py
@@ -4,6 +4,7 @@ TASK_COMPLETE_MSG = ['SUCCEEDED', 'Succeeded']
DEFAULT_PORT = 9440
VERSION_2 = 'v2.0'
VERSION_3 = 'v3'
+NUM_OF_REQUESTED_VMS = 20
CMN_RST_CMD = {
'get_vm': {'url': '/vms/%s', 'method': 'get'},
diff --git a/virtwho/virt/ahv/ahv_interface.py b/virtwho/virt/ahv/ahv_interface.py
index 71f4d1f..ce30a00 100644
--- a/virtwho/virt/ahv/ahv_interface.py
+++ b/virtwho/virt/ahv/ahv_interface.py
@@ -514,14 +514,30 @@ class AhvInterface(object):
self._logger.info("Getting the list of available vms")
is_pc = True if version == 'v3' else False
vm_uuid_list = []
- length = 0
+ length = ahv_constants.NUM_OF_REQUESTED_VMS
+ initial_offset = 0
offset = 0
total_matches = 0
count = 1
current = 0
- (url, cmd_method) = self.get_diff_ver_url_and_method(
+ url, cmd_method = self.get_diff_ver_url_and_method(
cmd_key='list_vms', intf_version=version)
- res = self.make_rest_call(method=cmd_method, uri=url)
+
+ kwargs = {
+ "method": cmd_method,
+ "uri": url
+ }
+ if is_pc is True:
+ kwargs["json"] = {
+ 'length': length,
+ 'offset': initial_offset
+ }
+ res = self.make_rest_call(**kwargs)
+
+ if res is None:
+ self._logger.error("Unable to get list of VMs")
+ return vm_uuid_list
+
data = res.json()
if "metadata" in data:
if "total_matches" in data["metadata"] and "length" in data["metadata"]:
@@ -539,8 +555,8 @@ class AhvInterface(object):
if length < total_matches:
self._logger.debug(
'Number of vms %s returned from REST is less than the total'
- 'numberr:%s. Adjusting the offset and iterating over all'
- 'vms until evry vm is returned from the server.' % (length, total_matches)
+ 'number: %s. Adjusting the offset and iterating over all'
+ 'vms until all vms are returned from the server.' % (length, total_matches)
)
count = math.ceil(total_matches/float(length))
@@ -557,12 +573,16 @@ class AhvInterface(object):
"Cannot access the uuid for the vm %s. "
"vm object: %s" % (vm_entity['name'], vm_entity)
)
-
- body['offset'] = body['offset'] + length
- body_data = json.dumps(body, indent=4)
- self._logger.debug('next vm list call has this body: %s' % body)
- res = self.make_rest_call(method=cmd_method, uri=url, data=body_data)
- data = res.json()
+ if is_pc is True:
+ body['offset'] = body['offset'] + length
+ self._logger.debug('Next vm list call has this body: %s' % body)
+ kwargs["json"] = body
+ res = self.make_rest_call(**kwargs)
+ if res is not None:
+ data = res.json()
+ else:
+ self._logger.error(f"Unable to get list of VMs with offset: {body['offset']}")
+ data = {}
current += 1
self._logger.info("Total number of vms uuids found and saved for processing %s" % len(vm_uuid_list))
@@ -713,13 +733,17 @@ class AhvInterface(object):
"""
if 'resources' in vm_entity:
if 'host_reference' in vm_entity['resources']:
- return vm_entity['resources']['host_reference']['uuid']
+ vm_uuid = vm_entity['resources']['host_reference']['uuid']
+ self._logger.debug(f"Host UUID {vm_uuid} found for VM: {vm_entity['uuid']}")
+ return vm_uuid
else:
self._logger.warning(
- "Did not find any host information for vm:%s" % vm_entity['uuid']
+ "Did not find any host information for VM: %s" % vm_entity['uuid']
)
elif 'host_uuid' in vm_entity:
- return vm_entity['host_uuid']
+ vm_uuid = vm_entity['host_uuid']
+ self._logger.debug(f"Host UUID {vm_uuid} found for VM: {vm_entity['uuid']}")
+ return vm_uuid
else:
# Vm is off therefore no host is assigned to it.
self._logger.debug(
@@ -769,6 +793,7 @@ class AhvInterface(object):
self._logger.info("Processing hosts for each vm.")
if len(vm_uuids) > 0:
+ # TODO: use threads for gathering information about VMs
for vm_uuid in vm_uuids:
vm_entity = self.get_vm(vm_uuid)
if vm_entity: