Skip to main content

Devices Management Overview

Devices Overview

Devices refer to the hardware components managed within a logical partition (LPAR) on AIX systems. The module allows configuring, modifying, and unconfiguring devices, ensuring they are in the desired state. Devices can be set to different states such as 'available', 'defined', or 'removed', depending on the required operation.

Devices Management

The module supports operations on individual devices or all devices within the LPAR, providing flexibility in device management. It also includes options for forcing changes on locked devices and recursively unconfiguring devices along with their children.

Device States

Attributes of devices can be changed when they are in the 'available' state, and devices can be unconfigured or stopped when in the 'defined' state.

Example of Configuring a Device

This example shows how to configure a device named proc0 to be in the 'available' state.


Example of configuring a device named proc0 to be in the 'available' state.

- name: Configure a device
devices:
device: proc0
state: available

Example of Unconfiguring a Device

This example demonstrates how to unconfigure a device named proc0 to be in the 'defined' state.


Example of unconfiguring a device named proc0 to be in the 'defined' state.

- name: Unconfigure a device
devices:
device: proc0
state: defined

Example of Removing a Device

This example illustrates how to remove a device named fcs0 and its children, setting the state to 'removed'.


Example of removing a device named fcs0 and its children, setting the state to 'removed'.

- name: Remove (delete) fcs0 device and children
devices:
device: fcs0
state: removed
recursive: 'true'

Main Functions

There are several main functions in this folder. Some of them are chdev, cfgdev, and rmdev. We will dive a little into chdev and cfgdev.

chdev

The chdev function changes the attributes of a device. It first fetches the initial properties of the device using get_device_attributes, then checks for idempotency with check_idempotency. If changes are needed, it constructs the appropriate command options and executes the change.


The chdev function changes the attributes of a device.

def chdev(module, device):
"""
Changes the attributes of the device.
param module: Ansible module argument spec.
param device: Volume Group name.
return: changed - True/False(device state modified or not),
msg - message
"""
attributes = module.params["attributes"]
force = module.params["force"]
chtype = module.params["chtype"]
parent_device = module.params["parent_device"]
msg = ''

''' get initial properties of the device before
attempting to modfiy it. '''
init_props = get_device_attributes(module, device)

attributes, msg = check_idempotency(module, init_props, attributes, msg)

opts = ""

cfgdev

The cfgdev function configures a device or discovers all devices. It determines the current state of the device using get_device_state and then executes the configuration command if the device is not already in the desired state.


The cfgdev function configures a device or discovers all devices.

def cfgdev(module, device):
"""
Configure the device or discover all devices (device=all)
param module: Ansible module argument spec.
param device: device name.
return: changed - True/False(device state modified or not),
msg - message
"""
current_state = 'None'
cmd = "cfgmgr "
if device != 'all':
current_state = get_device_state(module, device)
if current_state is True:
msg = f"Device { device } is already in Available state."
return False, msg

if current_state is None:
msg = f"Device { device } does not exist."
module.fail_json(msg=msg)

cmd += f"-l { device } "

rmdev

The rmdev function unconfigures or stops a device when its state is 'defined' and removes the device definition when its state is 'removed'. It uses get_device_state to determine the current state of the device and constructs the appropriate command options for the removal operation.


The rmdev function unconfigures or stops a device when its state is 'defined' and removes the device definition when its state is 'removed'.

def rmdev(module, device, state):
"""
Unconfigure/stop the device when state is 'defined'
Removes the device definition in Customized Devices object class when state is 'removed'
param module: Ansible module argument spec.
param device: device name.
param state: state of the device
return: changed - True/False(device state modified or not or device definition
is removed or not),
msg - message
"""
parent_device = module.params["parent_device"]
force = module.params["force"]
recursive = module.params["recursive"]
rmtype = module.params["rmtype"]
current_state = None
opts = ""

if device != 'all':
current_state = get_device_state(module, device)
if current_state is None:

 

This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human