From fac6ee194159e4394a98e247dc2011339ca5278c Mon Sep 17 00:00:00 2001 From: Chris Rasmussen Date: Mon, 30 Sep 2024 11:55:29 +1000 Subject: [PATCH] Push latest version updates --- python/v4api_sdk/.gitignore | 1 + python/v4api_sdk/create_image_sdk.py | 80 ++++++++++++++-------------- python/v4api_sdk/subnet_config.json | 4 +- 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/python/v4api_sdk/.gitignore b/python/v4api_sdk/.gitignore index fadf244..fa9708e 100644 --- a/python/v4api_sdk/.gitignore +++ b/python/v4api_sdk/.gitignore @@ -11,3 +11,4 @@ build/ dist/ *.egg-info/ eslint.config.mjs +ntnx_opsmgmt_py_client/ diff --git a/python/v4api_sdk/create_image_sdk.py b/python/v4api_sdk/create_image_sdk.py index 07977b2..5173ec0 100644 --- a/python/v4api_sdk/create_image_sdk.py +++ b/python/v4api_sdk/create_image_sdk.py @@ -40,16 +40,16 @@ def main(): parser.add_argument("pc_ip", help="Prism Central IP address or FQDN") parser.add_argument("username", help="Prism Central username") parser.add_argument( - "-p", "--poll", help="Time between task polling, in seconds", default=1 - ) + "-p", "--poll", help="Time between task polling, in seconds", default=1 + ) args = parser.parse_args() # get the cluster password cluster_password = getpass.getpass( - prompt="Please enter your Prism Central \ -password: ", - stream=None, - ) + prompt="Please enter your Prism Central \ + password: ", + stream=None, + ) pc_ip = args.pc_ip username = args.username @@ -59,12 +59,12 @@ def main(): if not cluster_password: while not cluster_password: print( - "Password cannot be empty. \ - Please enter a password or Ctrl-C/Ctrl-D to exit." - ) + "Password cannot be empty. \ + Please enter a password or Ctrl-C/Ctrl-D to exit." + ) cluster_password = getpass.getpass( - prompt="Please enter your Prism Central password: ", stream=None - ) + prompt="Please enter your Prism Central password: ", stream=None + ) try: # create utils instance for re-use later @@ -93,26 +93,26 @@ def main(): if not cluster.name == "Unnamed": found_clusters.append({"name": cluster.name, "ext_id": cluster.ext_id}) print( - f"The following clusters ({len(cluster_list.data)-1}) were found, not including Prism Central." - ) + f"The following clusters ({len(cluster_list.data)-1}) were found, not including Prism Central." + ) print( - "Note: By default Prism Central clusters appear as 'Unnamed'. Clusters matching this name have \ -not been included in this list." - ) + "Note: By default Prism Central clusters appear as 'Unnamed'. Clusters matching this name have \ + not been included in this list." + ) pprint(found_clusters) expected_cluster_name = input( - "\nPlease enter the name of the destination cluster: " - ).lower() + "\nPlease enter the name of the destination cluster: " + ).lower() matches = [ - x - for x in found_clusters - if x["name"].lower() == expected_cluster_name.lower() - ] + x + for x in found_clusters + if x["name"].lower() == expected_cluster_name.lower() + ] if not matches: print( - f"No cluster found matching the name {expected_cluster_name}. Exiting." - ) + f"No cluster found matching the name {expected_cluster_name}. Exiting." + ) sys.exit() # get the cluster ext_id @@ -129,8 +129,8 @@ def main(): vmm_config.verify_ssl = False api_client = VMMClient(configuration=vmm_config) api_client.add_default_header( - header_name="Accept-Encoding", header_value="gzip, deflate, br" - ) + header_name="Accept-Encoding", header_value="gzip, deflate, br" + ) api_instance = ntnx_vmm_py_client.api.ImagesApi(api_client=api_client) # generate unique ID to ensure image names are always different @@ -138,11 +138,11 @@ def main(): # setup new image properties new_image = ntnx_vmm_py_client.models.vmm.v4.content.Image.Image() - new_image.name = f"centos7_2211_generic_cloud_{unique_id}" - new_image.desc = "CentOS 7 Generic Cloud 2211" + new_image.name = f"rocky_linux_9_cloud_{unique_id}" + new_image.desc = "Rocky Linux 9 Cloud Image" new_image.type = "DISK_IMAGE" image_source = ntnx_vmm_py_client.models.vmm.v4.content.UrlSource.UrlSource() - image_source.url = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2211.qcow2" + image_source.url = "https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2" image_source.allow_insecure = False new_image.source = image_source image_cluster = ntnx_vmm_py_client.models.vmm.v4.ahv.config.ClusterReference.ClusterReference() @@ -160,13 +160,13 @@ def main(): # monitor_task function create_ext_id = image_create.data.ext_id utils.monitor_task( - task_ext_id=create_ext_id, - task_name="Create image", - pc_ip=pc_ip, - username=username, - password=cluster_password, - poll_timeout=poll_timeout, - ) + task_ext_id=create_ext_id, + task_name="Create image", + pc_ip=pc_ip, + username=username, + password=cluster_password, + poll_timeout=poll_timeout, + ) task = utils.get_task(create_ext_id) print(f"Image created with ext_id {task.data.entities_affected[0].ext_id}") else: @@ -174,10 +174,10 @@ def main(): except VMMException as vmm_exception: print( - f"Unable to authenticate using the supplied credentials. \ -Please check your username and/or password, then try again. \ -Exception details: {vmm_exception}" - ) + f"Unable to authenticate using the supplied credentials. \ + Please check your username and/or password, then try again. \ + Exception details: {vmm_exception}" + ) if __name__ == "__main__": diff --git a/python/v4api_sdk/subnet_config.json b/python/v4api_sdk/subnet_config.json index 07d0b01..3342055 100644 --- a/python/v4api_sdk/subnet_config.json +++ b/python/v4api_sdk/subnet_config.json @@ -1,8 +1,8 @@ { - "name": "UVM-Full-Test", + "name": "UVM", "description": "User VMS only, no CVMs or Nutanix Products", "subnet_type": "VLAN", - "network_id": 409, + "network_id": 406, "virtual_switch_reference": "ef6defb7-bfb2-4c08-9ac7-e2cf195077ec", "is_external": false, "is_advanced_networking": true,