-
Notifications
You must be signed in to change notification settings - Fork 1
virttest.staging
virttest.staging package¶
Subpackages¶
- virttest.staging.backports package
Submodules¶
virttest.staging.lv_utils module¶
Utilities to create logical volumes or take snapshots of existing ones.
author:
Plamen Dimitrov
copyright:
Intra2net AG 2012
license:
GPL v2
param vg_name:
Name of the volume group.
param lv_name:
Name of the logical volume.
param lv_size:
Size of the logical volume as string in the form “#G” (for example 30G).
param lv_snapshot_name:
Name of the snapshot with origin the logical volume.
param lv_snapshot_size:
Size of the snapshot with origin the logical volume also as “#G”.
param ramdisk_vg_size:
Size of the ramdisk virtual group.
param ramdisk_basedir:
Base directory for the ramdisk sparse file.
param ramdisk_sparse_filename:
Name of the ramdisk sparse file.
Sample ramdisk params:
ramdisk_vg_size = "40000"
ramdisk_basedir = "/tmp"
ramdisk_sparse_filename = "virtual_hdd"
Sample general params:
vg_name='autotest_vg',
lv_name='autotest_lv',
lv_size='1G',
lv_snapshot_name='autotest_sn',
lv_snapshot_size='1G'
The ramdisk volume group size is in MB.
virttest.staging.lv_utils.``lv_check
(vg_name, lv_name)¶
Check whether provided logical volume exists.
virttest.staging.lv_utils.``vg_check
(vg_name)¶
Check whether provided volume group exists.
virttest.staging.lv_utils.``vg_list
()¶
List available volume groups.
virttest.staging.lv_utils.``vg_ramdisk_cleanup
(ramdisk_filename, vg_ramdisk_dir, vg_name, loop_device)¶
Inline cleanup function in case of test error.
virttest.staging.service module¶
classvirttest.staging.service.``Factory
¶
Bases: object
Class to create different kinds of ServiceManager. The all interfaces to create manager are staticmethod, so we do not have to create an instance of factory when create manager.
-
GenericServiceManager:
-
Interface: create_generic_service()
-
Description: Object to manage the all services(lldp, sshd and so on).
You can list the all services by GenericServiceManager.list(). And you can operate any service by passing the service name, such as GenericServiceManager.start(“sshd”).Example: # Get the system service manager service_manager = Factory.create_generic_service()
# Stating service/unit “sshd” service_manager.start(“sshd”)
# Getting a list of available units units = service_manager.list()
-
-
SpecificServiceManager:
-
interface: create_specific_service(service_name)
-
description: Object to manage specific service(such as sshd). You can
not operate the other services nor list the all information on this host.# Get the specific service manager for sshd sshd = Factory.create_specific_service(“sshd”) sshd.start() sshd.stop()
-
After all, there is an unified interface to create both of them, create_service(service_name=None).
If we pass a service_name to it, it will return a SpecificServiceManager, otherwise, it will return GenericServiceManager.
classFactoryHelper
(run=<function run at 0x55457d0>)¶
Bases: object
Internal class to help create service manager.
Provide some functions to auto detect system type. And auto create command_generator and result_parser.
Init a helper to create service manager.
Parameters:
run – Funtion to run command.
Type:
process.run-like function.
get_generic_service_command_generator
()¶
Lazy initializer for ServiceCommandGenerator using the auto-detect init command.
Returns:
ServiceCommandGenerator for the current init command.
Return type:
_ServiceCommandGenerator
get_generic_service_manager_type
()¶
Get the ServiceManager type using the auto-detect init command.
Returns:
Subclass type of _GenericServiceManager from the current init command.
Return type:
_SysVInitServiceManager or _SystemdServiceManager.
get_generic_service_result_parser
()¶
Get the ServiceResultParser using the auto-detect init command.
Returns:
ServiceResultParser fro the current init command.
Return type:
_ServiceResultParser
get_name_of_init
()¶
Internal function to determine what executable is PID 1, :return: executable name for PID 1, aka init :rtype: str
get_specific_service_command_generator
()¶
Create a class that will create partial functions that generate commands for the current init command.
lldpad = SpecificServiceManager("lldpad",
auto_create_specific_service_command_generator())
lldpad.start()
lldpad.stop()
Returns:
A ServiceCommandGenerator for the auto-detected init command.
Return type:
_ServiceCommandGenerator
get_specific_service_result_parser
()¶
Create a class that will create partial functions that generate result_parser for the current init command.
Returns:
A ServiceResultParser for the auto-detected init command.
Return type:
_ServiceResultParser
staticFactory.``create_generic_service
(run=<function run at 0x55457d0>)¶
Detect which init program is being used, init or systemd and return a class with methods to start/stop services.
# Get the system service manager
service_manager = Factory.create_generic_service()
# Stating service/unit "sshd"
service_manager.start("sshd")
# Getting a list of available units
units = service_manager.list()
# Disabling and stopping a list of services
services_to_disable = ['ntpd', 'httpd']
for s in services_to_disable:
service_manager.disable(s)
service_manager.stop(s)
Returns:
SysVInitServiceManager or SystemdServiceManager
Return type:
_GenericServiceManager
staticFactory.``create_service
(service_name=None, run=<function run at 0x55457d0>)¶
# Unified interface for generic and specific service manager.
Returns:
_SpecificServiceManager if service_name is not None, _GenericServiceManager if service_name is None.
staticFactory.``create_specific_service
(service_name, run=<function run at 0x55457d0>)¶
# Get the specific service manager for sshd sshd = Factory.create_specific_service(“sshd”) sshd.start() sshd.stop() sshd.reload() sshd.restart() sshd.condrestart() sshd.status() sshd.enable() sshd.disable() sshd.is_enabled()
Parameters:
service_name (str) – systemd unit or init.d service to manager
Returns:
SpecificServiceManager that has start/stop methods
Return type:
_SpecificServiceManager
virttest.staging.service.``convert_systemd_target_to_runlevel
(target)¶
Convert systemd target to runlevel.
Parameters:
target (str) – systemd target
Returns:
sys_v runlevel
Return type:
str
Raises:
ValueError – when systemd target is unknown
virttest.staging.service.``convert_sysv_runlevel
(level)¶
Convert runlevel to systemd target.
Parameters:
level (strorint) – sys_v runlevel
Returns:
systemd target
Return type:
str
Raises:
ValueError – when runlevel is unknown
virttest.staging.service.``raw_status_parser
(cmdResult=None)¶
Just return the result of service sub-command.
virttest.staging.service.``systemd_command_generator
(command)¶
Generate list of command line argument strings for systemctl. One argument per string for compatibility Popen
WARNING: If systemctl detects that it is running on a tty it will use color, pipe to $PAGER, change column sizes and not truncate unit names. Use –no-pager to suppress pager output, or set PAGER=cat in the environment. You may need to take other steps to suppress color output. See https://bugzilla.redhat.com/show_bug.cgi?id=713567
Parameters:
command (str) – start,stop,restart, etc.
Returns:
list of command and arguments to pass to process.run or similar functions
Return type:
builtin.list
virttest.staging.service.``systemd_list_parser
(cmdResult=None)¶
Parse method for service sub-command list.
:return in form of dict-like, including service name, status and so on
For example:
{"sshd": "enabled",
"vsftpd": "disabled",
"systemd-sysctl": "static",
...
}
virttest.staging.service.``systemd_result_parser
(command)¶
Parse results for systemd style commands.
Parameters:
command – service sub-command(string).
Returns:
depends on sub-command.
virttest.staging.service.``systemd_status_parser
(cmdResult=None)¶
Parse method for service sub-command status.
:return True : if status is active(running). :return False : if status is stopped. :return None : if status is un-loaded.
virttest.staging.service.``sysvinit_command_generator
(command)¶
Generate lists of command arguments for sys_v style inits.
Parameters:
command (str) – start,stop,restart, etc.
Returns:
list of commands to pass to process.run or similar function
Return type:
builtin.list
virttest.staging.service.``sysvinit_list_parser
(cmdResult=None)¶
Parse method for service sub-command list.
:return in form of dict-like, including service name, status and so on
For example:
{"sshd": {0: 'off', 1: 'off', 2: 'off', ..., 6: 'off'},
"vsftpd": {0: 'off', 1: 'off', 2: 'off', ..., 6: 'off'},
"xinetd": {'discard-dgram:': 'off', 'rsync:': 'on',...},
...
}
virttest.staging.service.``sysvinit_result_parser
(command)¶
Parse results for sys_v style commands.
Parameters:
command – service sub-command(string).
Returns:
depends on sub-command.
virttest.staging.service.``sysvinit_status_parser
(cmdResult=None)¶
Parse method for service sub-command status.
:return True : if status is running or active. :return False : if status is stopped. :return None : if status is unrecognized.
virttest.staging.utils_cgroup module¶
Helpers for cgroup testing.
copyright:
2011 Red Hat Inc.
author:
Lukas Doktor <[email protected]>
classvirttest.staging.utils_cgroup.``CgconfigService
¶
Bases: object
Cgconfig service class.
cgconfig_condrestart
()¶
Condrestart cgconfig service
cgconfig_is_running
()¶
Check cgconfig service status
cgconfig_restart
()¶
Restart cgconfig service
cgconfig_start
()¶
Sart cgconfig service
cgconfig_stop
()¶
Sop cgconfig service
classvirttest.staging.utils_cgroup.``Cgroup
(module, _client)¶
Bases: object
Cgroup handling class.
Constructor :param module: Name of the cgroup module :param _client: Test script pwd + name
cgclassify_cgroup
(pid, cgroup)¶
Classify pid into cgroup
Parameters:
- pid – pid of the process
- cgroup – cgroup name
cgdelete_all_cgroups
()¶
Delete all cgroups in the module
cgdelete_cgroup
(cgroup, recursive=False)¶
Delete desired cgroup.
Params cgroup:
desired cgroup
Params force:
If true, sub cgroup can be deleted with parent cgroup
cgexec
(cgroup, cmd, args='')¶
Execute command in desired cgroup
Parameters:
- cgroup – Desired cgroup
- cmd – Executed command
- args – Executed command’s parameters
cgset_property
(prop, value, pwd=None, check=True, checkprop=None)¶
Sets the property value by cgset command
Parameters:
- prop – property name (file)
- value – desired value
- pwd – cgroup directory
- check – check the value after setup / override checking value
- checkprop – override prop when checking the value
get_all_cgroups
()¶
Get all sub cgroups in this controller
get_cgroup_index
(cgroup)¶
Get cgroup’s index in cgroups
Parameters:
cgroup – cgroup name
Returns:
index of cgroup
get_cgroup_name
(pwd=None)¶
Get cgroup’s name
Parameters:
pwd – cgroup name
Returns:
cgroup’s name
get_pids
(pwd=None)¶
Get all pids in cgroup
Params:
pwd: cgroup directory
Returns:
all pids(list)
get_property
(prop, pwd=None)¶
Gets the property value :param prop: property name (file) :param pwd: cgroup directory :return: [] values or None when FAILED
initialize
(modules)¶
Initializes object for use.
Parameters:
modules – Array of all available cgroup modules.
is_cgroup
(pid, pwd)¶
Checks if the ‘pid’ process is in ‘pwd’ cgroup :param pid: pid of the process :param pwd: cgroup directory :return: 0 when is ‘pwd’ member
is_root_cgroup
(pid)¶
Checks if the ‘pid’ process is in root cgroup (WO cgroup) :param pid: pid of the process :return: 0 when is ‘root’ member
mk_cgroup
(pwd=None, cgroup=None)¶
Creates new temporary cgroup :param pwd: where to create this cgroup (default: self.root) :param cgroup: desired cgroup name :return: last cgroup index
mk_cgroup_cgcreate
(pwd=None, cgroup=None)¶
Make a cgroup by executing the cgcreate command
Params:
cgroup: name of the cgroup to be created
Returns:
last cgroup index
rm_cgroup
(pwd)¶
Removes cgroup.
Parameters:
pwd – cgroup directory.
set_cgroup
(pid, pwd=None)¶
Sets cgroup membership :param pid: pid of the process :param pwd: cgroup directory
set_property
(prop, value, pwd=None, check=True, checkprop=None)¶
Sets the property value :param prop: property name (file) :param value: desired value :param pwd: cgroup directory :param check: check the value after setup / override checking value :param checkprop: override prop when checking the value
set_property_h
(prop, value, pwd=None, check=True, checkprop=None)¶
Sets the one-line property value concerning the K,M,G postfix :param prop: property name (file) :param value: desired value :param pwd: cgroup directory :param check: check the value after setup / override checking value :param checkprop: override prop when checking the value
set_root_cgroup
(pid)¶
Resets the cgroup membership (sets to root) :param pid: pid of the process :return: 0 when PASSED
smoke_test
()¶
Smoke test Module independent basic tests
test
(cmd)¶
Executes cgroup_client.py with cmd parameter.
Parameters:
cmd – command to be executed
Returns:
subprocess.Popen() process
classvirttest.staging.utils_cgroup.``CgroupModules
(mountdir=None)¶
Bases: object
Handles the list of different cgroup filesystems.
get_pwd
(module)¶
Returns the mount directory of ‘module’ :param module: desired module (memory, ...) :return: mount directory of ‘module’ or None
init
(_modules)¶
Checks the mounted modules and if necessary mounts them into tmp mountdir.
Parameters:
_modules – Desired modules.’memory’,’cpu,cpuset’...
Returns:
Number of initialized modules.
virttest.staging.utils_cgroup.``all_cgroup_delete
()¶
Clear all cgroups in system
virttest.staging.utils_cgroup.``get_all_controllers
()¶
Get all controllers used in system
Returns:
all used controllers(controller_list)
virttest.staging.utils_cgroup.``get_cgroup_mountpoint
(controller, mount_file='/proc/mounts')¶
Get desired controller’s mountpoint
Parameters:
- controller – Desired controller
- mount_file – Name of file contains mounting information, in most cases this are not need to be set.
Returns:
controller’s mountpoint
Raise:
TestError when contoller doesn’t exist in mount table
virttest.staging.utils_cgroup.``get_load_per_cpu
(_stats=None)¶
Gather load per cpu from /proc/stat :param _stats: previous values :return: list of diff/absolute values of CPU times [SUM, CPU1, CPU2, ...]
virttest.staging.utils_cgroup.``resolve_task_cgroup_path
(pid, controller)¶
Resolving cgroup mount path of a particular task
Params:
pid : process id of a task for which the cgroup path required
Params:
controller: takes one of the controller names in controller list
Returns:
resolved path for cgroup controllers of a given pid
virttest.staging.utils_koji module¶
classvirttest.staging.utils_koji.``KojiClient
(cmd=None)¶
Bases: object
Stablishes a connection with the build system, either koji or brew.
This class provides convenience methods to retrieve information on packages and the packages themselves hosted on the build system. Packages should be specified in the KojiPgkSpec syntax.
Verifies whether the system has koji or brew installed, then loads the configuration file that will be used to download the files.
Parameters:
cmd (string) – Optional command name, either ‘brew’ or ‘koji’. If not set, get_default_command() is used and to look for one of them.
Raise:
ValueError
CMD_LOOKUP_ORDER
= ['/usr/bin/brew', '/usr/bin/koji']¶
CONFIG_MAP
= {'/usr/bin/brew': '/etc/brewkoji.conf', '/usr/bin/koji': '/etc/koji.conf'}¶
RETRY_STEP
= 3¶
RETRY_TIMEOUT
= 30¶
get_default_command
()¶
Looks up for koji or brew “binaries” on the system
Systems with plain koji usually don’t have a brew cmd, while systems with koji, have both koji and brew utilities. So we look for brew first, and if found, we consider that the system is configured for brew. If not, we consider this is a system with plain koji.
Returns:
either koji or brew command line executable path, or None
get_pkg_base_url
()¶
Gets the base url for packages in Koji
get_pkg_info
(pkg)¶
Returns information from Koji on the package
Parameters:
pkg (KojiPkgSpec) – information about the package, as a KojiPkgSpec instance
Returns:
information from Koji about the specified package
get_pkg_rpm_file_names
(pkg, arch=None)¶
Gets the file names for the RPM packages specified in pkg
Parameters:
- pkg (KojiPkgSpec) – a package specification
- arch (string) – packages built for this architecture, but also including architecture independent (noarch) packages
get_pkg_rpm_info
(pkg, arch=None)¶
Returns a list of information on the RPM packages found on koji
Parameters:
- pkg (KojiPkgSpec) – a package specification
- arch (string) – packages built for this architecture, but also including architecture independent (noarch) packages
get_pkg_rpm_names
(pkg, arch=None)¶
Gets the names for the RPM packages specified in pkg
Parameters:
- pkg (KojiPkgSpec) – a package specification
- arch (string) – packages built for this architecture, but also including architecture independent (noarch) packages
get_pkg_urls
(pkg, arch=None)¶
Gets the urls for the packages specified in pkg
Parameters:
- pkg (KojiPkgSpec) – a package specification
- arch (string) – packages built for this architecture, but also including architecture independent (noarch) packages
get_pkgs
(pkg, dst_dir, arch=None)¶
Download the packages
Parameters:
- pkg (KojiPkgSpec) – a package specification
- dst_dir (string) – the destination directory, where the downloaded packages will be saved on
- arch (string) – packages built for this architecture, but also including architecture independent (noarch) packages
get_scratch_base_url
()¶
Gets the base url for scratch builds in Koji
get_scratch_pkg_urls
(pkg, arch=None)¶
Gets the urls for the scratch packages specified in pkg
Parameters:
- pkg (KojiScratchPkgSpec) – a scratch package specification
- arch (string) – packages built for this architecture, but also including architecture independent (noarch) packages
get_scratch_pkgs
(pkg, dst_dir, arch=None)¶
Download the packages from a scratch build
Parameters:
- pkg (KojiScratchPkgSpec) – a scratch package specification
- dst_dir (string) – the destination directory, where the downloaded packages will be saved on
- arch (string) – packages built for this architecture, but also including architecture independent (noarch) packages
get_session_options
()¶
Filter only options necessary for setting up a cobbler client session
Returns:
only the options used for session setup
is_command_valid
()¶
Checks if the currently set koji command is valid
Returns:
True or False
is_config_valid
()¶
Checks if the currently set koji configuration is valid
Returns:
True or False
is_pkg_spec_build_valid
(pkg)¶
Checks if build is valid on Koji
Parameters:
pkg – a Pkg instance
is_pkg_spec_tag_valid
(pkg)¶
Checks if tag is valid on Koji
Parameters:
pkg (KojiPkgSpec) – a package specification
is_pkg_valid
(pkg)¶
Checks if this package is altogether valid on Koji
This verifies if the build or tag specified in the package specification actually exist on the Koji server
Returns:
True or False
read_config
(check_is_valid=True)¶
Reads options from the Koji configuration file
By default it checks if the koji configuration is valid
Parameters:
check_valid (boolean) – whether to include a check on the configuration
Raise:
ValueError
Returns:
None
classvirttest.staging.utils_koji.``KojiDirIndexParser
¶
Bases: HTMLParser.HTMLParser
Parser for HTML directory index pages, specialized to look for RPM links
Initializes a new KojiDirListParser instance
handle_starttag
(tag, attrs)¶
Handle tags during the parsing
This just looks for links (‘a’ tags) for files ending in .rpm
exceptionvirttest.staging.utils_koji.``KojiDownloadError
(url, timeout, last_error)¶
Bases: exceptions.IOError
classvirttest.staging.utils_koji.``KojiPkgSpec
(text='', tag=None, build=None, package=None, subpackages=[])¶
Bases: object
A package specification syntax parser for Koji
This holds information on either tag or build, and packages to be fetched from koji and possibly installed (features external do this class).
New objects can be created either by providing information in the textual format or by using the actual parameters for tag, build, package and sub- packages. The textual format is useful for command line interfaces and configuration files, while using parameters is better for using this in a programatic fashion.
The following sets of examples are interchangeable. Specifying all packages part of build number 1000:
>>> from kvm_utils import KojiPkgSpec
>>> pkg = KojiPkgSpec('1000')
>>> pkg = KojiPkgSpec(build=1000)
Specifying only a subset of packages of build number 1000:
>>> pkg = KojiPkgSpec('1000:kernel,kernel-devel')
>>> pkg = KojiPkgSpec(build=1000,
subpackages=['kernel', 'kernel-devel'])
Specifying the latest build for the ‘kernel’ package tagged with ‘dist-f14’:
>>> pkg = KojiPkgSpec('dist-f14:kernel')
>>> pkg = KojiPkgSpec(tag='dist-f14', package='kernel')
Specifying the ‘kernel’ package using the default tag:
>>> kvm_utils.set_default_koji_tag('dist-f14')
>>> pkg = KojiPkgSpec('kernel')
>>> pkg = KojiPkgSpec(package='kernel')
Specifying the ‘kernel’ package using the default tag:
>>> kvm_utils.set_default_koji_tag('dist-f14')
>>> pkg = KojiPkgSpec('kernel')
>>> pkg = KojiPkgSpec(package='kernel')
If you do not specify a default tag, and give a package name without an explicit tag, your package specification is considered invalid:
>>> print kvm_utils.get_default_koji_tag()
None
>>> print kvm_utils.KojiPkgSpec('kernel').is_valid()
False
>>> print kvm_utils.KojiPkgSpec(package='kernel').is_valid()
False
Instantiates a new KojiPkgSpec object
Parameters:
- text (string) – a textual representation of a package on Koji that will be parsed
- tag (string) – a koji tag, example: Fedora-14-RELEASE (see U{http://fedoraproject.org/wiki/Koji#Tags_and_Targets})
- build (number) – a koji build, example: 1001 (see U{http://fedoraproject.org/wiki/Koji#Koji_Architecture})
- package (string) – a koji package, example: python (see U{http://fedoraproject.org/wiki/Koji#Koji_Architecture})
- subpackages (builtin.list) – a list of package names, usually a subset of the RPM packages generated by a given build
SEP
= ':'¶
describe
()¶
Describe this package specification, in a human friendly way
Returns:
package specification description
describe_invalid
()¶
Describes why this is not valid, in a human friendly way
is_valid
()¶
Checks if this package specification is valid.
Being valid means that it has enough and not conflicting information. It does not validate that the packages specified actually existe on the Koji server.
Returns:
True or False
parse
(text)¶
Parses a textual representation of a package specification
Parameters:
text (string) – textual representation of a package in koji
to_text
()¶
Return the textual representation of this package spec
The output should be consumable by parse() and produce the same package specification.
We find that it’s acceptable to put the currently set default tag as the package explicit tag in the textual definition for completeness.
Returns:
package specification in a textual representation
classvirttest.staging.utils_koji.``KojiScratchPkgSpec
(text='', user=None, task=None, subpackages=[])¶
Bases: object
A package specification syntax parser for Koji scratch builds
This holds information on user, task and subpackages to be fetched from koji and possibly installed (features external do this class).
New objects can be created either by providing information in the textual format or by using the actual parameters for user, task and subpackages. The textual format is useful for command line interfaces and configuration files, while using parameters is better for using this in a programatic fashion.
This package definition has a special behaviour: if no subpackages are specified, all packages of the chosen architecture (plus noarch packages) will match.
The following sets of examples are interchangeable. Specifying all packages from a scratch build (whose task id is 1000) sent by user jdoe:
>>> from kvm_utils import KojiScratchPkgSpec
>>> pkg = KojiScratchPkgSpec('jdoe:1000')
>>> pkg = KojiScratchPkgSpec(user=jdoe, task=1000)
Specifying some packages from a scratch build whose task id is 1000, sent by user jdoe:
>>> pkg = KojiScratchPkgSpec('jdoe:1000:kernel,kernel-devel')
>>> pkg = KojiScratchPkgSpec(user=jdoe, task=1000,
subpackages=['kernel', 'kernel-devel'])
Instantiates a new KojiScratchPkgSpec object
Parameters:
- text (string) – a textual representation of a scratch build on Koji that will be parsed
- task (number) – a koji task id, example: 1001
- subpackages (builtin.list) – a list of package names, usually a subset of the RPM packages generated by a given build
SEP
= ':'¶
parse
(text)¶
Parses a textual representation of a package specification
Parameters:
text (string) – textual representation of a package in koji
classvirttest.staging.utils_koji.``RPMFileNameInfo
(filename)¶
Simple parser for RPM based on information present on the filename itself
Initializes a new RpmInfo instance based on a filename
get_arch
()¶
Returns just the architecture as present on the RPM filename
get_filename_without_arch
()¶
Returns the filename without the architecture
This also excludes the RPM suffix, that is, removes the leading arch and RPM suffix.
get_filename_without_suffix
()¶
Returns the filename without the default RPM suffix
get_nvr_info
()¶
Returns a dictionary with the name, version and release components
If koji is not installed, this returns None
virttest.staging.utils_koji.``get_default_koji_tag
()¶
virttest.staging.utils_koji.``set_default_koji_tag
(tag)¶
Sets the default tag that will be used
virttest.staging.utils_memory module¶
virttest.staging.utils_memory.``drop_caches
()¶
Writes back all dirty pages to disk and clears all the caches.
virttest.staging.utils_memory.``freememtotal
()¶
virttest.staging.utils_memory.``get_buddy_info
(chunk_sizes, nodes='all', zones='all')¶
Get the fragement status of the host. It use the same method to get the page size in buddyinfo. 2^chunk_size * page_size The chunk_sizes can be string make up by all orders that you want to check splited with blank or a mathematical expression with ‘>’, ‘<’ or ‘=’. For example: The input of chunk_size could be: “0 2 4” And the return will be: {‘0’: 3, ‘2’: 286, ‘4’: 687} if you are using expression: “>=9” the return will be: {‘9’: 63, ‘10’: 225}
Parameters:
- chunk_size (string) – The order number shows in buddyinfo. This is not the real page size.
- nodes (string) – The numa node that you want to check. Default value is all
- zones (string) – The memory zone that you want to check. Default value is all
Returns:
A dict using the chunk_size as the keys
Return type:
dict
virttest.staging.utils_memory.``get_huge_page_size
()¶
virttest.staging.utils_memory.``get_num_anon_huge_pages
(pid=0)¶
virttest.staging.utils_memory.``get_num_huge_pages
()¶
virttest.staging.utils_memory.``get_num_huge_pages_free
()¶
virttest.staging.utils_memory.``get_num_huge_pages_rsvd
()¶
virttest.staging.utils_memory.``get_transparent_hugepage
()¶
virttest.staging.utils_memory.``memtotal
()¶
virttest.staging.utils_memory.``node_size
()¶
virttest.staging.utils_memory.``numa_nodes
()¶
virttest.staging.utils_memory.``read_from_meminfo
(key)¶
virttest.staging.utils_memory.``read_from_numa_maps
(pid, key)¶
Get the process numa related info from numa_maps. This function only use to get the numbers like anon=1.
Parameters:
- pid (String) – Process id
- key (String) – The item you want to check from numa_maps
Returns:
A dict using the address as the keys
Return type:
dict
virttest.staging.utils_memory.``read_from_numastat
(pid, key)¶
Get the process numastat from numastat output.
virttest.staging.utils_memory.``read_from_smaps
(pid, key)¶
Get specific item value from the smaps of a process include all sections.
Parameters:
- pid (String) – Process id
- key (String) – The item you want to check from smaps
Returns:
The value of the item in kb
Return type:
int
virttest.staging.utils_memory.``read_from_vmstat
(key)¶
Get specific item value from vmstat
Parameters:
key (String) – The item you want to check from vmstat
Returns:
The value of the item
Return type:
int
virttest.staging.utils_memory.``rounded_memtotal
()¶
virttest.staging.utils_memory.``set_num_huge_pages
(num)¶
virttest.staging.utils_memory.``set_transparent_hugepage
(sflag)¶
sflag only can be set always, madvise or never.
Module contents¶
virttest.remote_commander package
virttest.staging.backports package
© Copyright 2014, Red Hat. Created using Sphinx 1.5.1.