74 lines
2.0 KiB
Python
74 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Exercise 6: Failover Testing
|
|
This script demonstrates how to perform and manage failover tests.
|
|
"""
|
|
|
|
import sys
|
|
import time
|
|
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 main():
|
|
"""
|
|
Main function to demonstrate failover testing.
|
|
"""
|
|
# Step 1: Create and authenticate ZertoClient
|
|
# TODO: Initialize ZertoClient and authenticate
|
|
# Hint: Reuse the authentication code from previous exercises
|
|
|
|
# Step 2: Get the VPG
|
|
# TODO: Find and get the VPG you want to test
|
|
# Hint: Use client.vpgs.list() and client.vpgs.get()
|
|
|
|
# Step 3: Initiate failover test
|
|
# TODO: Start a failover test for the VPG
|
|
# Required steps:
|
|
# - Configure test settings
|
|
# - Start the test
|
|
# Hint: Use vpg.start_test() method
|
|
|
|
# Step 4: Monitor test progress
|
|
# TODO: Monitor the test status until completion
|
|
# Required steps:
|
|
# - Get test status
|
|
# - Check for completion
|
|
# - Handle any errors
|
|
# Hint: Use vpg.get_test_status() method
|
|
|
|
# Step 5: Stop the test
|
|
# TODO: Stop the running test
|
|
# Hint: Use vpg.stop_test() method
|
|
|
|
# Step 6: Clean up
|
|
# TODO: Ensure proper cleanup after the test
|
|
# Hint: Check if any cleanup is needed
|
|
|
|
# Step 7: Handle errors
|
|
# TODO: Add error handling for test operations
|
|
# Hint: Use try/except blocks for ZertoVPGError
|
|
|
|
if __name__ == "__main__":
|
|
main() |