def to_human_port_configuration(attributes): for k, v in attributes.items(): if v == "true": attributes[k] = True elif v == "false": attributes[k] = False yang_to_human(attributes)
def to_human_operation(op_name, in_name, attributes): yang_to_human(attributes) for k, v in attributes.items(): if v == "true": attributes[k] = True elif v == "false": attributes[k] = False
def to_human_fabric(attributes): for k, v in attributes.items(): if v == "true": attributes[k] = True elif v == "false": attributes[k] = False yang_to_human(attributes)
def to_human_syslog_server(server): for k, v in server.items(): if v == "true": server[k] = True elif v == "false": server[k] = False yang_to_human(server)
def to_human_clock_server(attributes): for k, v in attributes.items(): if v == "true": attributes[k] = True elif v == "false": attributes[k] = False yang_to_human(attributes)
def to_human_system(system_config): for k, v in system_config.items(): if v == "true": system_config[k] = True elif v == "false": system_config[k] = False yang_to_human(system_config)
def to_human_ipfilter_rule(attributes): for k, v in attributes.items(): if v == "true": attributes[k] = True elif v == "false": attributes[k] = False yang_to_human(attributes)
def to_human_singleton(module_name, obj_name, attributes): for k, v in attributes.items(): if v == "true": attributes[k] = True elif v == "false": attributes[k] = False yang_to_human(attributes)
def to_human_zoning(zoning_config): for k, v in zoning_config.items(): if v == "true": zoning_config[k] = True elif v == "false": zoning_config[k] = False if "default-zone-access" in zoning_config: if zoning_config["default-zone-access"] == "1": zoning_config["default-zone-access"] = "allaccess" else: zoning_config["default-zone-access"] = "noaccess" yang_to_human(zoning_config)
def to_human_list(module_name, list_name, attributes_list, result): for attributes in attributes_list: for k, v in attributes.items(): if v == "true": attributes[k] = True elif v == "false": attributes[k] = False if module_name == "brocade-snmp" and list_name == "v3-account": if k == "authentication-password" or k == "privacy-password": if str(v) != "None": attributes[k] = base64.b64decode(v) yang_to_human(attributes)
def to_human_switch(switch_config): # convert all boolean strings to boolean # first. Then convert integer booleans # to boolean yang_to_human(switch_config) for k, v in switch_config.items(): if v == "true": switch_config[k] = True elif v == "false": switch_config[k] = False if "enabled_state" in switch_config: if switch_config["enabled_state"] == "3": switch_config["enabled_state"] = False else: switch_config["enabled_state"] = True
def to_human_singleton(module_name, obj_name, attributes): yang_to_human(attributes) for k, v in attributes.items(): if v == "true": attributes[k] = True elif v == "false": attributes[k] = False if module_name == "brocade_time" and obj_name == "clock_server": if "ntp_server_address" in attributes and "server_address" in attributes[ "ntp_server_address"]: if not isinstance( attributes["ntp_server_address"]["server_address"], list): new_list = [] new_list.append( attributes["ntp_server_address"]["server_address"]) attributes["ntp_server_address"]["server_address"] = new_list if module_name == "brocade_access_gateway" and obj_name == "policy": to_human_access_gateway_policy(attributes)
def to_human_list(module_name, list_name, attributes_list, result): for attributes in attributes_list: yang_to_human(attributes) for k, v in attributes.items(): if v == "true": attributes[k] = True elif v == "false": attributes[k] = False if module_name == "brocade_interface" and list_name == "fibrechannel": to_human_fc(attributes) if module_name == "brocade_snmp" and list_name == "v3_account": if "authentication_password" in attributes: pword = attributes["authentication_password"] if str(pword) != "None": attributes["authentication_password"] = base64.b64decode( pword) if "privacy_password" in attributes: pword = attributes["privacy_password"] if str(pword) != "None": attributes["privacy_password"] = base64.b64decode(pword) if module_name == "brocade_security" and list_name == "user_config": if "virtual_fabric_role_id_list" in attributes and "role_id" in attributes[ "virtual_fabric_role_id_list"]: if not isinstance( attributes["virtual_fabric_role_id_list"]["role_id"], list): new_list = [] new_list.append( attributes["virtual_fabric_role_id_list"]["role_id"]) attributes["virtual_fabric_role_id_list"][ "role_id"] = new_list if module_name == "brocade_fibrechannel_switch" and list_name == "fibrechannel_switch": to_human_switch(attributes) if "dns_servers" in attributes: if attributes[ "dns_servers"] is not None and "dns_server" in attributes[ "dns_servers"]: if not isinstance(attributes["dns_servers"]["dns_server"], list): new_list = [] new_list.append( attributes["dns_servers"]["dns_server"]) attributes["dns_servers"]["dns_server"] = new_list if "ip_address" in attributes: if attributes[ "ip_address"] is not None and "ip_address" in attributes[ "ip_address"]: if not isinstance(attributes["ip_address"]["ip_address"], list): new_list = [] new_list.append(attributes["ip_address"]["ip_address"]) attributes["ip_address"]["ip_address"] = new_list if "ip_static_gateway_list" in attributes: if attributes[ "ip_static_gateway_list"] is not None and "ip_static_gateway" in attributes[ "ip_static_gateway_list"]: if not isinstance( attributes["ip_static_gateway_list"] ["ip_static_gateway"], list): new_list = [] new_list.append(attributes["ip_static_gateway_list"] ["ip_static_gateway"]) attributes["ip_static_gateway_list"][ "ip_static_gateway"] = new_list if module_name == "brocade_access_gateway" and list_name == "port_group": if "port_group_n_ports" in attributes: if attributes[ "port_group_n_ports"] is not None and "n_port" in attributes[ "port_group_n_ports"]: if not isinstance( attributes["port_group_n_ports"]["n_port"], list): new_list = [] new_list.append( attributes["port_group_n_ports"]["n_port"]) attributes["port_group_n_ports"]["n_port"] = new_list if "port_group_f_ports" in attributes: if attributes[ "port_group_f_ports"] is not None and "f_port" in attributes[ "port_group_f_ports"]: if not isinstance( attributes["port_group_f_ports"]["f_port"], list): new_list = [] new_list.append( attributes["port_group_f_ports"]["f_port"]) attributes["port_group_f_ports"]["f_port"] = new_list if module_name == "brocade_access_gateway" and list_name == "n_port_map": if "configured_f_port_list" in attributes: if attributes[ "configured_f_port_list"] is not None and "f_port" in attributes[ "configured_f_port_list"]: if not isinstance( attributes["configured_f_port_list"]["f_port"], list): new_list = [] new_list.append( attributes["configured_f_port_list"]["f_port"]) attributes["configured_f_port_list"][ "f_port"] = new_list
def to_human_fc(port_config): # convert real boolean strings to boolean first # then convert the non 0/1 integers to boolean # then convert the 0/1 integers to boolean for k, v in port_config.items(): if v == "true": port_config[k] = True elif v == "false": port_config[k] = False if "enabled-state" in port_config: if port_config["enabled-state"] == "2": port_config["enabled-state"] = True else: port_config["enabled-state"] = False for attrib in zero_one_attributes: if attrib in port_config: if port_config[attrib] == "0": port_config[attrib] = False else: port_config[attrib] = True if "los-tov-mode-enabled" in port_config: if port_config["los-tov-mode-enabled"] == "0": port_config["los-tov-mode-enabled"] = "Disabled" elif port_config["los-tov-mode-enabled"] == "1": port_config["los-tov-mode-enabled"] = "Fixed" elif port_config["los-tov-mode-enabled"] == "2": port_config["los-tov-mode-enabled"] = "FixedAuto" if "long-distance" in port_config: if port_config["long-distance"] == "0": port_config["long-distance"] = "Disabled" elif port_config["long-distance"] == "1": port_config["long-distance"] = "L0" elif port_config["long-distance"] == "2": port_config["long-distance"] = "L1" elif port_config["long-distance"] == "3": port_config["long-distance"] = "L2" elif port_config["long-distance"] == "4": port_config["long-distance"] = "LE" elif port_config["long-distance"] == "5": port_config["long-distance"] = "L0.5" elif port_config["long-distance"] == "6": port_config["long-distance"] = "LD" elif port_config["long-distance"] == "7": port_config["long-distance"] = "LS" if "speed" in port_config: if port_config["speed"] == "32000000000": port_config["speed"] = "32Gig" elif port_config["speed"] == "16000000000": port_config["speed"] = "16Gig" elif port_config["speed"] == "10000000000": port_config["speed"] = "10Gig" elif port_config["speed"] == "8000000000": port_config["speed"] = "8Gig" elif port_config["speed"] == "4000000000": port_config["speed"] = "4Gig" elif port_config["speed"] == "2000000000": port_config["speed"] = "2Gig" elif port_config["speed"] == "1000000000": port_config["speed"] = "1Gig" elif port_config["speed"] == "0": port_config["speed"] = "Auto" yang_to_human(port_config)