Module Expr Str Import alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias identifier ImportFrom alias identifier ImportFrom alias FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Str Str body Expr Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Call NameLoad Assign TupleStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If UnaryOpNot NameLoad body Expr Call AttributeLoad NameLoad attr Str NameLoad Expr Call AttributeLoad NameLoad attr Str NameLoad Return TupleLoad Dict Str Str Str NameLoad NameLoad NameLoad Dict Expr Call AttributeLoad NameLoad attr Str NameLoad Assign NameStore ListLoad TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad Assign NameStore Str Return TupleLoad Dict Str Str Str NameLoad NameLoad NameLoad Dict Expr Call AttributeLoad NameLoad attr Str NameLoad NameLoad If UnaryOpNot NameLoad body Expr Call AttributeLoad NameLoad attr Str NameLoad Assign NameStore NameLoad Assign NameStore Str Return TupleLoad Dict Str Str Str NameLoad NameLoad NameLoad Dict Expr Call AttributeLoad NameLoad attr BinOpMod Str Call NameLoad NameLoad Assign NameStore Dict For NameStore NameLoad body Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str If NameLoad body Assign NameStore ListLoad NameLoad orelse Assign NameStore ListLoad If CompareNotIn NameLoad NameLoad body Assign SubscriptStore NameLoad Index NameLoad Dict Str Str Str NameLoad NameLoad NameLoad orelse Assign SubscriptStore SubscriptLoad NameLoad Index NameLoad Index Str NameLoad Expr Call AttributeLoad SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Str attr NameLoad Expr Call AttributeLoad NameLoad attr Str NameLoad Assign NameStore NameLoad Return TupleLoad Dict Str Str Str NameLoad NameLoad NameLoad Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Str Str body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr NameLoad With Call AttributeLoad NameLoad attr BinOpMod Str NameLoad keyword Num NameStore body If UnaryOpNot NameLoad body Raise Call NameLoad BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr Str NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad If UnaryOpNot NameLoad body Expr Call AttributeLoad NameLoad attr Str NameLoad Return For NameStore NameLoad body For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr Str NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str NameLoad keyword NameLoad NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str keyword NameLoad NameLoad decorator_list
N/A N/A Module to provider function to poll switch. N/A logging N/A netaddr compass.actions util compass.db.api database compass.db.api switch switch_api compass.db.api user user_api compass.hdsdiscovery.hdmanager HDManager _poll_switch N/A N/A ip_addr credentials req_obj oper N/A mac SCAN N/A N/A Poll switch by ip addr.


    Args:
       ip_addr: ip addr of the switch.
       credentials: credentials of the switch.

    Returns: switch attributes dict and list of machine attributes dict.
     N/A under_monitoring under_monitoring N/A unreachable unreachable N/A polling_error error N/A hdmanager N/A HDManager N/A N/A vendor state err_msg N/A N/A hdmanager get_vendor ip_addr credentials N/A N/A vendor N/A N/A N/A N/A logging info *****error_msg: %s**** err_msg N/A N/A N/A logging error no vendor found or match switch %s ip_addr N/A N/A N/A vendor state err_msg vendor state err_msg N/A N/A N/A N/A logging debug hdmanager learn switch from %s ip_addr N/A results N/A N/A N/A N/A results N/A N/A hdmanager learn ip_addr credentials vendor req_obj oper N/A N/A N/A Exception N/A error N/A N/A N/A N/A logging exception error N/A state unreachable N/A err_msg SNMP walk for querying MAC addresses timedout N/A N/A N/A vendor state err_msg vendor state err_msg N/A N/A N/A N/A logging info pollswitch %s result: %s ip_addr results N/A N/A results N/A N/A N/A N/A logging error no result learned from %s ip_addr N/A state polling_error N/A err_msg No result learned from SNMP walk N/A N/A N/A vendor state err_msg vendor state err_msg N/A N/A N/A N/A logging info N/A poll switch result: %s N/A str results N/A machine_dicts N/A N/A machine results N/A N/A mac N/A machine N/A mac N/A port N/A machine N/A port N/A vlan N/A int N/A machine N/A vlan N/A vlan N/A N/A vlans N/A vlan N/A N/A vlans N/A N/A N/A mac machine_dicts N/A N/A N/A machine_dicts N/A mac N/A mac port vlans mac port vlans N/A N/A N/A N/A machine_dicts N/A mac N/A port port N/A N/A N/A N/A N/A machine_dicts N/A mac N/A vlans extend vlans N/A N/A N/A logging debug update switch %s state to under monitoring ip_addr N/A state under_monitoring N/A N/A N/A vendor state err_msg vendor state err_msg N/A N/A machine_dicts values N/A poll_switch N/A N/A poller_email ip_addr credentials req_obj oper N/A mac SCAN N/A N/A Query switch and update switch machines.

    .. note::
       When polling switch succeeds, for each mac it got from polling switch,
       A Machine record associated with the switch is added to the database.

    :param ip_addr: switch ip address.
    :type ip_addr: str
    :param credentials: switch crednetials.
    :type credentials: dict
    :param req_obj: the object requested to query from switch.
    :type req_obj: str
    :param oper: the operation to query the switch.
    :type oper: str, should be one of ['SCAN', 'GET', 'SET']

    .. note::
       The function should be called out of database session scope.
     N/A poller N/A N/A user_api get_user_object poller_email N/A ip_int N/A long N/A N/A netaddr IPAddress ip_addr N/A N/A N/A util lock N/A poll switch %s ip_addr timeout 120 lock N/A N/A N/A lock N/A N/A N/A Exception N/A failed to acquire lock to poll switch %s ip_addr N/A N/A N/A logging debug poll switch: %s ip_addr N/A N/A switch_dict machine_dicts N/A _poll_switch ip_addr credentials req_obj req_obj oper oper N/A switches N/A N/A switch_api list_switches ip_int ip_int user poller N/A N/A switches N/A N/A N/A N/A logging error no switch found for %s ip_addr N/A N/A switch switches N/A N/A machine_dict machine_dicts N/A N/A N/A N/A logging debug add machine: %s machine_dict N/A N/A N/A switch_api add_switch_machine N/A switch N/A id False user poller machine_dict N/A N/A N/A switch_api update_switch N/A switch N/A id user poller switch_dict N/A