def list_memory_profiles(self): path = "memprofiles_list" profiles = self._list(self._path(path)) for profile in profiles: profile.memory = [utils.objectify(n) for n in profile.memory] profile.nodes = [utils.objectify(n) for n in profile.nodes] return profiles
def list_cpu_profiles(self): path = "cpuprofiles_list" profiles = self._list(self._path(path)) for profile in profiles: profile.cpus = [utils.objectify(n) for n in profile.cpus] profile.nodes = [utils.objectify(n) for n in profile.nodes] return profiles
def list_interface_profiles(self): path = "ifprofiles_list" profiles = self._list(self._path(path)) for profile in profiles: profile.ports = [utils.objectify(n) for n in profile.ports] profile.interfaces = [utils.objectify(n) for n in profile.interfaces] return profiles
def list_storage_profiles(self): path = "storprofiles_list" profiles = self._list(self._path(path)) for profile in profiles: profile.disks = [utils.objectify(n) for n in profile.disks] profile.partitions = [utils.objectify(n) for n in profile.partitions] profile.stors = [utils.objectify(n) for n in profile.stors] profile.lvgs = [utils.objectify(n) for n in profile.lvgs] profile.pvs = [utils.objectify(n) for n in profile.pvs] return profiles
def do_storprofile_list(cc, args): """List storage profiles.""" profiles = cc.iprofile.list_storage_profiles() storprofiles = [] localstorprofiles = [] profile_disk_invalid = False for profile in profiles: profile.disks = [utils.objectify(n) for n in profile.disks] profile.partitions = [utils.objectify(n) for n in profile.partitions] profile.stors = [utils.objectify(n) for n in profile.stors] profile.ilvgs = [utils.objectify(n) for n in profile.lvgs] profile.ipvs = [utils.objectify(n) for n in profile.pvs] profile.diskconfig, crt_profile_disk_invalid = get_diskconfig(profile) profile_disk_invalid = (profile_disk_invalid or crt_profile_disk_invalid) profile.partconfig = get_partconfig(profile) profile.storconfig = get_storconfig_short(profile) profile.ilvg_config = get_ilvg_config(profile) profile.ipv_config = get_ipv_config(profile) if profile.profiletype == constants.PROFILE_TYPE_LOCAL_STORAGE: localstorprofiles.append(profile) else: storprofiles.append(profile) if profile_disk_invalid: print("WARNING: Storage profiles from a previous release are " "missing the persistent disk name in the disk config field. " "These profiles need to be deleted and recreated.") if storprofiles: field_labels = [ 'uuid', 'name', 'disk config', 'partition config', 'stor config' ] fields = [ 'uuid', 'profilename', 'diskconfig', 'partconfig', 'storconfig' ] utils.print_list(storprofiles, fields, field_labels, sortby=0) if localstorprofiles: field_labels = [ 'uuid', 'name', 'disk config', 'partition config', 'physical volume config', 'logical volume group config' ] fields = [ 'uuid', 'profilename', 'diskconfig', 'partconfig', 'ipv_config', 'ilvg_config' ] utils.print_list(localstorprofiles, fields, field_labels, sortby=0)
def _simpleTestHarness(no_wrap): from cgtsclient.common import utils def testFormatter(event): return "*{}".format(event["state"]) def buildFormatter(field, width): def f(dict): if field == 'number': return dict[field] return "{}".format(dict[field]).replace("_", " ") return {"formatter": f, "wrapperFormatter": width} set_no_wrap(no_wrap) field_labels = ['Time Stamp', 'State', 'Event Log ID', 'Reason Text', 'Entity Instance ID', 'Severity', 'Number'] fields = ['timestamp', 'state', 'event_log_id', 'reason_text', 'entity_instance_id', 'severity', 'number'] formatterSpecX = {"timestamp": 10, "state": 8, "event_log_id": 70, "reason_text": 30, "entity_instance_id": 30, "severity": 12, "number": 4} formatterSpec = {} for f in fields: formatterSpec[f] = buildFormatter(f, formatterSpecX[f]) logs = [] for i in range(0, 30): log = {} for f in fields: if f == 'number': log[f] = i else: log[f] = "{}{}".format(f, i) logs.append(utils.objectify(log)) formatterSpec = formatterSpecX formatters = build_wrapping_formatters(logs, fields, field_labels, formatterSpec) utils.print_list(logs, fields, field_labels, formatters=formatters, sortby=6, reversesort=True, no_wrap_fields=['entity_instance_id']) print("nowrap = {}".format(is_nowrap_set()))