4.7 KiB
4.7 KiB
Using rsd-lib
Composing and using a logical node
import rsd_lib
# Get a connection with the RSD endpoint
= rsd_lib.RSDLib('http://localhost:8443/redfish/v1',
rsd ='foo', password='bar').factory()
username
# Get the node collection object
= rsd.get_node_collection()
node_col
# Get a list of existing composed nodes
node_col.get_members()
# Compose a new node with no requirements specified
= node_col.compose_node()
node1
# Compose a new node specifying requirements
= node_col.compose_node(
node2 ='testnode',
name='this is a node',
description=[
processor_req
{'TotalCores': 4
}],=[
memory_req
{'CapacityMiB': 8000,
'MemoryDeviceType': 'DDR'
}],=[
remote_drive_req
{'CapacityGiB': 80,
'iSCSIAddress': 'iqn.oem.com:42',
'Master': {
'Type': 'Snapshot',
'Resource': '/redfish/v1/Services/1/LogicalDrives/1'
}
}]
)
# Get the python object for the node we created
= rsd.get_node(node1)
node_inst
# Assemble the composed node (After allocation, node must be assembled)
node_inst.assemble_node()
# Refresh the node object
node_inst.refresh()
# Get composed node state of node, should be 'assembled'
print(node_inst.composed_node_state)
# Power the node ON
node_inst.reset_node(rsd_lib.RESET_ON)
# Get a list of allowed reset values
print(node_inst.get_allowed_reset_node_values())
# Refresh the node object
node_inst.refresh()
# Get the current power state
print(node_inst.power_state)
# Set the next boot device to boot once from PXE in UEFI mode
node_inst.set_node_boot_source(rsd_lib.BOOT_SOURCE_TARGET_PXE,=rsd_lib.BOOT_SOURCE_ENABLED_ONCE,
enabled=rsd_lib.BOOT_SOURCE_MODE_UEFI)
mode
# Get the current boot source information
print(node_inst.boot)
# Get a list of allowed boot source target values
print(node_inst.get_allowed_node_boot_source_values())
# Get the memory summary
print(node_inst.memory_summary)
# Get the processor summary
print(node_inst.processor_summary)
# Delete/Deallocate the composed node
node_inst.delete_node()
Discovering Remote Storage Services
# Get the storage service collection object
= rsd.get_storage_service_collection()
storage_service_col
# Get storage service instance
= storage_service_col.get_members()[0]
storage_service
# Show all storage service uri
print(storage_service_col.members_identities)
# Get storage service instance with ID
= rsd.get_storage_service(storage_service_col.members_identities[0])
storage_service2
# Get physical drives contained by storage service
= storage_service.physical_drives()
physical_drive_col
# Get a physical drive from the collection
= physical_drive_col.get_members()[0]
physical_drive
# Get capacity of the physical drive
print(physical_drive.capacity_gib)
# Get logical drives contained by storage service
= storage_service.logical_drives()
logical_drive_col
# Get logical drive
= logical_drive_col.get_members()[0]
logical_drive
# Get type of a logical drive
print(logical_drive.drive_type)
# Get remote target collection
= storage_service.remote_targets()
remote_target_col
# Get remote target instance
= remote_target_col.get_members()[0]
target
# Get Initiator IQN of a remote target
print(target.initiators[0].iscsi.iqn)
Discovering NVMe Devices and Attaching them to Nodes
# Get the fabric collection object
= rsd.get_fabric_collection()
fabric_col
# Get fabric instance
= fabric_col.get_members()[0]
fabric
# Show all fabric uri
print(fabric_col.members_identities)
# Get a fabric instance with an ID
= rsd.get_fabric(fabric_col.members_identities[0])
fabric2
# Get endpoint collection
= fabric.endpoints()
endpoint_col
# Get endpoint instance
= endpoint_col.get_members()[0]
endpoint
# Get type of connected entity
print(endpoint.connected_entities[0].entity_type)
# Get link to entity
= endpoint.connected_entities[0].entity_link
drive_link
# Get a composed node instance
= node_col.get_members()[0]
node_inst
# Attach the endpoint to the composed node
=drive_link)
node_inst.attach_endpoint(endpoint
# Detach the endpoint from the composed node
=drive_link) node_inst.detach_endpoint(endpoint