Spaces:
Sleeping
Sleeping
Stage 6 - Quick Start Guide
✅ Installation Complete
Libraries Installed:
pip install netmiko>=4.0.0 napalm>=5.0.0 jinja2>=3.1.0
Test Results: ✅ 23/23 tests passing
🚀 Quick Start Examples
1. List Available Devices
python examples/deploy_to_gns3_lab.py --list
2. Dry-Run Deployment (Safe Testing)
# Test single device (no changes made)
python examples/deploy_to_gns3_lab.py --device R1 --dry-run
# Test all devices
python examples/deploy_to_gns3_lab.py --all --dry-run
3. Production Deployment
# Deploy to single device (REAL CHANGES!)
python examples/deploy_to_gns3_lab.py --device R1 --production
# Deploy to all devices
python examples/deploy_to_gns3_lab.py --all --production
4. Custom Credentials
python examples/deploy_to_gns3_lab.py --device SW1 \
--username admin \
--password mysecret \
--dry-run
📝 Before First Deployment
Update Device Inventory
Edit examples/deploy_to_gns3_lab.py and update the GNS3_DEVICES list with your actual device IPs:
GNS3_DEVICES = [
{
'name': 'R1',
'hostname': '192.168.1.1', # ← UPDATE THIS
'device_type': DeviceType.CISCO_IOS,
'vendor': 'cisco',
'model': '7200',
'role': 'router',
'description': 'Core Router 1'
},
# ... add more devices
]
Find Your GNS3 Device IPs
Option 1 - From GNS3 Web UI:
- Go to http://lab.grahampaasch.com:3080
- Open the "overgrowth" project
- Right-click each device → "Console"
- Run
show ip interface briefto get management IP
Option 2 - Use GNS3 API:
# List all nodes in project
curl http://lab.grahampaasch.com:3080/v2/projects
# Get device details
curl http://lab.grahampaasch.com:3080/v2/projects/<project-id>/nodes
🧪 Run Tests
# Run all Stage 6 tests
python -m pytest tests/test_deployment_engine.py -v
# Run specific test
python -m pytest tests/test_deployment_engine.py::TestDeviceDriver::test_cisco_ios_connection -v
# Run with detailed output
python tests/test_deployment_engine.py
🔧 Programmatic Usage
Example 1: Deploy with Template
from agent.deployment_engine import DeploymentEngine
from agent.device_driver import DeviceType
engine = DeploymentEngine(use_napalm=True)
device = {
'name': 'SW1',
'vendor': 'cisco',
'model': 'catalyst',
'role': 'switch',
'mgmt_ip': '192.168.1.10',
'interfaces': []
}
network_context = {
'vlans': [
{'id': 10, 'name': 'Data'},
{'id': 20, 'name': 'Voice'}
],
'domain_name': 'lab.local',
'ntp_servers': ['192.168.1.1'],
'dns_servers': ['8.8.8.8', '8.8.4.4']
}
credentials = {
'username': 'admin',
'password': 'cisco',
'device_type': DeviceType.CISCO_IOS
}
# Generate config from template and deploy
result = engine.generate_and_deploy(
device=device,
network_context=network_context,
credentials=credentials,
dry_run=True, # Set to False for production
pre_checks=['command:show version'],
post_checks=['interface:GigabitEthernet0/1']
)
print(f"Status: {result.status.value}")
print(f"Config deployed: {len(result.config_deployed)} chars")
Example 2: Deploy Custom Config
from agent.deployment_engine import DeploymentEngine, DeploymentTask
from agent.device_driver import DeviceType
engine = DeploymentEngine(use_napalm=True)
config = """
hostname R1
!
interface GigabitEthernet0/0
ip address 10.0.0.1 255.255.255.252
no shutdown
!
router ospf 1
network 10.0.0.0 0.0.0.3 area 0
!
end
"""
task = DeploymentTask(
device_id="R1",
device_type=DeviceType.CISCO_IOS,
hostname="192.168.1.1",
username="admin",
password="cisco",
config=config,
dry_run=False, # Production deployment
pre_checks=["ping:192.168.1.1"],
post_checks=["command:show ip interface brief"]
)
result = engine.deploy_single_device(task)
Example 3: Deploy to Multiple Devices
from agent.deployment_engine import DeploymentEngine, DeploymentTask
from agent.device_driver import DeviceType
engine = DeploymentEngine(use_napalm=True)
tasks = [
DeploymentTask(
device_id="R1",
device_type=DeviceType.CISCO_IOS,
hostname="192.168.1.1",
username="admin",
password="cisco",
config="hostname R1",
dry_run=True
),
DeploymentTask(
device_id="R2",
device_type=DeviceType.CISCO_IOS,
hostname="192.168.1.2",
username="admin",
password="cisco",
config="hostname R2",
dry_run=True
),
]
results = engine.deploy_multiple_devices(tasks, parallel=False)
for result in results:
print(f"{result.device_id}: {result.status.value}")
📚 Available Templates
- cisco_ios_l2_switch - Cisco IOS L2 access switch
- cisco_ios_l3_router - Cisco IOS L3 router with routing
- cisco_ios_router - Basic Cisco IOS router
- arista_eos - Arista EOS switch/router
- juniper_junos - Juniper JunOS device
See DEPLOYMENT_GUIDE.md for template details and variables.
🔍 Validation Checks
Pre-Deployment Checks (before config is applied)
ping:192.168.1.1- Verify device is reachablecommand:show version- Verify device respondsinterface:GigabitEthernet0/1- Check interface exists
Post-Deployment Checks (after config is applied)
command:show running-config | include hostname- Verify configinterface:Vlan10- Verify new VLAN interface existsping:10.0.0.1- Verify routing works
⚠️ Troubleshooting
Connection Timeout
ERROR - Cannot connect to 192.168.1.1
Solution:
- Verify device IP is correct
- Check device is powered on in GNS3
- Verify SSH is enabled:
ip ssh version 2 - Check firewall/network connectivity
Authentication Failed
ERROR - Authentication failed
Solution:
- Verify username/password are correct
- Check device AAA configuration
- Try with enable password:
credentials={'secret': 'enable-password'}
Template Not Found
WARNING - No specific template for vendor model
Solution:
- Check device vendor/model fields
- Use explicit template:
engine.render_template('cisco_ios_l2_switch', context)
Dry-Run Mode Not Working
Solution: Dry-run is enabled by default for safety. Use --production flag to actually deploy.
📖 Next Steps
- Update Device IPs in
examples/deploy_to_gns3_lab.py - Run Dry-Run Test to verify connectivity
- Deploy to Test Device (one device first)
- Verify Deployment via console or SSH
- Deploy to Remaining Devices
- Setup Rollback Testing (Todo #4)
- Test Parallel Deployment (Todo #5)
🎯 Current Status
✅ Todo 1: Install netmiko, napalm, jinja2
✅ Todo 2: Create test suite (23/23 passing)
🔄 Todo 3: Test with GNS3 lab devices (ready - need to update IPs)
⏳ Todo 4: Verify rollback functionality
⏳ Todo 5: Test parallel deployment
📞 Support
- Full Documentation:
DEPLOYMENT_GUIDE.md - Test Suite:
tests/test_deployment_engine.py - Example Script:
examples/deploy_to_gns3_lab.py - Source Code:
agent/deployment_engine.py,agent/device_driver.py,agent/config_templates.py
For questions, check the test suite - it demonstrates all features!