This project automates the creation and management of virtual machines (VMs) in OpenStack and dynamically registers them with a Slurm cluster.
- Automatically creates VMs in OpenStack based on Slurm job queue and minimum/maximum VM limits.
- Dynamically registers VMs with a Slurm cluster using
slurmd -Z. - Supports configuration through a
config.inifile and command-line arguments. - Sequentially names VMs with the prefix
ecc*.
This project assumes that you already have a Slurm controller running in the same OpenStack project where you want the execution nodes to be created.
If you do not have a Slurm controller, you can manually install one using the following Ansible role: https://github.com/usegalaxy-no/ansible-role-slurm
config.py: Handles configuration parsing fromconfig.iniand command-line arguments.openstack_utils.py: Contains OpenStack-related functions for creating VMs and managing VM names.main.py: The main entry point for the service.config.ini: Configuration file for OpenStack, Slurm, and service settings.
- Python: Ensure Python 3.6+ is installed.
- Dependencies: Install required Python packages:
pip install openstacksdk
- OpenStack Credentials: Ensure you have valid OpenStack credentials.
- Slurm Controller: Ensure the Slurm controller is configured to accept dynamic node registration.
Update the config.ini file with your OpenStack and Slurm settings. Example:
[openstack]
auth_url = http://openstack.example.com:5000/v3
project_name = your_project
username = your_username
password = your_password
user_domain_name = default
project_domain_name = default
[vm]
flavor = m1.small
image = ubuntu-20.04
network = private
min_vms = 1
max_vms = 5
vm_name_prefix = ecc
[service]
check_interval = 60
min_pending_jobs = 1 ; Minimum pending jobs before creating a new VM
[slurm]
memory = 80000
feature = f1
node_config = NodeName=node1 CPUs=16 Boards=1 SocketsPerBoard=1 CoresPerSocket=8 ThreadsPerCore=2 RealMemory=31848
cpus = 16-
Run the Service:
python main.py
-
Command-Line Arguments: Override configuration values using command-line arguments. Example:
python main.py --min_vms 2 --max_vms 10 --min_pending_jobs 5
-
VM Creation:
- The service checks the number of running VMs and pending jobs in the Slurm queue.
- If the number of running VMs is below the
min_vmsor there are at leastmin_pending_jobspending jobs, it creates new VMs.
-
VM Naming:
- VMs are named sequentially with the prefix
ecc*(e.g.,ecc1,ecc2).
- VMs are named sequentially with the prefix
-
Slurm Registration:
- Each VM is dynamically registered with the Slurm cluster using
slurmd -Z.
- Each VM is dynamically registered with the Slurm cluster using
Feel free to submit issues or pull requests to improve the project.
This project is licensed under the MIT License. See the LICENSE file for details.