import virt-who-1.31.23-3.el9_1

i9c changed/i9c/virt-who-1.31.23-3.el9_1
MSVSphere Packaging Team 2 years ago
parent 3b52b81a1c
commit 0708eb6af3

@ -0,0 +1,161 @@
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:

@ -0,0 +1,169 @@
diff --git a/rel-eng/packages/virt-who b/rel-eng/packages/virt-who
index 30ea970..e143cea 100644
--- a/rel-eng/packages/virt-who
+++ b/rel-eng/packages/virt-who
@@ -1 +1 @@
-1.31.23-2 ./
+1.31.23-3 ./
diff --git a/virt-who.spec b/virt-who.spec
index cc0d876..984fae9 100644
--- a/virt-who.spec
+++ b/virt-who.spec
@@ -21,7 +21,7 @@
Name: virt-who
Version: 1.31.23
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: Agent for reporting virtual guest IDs to subscription-manager
@@ -165,6 +165,12 @@ fi
%changelog
+* Tue Feb 07 2023 Jiri Hnidek <jhnidek@redhat.com> 1.31.23-3
+-
+
+* Tue Feb 07 2023 Jiri Hnidek <jhnidek@redhat.com> 1.31.24-3
+- 2165499: [1.31.23] Migrate virt-who.conf, when necessary (jhnidek@redhat.com)
+
* 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
diff --git a/virtwho/migrate/migrateconfiguration.py b/virtwho/migrate/migrateconfiguration.py
index b61039a..0b2c388 100644
--- a/virtwho/migrate/migrateconfiguration.py
+++ b/virtwho/migrate/migrateconfiguration.py
@@ -1,23 +1,27 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
-"""
-For moving variables from system environment to general config file
-
-Copyright (C) 2020 William Poteat <wpoteat@redhat.com>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+# For moving variables from system environment to general config file
+#
+# Copyright (C) 2020 William Poteat <wpoteat@redhat.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+"""
+This module is used for merging environment variables (typically defined in
+/etc/sysconfig/virt-who) into generic configuration file (typically /etc/virt-who.conf)
"""
import os
@@ -30,16 +34,22 @@ def main():
migrate_env_to_config()
-def migrate_env_to_config(sysconfig_filename=None, general_config_filename=None):
+def migrate_env_to_config(sysconfig_filename: str = None, general_config_filename: str = None) -> None:
+ """
+ Try to merge sysconfig file (typically /etc/sysconfig/virt-who) with generic
+ virt-who configuration file (typically /etc/virt-who.conf). When sysconfig file
+ is not defined, then it tries to read know environment variables: 'VIRTWHO_INTERVAL',
+ 'VIRTWHO_DEBUG' and 'VIRTWHO_ONE_SHOT'
+ @param sysconfig_filename: path to sysconfig file
+ @param general_config_filename: path to generic virt-who configuration file
+ @return: None
+ """
+
if not sysconfig_filename:
sysconfig_filename = SYSCONFIG_FILENAME
if not general_config_filename:
general_config_filename = GENERAL_CONFIG_FILENAME
- interval = None
- debug = None
- one_shot = None
-
# read know env variables
interval = os.environ.get('VIRTWHO_INTERVAL', None)
debug = os.environ.get('VIRTWHO_DEBUG', None)
@@ -65,6 +75,11 @@ def migrate_env_to_config(sysconfig_filename=None, general_config_filename=None)
if 'VIRTWHO_ONE_SHOT' in env_vars:
one_shot = env_vars.pop('VIRTWHO_ONE_SHOT')
+ # When there is no environment variable or anything defined in sysconfig file, then
+ # there is also no need to merge anything to virt-who.conf file, and we can end here
+ if interval is None and debug is None and one_shot is None and len(env_vars) == 0:
+ return
+
# read ini file at /etc/virt-who.conf
lines = []
if os.path.exists(general_config_filename):
@@ -98,18 +113,29 @@ def migrate_env_to_config(sysconfig_filename=None, general_config_filename=None)
output.append('\n')
output.append('[global]\n')
add_global(output, interval, debug, one_shot)
+
if not has_sys_env:
if len(env_vars) > 0:
if len(output) != 0:
output.append('\n')
output.append('[system_environment]\n')
add_system_environment(output, env_vars)
+
# write /etc/virt-who.conf
with open(general_config_filename, "w") as conf:
conf.writelines(output)
-def add_global(output, interval, debug, one_shot):
+def add_global(output: list, interval: str, debug: str, one_shot: str) -> None:
+ """
+ Add some options to [global] section with comment that this
+ option was migrated
+ @param output: list of lines to be added to final configuration file
+ @param interval: value of interval option
+ @param debug: value of debug option
+ @param one_shot: value of one_shot option
+ @return: None
+ """
if interval:
output.append("#migrated\ninterval=%s\n" % interval.strip())
if debug:
@@ -118,7 +144,15 @@ def add_global(output, interval, debug, one_shot):
output.append("#migrated\noneshot=%s\n" % ('True' if one_shot.strip() == '1' else 'False'))
-def add_system_environment(output, env_vars={}):
+def add_system_environment(output: list, env_vars: dict = None) -> None:
+ """
+ Add other environment variables defined in sysconfig file to [system_environment] section
+ @param output: list of lines to be added to final configuration file
+ @param env_vars: dictionary with other environment variables defined in sysconfig file
+ @return: None
+ """
+ if env_vars is None:
+ return
for key, value in env_vars.items():
if key:
output.append("#migrated\n%s=%s\n" % (key, value.strip()))

@ -21,7 +21,7 @@
Name: virt-who Name: virt-who
Version: 1.31.23 Version: 1.31.23
Release: %{release_number}%{?dist} Release: 3%{?dist}
Summary: Agent for reporting virtual guest IDs to subscription-manager Summary: Agent for reporting virtual guest IDs to subscription-manager
@ -30,6 +30,8 @@ Group: System Environment/Base
License: GPLv2+ and LGPLv3+ License: GPLv2+ and LGPLv3+
URL: https://github.com/candlepin/virt-who URL: https://github.com/candlepin/virt-who
Source0: %{name}-%{version}.tar.gz Source0: %{name}-%{version}.tar.gz
Patch0: virt-who-1.31.23-1-to-virt-who-1.31.23-2.patch
Patch1: virt-who-1.31.23-2-to-virt-who-1.31.23-3.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: %{python_ver}-devel BuildRequires: %{python_ver}-devel
@ -87,6 +89,8 @@ report them to the subscription manager.
%prep %prep
%setup -q %setup -q
%patch0 -p1
%patch1 -p1
%build %build
%{python_exec} setup.py build --rpm-version=%{version}-%{release_number} %{python_exec} setup.py build --rpm-version=%{version}-%{release_number}
@ -168,6 +172,17 @@ fi
* Wed Mar 15 2023 MSVSphere Packaging Team <packager@msvsphere.ru> - 1.31.23-1 * Wed Mar 15 2023 MSVSphere Packaging Team <packager@msvsphere.ru> - 1.31.23-1
- Rebuilt for MSVSphere 9.1. - Rebuilt for MSVSphere 9.1.
* Tue Feb 07 2023 Jiri Hnidek <jhnidek@redhat.com> 1.31.23-3
-
* Tue Feb 07 2023 Jiri Hnidek <jhnidek@redhat.com> 1.31.24-3
- 2165499: [1.31.23] Migrate virt-who.conf, when necessary (jhnidek@redhat.com)
* 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 * 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 - 2054504: Use usedforsecurity=False for md5() calls to make suds work on FIPS
enabled systems (oalbrigt@redhat.com) enabled systems (oalbrigt@redhat.com)

Loading…
Cancel
Save