import os import sys sys.path.insert(0, os.path.abspath('..')) import pyvmax # this obviously won't work... just testing vmax_api = pyvmax.connect('url', 'user', 'pass')
################################# ### Define and Parse CLI arguments PARSER = argparse.ArgumentParser(description='Example implementation of a Python REST client for EMC Unisphere for VMAX performance statistics.') RFLAGS = PARSER.add_argument_group('Required arguments') RFLAGS.add_argument('-url', required=True, help='Base Unisphere URL. e.g. https://10.0.0.1:8443') RFLAGS.add_argument('-user', required=True, help='Unisphere username. e.g. smc') RFLAGS.add_argument('-passwd', required=True, help='Unisphere password. e.g. smc') ARGS = PARSER.parse_args() URL = ARGS.url USER = ARGS.user PASSWORD = ARGS.passwd log = logging.getLogger('example_performance.py') vmax_api = pyvmax.connect(URL, USER, PASSWORD) def time_now(): return int(time.time() * 1000) def time_minutes_ago(minutes=1): return int(time_now() - (minutes * 60 * 1000)) def time_hours_ago(hours=1): return int(time_now() - (hours * 3600 * 1000)) def time_days_ago(days=1): return int(time_now() - (days * 24 * 3600 * 1000)) def time_weeks_ago(weeks=1): return int(time_now() - (weeks * 7 * 24 * 3600 * 1000))
################################# ### Define and Parse CLI arguments PARSER = argparse.ArgumentParser( description='Example implementation of a Python REST client for EMC Unisphere for VMAX.') RFLAGS = PARSER.add_argument_group('Required arguments') RFLAGS.add_argument('-url', required=True, help='Base Unisphere URL. e.g. https://10.0.0.1:8443') RFLAGS.add_argument('-user', required=True, help='Unisphere username. e.g. smc') RFLAGS.add_argument('-passwd', required=True, help='Unisphere password. e.g. smc') ARGS = PARSER.parse_args() URL = ARGS.url USER = ARGS.user PASSWORD = ARGS.passwd log = logging.getLogger('example_capacities.py') vmax_api = pyvmax.connect(URL, USER, PASSWORD) # discover the known slo symmetrix serial #'s slo_array_ids = vmax_api.get_slo_arrays()['symmetrixId'] log.info("discovered arrays") # going to build a list of dicts, each one a symmetrix slo_array_list = list() for symm_id in slo_array_ids: # get the array details log.info("symmetrix loop") symm_result = vmax_api.get_slo_array(symm_id)['symmetrix'][0] symmetrix = {'symmetrix_id' : symm_result['symmetrixId'], 'array_usable_gb' : symm_result['virtualCapacity']['total_capacity_gb'], 'srps_total_subscribed_gb' : 0, 'srps_total_usable_gb' : 0,