added option to specify scratch disk parameters on the vpg level in vpg.py, updated example

This commit is contained in:
Kosta Mushkin
2025-07-25 11:49:41 -04:00
parent 4ff43b659a
commit b6325c6ce4
2 changed files with 15 additions and 5 deletions
+10 -2
View File
@@ -220,11 +220,19 @@ def main():
} }
} }
} }
scratch = {
"Limitation": {
"HardLimitInMB": 407200,
"HardLimitInPercent": 0,
"WarningThresholdInMB": 400000,
"WarningThresholdInPercent": 0
}
}
input("Press Enter to create the first VPG...") input("Press Enter to create the first VPG...")
vpg_id = client1.vpgs.create_vpg(basic=basic, journal=journal, vpg_id = client1.vpgs.create_vpg(basic=basic, journal=journal,
recovery=recovery, networks=networks, sync=True) recovery=recovery, networks=networks, scratch=scratch, sync=True)
logging.info(f"VPG ID: {vpg_id} created successfully.") logging.info(f"VPG ID: {vpg_id} created successfully.")
# Add VMs to the first VPG # Add VMs to the first VPG
+5 -3
View File
@@ -175,10 +175,10 @@ class VPGs:
logging.error(f"Unexpected error: {e}") logging.error(f"Unexpected error: {e}")
raise raise
def create_vpg(self, basic, journal, recovery, networks, sync=True, status: ZertoVPGStatus = ZertoVPGStatus.Initializing, timeout=30, interval=5): def create_vpg(self, basic, journal, recovery, networks, scratch = None, sync=True, status: ZertoVPGStatus = ZertoVPGStatus.Initializing, timeout=30, interval=5):
vpg_name = basic.get("Name") vpg_name = basic.get("Name")
logging.info(f'VPGs.create_vpg(zvm_address={self.client.zvm_address}, vpg_name={vpg_name}, sync={sync})') logging.info(f'VPGs.create_vpg(zvm_address={self.client.zvm_address}, vpg_name={vpg_name}, sync={sync})')
vpg_settings_id = self.create_vpg_settings(basic, journal, recovery, networks, vpg_identifier=None) vpg_settings_id = self.create_vpg_settings(basic, journal, recovery, networks, scratch, vpg_identifier=None)
return self.commit_vpg(vpg_settings_id, vpg_name, sync, expected_status=status, timeout=timeout, interval=interval) return self.commit_vpg(vpg_settings_id, vpg_name, sync, expected_status=status, timeout=timeout, interval=interval)
def wait_for_vpg_ready(self, vpg_name, timeout=180, interval=5, expected_status=ZertoVPGStatus.Initializing): def wait_for_vpg_ready(self, vpg_name, timeout=180, interval=5, expected_status=ZertoVPGStatus.Initializing):
@@ -624,7 +624,7 @@ class VPGs:
logging.error("HTTPError occurred with no response attached.") logging.error("HTTPError occurred with no response attached.")
raise raise
def create_vpg_settings(self, basic=None, journal=None, recovery=None, networks=None, vpg_identifier=None): def create_vpg_settings(self, basic=None, journal=None, recovery=None, networks=None, scratch=None, vpg_identifier=None):
logging.info(f'VPGs.create_vpg_settings(zvm_address={self.client.zvm_address}, vpg_identifier={vpg_identifier})') logging.info(f'VPGs.create_vpg_settings(zvm_address={self.client.zvm_address}, vpg_identifier={vpg_identifier})')
vpg_settings_uri = f"https://{self.client.zvm_address}/v1/vpgSettings" vpg_settings_uri = f"https://{self.client.zvm_address}/v1/vpgSettings"
headers = { headers = {
@@ -643,6 +643,8 @@ class VPGs:
payload["Recovery"] = recovery payload["Recovery"] = recovery
if networks: if networks:
payload["Networks"] = networks payload["Networks"] = networks
if scratch:
payload["Scratch"] = scratch
logging.debug(f"VPGs.create_vpg_settings: Payload: {json.dumps(payload, indent=4)}") logging.debug(f"VPGs.create_vpg_settings: Payload: {json.dumps(payload, indent=4)}")
try: try: