Ejemplo n.º 1
0
def vxlan_show_vxlan_evpn_remote_vni(args):
    arg_length = len(args)
    api_response = invoke(
        "get_list_sonic_vxlan_sonic_vxlan_evpn_remote_vni_table_evpn_remote_vni_table_list",
        args)
    if api_response.ok():
        response = api_response.content
        if response is None:
            print("no vxlan evpn remote vni entires")
        elif response is not None:
            if len(response) != 0:
                if (arg_length == 1):
                    show_cli_output(args[0], response)
                else:
                    index = 0
                    while (index < len(
                            response['sonic-vxlan:EVPN_REMOTE_VNI_TABLE_LIST'])
                           ):
                        iter = response[
                            'sonic-vxlan:EVPN_REMOTE_VNI_TABLE_LIST'][index]

                        if (arg_length == 2
                                and (args[1] != iter['remote_vtep'])):
                            response[
                                'sonic-vxlan:EVPN_REMOTE_VNI_TABLE_LIST'].pop(
                                    index)
                        else:
                            index = index + 1
                    show_cli_output(args[0], response)
        return
Ejemplo n.º 2
0
def vxlan_show_vxlan_evpn_remote_mac(args):
    arg_length = len(args)
    list_len = 0
    api_response = invoke(
        "get_list_sonic_vxlan_sonic_vxlan_fdb_table_vxlan_fdb_table_list",
        args)
    if api_response.ok():
        response = api_response.content
        if response is None:
            print("no vxlan fdb entries")
        elif response is not None:
            if len(response) != 0:
                if (arg_length == 1):
                    show_cli_output(args[0], response)
                else:
                    index = 0
                    while (index < len(
                            response['sonic-vxlan:VXLAN_FDB_TABLE_LIST'])):
                        iter = response['sonic-vxlan:VXLAN_FDB_TABLE_LIST'][
                            index]
                        if (arg_length == 2
                                and (args[1] != iter['remote_vtep'])):
                            response['sonic-vxlan:VXLAN_FDB_TABLE_LIST'].pop(
                                index)
                        else:
                            index = index + 1
                    show_cli_output(args[0], response)
        return
Ejemplo n.º 3
0
def run(func, args):
    try:
        api_response = invoke(func, args)

        if api_response.ok():
            response = api_response.content
            if response is None:
                pass
            elif 'openconfig-interfaces:config' in response.keys():
                value = response['openconfig-interfaces:config']
                if value is None:
                    return
                show_cli_output(args[2], value)
            elif 'openconfig-network-instance:config' in response.keys():
                value = response['openconfig-interfaces:config']
                if value is None:
                    return
                show_cli_output(args[2], value)
        else:
            #error response
            print(api_response.error_message())

    except:
        # system/network error
        raise
Ejemplo n.º 4
0
def run(func, args):

    if func == 'get_tam_ifa_status':
        get_tam_ifa_status(args)
        return
    elif func == 'get_tam_ifa_flow_stats':
        get_tam_ifa_flow_stats(args)
        return

    response = invoke_api(func, args)
    if response.ok():
        if response.content is not None:
            # Get Command Output
            api_response = response.content
            if 'sonic-ifa:sonic-ifa' in api_response:
                value = api_response['sonic-ifa:sonic-ifa']
                if 'TAM_INT_IFA_FEATURE_TABLE' in value:
                    tup = value['TAM_INT_IFA_FEATURE_TABLE']
                elif 'TAM_INT_IFA_FLOW_TABLE' in value:
                    tup = value['TAM_INT_IFA_FLOW_TABLE']
                else:
                    api_response = None

            if api_response is None:
                print("Failed")
            elif func == 'get_sonic_ifa_sonic_ifa_tam_int_ifa_feature_table':
                show_cli_output(args[0], api_response)
            elif func == 'get_sonic_ifa_sonic_ifa_tam_int_ifa_flow_table':
                show_cli_output(args[0], api_response)
            else:
                return
    else:
        print response.error_message()
Ejemplo n.º 5
0
def run(func, args):
    api_response = invoke(func, args)
    if api_response.ok():
        if api_response.content is not None:
            response = api_response.content
            if 'openconfig-system:state' in response.keys():
                value = response['openconfig-system:state']
                if value is None:
                    return
                show_cli_output(sys.argv[2], system_state_key_change(value))

            elif 'openconfig-system:memory' in response.keys():
                value = response['openconfig-system:memory']
                if value is None:
                    return
                show_cli_output(sys.argv[2], memory_key_change(value['state']))
            elif 'openconfig-system:cpus' in response.keys():
                value = response['openconfig-system:cpus']
                if value is None:
                    return
                show_cli_output(sys.argv[2], value['cpu'])
            elif 'openconfig-system:processes' in response.keys():
                value = response['openconfig-system:processes']
                if 'pid' not in sys.argv:
                    if value is None:
                        return
                    show_cli_output(sys.argv[2], value['process'])
                else:
                    for proc in value['process']:
                        if proc['pid'] == sys.argv[3]:
                            show_cli_output(sys.argv[2],
                                            util_capitalize(proc['state']))
                            return
    else:
        print(api_response.error_message())
Ejemplo n.º 6
0
def vxlan_show_vxlan_interface(args):

    print ""
    api_response = invoke(
        "get_list_sonic_vxlan_sonic_vxlan_vxlan_tunnel_vxlan_tunnel_list",
        args)
    if api_response.ok():
        response = api_response.content
        if response is None:
            print("no vxlan configuration")
        elif response is not None:
            if len(response) != 0:
                show_cli_output(args[0], response)

    api_response = invoke(
        "get_list_sonic_vxlan_sonic_vxlan_evpn_nvo_evpn_nvo_list", args)
    if api_response.ok():
        response = api_response.content

        if response is None:
            print("no evpn configuration")
        elif response is not None:
            if len(response) != 0:
                show_cli_output(args[0], response)
    return
def run(func, args):

    try:
        response = invoke_api(func, args)
        if response.ok():
            if response.content is not None:
                # Get Command Output
                api_response = response.content

                if 'openconfig-interfaces:interfaces' in api_response:
                    value = api_response['openconfig-interfaces:interfaces']
                    if 'interface' in value:
                        tup = value['interface']
                        value['interface'] = sorted(tup, key=getId)

                if api_response is None:
                    print("Failed")
                else:
                    if func == 'get_openconfig_interfaces_interfaces_interface':
                        show_cli_output(args[1], api_response)
                    elif func == 'get_openconfig_interfaces_interfaces':
                        show_cli_output(args[0], api_response)
                    else:
                        return
        else:
            print response.error_message()

    except Exception as e:
        print("Exception when calling OpenconfigInterfacesApi->%s : %s\n" %
              (func, e))
def get_tam_int_ifa_ts_flow_stats(args):
    api_response = {}
    api = cc.ApiClient()

    # connect to COUNTERS_DB
    counters_db = ConfigDBConnector()
    counters_db.db_connect('COUNTERS_DB')

    if len(args) == 1 and args[0] != "all":
       path = cc.Path('/restconf/data/sonic-tam-int-ifa-ts:sonic-tam-int-ifa-ts/TAM_INT_IFA_TS_FLOW_TABLE/TAM_INT_IFA_TS_FLOW_TABLE_LIST={name}', name=args[0])
    else:
       path = cc.Path('/restconf/data/sonic-tam-int-ifa-ts:sonic-tam-int-ifa-ts/TAM_INT_IFA_TS_FLOW_TABLE')

    response = api.get(path)

    if response.ok():
        if response.content:
            if len(args) == 1 and args[0] != "all":
                api_response = response.content['sonic-tam-int-ifa-ts:TAM_INT_IFA_TS_FLOW_TABLE_LIST']
            else:
                api_response = response.content['sonic-tam-int-ifa-ts:TAM_INT_IFA_TS_FLOW_TABLE']['TAM_INT_IFA_TS_FLOW_TABLE_LIST']

            for i in range(len(api_response)):
                api_response[i]['Packets'] = 0
                api_response[i]['Bytes'] = 0
                if "acl-table-name" not in api_response[i] and "acl-rule-name" not in api_response[i]:
                  return

                acl_counter_key = 'COUNTERS:' + api_response[i]['acl-table-name'] + ':' + api_response[i]['acl-rule-name']
                flow_stats = counters_db.get_all(counters_db.COUNTERS_DB, acl_counter_key)
                if flow_stats is not None:
			api_response[i]['Packets'] = flow_stats['Packets']
			api_response[i]['Bytes'] = flow_stats['Bytes']

    show_cli_output("show_tam_int_ifa_ts_flow_stats.j2", api_response)
Ejemplo n.º 9
0
def run(func, args):
    global config

    try:
       args.insert(0,"0")  # NAT instance 0

       if func == 'get_nat_translations':
           api_response = get_nat_translations(func,args)
       elif func == 'get_nat_zones':
           api_response = get_nat_zones(func,args)
       elif func == 'get_nat_statistics':
           api_response = get_nat_statistics(func,args)
       elif func == 'get_nat_translations_count':
           api_response = get_nat_translations_count(func,args)
       elif func == 'get_nat_static_configs':
           api_response = get_nat_static_configs(func,args)
       elif func == 'get_nat_configs':
           api_response = get_nat_configs(func,args)
       else:
           response = invoke_api(func, args)
           api_response = get_response_dict(response)

       if config == False:
           show_cli_output(args[1], api_response)
 
    except Exception as e:
        print("Failure: %s\n" %(e))
Ejemplo n.º 10
0
def mclag_show_mclag_interface(args):
    mclag_iface_info = {}

    api_response = invoke(
        "get_sonic_mclag_sonic_mclag_mclag_interface_mclag_interface_list",
        args[1:])
    if api_response.ok():
        response = api_response.content
        if len(response) != 0:
            mclag_local_if = []
            mclag_remote_if = []
            mclag_local_if = response['sonic-mclag:MCLAG_INTERFACE_LIST']
            if not mclag_is_element_in_list(mclag_local_if, "if_type"):
                print("MCLAG Interface not configured in this domain")
                return

            api_response = invoke(
                "get_sonic_mclag_sonic_mclag_mclag_remote_intf_table_mclag_remote_intf_table_list",
                args[1:])
            if api_response.ok():
                response = api_response.content
                if len(response) != 0:
                    mclag_remote_if = response[
                        'sonic-mclag:MCLAG_REMOTE_INTF_TABLE_LIST']

        count, mclag_iface_info = mclag_get_mclag_intf_dict(
            mclag_local_if, mclag_remote_if)
        show_cli_output(args[0], mclag_iface_info)

    else:
        #error response
        print api_response
        print api_response.error_message()

    return
Ejemplo n.º 11
0
def run(func, args):
    c = openconfig_platform_client.Configuration()
    c.verify_ssl = False
    aa = openconfig_platform_client.OpenconfigPlatformApi(
        api_client=openconfig_platform_client.ApiClient(configuration=c))

    # create a body block
    keypath, body = generate_body(func, args)

    try:
        if body is not None:
            api_response = getattr(aa, func.__name__)(*keypath, body=body)

        else:
            api_response = getattr(aa, func.__name__)(*keypath)

        if api_response is None:
            print("Success")
        else:
            response = api_response.to_dict()
            value = response['openconfig_platformcomponents']['component'][0][
                'state']
            if value is None:
                return
            show_cli_output(sys.argv[2], filter_json_value(value))

    except ApiException as e:
        print("Exception when calling OpenconfigPlatformApi->%s : %s\n" %
              (func.__name__, e))
Ejemplo n.º 12
0
def run(func, args):

    c = openconfig_interfaces_client.Configuration()
    c.verify_ssl = False
    aa = openconfig_interfaces_client.OpenconfigInterfacesApi(
        api_client=openconfig_interfaces_client.ApiClient(configuration=c))

    # create a body block
    keypath, body = generate_body(func, args)

    try:
        if body is not None:
            api_response = getattr(aa, func.__name__)(*keypath, body=body)
        else:
            api_response = getattr(aa, func.__name__)(*keypath)

        if api_response is None:
            print("Success")
        else:
            # Get Command Output
            api_response = aa.api_client.sanitize_for_serialization(
                api_response)
            if 'openconfig-interfaces:interfaces' in api_response:
                value = api_response['openconfig-interfaces:interfaces']
                if 'interface' in value:
                    tup = value['interface']
                    value['interface'] = sorted(tup, key=getId)

            if api_response is None:
                print("Failed")
            else:
                if func.__name__ == 'get_openconfig_interfaces_interfaces_interface':
                    show_cli_output(args[1], api_response)
                elif func.__name__ == 'get_openconfig_interfaces_interfaces':
                    show_cli_output(args[0], api_response)
                else:
                    return
    except ApiException as e:
        #print("Exception when calling OpenconfigInterfacesApi->%s : %s\n" %(func.__name__, e))
        if e.body != "":
            body = json.loads(e.body)
            if "ietf-restconf:errors" in body:
                err = body["ietf-restconf:errors"]
                if "error" in err:
                    errList = err["error"]

                    errDict = {}
                    for dict in errList:
                        for k, v in dict.iteritems():
                            errDict[k] = v

                    if "error-message" in errDict:
                        print "%Error: " + errDict["error-message"]
                        return
                    print "%Error: Transaction Failure"
                    return
            print "%Error: Transaction Failure"
        else:
            print "Failed"
def run(func, args, renderer):
    response = invoke_api(func, args)

    api_response = response
    if "sonic-sag:SAG_LIST" in api_response["sag"]:
        api_response["miscmap"] = sh.get_if_master_and_oper(
            api_response["sag"]["sonic-sag:SAG_LIST"])
    #print(api_response)
    show_cli_output(renderer, api_response)
Ejemplo n.º 14
0
def run(func, args):
    aa = cc.ApiClient()

    path = cc.Path('/restconf/data/openconfig-platform:components/component=%s'%args[0])
    response = aa.get(path)
    if response.ok():
        show_cli_output(sys.argv[3], response.content)
    else:
        print response.error_message()
def run(func, args, renderer):
    response = invoke_api(func, args)

    if response.ok():
        if response.content is not None:
            api_response = response.content
            show_cli_output(renderer, api_response)
        else:
            print("Empty response")
    else:
        print(response.error_message())
def run(func, args):
    try:
        api_response = invoke(func, args)
        if api_response.ok():
            response = api_response.content
            if 'openconfig-ztp:state' in response.keys():
                value = response['openconfig-ztp:state']
                if value is not None:
                    show_cli_output(sys.argv[2], value)
    except:
        print("%Error: Transaction Failure")
def get_sonic_radius_global():
    api_response = {}
    api = cc.ApiClient()

    path = cc.Path(RADIUS_SERVER_GROUP + 'config')
    response = api.get(path)
    if response.ok():
        if response.content:
            api_response = response.content

    show_cli_output("show_radius_global.j2", api_response)
def run(func, args):
    c = openconfig_platform_client.Configuration()
    c.verify_ssl = False
    aa = openconfig_platform_client.OpenconfigPlatformApi(
        api_client=openconfig_platform_client.ApiClient(configuration=c))

    # create a body block
    keypath, body = generate_body(func, args)

    try:
        if body is not None:
            api_response = getattr(aa, func.__name__)(*keypath, body=body)

        else:
            api_response = getattr(aa, func.__name__)(*keypath)

        if api_response is None:
            print("Success")
        else:
            api_response = aa.api_client.sanitize_for_serialization(
                api_response)
            value = api_response['openconfig-platform:components'][
                'component'][0]['state']
            if value is None:
                return
            if 'oper-status' in value:
                temp = value['oper-status'].split(':')
                if temp[len(temp) - 1] is not None:
                    value['oper-status'] = temp[len(temp) - 1]
            show_cli_output(sys.argv[2], filter_json_value(value))

    except ApiException as e:
        if e.body != "":
            body = json.loads(e.body)
            if "ietf-restconf:errors" in body:
                err = body["ietf-restconf:errors"]
                if "error" in err:
                    errList = err["error"]

                    errDict = {}
                    for dict in errList:
                        for k, v in dict.iteritems():
                            errDict[k] = v

                    if "error-message" in errDict:
                        print "%Error: " + errDict["error-message"]
                        return
                    print "%Error: Application Failure"
                    return
            print "%Error: Application Failure"
        else:
            print "Failed"
Ejemplo n.º 19
0
def get_sonic_tacacs_global():
    api_response = {}
    api = cc.ApiClient()

    path = cc.Path(
        '/restconf/data/openconfig-system:system/aaa/server-groups/server-group=TACACS/config'
    )
    response = api.get(path)
    if response.ok():
        if response.content:
            api_response = response.content

    show_cli_output("show_tacacs_global.j2", api_response)
Ejemplo n.º 20
0
def get_tam_ifa_flow_stats(args):
    api_response = {}
    api = cc.ApiClient()

    if (len(args) == 1) and (args[0] != "all"):
        path = cc.Path(
            '/restconf/data/sonic-ifa:sonic-ifa/TAM_INT_IFA_FLOW_TABLE/TAM_INT_IFA_FLOW_TABLE_LIST={name}',
            name=args[0])
    else:
        path = cc.Path(
            '/restconf/data/sonic-ifa:sonic-ifa/TAM_INT_IFA_FLOW_TABLE')

    response = api.get(path)

    if response.ok():
        if response.content:
            if (len(args) == 1) and (args[0] != "all"):
                api_response = response.content[
                    'sonic-ifa:TAM_INT_IFA_FLOW_TABLE_LIST']
            else:
                api_response = response.content[
                    'sonic-ifa:TAM_INT_IFA_FLOW_TABLE'][
                        'TAM_INT_IFA_FLOW_TABLE_LIST']

            for i in range(len(api_response)):
                api_response[i]['Packets'] = 0
                api_response[i]['Bytes'] = 0

                path = cc.Path('/restconf/data/openconfig-acl:acl/acl-sets')
                acl_info = api.get(path)
                if acl_info.ok():
                    if acl_info.content:
                        acl_list = acl_info.content["openconfig-acl:acl-sets"][
                            "acl-set"]
                        for acl in acl_list:
                            if acl['name'] == api_response[i][
                                    'acl-table-name']:
                                rule = api_response[i]['acl-rule-name']
                                # tokenize the rulename with '_' and fetch last number
                                tmpseq = (rule.split("_", 1))[-1]
                                acl_entry_list = acl["acl-entries"][
                                    "acl-entry"]
                                for entry in acl_entry_list:
                                    if int(tmpseq) == int(
                                            entry["sequence-id"]):
                                        api_response[i]['Packets'] = entry[
                                            "state"]["matched-packets"]
                                        api_response[i]['Bytes'] = entry[
                                            "state"]["matched-octets"]

    show_cli_output("show_tam_ifa_flow_stats.j2", api_response)
Ejemplo n.º 21
0
def run(func, args):
    c = openconfig_system_client.Configuration()
    c.verify_ssl = False
    aa = openconfig_system_client.OpenconfigSystemApi(api_client=openconfig_system_client.ApiClient(configuration=c))

    # create a body block
    keypath, body = generate_body(func, args)

    try:
        if body is not None:
           api_response = getattr(aa,func.__name__)(*keypath, body=body)
           
        else :
           api_response = getattr(aa,func.__name__)(*keypath)
           #print(api_response)
        if api_response is None:
            print ("Success")
        else:
            response = api_response.to_dict()
            if 'openconfig_systemstate' in response.keys():
                value = response['openconfig_systemstate']
                if value is None:
                    return
                show_cli_output(sys.argv[2], system_state_key_change(value))

            elif 'openconfig_systemmemory' in response.keys():
                value = response['openconfig_systemmemory']
                if value is None:
                    return
		show_cli_output(sys.argv[2], memory_key_change(value['state']))
            elif 'openconfig_systemcpus' in response.keys():
                value = response['openconfig_systemcpus']
                if value is None:
                    return
                show_cli_output(sys.argv[2], value['cpu'])
            elif 'openconfig_systemprocesses' in response.keys():
                value = response['openconfig_systemprocesses']
		if len(sys.argv) < 4:
                    if value is None:
                    	return
	    	    show_cli_output(sys.argv[2],value['process'])
		else:
		    for proc in value['process']:
			if proc['pid'] == int(sys.argv[3]):
			    show_cli_output(sys.argv[2],util_capitalize(proc['state']))
			    return
	    	    print("command works")	
            else:
                print("Failed")
    except ApiException as e:
        print("Exception when calling OpenconfigSystemApi->%s : %s\n" %(func.__name__, e))
Ejemplo n.º 22
0
def run(func, args):
    api_response = invoke(func, args)
    if api_response.ok():
        response = api_response.content
        if response is not None:
            if 'sonic-udld:UDLD_LIST' in response.keys():
                value = response['sonic-udld:UDLD_LIST']
                if value is None:
                    return
                else:
                    show_cli_output(args[0], value)
            elif 'sonic-udld:_UDLD_PORT_TABLE_LIST' in response.keys():
                value = response['sonic-udld:_UDLD_PORT_TABLE_LIST']
                if value is None:
                    return
                else:
                    show_cli_output(args[0], value)
            elif 'intf_show' in response.keys():
                value = response['intf_show']
                if value is None:
                    return
                else:
                    show_cli_output(args[0], value)
            elif 'sonic-udld:_UDLD_PORT_NEIGH_TABLE_LIST' in response.keys():
                value = response['sonic-udld:_UDLD_PORT_NEIGH_TABLE_LIST']
                if value is None:
                    return
                else:
                    show_cli_output(args[0], value)
    else:
        print(api_response.error_message())
def run(func, args):
    response = invoke_api(func, args)

    if response.ok():
        if response.content is not None:
            # Get Command Output
            api_response = response.content
            if api_response is None:
                print("Failed")
                sys.exit(1)
            show_cli_output(args[0], api_response)
    else:
        print response.error_message()
        sys.exit(1)
Ejemplo n.º 24
0
def vxlan_show_vxlan_tunnel(args):

    list_len = 0
    api_response = invoke(
        "get_list_sonic_vxlan_sonic_vxlan_vxlan_tunnel_table_vxlan_tunnel_table_list",
        args)
    if api_response.ok():
        response = api_response.content
        if response is None:
            print("no vxlan configuration")
        elif response is not None:
            if len(response) != 0:
                show_cli_output(args[0], response)
    return
def run(func, args):
    try:
        api_response = invoke(func, args)
        if api_response.ok():
            response = api_response.content
            if response is None:
                return
            elif len(args) >= 3 and args[2].lower() == 'groups':
                if 'openconfig-network-instance-deviation:interfaces' in response.keys():
                    value = response['openconfig-network-instance-deviation:interfaces']
                    if value is None:
                        return
                    show_cli_output('show_igmp_snooping-groups.j2', value)
                elif 'openconfig-network-instance-deviation:interface' in response.keys():
                    show_cli_output('show_igmp_snooping-groups.j2', response)
            elif (len(args) >= 2 and args[1].lower() == 'snooping') or (len(args) >= 4 and args[2].lower() == 'vlan'):
                if 'openconfig-network-instance-deviation:interfaces' in response.keys():
                    value = response['openconfig-network-instance-deviation:interfaces']
                    if value is None:
                        return
                    show_cli_output(args[0], value)
                elif 'openconfig-network-instance-deviation:interface' in response.keys():
                    show_cli_output(args[0], response)
            else:
                print "%Error: Invalid command"
        else:
            #error response
            print api_response.error_message()

    except:
            # system/network error
            print "%Error: Transaction Failure"
Ejemplo n.º 26
0
def run(func, args):
    response = invoke_api(func, args)
    if response.ok():
        if response.content is not None:
            # Get Command Output
            api_response = response.content

            if api_response is None:
                print("%Error: Transaction Failure")
            elif func == 'get_openconfig_system_system_aaa_authentication_config':
                show_cli_output(args[0], api_response)
            else:
                return
    else:
        print(response.error_message())
Ejemplo n.º 27
0
def run(func, args):
    if func == 'get_tam_drop_monitor_supported':
        get_tam_drop_monitor_supported(args)
        return
    elif func == 'get_tam_drop_monitor_flow_stats':
        get_tam_drop_monitor_flow_stats(args)
        return

    response = invoke_api(func, args)
    if response.ok():
        if response.content is not None:
            # Get Command Output
            api_response = response.content

            if api_response is None:
                print("Failed")
            elif func == 'get_sonic_tam_drop_monitor_sonic_tam_drop_monitor_tam_drop_monitor_feature_table':
                show_cli_output(args[0], api_response)
            elif func == 'get_sonic_tam_drop_monitor_sonic_tam_drop_monitor_tam_drop_monitor_flow_table':
                show_cli_output(args[0], api_response)
            elif func == 'get_list_sonic_tam_drop_monitor_sonic_tam_drop_monitor_tam_drop_monitor_flow_table_tam_drop_monitor_flow_table_list':
                show_cli_output(args[1], api_response)
            elif func == 'get_sonic_tam_drop_monitor_sonic_tam_drop_monitor_tam_drop_monitor_aging_interval_table':
                show_cli_output(args[0], api_response)
            elif func == 'get_sonic_tam_drop_monitor_sonic_tam_drop_monitor_sample_rate_table':
                show_cli_output(args[0], api_response)
            else:
                return

    else:
        api_response = response.content
        if "ietf-restconf:errors" in api_response:
            err = api_response["ietf-restconf:errors"]
            if "error" in err:
                errList = err["error"]

                errDict = {}
                for dict in errList:
                    for k, v in dict.iteritems():
                        errDict[k] = v

                if "error-message" in errDict:
                    print "%Error: " + errDict["error-message"]
                    return
                print "%Error: Transaction Failure"
                return
        print response.error_message()
        print "%Error: Transaction Failure"
Ejemplo n.º 28
0
def vxlan_show_vxlan_vlanvnimap(args):

    #print("VLAN-VNI Mapping")
    list_len = 0
    print("")
    api_response = invoke(
        "get_list_sonic_vxlan_sonic_vxlan_vxlan_tunnel_map_vxlan_tunnel_map_list",
        args)
    if api_response.ok():
        response = api_response.content
        if response is None:
            print("no vxlan configuration")
        elif response is not None:
            if len(response) != 0:
                show_cli_output(args[0], response)
    return
Ejemplo n.º 29
0
def run(func, args):
    aa = cc.ApiClient()

    path = cc.Path(
        '/restconf/data/openconfig-platform:components/component=%s' % args[0])
    api_response = aa.get(path)
    if api_response.ok(
    ) and "openconfig-platform:state" in api_response.content:
        response = api_response.content
        versionResponse = response["openconfig-platform:state"]
        responseContent = {
            "Software Version": versionResponse['software-version']
        }
        show_cli_output(sys.argv[3], responseContent)
    else:
        print api_response.error_message()
def get_tam_int_ifa_ts_supported(args):
    api_response = {}

    # connect to APPL_DB
    app_db = ConfigDBConnector()
    app_db.db_connect('APPL_DB')

    key = 'SWITCH_TABLE:switch'
    data = app_db.get(app_db.APPL_DB, key, 'tam_int_ifa_ts_supported')

    if data and data == 'True':
        api_response['feature'] = data
    else:
        api_response['feature'] = 'False'

    show_cli_output("show_tam_ifa_ts_feature_supported.j2", api_response)