Exemple #1
0
def _init_sourceroute(net_api):
    """
    Setup sourceroute with the dhclient monitor.

    The net_api argument represents the exposed network api verbs.

    The net_api can contain:
    supervdsm proxy - enabling calls through the supervdsm service.
    api module object - enabling calls directly through the network api.
    """
    def _add_sourceroute(iface, ip, mask, route):
        net_api.add_sourceroute(iface, ip, mask, route)

    def _remove_sourceroute(iface):
        net_api.remove_sourceroute(iface)

    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.CONFIGURE,
        action_function=_add_sourceroute,
        required_fields=(
            dhclient_monitor.ResponseField.IFACE,
            dhclient_monitor.ResponseField.IPADDR,
            dhclient_monitor.ResponseField.IPMASK,
            dhclient_monitor.ResponseField.IPROUTE,
        ),
    )
    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.REMOVE,
        action_function=_remove_sourceroute,
        required_fields=(dhclient_monitor.ResponseField.IFACE, ),
    )
Exemple #2
0
def _init_sourceroute(net_api):
    """
    Setup sourceroute with the dhclient monitor.

    The net_api argument represents the exposed network api verbs.

    The net_api can contain:
    supervdsm proxy - enabling calls through the supervdsm service.
    api module object - enabling calls directly through the network api.
    """
    def _add_sourceroute(iface, ip, mask, route):
        net_api.add_sourceroute(iface, ip, mask, route)

    def _remove_sourceroute(iface):
        net_api.remove_sourceroute(iface)

    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.CONFIGURE,
        action_function=_add_sourceroute,
        required_fields=(dhclient_monitor.ResponseField.IFACE,
                         dhclient_monitor.ResponseField.IPADDR,
                         dhclient_monitor.ResponseField.IPMASK,
                         dhclient_monitor.ResponseField.IPROUTE))
    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.REMOVE,
        action_function=_remove_sourceroute,
        required_fields=(dhclient_monitor.ResponseField.IFACE,))
Exemple #3
0
def _register_notifications(cif):
    def _notify(**kwargs):
        cif.notify('|net|host_conn|no_id')

    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.CONFIGURE,
        action_function=_notify,
        required_fields=(dhclient_monitor.ResponseField.IFACE,
                         dhclient_monitor.ResponseField.IPADDR,
                         dhclient_monitor.ResponseField.IPMASK))
Exemple #4
0
def _register_notifications(cif):
    def _notify(**kwargs):
        cif.notify('|net|host_conn|no_id')

    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.CONFIGURE,
        action_function=_notify,
        required_fields=(dhclient_monitor.ResponseField.IFACE,
                         dhclient_monitor.ResponseField.IPADDR,
                         dhclient_monitor.ResponseField.IPMASK))
Exemple #5
0
def _register_notifications(cif):
    def _notify(**kwargs):
        # Delay the notification in order to allow the ifup job to finish
        time.sleep(5)
        cif.notify('|net|host_conn|no_id')

    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.CONFIGURE,
        action_function=_notify,
        required_fields=(dhclient_monitor.ResponseField.IFACE,
                         dhclient_monitor.ResponseField.IPADDR,
                         dhclient_monitor.ResponseField.IPMASK))
Exemple #6
0
def _register_notifications(cif):
    def _notify(**kwargs):
        # Delay the notification in order to allow the ifup job to finish
        time.sleep(5)
        cif.notify('|net|host_conn|no_id')

    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.CONFIGURE,
        action_function=_notify,
        required_fields=(dhclient_monitor.ResponseField.IFACE,
                         dhclient_monitor.ResponseField.IPADDR,
                         dhclient_monitor.ResponseField.IPMASK))
Exemple #7
0
def _init_sourceroute():
    def _add_sourceroute(iface, ip, mask, route):
        supervdsm.getProxy().add_sourceroute(iface, ip, mask, route)

    def _remove_sourceroute(iface):
        supervdsm.getProxy().remove_sourceroute(iface)

    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.CONFIGURE,
        action_function=_add_sourceroute,
        required_fields=(dhclient_monitor.ResponseField.IFACE,
                         dhclient_monitor.ResponseField.IPADDR,
                         dhclient_monitor.ResponseField.IPMASK,
                         dhclient_monitor.ResponseField.IPROUTE))
    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.REMOVE,
        action_function=_remove_sourceroute,
        required_fields=(dhclient_monitor.ResponseField.IFACE, ))
Exemple #8
0
def _init_sourceroute():
    def _add_sourceroute(iface, ip, mask, route):
        supervdsm.getProxy().add_sourceroute(iface, ip, mask, route)

    def _remove_sourceroute(iface):
        supervdsm.getProxy().remove_sourceroute(iface)

    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.CONFIGURE,
        action_function=_add_sourceroute,
        required_fields=(dhclient_monitor.ResponseField.IFACE,
                         dhclient_monitor.ResponseField.IPADDR,
                         dhclient_monitor.ResponseField.IPMASK,
                         dhclient_monitor.ResponseField.IPROUTE))
    dhclient_monitor.register_action_handler(
        action_type=dhclient_monitor.ActionType.REMOVE,
        action_function=_remove_sourceroute,
        required_fields=(dhclient_monitor.ResponseField.IFACE,))