@@ -125,83 +125,89 @@ def _launch(config, cookies, sys_uuid, vios_uuids):
125
125
logger .info ("Installation ISOs attached to the partition" )
126
126
127
127
logger .info ("Setting up storage" )
128
- # Re-run scenario: Check if physical disk or virtual disk is already attached to partition
128
+ setup_storage (config , cookies , active_vios_servers , sys_uuid , partition_uuid )
129
+
130
+ lpar_state = activation .check_lpar_status (config , cookies , partition_uuid )
131
+ if lpar_state != "running" :
132
+ logger .debug ("Setting partition bootstring as 'cd/dvd-all'" )
133
+ partition_payload = partition .get_partition_details (
134
+ config , cookies , sys_uuid , partition_uuid )
135
+ partition .set_partition_boot_string (
136
+ config , cookies , sys_uuid , partition_uuid , partition_payload , "cd/dvd-all" )
137
+
138
+ logger .info ("Activating the partition" )
139
+ activation .activate_partition (config , cookies , partition_uuid )
140
+ logger .info ("Partition activated" )
141
+
142
+ logger .info ("Monitoring boot process, this will take a while" )
143
+ monitor_util .monitor_bootstrap_boot (config )
144
+ monitor_util .monitor_pim (config )
145
+ except (AIAppError , AuthError , NetworkError , PartitionError , StorageError , VIOSError , paramiko .SSHException , Exception ) as e :
146
+ raise e
147
+
148
+ def setup_storage (config , cookies , active_vios , sys_uuid , lpar_id ):
149
+ try :
150
+ # Re-run scenario: Check if physical disk/virtualdisk/SAN storage(VFC) is already attached to partition
129
151
storage_attached = False
130
- for a_vios_uuid , a_vios in active_vios_servers .items ():
152
+ for a_vios_uuid , a_vios in active_vios .items ():
131
153
logger .debug (f"Checking for existing physical disk attachment in VIOS '{ a_vios_uuid } '" )
132
154
physical_disk_found , _ = storage .check_if_storage_attached (
133
- a_vios , partition_uuid )
155
+ a_vios , lpar_id )
134
156
if physical_disk_found :
135
157
logger .info (
136
- f"Physical disk is already attached to lpar '{ partition_uuid } '" )
158
+ f"Physical disk is already attached to lpar '{ lpar_id } '" )
137
159
storage_attached = True
138
160
if not storage_attached :
139
- vdisk_found , vdisk_name = storage .check_if_vdisk_attached (a_vios , partition_uuid )
161
+ vdisk_found , vdisk_name = vstorage .check_if_vdisk_attached (a_vios , lpar_id )
140
162
if vdisk_found :
141
- logger .info (f"Virtual disk '{ vdisk_name } ' is already attached to lpar '{ partition_uuid } '" )
163
+ logger .info (f"Virtual disk '{ vdisk_name } ' is already attached to lpar '{ lpar_id } '" )
142
164
storage_attached = True
143
165
if not storage_attached :
144
166
vfc_disk_found , _ = storage .check_if_vfc_disk_attached (
145
- a_vios , partition_uuid )
167
+ a_vios , lpar_id )
146
168
if vfc_disk_found :
147
169
logger .info (
148
- f"SAN storage(VFC) disk is already attached to lpar '{ partition_uuid } '" )
170
+ f"SAN storage(VFC) disk is already attached to lpar '{ lpar_id } '" )
149
171
storage_attached = True
150
172
151
173
vdisk_attached = False
152
- use_vdisk = util .use_virtual_disk (config )
153
- # Create and attach virtual disk to the partition
154
- if use_vdisk and not storage_attached :
155
- vios_storage_list = vios_operation .get_vios_with_physical_storage (
156
- config , active_vios_servers )
157
- if len (vios_storage_list ) == 0 :
158
- logger .error (
159
- "failed to find physical volume for the partition" )
160
- raise StorageError (
161
- "failed to find physical volume for the partition" )
162
- vios_storage_uuid = vios_storage_list [0 ][0 ]
163
- updated_vios_payload = vios_operation .get_vios_details (config , cookies , sys_uuid , vios_storage_uuid )
164
- use_existing_vd = util .use_existing_vd (config )
165
- if use_existing_vd :
166
- vstorage .attach_virtualdisk (updated_vios_payload , config , cookies , partition_uuid , sys_uuid , vios_storage_uuid )
167
- vdisk_attached = True
168
- else :
169
- # Create volume group, virtual disk and attach storage
170
- use_existing_vg = util .use_existing_vg (config )
171
- if not use_existing_vg :
172
- # Create volume group
173
- vg_id = vstorage .create_volumegroup (config , cookies , vios_storage_uuid )
174
- else :
175
- vg_id = vstorage .get_volume_group_id (config , cookies , vios_storage_uuid , util .get_volume_group_name (config ))
176
- vstorage .create_virtualdisk (config , cookies , vios_storage_uuid , vg_id )
177
- updated_vios_payload = vios_operation .get_vios_details (config , cookies , sys_uuid , vios_storage_uuid )
178
- vstorage .attach_virtualdisk (updated_vios_payload , config , cookies , partition_uuid , sys_uuid , vios_storage_uuid )
179
- vdisk_attached = True
174
+ if not util .use_physical_volume (config ) and not storage_attached :
175
+ handle_virtual_disk (config , cookies , active_vios , sys_uuid , lpar_id )
176
+ vdisk_attached = True
180
177
181
178
if not storage_attached and not vdisk_attached :
182
179
vios_storage_list = vios_operation .get_vios_with_physical_storage (
183
- config , active_vios_servers )
180
+ config , active_vios )
184
181
if len (vios_storage_list ) == 0 :
185
182
logger .error (
186
183
"failed to find physical volume for the partition" )
187
184
raise StorageError (
188
185
"failed to find physical volume for the partition" )
189
186
storage .attach_physical_storage (
190
- config , cookies , sys_uuid , partition_uuid , vios_storage_list )
191
-
192
- partition_payload = partition .get_partition_details (
193
- config , cookies , sys_uuid , partition_uuid )
194
- logger .debug ("Setting partition bootstring as 'cd/dvd-all'" )
195
- partition .set_partition_boot_string (
196
- config , cookies , sys_uuid , partition_uuid , partition_payload , "cd/dvd-all" )
187
+ config , cookies , sys_uuid , lpar_id , vios_storage_list )
188
+ except (StorageError , VIOSError , Exception ) as e :
189
+ raise e
197
190
198
- logger .info ("Activating the partition" )
199
- activation .activate_partition (config , cookies , partition_uuid )
200
- logger .info ("Partition activated" )
191
+ def handle_virtual_disk (config , cookies , active_vios , sys_uuid , lpar_id ):
192
+ try :
193
+ vios_storage_list = vios_operation .get_vios_with_physical_storage (
194
+ config , active_vios )
195
+ if len (vios_storage_list ) == 0 :
196
+ logger .error ("failed to find physical volume for the partition" )
197
+ raise StorageError ("failed to find physical volume for the partition" )
198
+ vios_storage_uuid = vios_storage_list [0 ][0 ]
199
+ updated_vios_payload = vios_operation .get_vios_details (config , cookies , sys_uuid , vios_storage_uuid )
200
+
201
+ # Check if virtual storage already exists under the given volumegroup
202
+ vg_id = vstorage .get_volume_group_id (config , cookies , vios_storage_uuid , util .get_volume_group_name (config ))
203
+ found , _ , _ = vstorage .check_if_vdisk_exists (config , cookies , vios_storage_uuid , vg_id , util .get_virtual_disk_name (config ))
204
+ # Create virtualdisk only if it doesn't exist under volumegroup
205
+ if not found :
206
+ vstorage .create_virtualdisk (config , cookies , vios_storage_uuid , vg_id )
207
+ updated_vios_payload = vios_operation .get_vios_details (config , cookies , sys_uuid , vios_storage_uuid )
201
208
202
- logger .info ("Monitoring boot process, this will take a while" )
203
- monitor_util .monitor_bootstrap_boot (config )
204
- monitor_util .monitor_pim (config )
205
- except (AIAppError , AuthError , NetworkError , PartitionError , StorageError , VIOSError , paramiko .SSHException , Exception ) as e :
209
+ vstorage .attach_virtualdisk (updated_vios_payload , config , cookies , lpar_id , sys_uuid , vios_storage_uuid )
210
+ except (StorageError , VIOSError , Exception ) as e :
206
211
raise e
207
-
212
+ logger .info (f"virtualdisk is attached to parition '{ lpar_id } ' successfully" )
213
+ return
0 commit comments