Thank you for considering contributing to the Infracli project! This guide will help you get started with setting up the development environment, understanding the project structure, and contributing code.
- Setting Up the Development Environment
- Project Structure
- Configuration Files
- VM Profiles
- Managers
- Main Script
- Adding a New Manager
- Running the CLI Tool
- Example Commands
- Contributing
- Testing
- Best Practices
-
Clone the Repository:
git clone <repository_url> cd infracli
-
Create a Virtual Environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies:
pip install -r requirements.txt
infracli/
├── configs/
│ ├── sites.yaml
├── managers/
│ ├── msdns_manager.py
│ ├── vcenter_connector.py
│ ├── vmware_manager.py
│ ├── purestorage_manager.py
│ ├── harvester_manager.py
│ ├── opennebula_manager.py
│ ├── cloudstack_manager.py
│ └── ...
├── vm_profiles/
│ ├── profile1.yaml
│ ├── profile2.yaml
│ └── ...
├── fscli.py
├── requirements.txt
└── ...
- Location:
configs/
- Purpose: Store configurations for different services and environments.
- Structure: YAML files containing Infrastructure configs.
- Location:
vm_profiles/
- Purpose: Define VM configurations and templates.
- Structure: YAML files containing VM profiles.
- Location:
managers/
- Purpose: Contain classes and methods to manage different services.
- Files:
msdns_manager.py
: Manages DNS records.vmware_manager.py
: Manages VMware VMs.harvester_manager.py
: Manages Harvester VMs.cloudstack_manager.py
: Manages CloudStack VMs.phpipam_manager.py
: Manages phpIPAM IP Management Solution.purestorage_manager.py
: Manages PureStorage arrays.vault_manager.py
: Manages OpenBAO Vault.
- Location:
fscli.py
- Purpose: Entry point for the CLI tool.
- Functionality: Parses command-line arguments and invokes appropriate manager methods.
-
Create a New Manager File:
- Add a new file in the
managers
directory, e.g.,new_manager.py
.
- Add a new file in the
-
Define the Manager Class:
- Implement the necessary methods for managing the new service.
-
Update
fscli.py
:- Import the new manager class.
- Add command-line argument parsing for the new manager.
-
Activate the Virtual Environment:
source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Run the CLI Tool:
python fscli.py <command> <subcommand> [options]
-
DNS Management:
python fscli.py dns get A example.com domain1.com python fscli.py dns add A example.com 192.168.1.1 --ttl 3600 domain1.com python fscli.py dns del A example.com 192.168.1.1 domain1.com python fscli.py dns list domain1.com
-
VM Management (VMware):
python fscli.py vm create profile1 vcenter01 python fscli.py vm delete vm_name vcenter01 python fscli.py vm list vcenter01 python fscli.py vm snapshot vm_name vcenter01 python fscli.py vm modify vm_name profile1 vcenter01
-
Storage Management:
python fscli.py storage create_lun array_name volume_name size python fscli.py storage create_host array_name host_name --iqn iqn_value --wwns wwn1 wwn2 python fscli.py storage add_initiator array_name host_name initiator_name iqn python fscli.py storage map_volume array_name volume_name host_name python fscli.py storage snapshot_lun array_name volume_name snapshot_name python fscli.py storage list_hosts array_name python fscli.py storage list_luns array_name python fscli.py storage list_host_lun_mappings array_name
-
Fork the Repository:
- Create a fork of the repository on GitHub.
-
Create a Feature Branch:
git checkout -b feature/new-feature
-
Commit Changes:
git add . git commit -m "Add new feature"
-
Push to the Branch:
git push origin feature/new-feature
-
Create a Pull Request:
- Open a pull request on GitHub to merge your changes into the main branch.
-
Unit Tests:
- Write unit tests for new features and bug fixes.
- Use a testing framework like
unittest
orpytest
.
-
Run Tests:
pytest tests/
-
Code Style:
- Follow PEP 8 guidelines for Python code.
- Use meaningful variable and function names.
-
Error Handling:
- Implement proper error handling and logging.
- Ensure that exceptions are caught and meaningful error messages are displayed.
-
Documentation:
- Document your code with comments and docstrings.
- Update the README file with any new features or changes.
Thank you for contributing to the Infracli project!