first full version of the exersises

This commit is contained in:
Kosta Mushkin
2025-05-29 19:19:25 -04:00
parent 3a075e5ecf
commit 4690e82e58
15 changed files with 1707 additions and 480 deletions
+120 -47
View File
@@ -1,57 +1,130 @@
# Exercise 7: Bulk Operations
# Exercise 7: Bulk VPG NIC Settings Management
## Overview
This final exercise covers bulk operations, focusing on managing multiple VMs efficiently. You'll learn how to perform operations on multiple VMs simultaneously.
## Objectives
- Perform bulk IP modifications
- Manage multiple VMs
- Handle bulk operations efficiently
- Monitor bulk task progress
## Time
5 minutes
This exercise demonstrates how to perform bulk operations on VPG NIC settings using two provided scripts:
1. `export_vpg_settings_nics_to_csv.py` - Exports current VPG NIC settings to a CSV file
2. `import_vpg_settings_nics_from_csv.py` - Imports and applies NIC settings from a CSV file
## Prerequisites
- Completed Exercise 6
- Working VPGs with multiple VMs
- Access to VM management
## Exercise Steps
1. Prepare VM list
2. Configure bulk operations
3. Execute bulk IP changes
4. Monitor operation progress
5. Verify changes
1. Python 3.6 or higher
2. Zerto Python SDK (`zvml` package) installed in development mode:
```bash
cd /path/to/zvml-python-sdk
pip install -e .
```
3. Access to a Zerto Virtual Manager (ZVM) with appropriate permissions
4. VPGs already created and configured in your environment
## Working Directory
The `working` directory contains:
- `bulk_ip.py` - Template to complete
- `vm_list.csv` - Sample VM list
## Exercise Overview
## Solution
The `solution` directory contains:
- `bulk_ip.py` - Complete working example
- `vm_list.csv` - Example VM list
This exercise will guide you through the process of:
1. Exporting current VPG NIC settings to a CSV file
2. Modifying the CSV file to update IP configurations
3. Importing and applying the updated settings back to the VPGs
## Key Concepts
- Bulk operations
- IP management
- Task monitoring
- Error handling
## Step 1: Export Current VPG Settings
## Common Issues
- Invalid IP configurations
- Operation timeouts
- Partial failures
- Resource constraints
Use the export script to save current VPG NIC settings to a CSV file:
## Lab Completion
Congratulations! You have completed all exercises in the Zerto Python SDK Hands-On Lab. You should now have a good understanding of:
- Zerto API basics
- Authentication and connection
- Site and resource management
- VPG operations
- Testing and bulk operations
```bash
python export_vpg_settings_nics_to_csv.py \
--zvm_address "192.168.111.20" \
--client_id "zerto-api" \
--client_secret "your-secret-here" \
--vpg_names "VpgTest1,VpgTest2" \
--ignore_ssl
```
Please complete the feedback form to help us improve the lab content.
The script will create two files:
- `ExportedSettings_[timestamp].json` - Full VPG settings in JSON format
- `ExportedSettings_[timestamp].csv` - NIC settings in CSV format
## Step 2: Modify the CSV File
Open the generated CSV file in a spreadsheet application (e.g., Microsoft Excel, Google Sheets) and modify the following settings as needed:
1. **Failover Network Settings**:
- `Failover ShouldReplaceIpConfiguration` - Set to "True" to modify IP settings
- `Failover Network` - Network identifier for failover
- `Failover DHCP` - Set to "True" for DHCP or "False" for static IP
- `Failover IP` - Static IP address (required if DHCP is False)
- `Failover Subnet` - Subnet mask (required if DHCP is False)
- `Failover Gateway` - Default gateway (optional)
- `Failover DNS1` - Primary DNS server (optional)
- `Failover DNS2` - Secondary DNS server (optional)
2. **Failover Test Network Settings**:
- `Failover Test ShouldReplaceIpConfiguration` - Set to "True" to modify IP settings
- `Failover Test Network` - Network identifier for test failover
- `Failover Test DHCP` - Set to "True" for DHCP or "False" for static IP
- `Failover Test IP` - Static IP address (required if DHCP is False)
- `Failover Test Subnet` - Subnet mask (required if DHCP is False)
- `Failover Test Gateway` - Default gateway (optional)
- `Failover Test DNS1` - Primary DNS server (optional)
- `Failover Test DNS2` - Secondary DNS server (optional)
## Step 3: Import Updated Settings
Use the import script to apply the modified settings:
```bash
python import_vpg_settings_nics_from_csv.py \
--zvm_address "192.168.111.20" \
--client_id "zerto-api" \
--client_secret "your-secret-here" \
--csv_file "ExportedSettings_2024-03-14_12-34-56.csv" \
--vpg_names "VpgTest1,VpgTest2" \
--ignore_ssl
```
The script will:
1. Validate the settings in the CSV file
2. Show a summary of changes to be applied
3. Ask for confirmation before applying changes
4. Apply the changes and commit them to the VPGs
## Important Notes
1. **Backup**: Always keep a backup of the original CSV file before making changes
2. **Validation**: The import script validates settings before applying them:
- Checks for conflicting DHCP and static IP settings
- Verifies required fields are present
- Ensures network identifiers are valid
3. **Safety**: The script requires explicit confirmation before applying changes
4. **Rollback**: If needed, you can re-import the original settings from the backup CSV
## Common Use Cases
1. **Bulk IP Address Changes**:
- Export current settings
- Update IP addresses in the CSV
- Import modified settings
2. **Network Migration**:
- Export current settings
- Update network identifiers
- Import modified settings
3. **DHCP to Static IP Conversion**:
- Export current settings
- Set `ShouldReplaceIpConfiguration` to "True"
- Set `DHCP` to "False"
- Add static IP settings
- Import modified settings
## Troubleshooting
1. **Validation Errors**:
- Ensure `ShouldReplaceIpConfiguration` is set to "True" when modifying IP settings
- Check that DHCP and static IP settings are not conflicting
- Verify all required fields are filled when using static IP
2. **Import Failures**:
- Verify network identifiers exist in the target site
- Check that IP addresses are in the correct format
- Ensure you have sufficient permissions on the ZVM
3. **CSV Format Issues**:
- Keep the original column headers
- Don't modify the `VPG Name`, `VM Identifier`, or `NIC Identifier` columns
- Use "True" or "False" (case-insensitive) for boolean values