initial commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
# Exercise 7: Bulk Operations
|
||||
|
||||
## 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
|
||||
|
||||
## 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
|
||||
|
||||
## Working Directory
|
||||
The `working` directory contains:
|
||||
- `bulk_ip.py` - Template to complete
|
||||
- `vm_list.csv` - Sample VM list
|
||||
|
||||
## Solution
|
||||
The `solution` directory contains:
|
||||
- `bulk_ip.py` - Complete working example
|
||||
- `vm_list.csv` - Example VM list
|
||||
|
||||
## Key Concepts
|
||||
- Bulk operations
|
||||
- IP management
|
||||
- Task monitoring
|
||||
- Error handling
|
||||
|
||||
## Common Issues
|
||||
- Invalid IP configurations
|
||||
- Operation timeouts
|
||||
- Partial failures
|
||||
- Resource constraints
|
||||
|
||||
## 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
|
||||
|
||||
Please complete the feedback form to help us improve the lab content.
|
||||
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Exercise 7: Bulk Operations
|
||||
This script demonstrates how to perform bulk IP modifications on multiple VMs.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import csv
|
||||
from pathlib import Path
|
||||
|
||||
# Add the parent directory to the Python path to import the SDK
|
||||
sys.path.append(str(Path(__file__).parent.parent.parent.parent))
|
||||
|
||||
# Import the SDK modules
|
||||
from zvml import ZertoClient
|
||||
from zvml.vpgs import VPG
|
||||
from zvml.common import ZertoVPGError
|
||||
|
||||
# Import configuration
|
||||
try:
|
||||
from prerequisites.config import (
|
||||
ZVM_HOST,
|
||||
ZVM_PORT,
|
||||
ZVM_SSL_VERIFY,
|
||||
KEYCLOAK_SERVER_URL,
|
||||
KEYCLOAK_REALM,
|
||||
CLIENT_ID,
|
||||
CLIENT_SECRET
|
||||
)
|
||||
except ImportError:
|
||||
print("Error: Please copy config.example.py to config.py and update with your values")
|
||||
sys.exit(1)
|
||||
|
||||
def read_vm_list(csv_file):
|
||||
"""
|
||||
Read VM list from CSV file.
|
||||
Expected format: vm_name,ip_address,subnet_mask,gateway
|
||||
"""
|
||||
# TODO: Implement CSV reading
|
||||
# Hint: Use csv.DictReader
|
||||
pass
|
||||
|
||||
def main():
|
||||
"""
|
||||
Main function to demonstrate bulk IP operations.
|
||||
"""
|
||||
# Step 1: Create and authenticate ZertoClient
|
||||
# TODO: Initialize ZertoClient and authenticate
|
||||
# Hint: Reuse the authentication code from previous exercises
|
||||
|
||||
# Step 2: Read VM list
|
||||
# TODO: Read the VM list from CSV file
|
||||
# Hint: Use the read_vm_list function
|
||||
|
||||
# Step 3: Get VPG
|
||||
# TODO: Find and get the VPG containing the VMs
|
||||
# Hint: Use client.vpgs.list() and client.vpgs.get()
|
||||
|
||||
# Step 4: Prepare IP changes
|
||||
# TODO: Prepare the IP modification data
|
||||
# Required for each VM:
|
||||
# - VM identifier
|
||||
# - New IP settings
|
||||
# - Network information
|
||||
|
||||
# Step 5: Apply IP changes
|
||||
# TODO: Apply the IP changes to all VMs
|
||||
# Hint: Use vpg.modify_vm_ips() method
|
||||
|
||||
# Step 6: Monitor progress
|
||||
# TODO: Monitor the bulk operation progress
|
||||
# Required steps:
|
||||
# - Track operation status
|
||||
# - Handle any failures
|
||||
# - Report results
|
||||
|
||||
# Step 7: Handle errors
|
||||
# TODO: Add error handling for bulk operations
|
||||
# Hint: Use try/except blocks for ZertoVPGError
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,6 @@
|
||||
vm_name,ip_address,subnet_mask,gateway
|
||||
vm-001,192.168.1.101,255.255.255.0,192.168.1.1
|
||||
vm-002,192.168.1.102,255.255.255.0,192.168.1.1
|
||||
vm-003,192.168.1.103,255.255.255.0,192.168.1.1
|
||||
vm-004,192.168.1.104,255.255.255.0,192.168.1.1
|
||||
vm-005,192.168.1.105,255.255.255.0,192.168.1.1
|
||||
|
Reference in New Issue
Block a user