initial commit
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Exercise 5: VPG Operations - VPG Creation
|
||||
This script demonstrates how to create and configure a VPG.
|
||||
"""
|
||||
|
||||
import sys
|
||||
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 VPG creation.
|
||||
"""
|
||||
# Step 1: Create and authenticate ZertoClient
|
||||
# TODO: Initialize ZertoClient and authenticate
|
||||
# Hint: Reuse the authentication code from previous exercises
|
||||
|
||||
# Step 2: Get source and target sites
|
||||
# TODO: Get local site and a peer site
|
||||
# Hint: Use client.sites.get_local() and client.sites.list()
|
||||
|
||||
# Step 3: Configure VPG settings
|
||||
# TODO: Create VPG settings with required parameters
|
||||
# Required settings:
|
||||
# - VPG name
|
||||
# - Source site
|
||||
# - Target site
|
||||
# - Journal history
|
||||
# - RPO
|
||||
# - Test network
|
||||
# - Recovery network
|
||||
|
||||
# Step 4: Create the VPG
|
||||
# TODO: Create a new VPG with the configured settings
|
||||
# Hint: Use client.vpgs.create() method
|
||||
|
||||
# Step 5: Validate the VPG
|
||||
# TODO: Validate the VPG configuration
|
||||
# Hint: Use vpg.validate() method
|
||||
|
||||
# Step 6: Handle errors
|
||||
# TODO: Add error handling for VPG operations
|
||||
# Hint: Use try/except blocks for ZertoVPGError
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Exercise 5: VPG Operations - VM Management
|
||||
This script demonstrates how to manage VMs within a VPG.
|
||||
"""
|
||||
|
||||
import sys
|
||||
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 VM management in VPGs.
|
||||
"""
|
||||
# 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 manage
|
||||
# Hint: Use client.vpgs.list() and client.vpgs.get()
|
||||
|
||||
# Step 3: List current VMs in the VPG
|
||||
# TODO: Get a list of VMs currently in the VPG
|
||||
# Hint: Use vpg.get_vms() method
|
||||
|
||||
# Step 4: Add VMs to the VPG
|
||||
# TODO: Add one or more VMs to the VPG
|
||||
# Required steps:
|
||||
# - Find eligible VMs
|
||||
# - Configure VM settings
|
||||
# - Add VMs to VPG
|
||||
# Hint: Use vpg.add_vms() method
|
||||
|
||||
# Step 5: Remove VMs from the VPG
|
||||
# TODO: Remove one or more VMs from the VPG
|
||||
# Hint: Use vpg.remove_vms() method
|
||||
|
||||
# Step 6: Validate VPG after changes
|
||||
# TODO: Validate the VPG after VM changes
|
||||
# Hint: Use vpg.validate() method
|
||||
|
||||
# Step 7: Handle errors
|
||||
# TODO: Add error handling for VM operations
|
||||
# Hint: Use try/except blocks for ZertoVPGError
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user