Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
4f20939
Update README.md
enoch85 Apr 8, 2025
3fd0c1c
Create migrate_wrapper.py
enoch85 Apr 8, 2025
19b55a7
Create custom_netbox.py
enoch85 Apr 8, 2025
ba9fca0
Update migrate.py
enoch85 Apr 8, 2025
9dcb977
Create requirements.txt
enoch85 Apr 8, 2025
bbc4eaf
Create INSTALLATION.md
enoch85 Apr 8, 2025
284b608
Update INSTALLATION.md
enoch85 Apr 8, 2025
bdd3cc1
Update requirements.txt
enoch85 Apr 8, 2025
df681e1
Update custom_netbox.py
enoch85 Apr 8, 2025
5b203c1
Update migrate_wrapper.py
enoch85 Apr 8, 2025
6a495bd
Update INSTALLATION.md
enoch85 Apr 8, 2025
a7105f8
Update custom_fields.yml
enoch85 Apr 8, 2025
480d9a4
Delete custom_fields.yml
enoch85 Apr 8, 2025
ae4c404
Create set_custom_fields.py
enoch85 Apr 8, 2025
a2b3b7f
Create max-page-size-check.sh
enoch85 Apr 8, 2025
b710197
Update INSTALLATION.md
enoch85 Apr 8, 2025
9c66628
Create http-based-import.py
enoch85 Apr 8, 2025
023a1cc
Update set_custom_fields.py
enoch85 Apr 9, 2025
71f5973
Update custom_netbox.py
enoch85 Apr 9, 2025
05a438c
Update migrate_wrapper.py
enoch85 Apr 9, 2025
8a8e7d5
Create extended_migrate.py
enoch85 Apr 9, 2025
df71fcc
Rename max-page-size-check.sh to scripts/max-page-size-check.sh
enoch85 Apr 9, 2025
dec5abc
Update max-page-size-check.sh
enoch85 Apr 9, 2025
5c3c08e
Rename set_custom_fields.py to scripts/set_custom_fields.py
enoch85 Apr 9, 2025
5376a03
Update migrate.py
enoch85 Apr 9, 2025
8769bf2
Update migrate_wrapper.py
enoch85 Apr 9, 2025
617c269
Update extended_migrate.py
enoch85 Apr 9, 2025
3f67178
Update custom_netbox.py
enoch85 Apr 9, 2025
821ff93
Merge pull request #1 from enoch85/enoch85-patch-1
enoch85 Apr 9, 2025
4ad65ff
Create netbox.py
enoch85 Apr 9, 2025
d7659d2
Update migrate.py
enoch85 Apr 9, 2025
94ef5c2
Update custom_netbox.py
enoch85 Apr 9, 2025
e7f81f7
Update migrate.py
enoch85 Apr 9, 2025
41cb9c1
Update migrate_wrapper.py
enoch85 Apr 9, 2025
c1fbc54
refactor - split into smaller files
enoch85 Apr 9, 2025
043ec51
Create utils.py
enoch85 Apr 9, 2025
456688c
Create db.py
enoch85 Apr 9, 2025
e3fb099
Create available_subnets.py
enoch85 Apr 9, 2025
17780d7
Update migrate_wrapper.py
enoch85 Apr 9, 2025
922c8a9
Update migrate.py
enoch85 Apr 9, 2025
42d0d56
Update extended_migrate.py
enoch85 Apr 9, 2025
31519da
Create ips.py
enoch85 Apr 9, 2025
39a9cbb
Create __init__.py
enoch85 Apr 9, 2025
3c60c9d
Create __init__.py
enoch85 Apr 9, 2025
4c4cbd9
Create sites.py
enoch85 Apr 9, 2025
7f551a2
Create devices.py
enoch85 Apr 9, 2025
1689467
Create interfaces.py
enoch85 Apr 9, 2025
7439373
Create vlans.py
enoch85 Apr 9, 2025
267f6e9
Create vms.py
enoch85 Apr 9, 2025
2b3efc1
Create patch_cables.py
enoch85 Apr 9, 2025
77e086e
Create files.py
enoch85 Apr 9, 2025
2171507
Create services.py
enoch85 Apr 9, 2025
21936ea
Create nat.py
enoch85 Apr 9, 2025
1fe92f2
Create load_balancer.py
enoch85 Apr 9, 2025
c016ee2
Create monitoring.py
enoch85 Apr 9, 2025
23a074e
Create setup.py
enoch85 Apr 9, 2025
3e48f40
Update README.md
enoch85 Apr 9, 2025
b676587
Rename rhevm_pull.py to scripts/rhevm_pull.py
enoch85 Apr 9, 2025
beaa391
Rename free.py to scripts/free.py
enoch85 Apr 9, 2025
629c739
Merge pull request #2 from enoch85/refactor
enoch85 Apr 9, 2025
acea09d
Update custom_netbox.py
enoch85 Apr 9, 2025
9f605c8
Delete netbox.py
enoch85 Apr 9, 2025
6ea23df
Update migrate_wrapper.py
enoch85 Apr 9, 2025
ed622a8
Update INSTALLATION.md
enoch85 Apr 9, 2025
c7611da
Update INSTALLATION.md
enoch85 Apr 9, 2025
c5b96e2
Create setup_dev.sh
enoch85 Apr 9, 2025
c665e97
refactor some more
enoch85 Apr 9, 2025
e7c781e
refactor some more
enoch85 Apr 9, 2025
51f6a6d
rename folder
enoch85 Apr 9, 2025
93ce3e9
move around
enoch85 Apr 9, 2025
441048f
move around
enoch85 Apr 9, 2025
6b8903d
fix
enoch85 Apr 9, 2025
b79ecb5
Update db.py
enoch85 Apr 9, 2025
a440b65
Update devices.py
enoch85 Apr 9, 2025
69ba0cb
Update custom_netbox.py
enoch85 Apr 9, 2025
036d940
Update vms.py
enoch85 Apr 9, 2025
ef81ccc
Update available_subnets.py
enoch85 Apr 9, 2025
4c77db1
Update migrate_wrapper.py
enoch85 Apr 9, 2025
eefdd30
Update patch_cables.py
enoch85 Apr 9, 2025
ba6c360
Update config.py
enoch85 Apr 9, 2025
66d66e0
Update vms.py
enoch85 Apr 9, 2025
0a341e1
rename
enoch85 Apr 10, 2025
613737d
Update migrate.py
enoch85 Apr 10, 2025
1421b5b
Update custom_netbox.py
enoch85 Apr 10, 2025
18d58f5
Update utils.py
enoch85 Apr 10, 2025
1df5309
Update config.py
enoch85 Apr 10, 2025
6474f3f
Update db.py
enoch85 Apr 10, 2025
f2c2b4f
Update set_custom_fields.py
enoch85 Apr 10, 2025
033c358
Update INSTALLATION.md
enoch85 Apr 10, 2025
c9fc735
Update set_custom_fields.py
enoch85 Apr 10, 2025
b883871
Update set_custom_fields.py
enoch85 Apr 10, 2025
97f76a3
Update migrate.py
enoch85 Apr 10, 2025
8f5d805
setup_dev
enoch85 Apr 10, 2025
97dd36d
Update setup_dev.sh
enoch85 Apr 10, 2025
a7a3be7
Update setup_dev.sh
enoch85 Apr 10, 2025
ac3c713
Update setup_dev.sh
enoch85 Apr 10, 2025
8db45cd
Update setup_dev.sh
enoch85 Apr 10, 2025
1ac7f0d
Update migrate.py
enoch85 Apr 10, 2025
90ed151
Update setup_dev.sh
enoch85 Apr 10, 2025
06ae0ba
Update migrate.py
enoch85 Apr 10, 2025
79094b8
Update set_custom_fields.py
enoch85 Apr 10, 2025
a8cf7c7
Update setup_dev.sh
enoch85 Apr 10, 2025
dab78e4
Create ip_ranges.py
enoch85 Apr 10, 2025
b65c834
Update patch_cables.py
enoch85 Apr 10, 2025
9acdc45
Update services.py
enoch85 Apr 10, 2025
604477b
Update custom_netbox.py
enoch85 Apr 10, 2025
078cf1f
Update config.py
enoch85 Apr 10, 2025
18749ca
Update migrate.py
enoch85 Apr 10, 2025
c3e517d
Update load_balancer.py
enoch85 Apr 10, 2025
cd19398
Update ips.py
enoch85 Apr 10, 2025
ad72fa9
Update patch_cables.py
enoch85 Apr 10, 2025
f945a3e
Update available_subnets.py
enoch85 Apr 10, 2025
8f6979c
Update ip_ranges.py
enoch85 Apr 10, 2025
62d50cf
Update migrate.py
enoch85 Apr 10, 2025
58c64cb
Update available_subnets.py
enoch85 Apr 10, 2025
e89a963
Update ip_ranges.py
enoch85 Apr 10, 2025
aedcc86
Update available_subnets.py
enoch85 Apr 10, 2025
b72f199
Update ip_ranges.py
enoch85 Apr 10, 2025
09534a2
Update available_subnets.py
enoch85 Apr 10, 2025
5d10fb6
Update ip_ranges.py
enoch85 Apr 10, 2025
9b400b2
Update available_subnets.py
enoch85 Apr 10, 2025
f34891d
Update ip_ranges.py
enoch85 Apr 10, 2025
11d1aa3
Update available_subnets.py
enoch85 Apr 10, 2025
d292167
Update ip_ranges.py
enoch85 Apr 10, 2025
d644f94
Update utils.py
enoch85 Apr 10, 2025
7d44d70
Update available_subnets.py
enoch85 Apr 10, 2025
94d3441
Update ip_ranges.py
enoch85 Apr 10, 2025
a5f0b95
Update INSTALLATION.md
enoch85 Apr 10, 2025
1f37bef
Update migrate.py
enoch85 Apr 10, 2025
8e84915
Update README.md
enoch85 Apr 10, 2025
d4b5728
Update config.py
enoch85 Apr 14, 2025
dca7fea
Update custom_netbox.py
enoch85 Apr 14, 2025
603a83e
Update migrate.py
enoch85 Apr 14, 2025
7be1f5b
Update devices.py
enoch85 Apr 14, 2025
32c1234
Update vms.py
enoch85 Apr 14, 2025
08f1fe2
Update sites.py
enoch85 Apr 14, 2025
3726892
Update utils.py
enoch85 Apr 14, 2025
18bffc2
Update INSTALLATION.md
enoch85 Apr 14, 2025
af1217b
Update README.md
enoch85 Apr 14, 2025
6eb621d
Update migrate.py
enoch85 Apr 14, 2025
2d2d5fe
Update utils.py
enoch85 Apr 14, 2025
d54f21f
change to false
enoch85 Apr 14, 2025
e329a50
Update ips.py
enoch85 Apr 14, 2025
3a05731
Update utils.py
enoch85 Apr 14, 2025
4920ca3
Update migrate.py
enoch85 Apr 14, 2025
4e44d6a
Create netbox_status.py
enoch85 Apr 14, 2025
97cffb0
Create site_tenant.py
enoch85 Apr 14, 2025
b4760a6
Update ips.py
enoch85 Apr 14, 2025
7d0a01a
Update utils.py
enoch85 Apr 14, 2025
62ec3a4
Update available_subnets.py
enoch85 Apr 14, 2025
aede5b9
Update migrate.py
enoch85 Apr 14, 2025
39fe104
Update netbox_status.py
enoch85 Apr 14, 2025
b5b82bf
Update ips.py
enoch85 Apr 14, 2025
ee2118a
Update netbox_status.py
enoch85 Apr 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
313 changes: 313 additions & 0 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,313 @@
# Installation and Setup Guide

This guide covers the detailed installation and setup process for the Racktables to NetBox migration tool.

## Prerequisites

Before starting, ensure you have:

1. Python 3.6 or higher installed
2. Access to your Racktables MySQL/MariaDB database
3. A running NetBox instance (version 4.2.6 or higher) with API access
4. Administrative privileges on the NetBox instance to add custom fields

## Automated Setup (Recommended)

The tool includes a setup script that automates the installation process:

```bash
# Clone the repository
git clone https://github.com/enoch85/racktables-to-netbox.git
cd racktables-to-netbox

# Make the setup script executable
chmod +x setup_dev.sh

# Run automated setup
./setup_dev.sh
```

The `setup_dev.sh` script has several options:

- `--netbox`: Sets up a complete NetBox Docker environment with proper configuration
- `--gitclone`: Configures minimal requirements after a git clone (default if no options specified)
- `--package`: Sets up for package distribution
- `--help`: Displays help message

For a complete setup with NetBox included:

```bash
./setup_dev.sh --netbox
```

This will:
1. Set up a virtual environment
2. Install all dependencies
3. Create a NetBox Docker installation with proper configuration
4. Generate secure credentials
5. Configure NetBox with MAX_PAGE_SIZE set to 0
6. Create symlinks for development
7. Save configuration for easy use

## Quick Manual Installation

```bash
# Clone the repository
git clone https://github.com/enoch85/racktables-to-netbox.git
cd racktables-to-netbox

# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Configure connection settings in migration/config.py or use environment variables
# (See Configuration section below)

# Run the migration
python migrate.py --site "YourSiteName" # Optional site filtering
```

## Detailed Installation Steps

### 1. Clone the Repository

```bash
git clone https://github.com/enoch85/racktables-to-netbox.git
cd racktables-to-netbox
```

### 2. Set Up a Python Environment

Modern Python distributions like Ubuntu 24.04 use externally managed environments (PEP 668) which prevent installing packages directly with pip. You have two options:

#### Option A: Use a Virtual Environment (Recommended)

```bash
# Make sure you have the required packages
sudo apt install python3-full python3-venv

# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
```

#### Option B: Use pipx

If you prefer to use pipx (which manages isolated environments for applications):

```bash
# Install pipx if not already installed
sudo apt install pipx
pipx ensurepath

# Create a directory for the tool to operate in
mkdir -p ~/.local/pipx/venvs/racktables-netbox
cd ~/.local/pipx/venvs/racktables-netbox

# Clone the repository here
git clone https://github.com/enoch85/racktables-to-netbox.git .

# Install dependencies in this isolated environment
pipx run --pip-args="-r requirements.txt" python -c ""
```

### 3. Install Dependencies

With your virtual environment activated (if using Option A):

```bash
pip install -r requirements.txt
```

### 4. Configure NetBox MAX_PAGE_SIZE Setting

This setting is required for the migration tool to properly fetch all objects in a single request.

```bash
# First, edit the script to set your NetBox Docker path
nano scripts/max-page-size-check.sh

# Make the script executable
chmod +x scripts/max-page-size-check.sh

# Run the script
./scripts/max-page-size-check.sh
```

This will check if the MAX_PAGE_SIZE is already set to 0 and offer to update it if needed.

### 5. Configure Database and API Connection

Edit `migration/config.py` to set your connection parameters:

```python
# NetBox API connection settings
NB_HOST = 'localhost'
NB_PORT = 8000
NB_TOKEN = '0123456789abcdef0123456789abcdef01234567'
NB_USE_SSL = False

# Database connection parameters
DB_CONFIG = {
'host': '10.248.48.4',
'port': 3306,
'user': 'root',
'password': 'secure-password',
'db': 'test1',
'charset': 'utf8mb4',
'cursorclass': DictCursor
}
```

Alternatively, you can use environment variables:

```bash
# NetBox connection
export NETBOX_HOST=localhost
export NETBOX_PORT=8000
export NETBOX_TOKEN=0123456789abcdef0123456789abcdef01234567
export NETBOX_USE_SSL=False

# Database connection
export RACKTABLES_DB_HOST=10.248.48.4
export RACKTABLES_DB_PORT=3306
export RACKTABLES_DB_USER=root
export RACKTABLES_DB_PASSWORD=secure-password
export RACKTABLES_DB_NAME=test1
```

### 6. Run the Migration

Basic usage with a specific site:
```bash
python migrate.py --site "YourSiteName"
```

Basic usage with a specific tenant:
```bash
python migrate.py --tenant "YourTenantName"
```

Combining site and tenant filters:
```bash
python migrate.py --site "YourSiteName" --tenant "YourTenantName"
```

Other migration options:
```bash
# Run only basic migration (no extended components)
python migrate.py --basic-only

# Run only extended migration components
python migrate.py --extended-only

# Skip setting up custom fields
python migrate.py --skip-custom-fields

# Use custom configuration file
python migrate.py --config your_config.py
```

## Package Installation (Optional)

Only necessary if you want the tool available system-wide:

```bash
# Install in development mode (editable)
pip install -e .

# Or install normally
pip install .

# Then run using the command
migrate-racktables --site "YourSiteName"
```

## Troubleshooting

### Common Issues

1. **Database Connection Issues**

If you encounter database connection problems, check:
- Database credentials in `config.py`
- Network connectivity to the database server
- Database server is running and accessible
- Firewall rules allowing connections to the database port

Try connecting with a MySQL client to verify credentials.

2. **NetBox API Connection Issues**

If you have problems connecting to NetBox:
- Verify the API token is valid and has appropriate permissions
- Check network connectivity to the NetBox server
- Ensure the API is enabled in NetBox settings
- Confirm your NetBox version is 4.2.6 or higher

Test with a simple API call:
```bash
curl -H "Authorization: Token YOUR_TOKEN" http://your-netbox-host:port/api/
```

3. **Memory or Performance Issues**

If the script runs out of memory or is too slow:
- Try running parts of the migration by adjusting the boolean flags in `config.py`
- Increase your Python process memory limit if possible
- Run the script on a machine with more resources
- Consider filtering by site with the `--site` parameter
- Consider filtering by tenant with the `--tenant` parameter

## Post-Migration Verification

After migration completes, verify:

1. Device counts match between Racktables and NetBox
2. VLANs and IP prefixes are correctly defined
3. Interfaces are properly connected
4. IP addresses are correctly assigned
5. Parent-child relationships are maintained
6. Custom fields are populated with the right data
7. Tenant associations are correct (if using tenant filtering)

## Setup Script Details

The included `setup_dev.sh` script provides several useful features:

### Setting up NetBox (`--netbox`)

When run with the `--netbox` option, the script:
- Generates secure credentials for NetBox and PostgreSQL
- Clones the NetBox Docker repository
- Creates a Docker Compose override with proper settings
- Sets MAX_PAGE_SIZE=0 required for migration
- Creates admin user and API token
- Configures the migration tool to use the local NetBox

### Basic Setup (`--gitclone`)

This is the default mode and sets up:
- Python virtual environment
- Required dependencies
- Symlinks for development
- Package in development mode

### Packaging (`--package`)

Sets up the environment for creating distributable packages:
- Builds Python package
- Creates necessary packaging files
- Prepares for distribution via PyPI

## Getting Help

If you encounter issues not covered in this guide:

1. Check the error logs in the `errors` file created during migration
2. Examine the NetBox logs for API-related issues
3. Run the migration with increased verbosity
4. Open an issue on the GitHub repository with details about your problem
Loading