Spaces:
Sleeping
Sleeping
Graham Paasch commited on
Commit ·
b25bf68
1
Parent(s): 6d91bcf
docs: Stage 6 Quick Start Guide
Browse files- Created STAGE6_QUICKSTART.md with practical examples
- Installation verification (23/23 tests passing)
- CLI usage examples for GNS3 deployment script
- Programmatic API examples
- Troubleshooting guide
- Next steps for real device testing
- STAGE6_QUICKSTART.md +312 -0
STAGE6_QUICKSTART.md
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Stage 6 - Quick Start Guide
|
| 2 |
+
|
| 3 |
+
## ✅ Installation Complete
|
| 4 |
+
|
| 5 |
+
**Libraries Installed:**
|
| 6 |
+
```bash
|
| 7 |
+
pip install netmiko>=4.0.0 napalm>=5.0.0 jinja2>=3.1.0
|
| 8 |
+
```
|
| 9 |
+
|
| 10 |
+
**Test Results:** ✅ 23/23 tests passing
|
| 11 |
+
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
## 🚀 Quick Start Examples
|
| 15 |
+
|
| 16 |
+
### 1. List Available Devices
|
| 17 |
+
```bash
|
| 18 |
+
python examples/deploy_to_gns3_lab.py --list
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
### 2. Dry-Run Deployment (Safe Testing)
|
| 22 |
+
```bash
|
| 23 |
+
# Test single device (no changes made)
|
| 24 |
+
python examples/deploy_to_gns3_lab.py --device R1 --dry-run
|
| 25 |
+
|
| 26 |
+
# Test all devices
|
| 27 |
+
python examples/deploy_to_gns3_lab.py --all --dry-run
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
### 3. Production Deployment
|
| 31 |
+
```bash
|
| 32 |
+
# Deploy to single device (REAL CHANGES!)
|
| 33 |
+
python examples/deploy_to_gns3_lab.py --device R1 --production
|
| 34 |
+
|
| 35 |
+
# Deploy to all devices
|
| 36 |
+
python examples/deploy_to_gns3_lab.py --all --production
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
### 4. Custom Credentials
|
| 40 |
+
```bash
|
| 41 |
+
python examples/deploy_to_gns3_lab.py --device SW1 \
|
| 42 |
+
--username admin \
|
| 43 |
+
--password mysecret \
|
| 44 |
+
--dry-run
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## 📝 Before First Deployment
|
| 50 |
+
|
| 51 |
+
### Update Device Inventory
|
| 52 |
+
|
| 53 |
+
Edit `examples/deploy_to_gns3_lab.py` and update the `GNS3_DEVICES` list with your actual device IPs:
|
| 54 |
+
|
| 55 |
+
```python
|
| 56 |
+
GNS3_DEVICES = [
|
| 57 |
+
{
|
| 58 |
+
'name': 'R1',
|
| 59 |
+
'hostname': '192.168.1.1', # ← UPDATE THIS
|
| 60 |
+
'device_type': DeviceType.CISCO_IOS,
|
| 61 |
+
'vendor': 'cisco',
|
| 62 |
+
'model': '7200',
|
| 63 |
+
'role': 'router',
|
| 64 |
+
'description': 'Core Router 1'
|
| 65 |
+
},
|
| 66 |
+
# ... add more devices
|
| 67 |
+
]
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
### Find Your GNS3 Device IPs
|
| 71 |
+
|
| 72 |
+
**Option 1 - From GNS3 Web UI:**
|
| 73 |
+
1. Go to http://lab.grahampaasch.com:3080
|
| 74 |
+
2. Open the "overgrowth" project
|
| 75 |
+
3. Right-click each device → "Console"
|
| 76 |
+
4. Run `show ip interface brief` to get management IP
|
| 77 |
+
|
| 78 |
+
**Option 2 - Use GNS3 API:**
|
| 79 |
+
```bash
|
| 80 |
+
# List all nodes in project
|
| 81 |
+
curl http://lab.grahampaasch.com:3080/v2/projects
|
| 82 |
+
|
| 83 |
+
# Get device details
|
| 84 |
+
curl http://lab.grahampaasch.com:3080/v2/projects/<project-id>/nodes
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
---
|
| 88 |
+
|
| 89 |
+
## 🧪 Run Tests
|
| 90 |
+
|
| 91 |
+
```bash
|
| 92 |
+
# Run all Stage 6 tests
|
| 93 |
+
python -m pytest tests/test_deployment_engine.py -v
|
| 94 |
+
|
| 95 |
+
# Run specific test
|
| 96 |
+
python -m pytest tests/test_deployment_engine.py::TestDeviceDriver::test_cisco_ios_connection -v
|
| 97 |
+
|
| 98 |
+
# Run with detailed output
|
| 99 |
+
python tests/test_deployment_engine.py
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
---
|
| 103 |
+
|
| 104 |
+
## 🔧 Programmatic Usage
|
| 105 |
+
|
| 106 |
+
### Example 1: Deploy with Template
|
| 107 |
+
```python
|
| 108 |
+
from agent.deployment_engine import DeploymentEngine
|
| 109 |
+
from agent.device_driver import DeviceType
|
| 110 |
+
|
| 111 |
+
engine = DeploymentEngine(use_napalm=True)
|
| 112 |
+
|
| 113 |
+
device = {
|
| 114 |
+
'name': 'SW1',
|
| 115 |
+
'vendor': 'cisco',
|
| 116 |
+
'model': 'catalyst',
|
| 117 |
+
'role': 'switch',
|
| 118 |
+
'mgmt_ip': '192.168.1.10',
|
| 119 |
+
'interfaces': []
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
network_context = {
|
| 123 |
+
'vlans': [
|
| 124 |
+
{'id': 10, 'name': 'Data'},
|
| 125 |
+
{'id': 20, 'name': 'Voice'}
|
| 126 |
+
],
|
| 127 |
+
'domain_name': 'lab.local',
|
| 128 |
+
'ntp_servers': ['192.168.1.1'],
|
| 129 |
+
'dns_servers': ['8.8.8.8', '8.8.4.4']
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
credentials = {
|
| 133 |
+
'username': 'admin',
|
| 134 |
+
'password': 'cisco',
|
| 135 |
+
'device_type': DeviceType.CISCO_IOS
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
# Generate config from template and deploy
|
| 139 |
+
result = engine.generate_and_deploy(
|
| 140 |
+
device=device,
|
| 141 |
+
network_context=network_context,
|
| 142 |
+
credentials=credentials,
|
| 143 |
+
dry_run=True, # Set to False for production
|
| 144 |
+
pre_checks=['command:show version'],
|
| 145 |
+
post_checks=['interface:GigabitEthernet0/1']
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
print(f"Status: {result.status.value}")
|
| 149 |
+
print(f"Config deployed: {len(result.config_deployed)} chars")
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
### Example 2: Deploy Custom Config
|
| 153 |
+
```python
|
| 154 |
+
from agent.deployment_engine import DeploymentEngine, DeploymentTask
|
| 155 |
+
from agent.device_driver import DeviceType
|
| 156 |
+
|
| 157 |
+
engine = DeploymentEngine(use_napalm=True)
|
| 158 |
+
|
| 159 |
+
config = """
|
| 160 |
+
hostname R1
|
| 161 |
+
!
|
| 162 |
+
interface GigabitEthernet0/0
|
| 163 |
+
ip address 10.0.0.1 255.255.255.252
|
| 164 |
+
no shutdown
|
| 165 |
+
!
|
| 166 |
+
router ospf 1
|
| 167 |
+
network 10.0.0.0 0.0.0.3 area 0
|
| 168 |
+
!
|
| 169 |
+
end
|
| 170 |
+
"""
|
| 171 |
+
|
| 172 |
+
task = DeploymentTask(
|
| 173 |
+
device_id="R1",
|
| 174 |
+
device_type=DeviceType.CISCO_IOS,
|
| 175 |
+
hostname="192.168.1.1",
|
| 176 |
+
username="admin",
|
| 177 |
+
password="cisco",
|
| 178 |
+
config=config,
|
| 179 |
+
dry_run=False, # Production deployment
|
| 180 |
+
pre_checks=["ping:192.168.1.1"],
|
| 181 |
+
post_checks=["command:show ip interface brief"]
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
result = engine.deploy_single_device(task)
|
| 185 |
+
```
|
| 186 |
+
|
| 187 |
+
### Example 3: Deploy to Multiple Devices
|
| 188 |
+
```python
|
| 189 |
+
from agent.deployment_engine import DeploymentEngine, DeploymentTask
|
| 190 |
+
from agent.device_driver import DeviceType
|
| 191 |
+
|
| 192 |
+
engine = DeploymentEngine(use_napalm=True)
|
| 193 |
+
|
| 194 |
+
tasks = [
|
| 195 |
+
DeploymentTask(
|
| 196 |
+
device_id="R1",
|
| 197 |
+
device_type=DeviceType.CISCO_IOS,
|
| 198 |
+
hostname="192.168.1.1",
|
| 199 |
+
username="admin",
|
| 200 |
+
password="cisco",
|
| 201 |
+
config="hostname R1",
|
| 202 |
+
dry_run=True
|
| 203 |
+
),
|
| 204 |
+
DeploymentTask(
|
| 205 |
+
device_id="R2",
|
| 206 |
+
device_type=DeviceType.CISCO_IOS,
|
| 207 |
+
hostname="192.168.1.2",
|
| 208 |
+
username="admin",
|
| 209 |
+
password="cisco",
|
| 210 |
+
config="hostname R2",
|
| 211 |
+
dry_run=True
|
| 212 |
+
),
|
| 213 |
+
]
|
| 214 |
+
|
| 215 |
+
results = engine.deploy_multiple_devices(tasks, parallel=False)
|
| 216 |
+
|
| 217 |
+
for result in results:
|
| 218 |
+
print(f"{result.device_id}: {result.status.value}")
|
| 219 |
+
```
|
| 220 |
+
|
| 221 |
+
---
|
| 222 |
+
|
| 223 |
+
## 📚 Available Templates
|
| 224 |
+
|
| 225 |
+
1. **cisco_ios_l2_switch** - Cisco IOS L2 access switch
|
| 226 |
+
2. **cisco_ios_l3_router** - Cisco IOS L3 router with routing
|
| 227 |
+
3. **cisco_ios_router** - Basic Cisco IOS router
|
| 228 |
+
4. **arista_eos** - Arista EOS switch/router
|
| 229 |
+
5. **juniper_junos** - Juniper JunOS device
|
| 230 |
+
|
| 231 |
+
See `DEPLOYMENT_GUIDE.md` for template details and variables.
|
| 232 |
+
|
| 233 |
+
---
|
| 234 |
+
|
| 235 |
+
## 🔍 Validation Checks
|
| 236 |
+
|
| 237 |
+
### Pre-Deployment Checks (before config is applied)
|
| 238 |
+
- `ping:192.168.1.1` - Verify device is reachable
|
| 239 |
+
- `command:show version` - Verify device responds
|
| 240 |
+
- `interface:GigabitEthernet0/1` - Check interface exists
|
| 241 |
+
|
| 242 |
+
### Post-Deployment Checks (after config is applied)
|
| 243 |
+
- `command:show running-config | include hostname` - Verify config
|
| 244 |
+
- `interface:Vlan10` - Verify new VLAN interface exists
|
| 245 |
+
- `ping:10.0.0.1` - Verify routing works
|
| 246 |
+
|
| 247 |
+
---
|
| 248 |
+
|
| 249 |
+
## ⚠️ Troubleshooting
|
| 250 |
+
|
| 251 |
+
### Connection Timeout
|
| 252 |
+
```
|
| 253 |
+
ERROR - Cannot connect to 192.168.1.1
|
| 254 |
+
```
|
| 255 |
+
**Solution:**
|
| 256 |
+
- Verify device IP is correct
|
| 257 |
+
- Check device is powered on in GNS3
|
| 258 |
+
- Verify SSH is enabled: `ip ssh version 2`
|
| 259 |
+
- Check firewall/network connectivity
|
| 260 |
+
|
| 261 |
+
### Authentication Failed
|
| 262 |
+
```
|
| 263 |
+
ERROR - Authentication failed
|
| 264 |
+
```
|
| 265 |
+
**Solution:**
|
| 266 |
+
- Verify username/password are correct
|
| 267 |
+
- Check device AAA configuration
|
| 268 |
+
- Try with enable password: `credentials={'secret': 'enable-password'}`
|
| 269 |
+
|
| 270 |
+
### Template Not Found
|
| 271 |
+
```
|
| 272 |
+
WARNING - No specific template for vendor model
|
| 273 |
+
```
|
| 274 |
+
**Solution:**
|
| 275 |
+
- Check device vendor/model fields
|
| 276 |
+
- Use explicit template: `engine.render_template('cisco_ios_l2_switch', context)`
|
| 277 |
+
|
| 278 |
+
### Dry-Run Mode Not Working
|
| 279 |
+
**Solution:** Dry-run is enabled by default for safety. Use `--production` flag to actually deploy.
|
| 280 |
+
|
| 281 |
+
---
|
| 282 |
+
|
| 283 |
+
## 📖 Next Steps
|
| 284 |
+
|
| 285 |
+
1. **Update Device IPs** in `examples/deploy_to_gns3_lab.py`
|
| 286 |
+
2. **Run Dry-Run Test** to verify connectivity
|
| 287 |
+
3. **Deploy to Test Device** (one device first)
|
| 288 |
+
4. **Verify Deployment** via console or SSH
|
| 289 |
+
5. **Deploy to Remaining Devices**
|
| 290 |
+
6. **Setup Rollback Testing** (Todo #4)
|
| 291 |
+
7. **Test Parallel Deployment** (Todo #5)
|
| 292 |
+
|
| 293 |
+
---
|
| 294 |
+
|
| 295 |
+
## 🎯 Current Status
|
| 296 |
+
|
| 297 |
+
✅ **Todo 1:** Install netmiko, napalm, jinja2
|
| 298 |
+
✅ **Todo 2:** Create test suite (23/23 passing)
|
| 299 |
+
🔄 **Todo 3:** Test with GNS3 lab devices (ready - need to update IPs)
|
| 300 |
+
⏳ **Todo 4:** Verify rollback functionality
|
| 301 |
+
⏳ **Todo 5:** Test parallel deployment
|
| 302 |
+
|
| 303 |
+
---
|
| 304 |
+
|
| 305 |
+
## 📞 Support
|
| 306 |
+
|
| 307 |
+
- **Full Documentation:** `DEPLOYMENT_GUIDE.md`
|
| 308 |
+
- **Test Suite:** `tests/test_deployment_engine.py`
|
| 309 |
+
- **Example Script:** `examples/deploy_to_gns3_lab.py`
|
| 310 |
+
- **Source Code:** `agent/deployment_engine.py`, `agent/device_driver.py`, `agent/config_templates.py`
|
| 311 |
+
|
| 312 |
+
**For questions, check the test suite - it demonstrates all features!**
|