@@ -40,16 +40,16 @@ def main():
4040 parser .add_argument ("pc_ip" , help = "Prism Central IP address or FQDN" )
4141 parser .add_argument ("username" , help = "Prism Central username" )
4242 parser .add_argument (
43- "-p" , "--poll" , help = "Time between task polling, in seconds" , default = 1
44- )
43+ "-p" , "--poll" , help = "Time between task polling, in seconds" , default = 1
44+ )
4545 args = parser .parse_args ()
4646
4747 # get the cluster password
4848 cluster_password = getpass .getpass (
49- prompt = "Please enter your Prism Central \
50- password: " ,
51- stream = None ,
52- )
49+ prompt = "Please enter your Prism Central \
50+ password: " ,
51+ stream = None ,
52+ )
5353
5454 pc_ip = args .pc_ip
5555 username = args .username
@@ -59,12 +59,12 @@ def main():
5959 if not cluster_password :
6060 while not cluster_password :
6161 print (
62- "Password cannot be empty. \
63- Please enter a password or Ctrl-C/Ctrl-D to exit."
64- )
62+ "Password cannot be empty. \
63+ Please enter a password or Ctrl-C/Ctrl-D to exit."
64+ )
6565 cluster_password = getpass .getpass (
66- prompt = "Please enter your Prism Central password: " , stream = None
67- )
66+ prompt = "Please enter your Prism Central password: " , stream = None
67+ )
6868
6969 try :
7070 # create utils instance for re-use later
@@ -93,26 +93,26 @@ def main():
9393 if not cluster .name == "Unnamed" :
9494 found_clusters .append ({"name" : cluster .name , "ext_id" : cluster .ext_id })
9595 print (
96- f"The following clusters ({ len (cluster_list .data )- 1 } ) were found, not including Prism Central."
97- )
96+ f"The following clusters ({ len (cluster_list .data )- 1 } ) were found, not including Prism Central."
97+ )
9898 print (
99- "Note: By default Prism Central clusters appear as 'Unnamed'. Clusters matching this name have \
100- not been included in this list."
101- )
99+ "Note: By default Prism Central clusters appear as 'Unnamed'. Clusters matching this name have \
100+ not been included in this list."
101+ )
102102 pprint (found_clusters )
103103 expected_cluster_name = input (
104- "\n Please enter the name of the destination cluster: "
105- ).lower ()
104+ "\n Please enter the name of the destination cluster: "
105+ ).lower ()
106106
107107 matches = [
108- x
109- for x in found_clusters
110- if x ["name" ].lower () == expected_cluster_name .lower ()
111- ]
108+ x
109+ for x in found_clusters
110+ if x ["name" ].lower () == expected_cluster_name .lower ()
111+ ]
112112 if not matches :
113113 print (
114- f"No cluster found matching the name { expected_cluster_name } . Exiting."
115- )
114+ f"No cluster found matching the name { expected_cluster_name } . Exiting."
115+ )
116116 sys .exit ()
117117
118118 # get the cluster ext_id
@@ -129,20 +129,20 @@ def main():
129129 vmm_config .verify_ssl = False
130130 api_client = VMMClient (configuration = vmm_config )
131131 api_client .add_default_header (
132- header_name = "Accept-Encoding" , header_value = "gzip, deflate, br"
133- )
132+ header_name = "Accept-Encoding" , header_value = "gzip, deflate, br"
133+ )
134134 api_instance = ntnx_vmm_py_client .api .ImagesApi (api_client = api_client )
135135
136136 # generate unique ID to ensure image names are always different
137137 unique_id = uuid .uuid1 ()
138138
139139 # setup new image properties
140140 new_image = ntnx_vmm_py_client .models .vmm .v4 .content .Image .Image ()
141- new_image .name = f"centos7_2211_generic_cloud_ { unique_id } "
142- new_image .desc = "CentOS 7 Generic Cloud 2211 "
141+ new_image .name = f"rocky_linux_9_cloud_ { unique_id } "
142+ new_image .desc = "Rocky Linux 9 Cloud Image "
143143 new_image .type = "DISK_IMAGE"
144144 image_source = ntnx_vmm_py_client .models .vmm .v4 .content .UrlSource .UrlSource ()
145- image_source .url = "https://cloud.centos .org/centos/7/ images/CentOS-7- x86_64- GenericCloud-2211. qcow2"
145+ image_source .url = "https://dl.rockylinux .org/pub/rocky/9/ images/x86_64/Rocky-9- GenericCloud-Base.latest.x86_64. qcow2"
146146 image_source .allow_insecure = False
147147 new_image .source = image_source
148148 image_cluster = ntnx_vmm_py_client .models .vmm .v4 .ahv .config .ClusterReference .ClusterReference ()
@@ -160,24 +160,24 @@ def main():
160160 # monitor_task function
161161 create_ext_id = image_create .data .ext_id
162162 utils .monitor_task (
163- task_ext_id = create_ext_id ,
164- task_name = "Create image" ,
165- pc_ip = pc_ip ,
166- username = username ,
167- password = cluster_password ,
168- poll_timeout = poll_timeout ,
169- )
163+ task_ext_id = create_ext_id ,
164+ task_name = "Create image" ,
165+ pc_ip = pc_ip ,
166+ username = username ,
167+ password = cluster_password ,
168+ poll_timeout = poll_timeout ,
169+ )
170170 task = utils .get_task (create_ext_id )
171171 print (f"Image created with ext_id { task .data .entities_affected [0 ].ext_id } " )
172172 else :
173173 print ("Image creation cancelled." )
174174
175175 except VMMException as vmm_exception :
176176 print (
177- f"Unable to authenticate using the supplied credentials. \
178- Please check your username and/or password, then try again. \
179- Exception details: { vmm_exception } "
180- )
177+ f"Unable to authenticate using the supplied credentials. \
178+ Please check your username and/or password, then try again. \
179+ Exception details: { vmm_exception } "
180+ )
181181
182182
183183if __name__ == "__main__" :
0 commit comments