def ssp_lus_clean(cs, cluster_id, *startswith): cluster = cs.cluster.get(cluster_id) # the ssp associated with the cluster ssp_id = cluster.sharedstoragepool_id() laps = timer(None) ssp = cs.sharedstoragepool.get(ssp_id) lu_udid_for_delete = [] for lu in ssp.logical_units.logical_unit: for sw in startswith: if lu.unit_name.startswith(sw): lu_udid_for_delete.append(lu.unique_device_id) break print ("Elapsed time for search: >%f<" % (timer(laps),)) if len(lu_udid_for_delete) == 0: x = "For SSP: >%s<, found no LUs starting with: >%s<" print (x % (ssp_id, ",".join(startswith))) else: x = "For SSP: >%s<, found >%d< LUs starting with: >%s<" print (x % (ssp_id, len(lu_udid_for_delete), ",".join(startswith))) total_deleted = 0 cur_len = len(lu_udid_for_delete) laps2 = timer(None) chunksize = 100 for chunk in _chunks(lu_udid_for_delete, chunksize): # chunksizes = [1, 2, 4, 8, 16, 32, 64, 128] # for chunk in _chunks2(lu_udid_for_delete, chunksizes): ssp = ssp.update_del_lus(chunk) laptime = timer(laps2) chunklen = len(chunk) total_deleted += chunklen # print ("Deleted >%d< in >%f< seconds, " # "total deleted: >%d<" % # (chunklen, laptime, total_deleted)) del_rate = laptime / float(chunklen) x = ("Starting at LU >%d<," " deleted >%d< in >%f< seconds, " " rate: >%f< s/LU," " total deleted: >%d<") print (x % (cur_len, chunklen, laptime, del_rate, total_deleted)) cur_len -= chunklen x = "For SSP: >%s<, number of LUs deleted: >%d<" print (x % (ssp_id, len(lu_udid_for_delete))) print ("Elapsed time for delete: >%f<" % (timer(laps),))
def ssp_lus_clean(cs, cluster_id, startswith, num_threads=1): def time_update_del_lus(ssp, chunk): t0 = time.time() ssp.update_del_lus(chunk) print ("Deleted >%d< in >%f< seconds" % (len(chunk), time.time() - t0)) cluster = cs.cluster.get(cluster_id) # the ssp associated with the cluster ssp_id = cluster.sharedstoragepool_id() laps = timer(None) ssp = cs.sharedstoragepool.get(ssp_id) lu_udid_for_delete = [] for lu in ssp.logical_units.logical_unit: for sw in startswith: if lu.unit_name.startswith(sw): lu_udid_for_delete.append(lu.unique_device_id) break print ("Elapsed time for search: >%f<" % (timer(laps),)) if len(lu_udid_for_delete) == 0: x = "For SSP: >%s<, found no LUs starting with: >%s<" print (x % (ssp_id, ",".join(startswith))) else: x = "For SSP: >%s<, found >%d< LUs starting with: >%s<" print (x % (ssp_id, len(lu_udid_for_delete), ",".join(startswith))) chunksize = 1 pool = eventlet.GreenPool(num_threads) for chunk in _chunks(lu_udid_for_delete, chunksize): try: pool.spawn_n(time_update_del_lus, ssp, chunk) except (SystemExit, KeyboardInterrupt): # TODO are these correct? break pool.waitall() x = "For SSP: >%s<, number of LUs deleted: >%d<" print (x % (ssp_id, len(lu_udid_for_delete))) print ("Elapsed time for delete: >%f<" % (timer(laps),))
def ssp_lpars_clean(cs, ms_id, *startswith): lps = cs.logicalpartition.list(ms_id) lp_ids_for_delete = [] laps = timer(None) for lp in lps: print (lp.id, lp.partition_name) for sw in startswith: if lp.partition_name.startswith(sw): lp_ids_for_delete.append(lp.id) break print ("Elapsed time for search: >%f<" % (timer(laps),)) if len(lp_ids_for_delete) == 0: x = "For ms_id: >%s<, found no LPARs starting with: >%s<" print (x % (ms_id, ",".join(startswith))) return for lp_id in lp_ids_for_delete: cs.managedsystem.deletebyid(ms_id, "LogicalPartition", lp_id) x = "For ms_id: >%s<, number of LPARs deleted: >%d<" print (x % (ms_id, len(lp_ids_for_delete))) print ("Elapsed time for delete: >%f<" % (timer(laps),))
def stress_ssp(cs, cluster_id, num_images, image_size, num_deploys_at_steady_state, perform_clone, thin, num_green_threads, cleanup): cluster = cs.cluster.get(cluster_id) ssp_id = cluster.sharedstoragepool_id() # the ssp associated with the cluster ssp = cs.sharedstoragepool.get(ssp_id) # setup timer laps = timer(None) # get a pool of images # (source_lu, ssp) = ssp.update_append_lu("SOURCE-DM", 10, thin=True) (image_lu_pool, ssp) = _setup_image_pool(ssp, num_images, image_size, thin) print ("Elapsed time for image pool setup: >%f<" % (timer(laps),)) ################## # establish steady state results = \ _perform_clone_set(num_green_threads, cs, cluster, ssp_id, image_lu_pool, num_deploys_at_steady_state, perform_clone, "GUESTA") elapsed = timer(laps) print ("Initial clone from image," " deploys: >%d<," " elapsed time: >%f<," " thats >%s< per deploy" % (num_deploys_at_steady_state, elapsed, elapsed / float(num_deploys_at_steady_state))) # extract deployed image pool from results deployed_image_pool = [lu for (_, lu) in results] ################## # clone step results = \ _perform_clone_set(num_green_threads, cs, cluster, ssp_id, deployed_image_pool, num_deploys_at_steady_state, perform_clone, "GUESTB") elapsed = timer(laps) print ("Clone from clones," " deploys: >%d<," " elapsed time: >%f<," " thats >%s< per deploy" % (num_deploys_at_steady_state, elapsed, elapsed / float(num_deploys_at_steady_state))) # extract deployed image pool from results cloned_image_pool = [lu for (_, lu) in results] ################## # don't cleanup unless requested if not cleanup: print ("Cleanup not requested ...") return ################## # tear down ssp = cs.sharedstoragepool.get(ssp_id) ######### # tear down deploys print ("Tear down deploys") if len(deployed_image_pool) != num_deploys_at_steady_state: print ("deployed_image_pool accounting mismatch" " len(deployed_image_pool): >%d<," " num_deploys_at_steady_state: >%d<" % (len(deployed_image_pool), num_deploys_at_steady_state)) chunksize = 10 for chunk in _chunks(deployed_image_pool, chunksize): print (" delete chunk of: >%d<" % (len(chunk),)) ssp = _teardown_lu_pool(ssp, chunk) print ("Elapsed time for deployed pool teardown: >%f<" % (timer(laps),)) ######### # tear down clones print ("Tear down clones") if len(cloned_image_pool) != num_deploys_at_steady_state: print ("cloned_image_pool accounting mismatch" " len(cloned_image_pool): >%d<," " num_deploys_at_steady_state: >%d<" % (len(cloned_image_pool), num_deploys_at_steady_state)) chunksize = 10 for chunk in _chunks(cloned_image_pool, chunksize): print (" delete chunk of: >%d<" % (len(chunk),)) ssp = _teardown_lu_pool(ssp, chunk) print ("Elapsed time for cloned pool teardown: >%f<" % (timer(laps),)) ######### # tear down images if len(image_lu_pool) != num_images: print ("deployed_image_pool accounting mismatch" " len(image_lu_pool): >%d<," " len(image_lu_pool): >%d<" % (len(deployed_image_pool), num_images)) ssp = _teardown_lu_pool(ssp, image_lu_pool) print ("Elapsed time for image pool teardown: >%f<" % (timer(laps),))
def stress_ssp( cs, cluster_id, image_pool_lu_udids, image_size, num_deploys_at_steady_state, perform_clone, thin, num_green_threads, cleanup, ): cluster = cs.cluster.get(cluster_id) ssp_id = cluster.sharedstoragepool_id() # the ssp associated with the cluster ssp = cs.sharedstoragepool.get(ssp_id) # setup timer laps = timer(None) # get a pool of images if False: # old way, create empty ones num_images = 10 (image_lu_pool, ssp) = _setup_image_pool(ssp, num_images, image_size, thin) else: (image_lu_pool, ssp) = _setup_image_pool_from_list(ssp, image_pool_lu_udids) print("Elapsed time for image pool setup: >%f<" % (timer(laps),)) # establish steady state results = _establish_steady_state( num_green_threads, cs, cluster, ssp_id, image_lu_pool, num_deploys_at_steady_state, perform_clone ) elapsed = timer(laps) print( "Reached steady state," " deploys: >%d<," " elapsed time: >%f<," " thats >%s< per deploy" % (num_deploys_at_steady_state, elapsed, elapsed / float(num_deploys_at_steady_state)) ) # extract deployed image pool from results deployed_image_pool = [lu for (_, lu) in results] # operate at steady state TBD # don't cleanup unless requested if not cleanup: print("Cleanup not requested ...") return ######### # tear down ssp = cs.sharedstoragepool.get(ssp_id) # tear down deploys print("Tear down deploys") if len(deployed_image_pool) != num_deploys_at_steady_state: print( "deployed_image_pool accounting mismatch" " len(deployed_image_pool): >%d<," " num_deploys_at_steady_state: >%d<" % (len(deployed_image_pool), num_deploys_at_steady_state) ) chunksize = 10 for chunk in _chunks(deployed_image_pool, chunksize): print(" delete chunk of: >%d<" % (len(chunk),)) ssp = _teardown_lu_pool(ssp, chunk) print("Elapsed time for deployed pool teardown: >%f<" % (timer(laps),)) # tear down images if False: if len(image_lu_pool) != num_images: print( "deployed_image_pool accounting mismatch" " len(image_lu_pool): >%d<," " len(image_lu_pool): >%d<" % (len(deployed_image_pool), num_images) ) ssp = _teardown_lu_pool(ssp, image_lu_pool) print("Elapsed time for image pool teardown: >%f<" % (timer(laps),))